akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
using namespace std;

int main()
{
	long n, u, k, r, v1, c1;
	const long INF = 0xFFFFFFFF;

	cin >> n >> k >> r;

	vector<vector<long> > v(n), c(n);
	vector<long> w(n, INF);
	typedef pair<long, long> wt;
	priority_queue<wt, vector<wt>, greater<wt> > que;

	for (long i = 0; i < k; i++) {
		cin >> u >> v1 >> c1;
			v[u].push_back(v1);
			c[u].push_back(c1);
	}

	w[r] = 0;
	que.push(wt(0, r));

	while (!que.empty()) {
		wt g = que.top();
		que.pop();

		int k = g.second;

		if (w[k] < g.first)
			continue;

		for (long i = 0; i < (long)v[k].size(); i++) {
			if (w[v[k][i]] > w[k] + c[k][i]) {
				w[v[k][i]] = w[k] + c[k][i];
				que.push(wt(w[v[k][i]], v[k][i]));
			}
		}
	}

	for (long i = 0; i < n; i++) {
		if (w[i] < INF)
			cout << w[i] << endl;
		else
			cout << "INF" << endl;
	}

	return 0;
}


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

int main(){
	int n;	cin>>n;
	string s;	cin>>s;

	int ans=0;
	for(int x=0; x<1000; x++){
		// sから取り出した3ケタの数字が、iになるかどうかを全探索。
		bool a=false, b=false, c=false;
		for(int i=0;i<n;i++){
			if(a==false){
				if(s[i]-'0'==x/100){
					a=true;	continue;
				}
			}else if(b==false){
				if(s[i]-'0'==(x/10)%10){
					b=true;	continue;
				}
			}else if(c==false){
				if(s[i]-'0'==x%10){
					c=true;	break;
				}
			}
		}
		if(a&&b&&c){
			++ans;
		}
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define vd vector<double>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define reverse_v(a) reverse(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    (c) ? (cout << "Yes" << endl) : (cout << "No" << endl);
}

void Print(bool c)
{
    (c) ? (cout << "YES" << endl) : (cout << "NO" << endl);
}

//最小公倍数
template <typename T>
T gcd(T a, T b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

//最大公約数
template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}
//セカンドキー->ファーストキーの順ソート
bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

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

int eve(int x)
{
    if (x % 400 == 0)
        return 1;
    if (x % 100 == 0)
        return 0;
    if (x % 4 == 0)
        return 1;
    return 0;
}

int main(void)
{
    int n, a, b;
    string s;
    cin >> n >> a >> b >> s;
    ll all = 0, sea = 0;
    vll ans(n);
    rep(i, 0, n)
    {
        if (s[i] == 'c')
            continue;
        if (s[i] == 'a' && all < a + b)
            ans[i] = 1, all++;
        else if (s[i] == 'b' && all < a + b && sea < b)
            ans[i] = 1, all++, sea++;
    }
    for (auto x : ans)
        print(x);
}

Measured memory_bytes: 1664
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

vector<int> as;

void dfs(const int cur, vector<int> &ord, vector<bool> &visited, int &loop_start) {
    if (visited[cur]) {
        loop_start = cur;
        return;
    }
    ord.push_back(cur);
    visited[cur] = true;
    dfs(as[cur], ord, visited, loop_start);
}

int solve(const int N, ll K) {
    vector<int> ord;
    int loop_start_town = -1;
    {
        vector<bool> visited(N, false);
        dfs(0, ord, visited, loop_start_town);
    }
    assert(loop_start_town >= 0);

    int loop_start_ind = -1;
    for (int i = 0; i < (int) ord.size(); i++) {
        if (ord[i] == loop_start_town) {
            loop_start_ind = i;
            break;
        }
    }
    assert(loop_start_ind >= 0);

    // printf("loop_start_town: %d, loop_start_ind: %d\n", loop_start_town, loop_start_ind);
    // for (auto o : ord) {
    //     cout << o << " ";
    // }
    // cout << endl;

    if (K <= loop_start_ind) {
        return ord[K];
    }

    K -= loop_start_ind;
    int loop_size = (int) ord.size() - loop_start_ind;
    // printf("loop_size: %d, target is %lld from loop_start\n", loop_size, K % loop_size);
    return ord[loop_start_ind + (K % loop_size)];
}

int main(void) {
    int N;
    ll K;
    cin >> N >> K;

    as.resize(N);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        a--;
        as[i] = a;
    }

    cout << solve(N, K) + 1 << endl;

    return 0;
}


Measured memory_bytes: 13896
#include<bits/stdc++.h>
#define ll long long int 
#define FOR(i,a,b) for( ll i=(a) ; i<=(b) ; ++i)
#define FORR(i,a,b) for( ll i=(a) ; i>=(b) ; --i)
#define RD(v,n) for(ll i =0;i<n;i++ ) cin>>v[i]
#define bolt ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

int main()
{
	bolt;
    string s;
    unordered_map<string,int> mp;
    mp["SAT"] = 1;
    mp["FRI"] = 2;
    mp["THU"] = 3;
    mp["WED"] = 4;
    mp["TUE"] = 5;
    mp["MON"] = 6;
    mp["SUN"] = 7;
    cin>>s;
    cout<<mp[s]<<"\n";

	return 0;
}

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

double absol(double a, double b)
{
	double to_return = a - b;
	if(to_return < 0.00)
	{
		to_return = to_return * -1.00;
	}
	return to_return;
}

int main()
{
	int a,b,h,m;
	cin>>a>>b>>h>>m;
	double deg_min = 6 * m;
	double deg_hr = 30*h;
	deg_hr += 1.00 * 0.5 * m;
	double delta = absol(deg_min, deg_hr);
	if(delta > 180.00)
	{
		delta = 360.00 * 1.00 - delta;
	}
	double x = a*a*1.00;
	x += b*b*1.00;
	double z = 2.00*a*b*1.00;
	delta = delta * 3.141592653589793238;
	delta = delta/(180.00 * 1.00);
	z = z * cos(delta);
	x -= z;
	double ans = sqrt(x);
	cout<<setprecision(30)<<ans;
	return 0;
}


Measured memory_bytes: 4088
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=200000000000000;
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
}

	
int main(){
	init();
	
	ll N,A,B;
	cin>>N>>A>>B;
	ll ans=0;
	ll s;
	cin>>s;
	for(int i=0;i<N-1;i++){
		ll g;
		cin>>g;
		ans+=min(B,A*(g-s));
		s=g;
	}
	cout<<ans<<endl;
}


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

using namespace std;

using ll = long long;

int main(){
    ll n; cin >> n;
    ll ans = 0;
    for(ll i = 1;  i <= n; ++i){
        if(i % 3 != 0 && i % 5 != 0) ans += i;
    }
    cout << ans;
    return 0;
}


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

int main() {
    int h, m, h2, m2, k;
    cin >> h >> m >> h2 >> m2 >> k;
    cout << (h2 - h) * 60 + m2 - m - k << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
#define SIZE 1000
int main(){
  int n,a=1,i=0,j=0;
  int b[SIZE];
  scanf("%d", &n);
  while(n!=0){
    if(n>0){
      a=n%2;
      b[i]=a;
      n=-(n/2);
      i++;
    }
    else{
      a=(-n)%2;
      b[i]=a;
      if(a==1) n=-(n/2)+1;
      else n=-(n/2);
      i++;
    }
    j++;
  }
  if(j==0) printf("%d",0);
  for(i=j-1;i>=0;i--){
    printf("%d", b[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
s = input()
if s[0] == s[1] == s[2] == 'R':
    print(3)
elif s[0] == s[1] == 'R' or s[1] == s[2] == 'R':
    print(2)
elif s[0] == 'R' or s[1] == 'R' or s[2] == 'R':
    print(1)
else:
    print(0)

Measured memory_bytes: 9052
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N), ind(N);
    for(auto& x: A) cin >> x;
    
    vector<ll> s(N);
    s[0] = A[0];
    for(int i=1; i<N; i++){
        if(i%2==0) s[i] = s[i-2] + A[i];
        else s[i] = s[i-1];
    }
    vector<ll> dp(N);
    dp[0] = 0;
    dp[1] = max(A[0], A[1]);
    for(int i=2; i<N; i++){
        if(i%2==0) dp[i] = max(dp[i-1], dp[i-2] + A[i]);
        else dp[i] = max(s[i-1], dp[i-2] + A[i]);
    }
    
    cout << dp[N-1] << endl;
    // debug(dp);
}

Measured memory_bytes: 9212
n=int(input())
ll=[]
for _ in range(n):
    x,l=map(int,input().split())
    ll.append((x+l,x-l))
ll=sorted(ll)
ans=0
c=-10**10
for t,s in ll:
    if c<=s:
        c=t
        ans+=1
print(ans)

Measured memory_bytes: 17756
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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 rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int dp[510][510];

int main(){
  int n,m,Q;
  cin >> n >> m >> Q;
  rep(i,m){
    int l,r;
    cin >> l >> r;
    dp[l][r]++;
  }
  for(int i=1;i<=n;i++)for(int j=1;j<=n;j++) dp[i][j]+=dp[i][j-1];
  for(int i=1;i<=n;i++)for(int j=1;j<=n;j++) dp[i][j]+=dp[i-1][j];
  vector<int> ans(Q);
  rep(i,Q){
    int p,q;
    cin >> p >> q;
    ans[i]=dp[q][q]-dp[p-1][q]-dp[q][p-1]+dp[p-1][p-1];
  }
  rep(i,Q){
    cout << ans[i] << endl;
  }
  /*
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      cout << dp[i][j];
    }cout << endl;
  }
  */
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define ll long long
#define int ll
using namespace std;
const int inf=0x3f3f3f3f,N=1e6;
ll n,ret,ans;
ll m,x,a[N];
void ksm(ll m,ll x)
{
	if(m==1)
	{
		ans=0;ret=x;return ;
	}
	ksm(m/2,x);ans*=2;
	ans++;ret*=2;if(ret>=10)ret-=9,ans++;
	if(m&1)
	{
		ans++;ret+=x;if(ret>=10)ret-=9,ans++;
	}
}
main()
{
	cin>>n;ll ass=-1,la=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&x,&m);
		ksm(m,x);
		ass+=ans+1;la+=ret;if(la>=10)la-=9,ass++;
	}cout<<ass;
	return 0;
}


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

int main() {
	string S;
	cin >> S;
	bool A_flag = false;
	bool B_flag = false;
	bool C_flag = false;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'a')A_flag = true;
		else if (S[i] == 'b')B_flag = true;
		else if (S[i] == 'c')C_flag = true;
	}
	if (A_flag == true && B_flag == true && C_flag == true)cout << "Yes";
	else cout << "No";

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;
typedef long long ll;

int n, a[100001], root;
vector<int> adj[100001];

void fck(){
	puts("NO");
	exit(0);
}

vector<ll> v[100001];

ll dfs(int now, int par){
	if(adj[now].size() == 1) return a[now]; /// leaf


    for(int dest:adj[now]){
		if(dest==par) continue;
		ll res = dfs(dest, now);
		v[now].push_back(res);
	}
    if(now==root){
        ll mx=*max_element(v[now].begin(), v[now].end());
        ll sum=0;
        for(ll e:v[now]) sum+=e;
        if(mx > sum-mx) fck(); ///
        if(sum%2==1 || sum/2 != a[now]) fck(); ///
        return 0;
    }
    else{
		ll mx=*max_element(v[now].begin(), v[now].end());
		ll sum=0;
        for(ll e:v[now]) sum+=e;

        ll maxPair=0;
        if(v[now].size() > 1){
			if(mx > sum-mx) maxPair=(sum-mx);
			else maxPair=sum/2;
		}

		ll LL=sum-maxPair, RR=sum;
		if(a[now] < LL || a[now] > RR) fck(); ///
		ll sP = sum - a[now];
		return sum - 2*sP;
    }
}

int main(){
	scanf("%d", &n);
	for(int i=1; i<=n; i++)
		scanf("%d", &a[i]);
	for(int i=1, a, b; i<n; i++){
		scanf("%d %d", &a, &b);
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	if(n==2){
        puts(a[1]==a[2]?"YES":"NO");
        return 0;
	}

	for(int i=1; i<=n; i++){
		if(adj[i].size() != 1){
			root=i;
			break;
		}
	}
    dfs(root, root);
    puts("YES");
	return 0;
}


Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n,w;
    cin>>n>>w;
    
    ll wt[n],val[n];
    for(int i=0;i<n;i++){
        int wi,vi;
        cin>>wi>>vi;
        wt[i]=wi;
        val[i]=vi;
    }
    vector<vector<ll>>dp(n,vector<ll>(w+1,0));
    for(int i=0;i<n;i++){
        for(int j=0;j<=w;j++){
            if(i==0){
                if(j>=wt[i]){
                   dp[i][j]=val[i];
                }
            }
            else if(wt[i]<=j){
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-wt[i]]+val[i]);
            }
            else if(j<wt[i]){
                dp[i][j]=dp[i-1][j];
            }
        }
    }
   cout<<dp[n-1][w];
    
    return 0;
}
        
    

Measured memory_bytes: 79488
from collections import Counter

N = int(input())
A = list(map(int,input().split()))
A = Counter(A)
keys = list(A.keys())
count = 0
for i in range(len(A)):
    if keys[i]!=A[keys[i]]:
        if keys[i]>A[keys[i]]:
            count += A[keys[i]]
        else:
            count += A[keys[i]]-keys[i]
print(count)


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

using namespace std;

int n;

void solve(){
    int i,j;
    string str;
    cin >> str;
    vector<int> v;
    for(i = 0;i < str.length();i++){
        if(str[i] == 'A') v.push_back(1);
        else if(i < str.length()-1 && str[i] == 'B' && str[i+1] == 'C'){
            v.push_back(2);
            i++;
        }
        else v.push_back(0);
    }
    long long ans = 0;
    for(i = 0,j = 0;i < v.size();i++){
        if(v[i] == 1) j++;
        if(v[i] == 2) ans += j;
        if(v[i] == 0) j = 0;
    }
    cout << ans << endl;
}

int main(){
    solve();
}


Measured memory_bytes: 1532
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        long G = sc.nextLong() / 100;
        int[] p = new int[d], g = new int[d], max = new int[d];
        int k = (int)Math.pow(2, d);
        for(int i = 0; i < d; i++){
            p[i] = sc.nextInt();
            g[i] = sc.nextInt() / 100;
            max[i] = (i + 1) * p[i] + g[i];
        }
        int ans = Integer.MAX_VALUE;
        for(int i = 0; i < k; i++){
            long gg = G;
            String kk = to2(i, d);
            int tmp = 0;
            int min = -1;
            for(int j = 0; j < d; j++){
                if(kk.charAt(j) == '1'){
                    gg -= max[j];
                    tmp += p[j];
                }else{
                    min = j;
                }
            }
            if(min >= 0){
                if(gg < (min + 1) * p[min]){
                    tmp += Math.min((Math.max(gg, 0) + min) / (min + 1), p[min]);
                }
                else tmp = Integer.MAX_VALUE;
            }
//            else if(min == -1 && gg > 0) tmp = Integer.MAX_VALUE;
   //         else tmp = Integer.MAX_VALUE;
       //     System.out.println(kk + " " + tmp);
            ans = Math.min(ans, tmp);
        }
        System.out.println(ans);
    }
    static String to2 (int m, int d){
        String ans = "";
        for(int i = 0; i < d; i++){
            if(m % 2 == 0){
                m /= 2;
                ans = "0" + ans;
            }
            else{
                m--;
                m /= 2;
                ans = "1" + ans;
            }
        }
        return ans;
    }
}

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

int h1, m1, h2, m2;
int k;

int main () {
    while(scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k) == 5) {
        int d = h2 * 60 + m2 - k - h1 * 60 - m1;
        printf("%d\n", max(0, d));
    }
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define REP(i, n) for (long long i = 0; i < (n); i++)
struct UnionFind {
    vector<int> parent, size;
    UnionFind(int n) {
        parent.resize(n, -1);
        size.resize(n, 1);
    }
    void unite(int x, int y) {
        if (same(x, y)) {
            return;
        }
        x = root(x);
        y = root(y);
        if (size[x] <= size[y]) {
            swap(x, y);
        }
        parent[y] = x;
        size[x] += size[y];
    }
    bool same(int x, int y) { return (root(x) == root(y)); }
    int root(int x) {
        while (parent[x] != -1) {
            x = parent[x];
        }
        return x;
    }
    int getsize(int x) { return size[root(x)]; }
};
vector<vector<P>> mst(vector<vector<P>> graph) {
    vector<pair<ll, P>> as;
    REP(i, graph.size()) {
        REP(j, graph[i].size()) { as.push_back({graph[i][j].second, {i, graph[i][j].first}}); }
    }
    sort(as.begin(), as.end());
    UnionFind uf(graph.size());
    vector<vector<P>> ans(graph.size());
    REP(i, as.size()) {
        if (!uf.same(as[i].second.first, as[i].second.second)) {
            ans[as[i].second.first].push_back({as[i].second.second, as[i].first});
            ans[as[i].second.second].push_back({as[i].second.first, as[i].first});
            uf.unite(as[i].second.second, as[i].second.first);
        }
    }
    return ans;
}
signed main() {
    int v;
    cin >> v;
    vector<vector<P>> graph(v);
    vector<vector<P>> ans(v);
    REP(i, v) {
        REP(j, v) {
            int a;
            cin >> a;
            if (a != -1) {
                graph[i].push_back({j, a});
            }
        }
    }
    ans = mst(graph);
    ll sum = 0;
    REP(i, v) {
        REP(j, ans[i].size()) { sum += ans[i][j].second; }
    }
    cout << sum / 2 << endl;
}


Measured memory_bytes: 3380
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Pollock
 */
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a[] = new int[5];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
        }
        int idx = 0;
        for (int i = 0; i < a.length; i++) {
            if (a[i] == 0) {
                idx = i;
            }
        }
            System.out.println(idx + 1);
        }
    }



Measured memory_bytes: 35648
//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
#pragma comment(linker,"/STACK:33554432") /*32Mb*/

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <cmath>
#include <list>
#include <iomanip>
#include <set>
#include <map>
#include <sstream>
using namespace std;

typedef  long long LL;
typedef  unsigned long long ULL;
typedef  long double LD;
typedef  pair<int, int> PII;
typedef vector<int> VI;

#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define RFOR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i)) 
#define For(i,a,b) for(int (i)=(a);i<(b);++(i))
#define FoR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i)) 
#define MP make_pair
#define MOD 1000000007
#define mod 1000000000
#define INF 1000000000
#define PB push_back
#define y0 kihrbdb
#define y1 ugvrrtgtrg
#define eps 1e-5
#define X first
#define Y second

int n;
LL arr[100010];
LL dp[100010][2];
LL A, B;
int va[100010], vb[100010];

int main()
{
	cout.setf(ios::fixed, ios::floatfield);
	cout.precision(4);

	cin >> n >> A >> B;
	For(i, 0, n) cin >> arr[i];
	For(i, 0, n) va[i] = vb[i] = -1;

	int l = 0, r = 0;
	while (r < n && arr[r] - arr[l] < A) r++;
	while (r < n)
	{
		while (l + 1 < n && arr[r] - arr[l + 1] >= A) l++;
		if (l < n)
		{
			va[r] = l;
			r++;
		}
	}
	l = 0, r = 0;
	while (r < n && arr[r] - arr[l] < B) r++;
	while (r < n)
	{
		while (l + 1 < n && arr[r] - arr[l + 1] >= B) l++;		
		if (l < n)
		{
			vb[r] = l;
			r++;
		}
	}

	dp[0][0] = 1;
	dp[0][1] = 1;
	int ca = 0, cb = 0;
	For(i, 1, n)
	{
		if (va[i] >= 0)
		{
			if (va[i] == i - 1)
				dp[i][1] = (dp[va[i]][1] + dp[va[i]][0]) % MOD;
			else if (cb >= 0 && cb <= va[i] + 1)
				dp[i][1] = dp[va[i] + 1][0];
			else dp[i][1] = 0;
		}
		else if (cb == 0) dp[i][1] = 1;
		if (vb[i] >= 0)
		{
			if (vb[i] == i - 1)
				dp[i][0] = (dp[vb[i]][0] + dp[vb[i]][1]) % MOD;
			else if (ca >= 0 && ca <= vb[i] + 1)
				dp[i][0] = dp[vb[i] + 1][1];
			else dp[i][0] = 0;
		}
		else if (ca == 0) dp[i][0] = 1;

		if (arr[i] - arr[i - 1] < A) ca = i;
		if (arr[i] - arr[i - 1] < B) cb = i;
	}

	cout << (dp[n - 1][0] + dp[n - 1][1]) % MOD << endl;

	return 0;
}

Measured memory_bytes: 3456
# -*- coding: utf-8 -*-
import sys


def get_num():
    return int(input())


def get_nums(n):
    res = [0 for _ in range(n)]
    for i in range(n):
        res[i] = int(input())
    return res


def get_numbers():
    return map(int, input().split())


a, b = get_numbers()

print(max(a + b, a - b, a * b))

Measured memory_bytes: 38384
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

ll count(ll A){
    ll cnt = 0;
    ll sum = 0;
    rep(i,A){
        sum += i+1;
        if(sum==A){
            cnt = i+1;
            break;
        }else if(sum>A){
            cnt += i;
            break;
        }
    }
    return cnt;
}

int main() {
    // 入力
    ll N;
    cin >> N;
    vector<ll> v;
    map<ll,ll> mp;
    ll n = N;
    ll out = 0;
    while(n!=1){
        for(ll i=2;i<=sqrt(N);i++){
            if(n%i==0){
                n /= i;
                if(mp.count(i)) mp[i]++;
                else{
                    mp.emplace(i,1);
                    v.push_back(i);
                }
                break;
            }else if(i==(ll)sqrt(N)){
                if(mp.count(n)) mp[n]++;
                else{
                    mp.emplace(n,1);
                    v.push_back(n);
                }
                n /= n;
                break;
            }
        }
    }
    ll M = mp.size();
    rep(i,M){
        out += count(mp[v[i]]);
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3728
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

ld const PI = acos(-1) ;
int const N = 100 + 5 , MAX = 5e5 ;
int n , res[N] ;
ld x[N] , y[N] ;

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

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

	cout << fixed << setprecision(10) ;

	for (int i = 0 ; i < MAX ; i ++) {
		ld xx = (ld)cos(2 * PI / MAX * i) * 1e13 , yy = (ld)sin(2 * PI / MAX * i) * 1e13 ;

		ld mn = 1e30 + 20 ;
		int best = 0 ;

		for (int j = 0 ; j < n ; j ++) {
			ld dist = (xx - x[j]) * (xx - x[j]) + (yy - y[j]) * (yy - y[j]) ;
			if (dist < mn) mn = dist , best = j ;
		}

		res[best] ++ ;
	}

	for (int i = 0 ; i < n ; i ++) cout << (ld)res[i] / MAX << '\n' ;
}

Measured memory_bytes: 256
/* ****mittal21**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define ld          long double
#define pb          push_back
#define endl        '\n'
#define pii         pair<long long int,long long int>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
#define N  300009
vi a(N),seg(4*N);
void build(ll cur,ll st,ll end)
{
  if(st==end)
  {
    seg[cur]=a[st];
    return;
  }
  ll mid=(st+end)>>1;
  build(2*cur,st,mid);
  build(2*cur+1,mid+1,end);
  seg[cur]=max(seg[2*cur],seg[2*cur+1]);  /*  1-change here  */
}
ll query(ll cur,ll st,ll end,ll l,ll r)
{
  if(l<=st&&r>=end)
  return seg[cur];
  if(r<st||l>end)
  return 0;                           /*  2-change here  */
  ll mid=(st+end)>>1;
  ll ans1=query(2*cur,st,mid,l,r);
  ll ans2=query(2*cur+1,mid+1,end,l,r);
  return (max(ans1,ans2));                 /*  3-change here  */
}
void update(ll cur,ll st,ll end,ll pos,ll upd)
{
  if(st==end)
  {
    a[pos]=upd;          /*  4-change here  */
    seg[cur]=upd;          /*  5-change here  */
    return;
  }
  ll mid=(st+end)>>1;
  if(st<=pos&&pos<=mid)
    update(2*cur,st,mid,pos,upd);
  else
    update(2*cur+1,mid+1,end,pos,upd);
  seg[cur]=max(seg[2*cur],seg[2*cur+1]);  /*  6-change here  */
}
void solve()
{
   ll n,k;
   cin>>n>>k;
   ll b[n+3];
   for(int i=1;i<=n;i++)
   {
      cin>>b[i];
      b[i]++;
   }
   update(1,1,300001,b[1],1);
   a[b[1]]=1;
   for(int i=2;i<=n;i++)
   {
      ll o=query(1,1,300001,max(1LL,b[i]-k),min(300001LL,b[i]+k));
      a[b[i]]=max(o+1,a[b[i]]);
      // a[b[i]]=max(a[b[i]],o+1);
      update(1,1,300001,b[i],a[b[i]]);
   }
   ll ans=0;
   for(int i=1;i<=300001;i++)
    ans=max(ans,a[i]);
  cout<<ans;
   return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll testcase=1;
    //cin>>testcase;
    while(testcase--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 17196
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
//-------------
int main() {
    int A,B,C,X;
    cin >> A >> B >>C>>X;
    int Ans=0;
    //A 500,B 100,C 50
    X/=50;
    //A 10,B 2,C 1
    if(X%2==1){
        X--;
        C--;
        if(C<0){
            cout << 0 <<endl;
            return 0;
        }
    }
    int S_a=min(X/10,A);
    int X_a,X_b;
    for(int i=0;i<=S_a;i++){
        X_a=X-10*i;
        int S_b=min(X_a/2,B);
        for(int k=0;k<=S_b;k++){
            X_b=X_a-2*k;
            if(X_b>C)continue;else{
                //printf("500*%2d 100*%2d 50*%2d\n",i,k,X_b);
                Ans++;
            }
        }
    }


    cout << Ans <<endl;
}

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


int main(){
    int N;
    cin >> N;
    int d[110],var[110];
    for(int i = 0; i < N; i++) {
        cin >> d[i];
    }
    for(int i = 0; i < 110; i++) {
        var[i] = 0;
    }
    
    for(int i = 0;i < N ; i++){
        var[d[i]] += 1;
    }
    
    int counter = 0;
    for(int i = 0;i < 110 ; i++){
        if(var[i]!=0) counter++;
    }
        cout << counter << endl;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		for (int i = 0; i < s.length(); ++i) {
			if (i == 5 || i == 13)
				System.out.print(" ");
			else
				System.out.print(s.charAt(i));
		}
		System.out.println();
	}
}


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

int main(){
  int h, w;
  cin >> h >> w;
  int cnt = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      char a;
      cin >> a;
      if(a == '#') cnt++;
    }
  }
  cout << (cnt == h + w - 1 ? "Possible" : "Impossible") << endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    cin >> n;
    string ans = "";
    while(n){
        // cout << (n % 26 + 25) % 26 << ' ';
        ans += (char) ('a' + (((n % 26) + 25) % 26));
        n--;
        n /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans;

    return 0;
}



Measured memory_bytes: 3584
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var firstLine = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var N = firstLine[0];
            var K = firstLine[1];
            var secoundLine = Console.ReadLine().Split(' ').Select(int.Parse).OrderBy(x => x).ToArray();
            int ret = 0;

            for (int i = 0; i < secoundLine.Length;)
            {
                if (i == 0)
                {
                    i += K;
                }
                else
                {
                    i += K - 1;
                }
                ret++;
            }
            Console.WriteLine(ret);
        }
    }
}

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

using Int = long long;
const char newl = '\n';

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
template<typename T=int>
vector<T> read(size_t n){
  vector<T> ts(n);
  for(size_t i=0;i<n;i++) cin>>ts[i];
  return ts;
}


template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;}
  Mint operator-(Mint a) const{return Mint(v)-=a;}
  Mint operator*(Mint a) const{return Mint(v)*=a;}
  Mint operator/(Mint a) const{return Mint(v)/=a;}

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  static Mint comb(long long n,int k){
    Mint num(1),dom(1);
    for(int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int n;
  cin>>n;
  auto as=read(n);

  using M = Mint<int>;
  M sm{0};
  for(int a:as) sm+=M(a);
  M ans=sm*sm;
  for(int a:as) ans-=M(a)*M(a);
  cout<<ans/M(2)<<newl;
  return 0;
}


Measured memory_bytes: 3976
#include <bits/stdc++.h>
using namespace std;
int main(){
	string data[256],id;
	bool door=false;
	int n,m;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>data[i];
	}
	cin>>m;
	for(int i=0;i<m;i++){
		cin>>id;
		bool f=false;
		for(int j=0;j<n;j++){
			if(id==data[j]){
				f=true;
				if(door){
					door=false;
					cout<<"Closed by "<<id<<endl;
					break;
				}else{
					door=true;
					cout<<"Opened by "<<id<<endl;
					break;
				}
			}
		}
		if(!f)cout<<"Unknown "<<id<<endl;
	}
}

Measured memory_bytes: 1216
import sys

MOD = 10**9 + 7

def solve():
    N = int(input())
    ans = 1

    for i in range(2, N + 1):
        ans *= i
        ans %= MOD

    print(ans)
    
def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None


if __name__ == '__main__':
    solve()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll n,a[405],b[405];
ll dp[2][405][405],F[405],R[405];
//(p_i^b_i / b_i! x^b_i + p_i^(b_i+1) / (b_i+1)! x^(b_i+1)....)の積をf(x)とする
//この時、(x^nの係数) * n!がnターン終了時に終了条件を満たす確率
//よって、sum_n (n * ((x^nの係数) * n! - (x^(n-1)の係数) * (n-1)!)が求める答え
//ここで、(p_i^b_i / b_i! x^b_i + p_i^(b_i+1) / (b_i+1)! x^(b_i+1)....) = exp(p_i x) - p_i^0 / 0! * x^0 - ... - p_i^(b_i-1) / (b_i-1)! * x^(b_i-1)
//よって、簡単なDPによってf(x)をexp(a/s x) * x^b * dp[a][b]の和で書くことができる
//以下 sum_n (n * ( a^(n-b) / (n-b)! * n! - a^(n-1-b) / (n-1-b)! * (n-1)!) を計算する
//b! * sum_n (n * ( a^(n-b) * n choose b - a^(n-1-b) * (n-1) choose b)
//b! * sum_n (n * ( a^(n-b) * n choose b - a^(n-1-b) * (n-1) choose b)
//-b! * sum_n (a^0 * b choose b + a^1 * (b+1) choose b + ....)
//f(b) = a^0 * b choose b + a^1 * (b+1) choose b + ....とすると、(1-a)f(b) = a^0 * b choose b + a^1 * b choose (b-1) +  a^2 * (b+1) choose (b-1)....
//(1-a)f(b) = f(b-1), f(0) = (1-a)^(-1)よりf(b) = (1-a)^(-1-b)
//以上より、sum_n (n * ( a^(n-b) / (n-b)! * n! - a^(n-1-b) / (n-1-b)! * (n-1)!) = -b! * (1-a)^(-1-b)
ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
int main(){
    F[0] = 1;
	for(int i=1;i<405;i++) F[i] = F[i-1]*i%mod;
	rep(i,405) R[i] = modpow(i,mod-2);
	cin >> n;
	ll s = 0;
	rep(i,n) {cin >> a[i] >> b[i];s += a[i];}
	dp[0][0][0] = 1;
	int cur = 0,nxt = 1;
	rep(i,n){
		rep(j,405) rep(k,405) dp[nxt][j][k] = 0;
		rep(j,405) rep(k,405){
			if(dp[cur][j][k] == 0) continue;
			dp[nxt][j+a[i]][k] += dp[cur][j][k];
			ll up = 1, dw = 1;
			for(int x=0;x<b[i];x++){
				dp[nxt][j][k+x] += dp[cur][j][k]*(-up)%mod*dw%mod;
				up = up*a[i]%mod*R[s]%mod;
				dw = dw*R[(x+1)]%mod;
			}
		}
		rep(j,405) rep(k,405) if(dp[nxt][j][k]) dp[nxt][j][k] = (dp[nxt][j][k] % mod + mod) % mod;
		swap(cur,nxt);
	}
	ll ans = 0;
	rep(j,s+1)rep(k,405){
	    if(dp[cur][j][k] == 0) continue;
		ll coef = F[k] * modpow(modpow((s-j)*R[s]%mod,k+1),mod-2) % mod;
		ans -= dp[cur][j][k]*coef%mod;
	}
	cout << (ans%mod+mod)%mod << endl;
}

Measured memory_bytes: 2816
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;

int main() {
  int N; cin >> N;
  set<int> st;
  for(int i = 0; i < N; i++) {
    int A; cin >> A;
    st.insert(A);
  }
  if(st.size() == N) cout << "YES" << endl;
  else cout << "NO" << endl;


  return 0;
}


Measured memory_bytes: 9600
import sys
def input(): return sys.stdin.readline().rstrip()
from operator import itemgetter
def main():
    n=int(input())
    XYH=[tuple(map(int,input().split())) for i in range(n)]
    XYH.sort(key=itemgetter(2),reverse=True)
    for cy in range(101):
        for cx in range(101):
            hc=XYH[0][2]+abs(cx-XYH[0][0])+abs(cy-XYH[0][1])
            for x,y,h in XYH[1:]:
                if h!=max(0,hc-abs(x-cx)-abs(y-cy)):
                    break
            else:
                print(cx,cy,hc)
                sys.exit()

if __name__=='__main__':
    main()

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

now = 1
loop_node = []
first_loop = 0
l = [0 for _ in range(N)]
while True:
    l[now - 1] += 1
    if l[now - 1] == 3:
        break

    if l[now - 1] == 2:
        loop_node.append(now)

    now = A[now - 1]
    first_loop += 1

loop_num = len(loop_node)
first_loop -= loop_num * 2

if K < first_loop:
    now = 1
    for _ in range(K):
        now = A[now - 1]
    print(now)
else:
    print(loop_node[(K - first_loop) % loop_num])


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

void Quicksort_rand(int A[], int L, int R);

int main(void)
{
	int i, N, M, X[100005];

	scanf("%d %d", &N, &M);
	for (i = 1; i <= M; i++)scanf("%d", &X[i]);

	if (N >= M) {
		printf("0");
		return 0;
	}

	Quicksort_rand(X, 1, M);
	int length, distance[100005];
	length = X[M] - X[1];
	for (i = 1; i < M; i++) {
		distance[i] = X[i+1] - X[i];
	}
	Quicksort_rand(distance, 1, M - 1);
	for (i = 0; i < N - 1; i++) {
		length -= distance[M-1-i];
	}
	printf("%d", length);


	return 0;
}

void Quicksort_rand(int A[], int L, int R)/*A[L]~A[R]までソート*/
{
	if (L < R)
	{
		int r, tmp, p = L, k = L + 1;

		srand(0);
		r = rand() % (R - L + 1) + L;//pivotを選択

		//pivotを先頭に置く
		tmp = A[L];
		A[L] = A[r];
		A[r] = tmp;

		//左の翼と右の翼に分ける
		while (k <= R) {
			if (A[k] < A[L]) {
				tmp = A[k];
				A[k] = A[p + 1];
				A[p + 1] = tmp;
				p++;
			}
			k++;
		}

		//pivotを左右の翼の境目に置く
		tmp = A[L];
		A[L] = A[p];
		A[p] = tmp;

		//左右の翼で再帰
		Quicksort_rand(A, L, p - 1);
		Quicksort_rand(A, p + 1, R);
	}
	return;
}

Measured memory_bytes: 896
def main():
    import sys
    input = sys.stdin.readline
    from collections import defaultdict
    N = int(input())
    A = list(map(int, input().split()))
    dic = defaultdict(int)
    for i in A:
        dic[i] += 1
    for i in range(1, N+1):
        print(dic[i])


if __name__ == '__main__':
    main()

Measured memory_bytes: 37340
package main

import "fmt"

func main() {
        var a, b, c int
        fmt.Scanf("%d %d %d", &a, &b, &c)
        if (((a*10)+b)*10+c)%4 == 0 {
                fmt.Println("YES")
        } else {
                fmt.Println("NO")
        }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }

int main(){
    ll n,l;
    cin>>n>>l;
    ll sum;
    vector<ll> a(n);
    rep(i,n) {cin>>a.at(i); sum+=a.at(i);}
    vector<ll> ans={};
    bool possible=false;
    ll div=0;
    rep(i,n-1){
        if(a.at(i)+a.at(i+1)>=l){possible=true; div=i+1;}
    }
    if(possible){
        cout<<"Possible"<<endl;
        for(int i=1;i<div;i++){
            cout<<i<<endl;
        }
        for(int i=n-1;i>div;i--){
            cout<<i<<endl;
        }
        cout<<div<<endl;
    }
    else{
        cout<<"Impossible"<<endl;
    }
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
//#include <unordered_set>
//#include <unordered_map>
#include <stdio.h>

#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INPUT1(n, a) for(int i##n = 0; i##n < n; i##n++) {cin >> a[i##n]; } //n = count, a = vector 
#define OUTPUT1(n, a) cout << "---count---" << endl << n << endl << "---content---" << endl; for(const auto b : a){cout << b << endl; }
#define INPUT2(x, y, field) for(int i##x = 0; i##x < y; i##x++) { for(int j##x = 0; j##x < x; j##x++) { cin >> field[i##x][j##x]; } }
#define OUTPUT2(x, y, field) cout << "---count---" << endl << x << " " << y << endl <<"---content---" << endl; for(int i##x = 0; i##x < y; i##x++) { cout << i##x << "   "; for(int j##x = 0; j##x < x; j##x++) { cout << field[i##x][j##x] << " "; } cout << endl; }

using namespace std;
//using ll = long long;

const int INF = 1001001001;

int main()
{
    int x(0);
	rep(i, 10000){
	    cin>>x;
	    if(x==0)break;
	    cout<<"Case "<<i+1<<": "<<x<<endl;
	}
}


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INT = 1e9;
const ll LINF = 1e17;

void solve(){
    int N; cin >> N;
    vector<vector<int>> imos(1010,vector<int>(1010,0));
    for(int i = 0; i < N;i++){
        int x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2;
        x1++;y1++;x2++;y2++;
        imos[x1][y1]++;
        imos[x1][y2]--;
        imos[x2][y1]--;
        imos[x2][y2]++;
    }
    int ans = 0;
    for(int i = 1; i< 1010;i++){
        for(int j = 1; j< 1010;j++){
            imos[i][j] += (imos[i-1][j]+imos[i][j-1]-imos[i-1][j-1]);
            ans = max(ans,imos[i][j]);
        }
    }
    cout << ans << endl;
}
int main(void){
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 6848
inputs = ""
str = 'abcdefghijklmnopqrstuvwxyz'
list = {}

while input = gets
  inputs << input.chomp
end

str.split('').each do |c|
  list[c] = 0
end

inputs.split('').each do |c|
  c = c.downcase
  list[c] = list[c] + 1 if str.include?(c)
end

list.each do |k,v|
  puts "#{k} : #{v}"
end

Measured memory_bytes: 8720
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	int n;
	int k;
	int a[5555];
	int now=0;
	int ans=0;
	cin>>n>>k;
	rep(i,n)
		cin>>a[i];
	sort(a,a+n);
	reverse(a,a+n);
	rep(i,n)
	{
		if(now+a[i]>=k)
		{
			ans=0;
		}
		else 
		{
			now+=a[i];
			ans++;
		}
	 } 
	 cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cstring>
#include <algorithm>
using namespace std;
int f[105][15];
int p[105][15];
int c[105];
int main() {
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i) {
		for(int j=1;j<=10;++j) {
			scanf("%d",&f[i][j]);
		}
	}
	for(int i=1;i<=n;++i) {
		for(int j=0;j<=10;++j) {
			scanf("%d",&p[i][j]);
		}
	}
	int ans=INT_MIN;
	for(int i=1;i<(1<<10);++i) {
		memset(c,0,sizeof(c));
		int sum=0;
		for(int j=1;j<=n;++j) {
			for(int k=1;k<=10;++k) {
				if(f[j][k]&&(i>>(k-1)&1)) {
					c[j]++;
				}
			}
			sum+=p[j][c[j]];
		}
		ans=max(ans,sum);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define MX 4000000
int dp[2005][2005];
long long fact[MX+5],inv[MX+5];
long long pow_log(long long x,int y)
{
	if (!y)
	return 1;
	long long ret=pow_log(x,y/2);
	ret=(ret*ret)%mod;
	if (y%2)
	ret=(ret*x)%mod;
	return ret;
}
long long ncr(int n,int r)
{
	return ((fact[n]*inv[r])%mod*inv[n-r])%mod;
}
int n,k;
int solve(int w,int c)
{
	if (w==n && c==n)
	return 1;
	if (dp[w][c]!=-1)
	return dp[w][c];
	int ret=0;
	if (w!=n)
	ret=solve(w+1,c);
	if (c<w)
	ret=(ret+solve(w,c+1)*ncr(n*k-w-c*(k-1)-1,k-2)%mod*(n-c))%mod;
	return dp[w][c]=ret;
}
int main()
{
	fact[0]=1;
	for (int i=1;i<=MX;i++)
	fact[i]=(i*fact[i-1])%mod;
	inv[MX]=pow_log(fact[MX],mod-2);
	for (int i=MX-1;i>=0;i--)
	inv[i]=((i+1)*inv[i+1])%mod;
	scanf("%d%d",&n,&k);
	if (k==1)
	{
		printf("1");
		return 0;
	}
	memset(dp,-1,sizeof(dp));
	printf("%d",solve(0,0));
}

Measured memory_bytes: 82264