akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define endl '\n'
#ifndef CODE_JAM
#undef CASE_INFO
#endif
#else
#pragma GCC optimize "trapv"
#endif
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(n) for(int i = 0; i < n; i++)
#define repj(n) for(int j = 0; j < n; j++)
#define all(p) p.begin(), p.end()
#define count_1(p) __builtin_popcountll(p)
#define count_0(p) __builtin_ctzll(p)
using namespace std;
template<class X=int>inline X mid(X s,X e){return (s+(e-s)/2);}
template<class X=int>inline X len(X s,X e){return (e-s+1);}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int oo = 987654321;
const ll OO = 1e18;

void solve() {
	int n, d;
	cin >> n >> d;
	vector<pii> A(n);
	rep(n) cin >> A[i].F >> A[i].S;
	sort(all(A), [](const pii &a, const pii &b) {
			ll d1 = 1LL*a.F*a.F + 1LL*a.S*a.S;
			ll d2 = 1LL*b.F*b.F + 1LL*b.S*b.S;
			return d1 < d2;
	});
	function<long long(pii)> dist = [](const pii& a) -> long long {
		return 1LL*a.F*a.F + 1LL*a.S*a.S;
	};
	int lo = 0, hi = n - 1;
	int ans = 0;
	while(lo <= hi) {
		int mi = lo + (hi - lo)/2;
		if(dist(A[mi]) <= 1LL*d*d)
			ans = lo = mi + 1;
		else
			hi = mi - 1;
	}
	cout << ans << endl;
}

signed main() {
	clock_t start = clock();
	int T = 1;
	#ifdef TEST_CASES
	cin >> T;
	#endif
	for(int t = 1; t <= T; t++) {
		#ifdef CASE_INFO
		cout << "Case #" << t << ": ";
		#endif
		solve();
	}
	cerr << (double)(clock() - start)/CLOCKS_PER_SEC << "\n";
	return 0;
}


Measured memory_bytes: 4908
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextLong()
    val h = (0 until n).map { sc.next().toLong() }
    println(problem139c(n, h))
}

fun problem139c(n: Long, h: List<Long>): Int {
    var count = 0
    var max = 0
    for (i in h.indices) {
        if (i >= h.size - 1) {
            max = Math.max(max, count)
            break
        }
        val hi = h[i]
        val hiNext = h[i + 1]
        if (hi >= hiNext) {
            count++
        } else {
            max = Math.max(max, count)
            count = 0
        }
    }
    return max
}

Measured memory_bytes: 51364
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    vector<pair<int, int>> AB(N);
    rep(i, N) AB[i] = { A[i], B[i] };

    sort(all(AB), [](auto&& l, auto&& r) { return l.second == r.second ? l.first < r.first : l.second < r.second; });
    vector<pair<int, int>> Aindex(N);
    rep(i, N) Aindex[i] = { AB[i].first, i };
    sort(all(Aindex));

    vector<int> type(N, -1);
    rep(i, N) {
        if (i > 0 && Aindex[i].first <= AB[i - 1].second) type[i] = 1;
        else if (Aindex[i].first <= AB[i].second) type[i] = 0;
    }

    if (any_of(all(type), [](int x) {return x == -1; })) {
        write("No");
        return 0;
    }
    if (any_of(all(type), [](int x) {return x == 1; })) {
        write("Yes");
        return 0;
    }

    for (int i = 0, loop = 0; loop < N;) {
        i = Aindex[i].second;
        loop++;

        if (i == 0 && loop != N) {
            write("Yes");
            return 0;
        }
    }

    write("No");
}

Measured memory_bytes: 2944
N, M, C = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

ans = 0
for i in range(N):
    A = [int(x) for x in input().split()]
    sum = 0
    for j in range(M):
        sum += A[j] * B[j] 
    if sum + C > 0:
        ans += 1

print(ans)


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

// 参考: https://www.hamayanhamayan.com/entry/2019/01/12/151211
// 類題: https://yukicoder.me/problems/no/719

const ll maxn=1<<16;
ll dp[maxn];  // 集合sがグルーピング済みの時のスコアの最大値
ll sub[maxn]; // 集合sをグルーピングした時のスコアの合計値

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  vvll a(n,vll(n));
  rep(i,n) rep(j,n) cin>>a[i][j];
  
  rep(s,1<<n){
    ll cnt=0;
    rep(i,n) if(s>>i&1) {
      irep(j,i+1,n) if(s>>j&1) cnt+=a[i][j];
    }
    sub[s]=cnt;
  }
  // rep(i,1<<n) cout<<sub[i]<<endl;

  // NOTE: ここでやっていること
  // 集合sを小さい値から見る => 今見ている集合sを2つの部分集合の和と捉え、その最大値を求める  
  // 今見ている集合sを、2つの部分集合に分けた時の最大値をdp[s]に格納していく
  // このとき、sは小さい方から見ていく ..1, ...10, ...11
  // すると、例えば今見ているsが111だったとして、111未満の集合の最大は求まった状態となるので、この部分集合の中から最大値となる2組を選ぶ
  rep(s,1<<n) for(ll bit=s; bit>=0; bit--){
    bit&=s;
    // chmax(dp[s],dp[s-bit]+sub[bit]);
    
    // ↑の1行にまとめても良いが、bit==s以外、すなわちs未満の部分集合のグルーピングの最大値は求まっているから下の様にも書ける
    if(s==bit) chmax(dp[s],dp[s-bit]+sub[bit]);
    else chmax(dp[s],dp[s-bit]+dp[bit]);
    
  }
  
  cout<<dp[(1<<n)-1]<<endl;
  
}

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

typedef long long ll;

unordered_map<ll, ll> memo;
ll dfs(ll h) { 
  if (h == 1) return 1;
  if (memo.find(h) != memo.end()) { 
    return memo[h];
  }
  memo[h] = 1+2*dfs(h/2);
  return memo[h];
}

int main() {
  ll H; cin >> H;
  ll ans = dfs(H);
  cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdIn=new Scanner(System.in);
		String x=stdIn.next();
        
        if(x.indexOf("7")>=0){
            System.out.println("Yes");
            
        }
        else{
            System.out.print("No");
            
        }
	}

}


Measured memory_bytes: 35592
N,K= map(int, input().split())

A=0
count=0
for i in range(1,N+1):
    j=i
    count=0
    while j<K:
        j=j*2
        #print(j)
        count=count+1
    else:
        A=A+(1/N)*pow(0.5,count)
        
print(A)
            

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<pii, null_type, less<pii>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define MAX 5002
map<ll,ll> CC;
vector<pair<ll,pii> > queries;

void build(ll* a,ll* tree,ll ti,ll l,ll r){
	if(l==r){
		tree[ti]=a[l];
		return;
	}
	ll mid = (l+r)/2;
	build(a,tree,2*ti,l,mid);
	build(a,tree,2*ti+1,mid+1,r);
	tree[ti] = tree[2*ti]+tree[2*ti+1];
}

ll query(ll* tree,ll ti,ll l,ll r,ll left,ll right){
	if(left==-1 || right==-1) return 0;
	if(l>=left && r<=right) return tree[ti];
	if(l>right || r<left) return 0;
	ll mid = (l+r)/2;
	ll first = query(tree,2*ti,l,mid,left,right);
	ll second = query(tree,2*ti+1,mid+1,r,left,right);
	return first+second;
}

void update(ll* tree,ll ti,ll index,ll l,ll r,ll x){
	if(l==r){
		tree[ti]+=x;
		return;
	}
	ll mid = (l+r)/2;
	if(index<=mid){
		update(tree,2*ti,index,l,mid,x);
	}else{
		update(tree,2*ti+1,index,mid+1,r,x);
	}
	tree[ti] = tree[2*ti]+tree[2*ti+1];
	return;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll Q;cin>>Q;
	ll count=1;

	vector<ll> A;

	For(w,0,Q){
		ll x;cin>>x;
		if(x==1){
			ll a,b;cin>>a>>b;
			queries.pb({1,{a,b}});
			A.pb(a);
		}else{
			queries.pb({2,{-1,-1}});
		}
	}
	sort(A.begin(),A.end());
	for(ll a:A){
		if(CC.find(a)==CC.end()) CC.insert({a,count++});
	}

	ll time=1;
	ll tree[4*count];
	memset(tree,0,sizeof(tree));
	
	ordered_set s;
	ll B = 0;
	For(w,0,Q){
		ll x = queries[w].fi;
		if(x==1){
			ll a = queries[w].se.fi,b = queries[w].se.se;
			B += b;
			s.insert({a,time++});

			update(tree,1,CC[a],0,count-1,a);

		}else{
			ll ans = (*s.find_by_order((s.size()-1)/2)).fi;

			ll sum = s.order_of_key({ans,0})*ans-((s.size()-s.order_of_key({ans,0}))*ans);

			sum+=(query(tree,1,0,count-1,CC[ans],count-1)-query(tree,1,0,count-1,1,CC[ans]-1));

			cout<<ans<<" "<<B+sum<<endl;
		}
	}	











	
}

Measured memory_bytes: 24492
/*
    mdsaqib
*/

#include <bits/stdc++.h>
#define int long long
#define all(c) (c).begin(),(c).end()
#define endl '\n'
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
using namespace std;

signed main(){
    fast;
    string s,t;
    cin >> s;
    cin >> t;
    bool b=true;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]){
            b=false;
            break;
        }
    }
    if(b)cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 3648
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N = INT()
A = LIST()
B = LIST()
A_before = sum(A)

for i in range(N):
  A[i+1] = max(min(A[i+1]- (B[i] - A[i]), A[i+1]), 0)
  A[i] = max(A[i] - B[i], 0)
  
print(A_before - sum(A))

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

int linerSearch(vector<int> A,int n,int key){
    int i=0;
    A.at(n)=key;
    while(A.at(i)!=key) i++;
    return i!=n;
}

int main(){
    int n;
    cin>>n;
    vector<int> s(n+1);
    for(int i=0;i<n;i++){
        cin>>s.at(i);
    }
    int q;
    cin>>q;
    vector<int> t(q);
    for(int i=0;i<q;i++){
        cin>>t.at(i);
    }
    int ans=0;
    for(int i=0;i<q;i++){
        if(linerSearch(s,n,t.at(i))) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3164
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1e18;

bool cmp(const pair<int, int>& a, const pair<int, int>& b) {
  if (a.first < b.first) {
    return true;
  } else if (a.first == b.first) {
    if (a.second < b.second) {
      return true;
    }
  }
  return false;
}

int main() {
  //
  ll n, C;
  cin >> n >> C;
  vector<vector<pll>> tmp(C);
  rep(i, n) {
    ll s, t, c;
    cin >> s >> t >> c;
    c--;
    tmp[c].push_back({s, t});
  }

  // merge
  vector<pll> prg;
  rep(c, C) {
    if (tmp[c].size() == 0) continue;

    sort(ALL(tmp[c]));
    // vector<pll> x;
    pll cur = tmp[c][0];
    REP(i, 1, tmp[c].size()) {
      if (cur.second == tmp[c][i].first) {
        cur.second = tmp[c][i].second;
      } else {
        // x.push_back(cur);
        prg.push_back({cur.first, 0});
        prg.push_back({cur.second, 1});
        cur = tmp[c][i];
      }
    }
    prg.push_back({cur.first, 0});
    prg.push_back({cur.second, 1});
    // x.push_back(cur);
  }

  sort(ALL(prg), cmp);
  ll cnt = 0;
  ll ans = 0;
  for (auto& x : prg) {
    if (x.second == 0) {
      cnt++;
      ans = max(ans, cnt);
    } else {
      cnt--;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8820
import java.io.*;
import java.util.function.*;
import java.util.stream.*;

class Main
{
    /**
     * ABC 062 B: Picture Frame
     *     (周囲1ピクセルを'#'で囲む)
     */ 
    public static void main(String[] args) throws IOException
    {
        // 入力
        BufferedReader br = new BufferedReader(
                new InputStreamReader(System.in));
        int[] HW = Stream.of(br.readLine().split(" ")).mapToInt(
                item -> new Integer(item)).toArray();
        Stream<String> lines = br.lines();
        
        // データ部分を抽出
        Stream<String> a = lines.filter(item -> item.indexOf(" ") < 0);

        // 枠線を決める
        // Streamは同じインスタンスで2度処理を実行できないため、Supplierを通す
        Supplier<Stream<String>> frame = () ->
                Stream.of(new String(new char[HW[1]]).replace("\0", "#"));
        Stream<String> out = Stream.concat(frame.get(), Stream.concat(a, frame.get())).map(
                item -> "#" + item + "#") ;        

        // 出力(末尾は改行を入れない)
        System.out.print(out.collect(Collectors.joining("\n")));
    }
}


Measured memory_bytes: 26836
#include <iostream>
#include <vector>
#include <algorithm>
// #include <ctime>

using namespace std;
typedef unsigned long long ull;

int main(){
	ull v = 0;
	const int MAX_N = 50;
	int X1[MAX_N], Y1[MAX_N], D1[MAX_N], X2[MAX_N], Y2[MAX_N], D2[MAX_N];
	int N, K;

	cin >> N >> K;

	vector<int> X(2 * N), Y(2 * N), D(2 * N);

	for (int i = 0; i<N; i++){
		cin >> X1[i] >> Y1[i] >> D1[i] >> X2[i] >> Y2[i] >> D2[i];
		X[i]     = X1[i];
		X[i + N] = X2[i];
		Y[i]     = Y1[i];
		Y[i + N] = Y2[i];
		D[i]     = D1[i];
		D[i + N] = D2[i];
	}
//	clock_t st = clock();
	sort(X.begin(), X.end());
	sort(Y.begin(), Y.end());
	sort(D.begin(), D.end());
	X.erase(unique(X.begin(), X.end()), X.end());
	Y.erase(unique(Y.begin(), Y.end()), Y.end());
	D.erase(unique(D.begin(), D.end()), D.end());

	for (int i = 0, nx = X.size() - 1; i<nx; i++){
	for (int j = 0, ny = Y.size() - 1; j<ny; j++){
	for (int k = 0, nd = D.size() - 1; k<nd; k++){
		int kind = 0;
		for (int l = 0; l < N; l++){
			if (X1[l] <= X[i] && X[i+1] <= X2[l] && 
				Y1[l] <= Y[j] && Y[j+1] <= Y2[l] && 
				D1[l] <= D[k] && D[k+1] <= D2[l]) kind++;
		}
		if (kind >= K) v += (ull)(X[i+1] - X[i]) * (Y[j+1] - Y[j]) * (D[k+1] - D[k]);
	}
	}
	}

	cout << v << endl;
//	clock_t ed = clock();
//	cout << (double)(ed - st) / CLOCKS_PER_SEC << endl;
	return 0;
}

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

int main(){
    while(1){
        int n;
        cin >> n;
        if(!n) break;

        for(int i = 0;i < n;i++){
            int pm, pe, pj;
            cin >> pm >> pe >> pj;

            char ans = 'C';
            int ave = (pm + pe + pj) / 3;
            if(pm == 100 || pe == 100 || pj == 100) ans = 'A';
            else if((pm + pe) / 2 >= 90) ans = 'A';
            else if(ave >= 80) ans = 'A';
            else if(ave >= 70) ans = 'B';
            else if(ave >= 50 && (pm >= 80 || pe >= 80)) ans = 'B';

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

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  while(true){
    c -= b;
    if(c<=0){
      cout << "Yes" << endl;
      return 0;
    }
    a -= d;
    if(a<=0){
      cout << "No" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3560
#include <cstdio>
#include <algorithm>
#include <queue>

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

char grid[1005][1005];

int dist[1005][1005];

int main(){
  int H,W;
  scanf("%d %d",&H,&W);
  for(int i=0;i<H;i++){
    scanf("%s",grid[i]);
  }
  std::queue<std::pair<int,int> > q;
  for(int i=0;i<H;i++){
    for(int j=0l;j<W;j++){
      if(grid[i][j]=='#'){
	dist[i][j]=0;
	q.push({i,j});
      }else{
	dist[i][j]=-1;
      }
    }
  }
  while(!q.empty()){
    int x=q.front().first;
    int y=q.front().second;
    q.pop();
    for(int d=0;d<4;d++){
      int x1=x+dx[d];
      int y1=y+dy[d];
      if(x1<0||x1>=H||y1<0||y1>=W) continue;
      if(dist[x1][y1]==-1){
	dist[x1][y1]=dist[x][y]+1;
	q.push({x1,y1});
      }
    }
  }
  int far=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      far=std::max(far,dist[i][j]);
    }
  }
  printf("%d\n",far);
  return 0;
}


Measured memory_bytes: 13328
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
int n,k,r,s,p;
ll ans = 0;
void pl(char c) {
  //if (cnt == 1) {cnt = 0; return;}
  
  if (c == 'r') ans += p;
  else if (c == 's') ans += r;
  else ans += s;
  return;
} 
int main() {
  cin>>n>>k>>r>>s>>p;
  string t;
  cin >> t;
  int j = 0;
  vector<int> cnt(n,1);
  while (j < k)
  {
    for (int i = j; i < n-k; i+=k)
    {
      if (t[i] == t[i+k] && cnt[i] == 1) cnt[i+k] = 0;
    }
    //cout << ans << endl;
    j++;
  }
  for (int i = 0; i < n; i++)
  {
    if (cnt[i]) pl(t[i]);
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3844
#include <bits/stdc++.h>
#include <tuple>
#include <iterator>
using namespace std;
using ll = long long;

int main()
{
  ll x, y;
  cin >> x >> y;
  ll cnt = 0;
  while (x <= y)
  {
    x *= 2;
    cnt++;
  }
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  multiset<ll> S;
  rep(i, N) {
    auto itr = S.upper_bound(A[i]-1);
    if(itr == S.begin()) {
      S.insert(A[i]);
    } else {
      S.erase(--itr);
      S.insert(A[i]);
    }
  }
  cout << S.size() << endl;
  return 0;
}


Measured memory_bytes: 5760
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

const int MAX = 80;

int main(){
    int N;
    int A[MAX];
    long long DP[MAX] = {0};
    long long ans = 0;

    DP[0] = 1000;

    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> A[i];
    }


    for(int i = 1;i < N;i++){
        long long m = 0;

        for(int j = 0;j < i;j++){
            long long n = A[i] * (DP[j] / A[j]) + DP[j] % A[j];
            m = max(n,m);
        }

        DP[i] = max(DP[i - 1],m);
    }

    for(int i = 0;i < N;i++){
        ans = max(ans,DP[i]);
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
  int K,N=0;
  string S;
  cin >> K >> S;
  N += S.size();
  if(N<=K){
    cout << S << endl;
    return 0;
  }
  for(int i=0; i<K; i++){
    cout << S[i];
  }
  cout << "..." << endl;
}


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

using namespace std;

typedef pair< int, int > Pi;

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

  map< Pi, int > mp;

  for(int i = 0; i < N; i++) {
    int A;
    cin >> A;
    --A;
    mp[minmax(i, A)]++;
  }
  int ret = 0;
  for(auto k : mp) {
    if(k.second == 2) ++ret;
  }
  cout << ret << endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int h,w; cin>>h>>w;
	int a[h][w], b[h][w];
	const int max_k=(h+w)*80+5; //////
	rep(i,h) rep(j,w) cin>>a[i][j];
	rep(i,h) rep(j,w) cin>>b[i][j];
  vector<vector<vector<bool>>> dp(h, vector<vector<bool>>(w, vector<bool>(max_k,false))); //////
	// bool dp[h][w][max_k]; memset(dp,false,sizeof(dp));
	const int dh[2]={1,0}, dw[2]={0,1};
	dp[0][0][abs(a[0][0]-b[0][0])]=true;
	rep(now_h,h)rep(now_w,w){
		rep(i,2){
			int next_h=now_h+dh[i], next_w=now_w+dw[i];
			if(next_h>=h||next_w>=w) continue;
			int d=abs(a[next_h][next_w]-b[next_h][next_w]);
			rep(k,max_k){
				if(!dp[now_h][now_w][k]) continue;
				if(k+d<max_k) dp[next_h][next_w][k+d]=true;
				if(abs(k-d)<max_k) dp[next_h][next_w][abs(k-d)]=true;
			}
		}
	}
	int ans=max_k;
	rep(k,max_k){
		if(dp[h-1][w-1][k]) return cout<<k<<endl,0;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 10752
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    n = int(input())

    #output
    answer = n*(n+1)//2
    for i in range(2, n+1):
        for j in range(i, n+1, i):
            answer += j

    print(answer)

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

Measured memory_bytes: 73364
import math
N,H = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(N)]
n = max(src)[0]
src.sort(key=lambda x:x[1],reverse=True)
ans = d = 0
for a,b in src:
    if b <= n: break
    d += b
    ans += 1
    if d >= H:
        print(ans)
        exit()

ans += math.ceil((H-d) / n)
print(ans)


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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T1,typename T2> using P = pair< T1, T2 >;
using Pii = P<int,int>;
using Pdd = P<double,double>;
using Psi = P<string,double>;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

template<typename T1,typename T2> using M = map< T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

V<Psi> RLE(string s){
    V<Psi> rle; 
    string r = "";
    int cnt = 0;
    for(int i=0; i<s.size(); i++){
        string c = s.substr(i,1);
        if(c == r){
            cnt++;
        }else{
            if(cnt!=0) rle.pb(mp(r,cnt));
            r = c;
            cnt = 1;
        }
    }
    rle.pb(mp(r,cnt));
    return rle;
}

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

    auto lre = RLE(s);

    Vi l;
    l.pb(1);
    for(auto i: lre){
        l.pb(l[l.size()-1]+i.se);
    }

    int max_x = 0;
    REP(i,lre.size()){
        int cnt_k = 0;
        int m;
        if(lre[i].fi=="0") m = i+2*k;
        else  m = i+2*k+1;
        if(m>lre.size()) m = l.size()-1;
        int x = l[m] - l[i];

        max_x = max(max_x,x);
    }

    cout<<max_x<<endl;

    return 0;
}

Measured memory_bytes: 7540
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        long n  = s.nextLong();
        
        int factors[] = new int[(int)n+1];
        long sum = 0;

        Arrays.fill(factors,1);
        sum = n*(n+1)/2;
        for(int i = 2; i <= n; i++) {
            for(int j = i; j <= n; j = j+i) {
//                factors[j]++;
                sum += j; 
            }
        }
//        for(int i = 1; i <= n; i++) {
//            System.out.print(factors[i]+" ");
//            sum += i*factors[i]; 
//        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 74888
use std::io::stdin;

fn main() {
    let mut n = String::new();
    stdin().read_line(&mut n);
    let mut a = String::new();
    stdin().read_line(&mut a);
    let mut max = 0;
    let mut min = 1000000000;
    for a in a.trim().split_whitespace() {
        let a: i32 = a.parse().unwrap();
        if max < a { max = a };
        if min > a { min = a };
    }
    println!("{}", max - min);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
int sq[111][111];
int x[111],y[111],a[111];
int main(void){

  int i,j,k,t,tmp;
  string s;
  int W,H,N;
  int x,y,a;

  cin>>W>>H>>N;

  for(i=1;i<=N;i++){
    cin>>x>>y>>a;

    if(a==1){
      for(j=0;j<H;j++){
        for(k=0;k<x;k++){
          sq[k][j]=-1;
        }
      }
    }
    if(a==2){
      for(j=0;j<H;j++){
        for(k=x;k<W;k++){
          sq[k][j]=-1;
        }
      }
    }
    if(a==3){
      for(j=0;j<y;j++){
        for(k=0;k<W;k++){
          sq[k][j]=-1;
        }
      }
    }
    if(a==4){
      for(j=y;j<H;j++){
        for(k=0;k<W;k++){
          sq[k][j]=-1;
        }
      }
    }
  }

  t=0;
  for(j=0;j<H;j++){
    for(k=0;k<W;k++){
      if(sq[k][j]==0) t++;
    }
  }
  cout<<t<<endl;
  return 0;
}

Measured memory_bytes: 256
X,N=map(int,input().split())
P=list(map(int,input().split()))

minv=101
v=0

if X in P:
  for i in range(200):
    if not(i in P):
      if abs(X-i) < minv:
        minv=abs(X-i)
        v=i
else:
  v=X
       

print(v)


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
int main () {
    #define int long long
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int x = 0;
    int res = 0, ans;
    for (int i = 0, k = -1; i < n; i++, k = -k) {
        x += a[i];
        if (x == 0) {
            res++;
            x = k;
            continue;
        }
        if (x * k < 0) {
            res += abs(x)+1;
            x = k;
            continue;
        }
    }
    ans = res;
    res = 0, x = 0;
    for (int i = 0, k = 1; i < n; i++, k = -k) {
        x += a[i];
        if (x == 0) {
            res++;
            x = k;
            continue;
        }
        if (x * k < 0) {
            res += abs(x)+1;
            x = k;
            continue;
        }
    }
    ans = min(ans, res);
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#define MOD 1000000007LL

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

ll inv(ll a){
    if(a==0) return 0;
    ll ap=a, ans=1, k=MOD-2;
    while(k>0){
        if(k%2==1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k/=2;
    }
    return ans;
}

vector<int> v[200001];
int d[200001], dmax;
vector<int> dist[200001];
int pp[200001];

void dfs(int x){
	for(auto y:v[x]){
		if(d[y]<0){
			d[y]=d[x]+1;
			dist[d[y]].push_back(y);
			dmax=max(d[y], dmax);
			dfs(y);
		}
	}
}

int p1;

void dfs2(int x){
	int ct=0;
	for(auto y:v[x]){
		if(d[y]>d[x]) ct++;
	}
	if(ct>1){
		for(auto y:v[x]){
			if(d[y]<d[x]) continue;
			p1=y;
			dfs2(y);
		}
	}
	if(ct==1){
		for(auto y:v[x]){
			if(d[y]<d[x]) continue;
			pp[y]=p1;
			dfs2(y);
		}
	}
}

map<int, vector<int> > g;

void dfs3(int x){
	bool e=0;
	if(g[pp[x]].empty()) e=1;
	g[pp[x]].push_back(x);
	if(e && pp[x]!=0) dfs3(pp[x]);
}

ll dfs4(int x){
	if(g[x].empty()){
		return 500000004;
	}
	ll sum=0, prod=1;
	for(auto y:g[x]){
		ll c=dfs4(y);
		sum+=(c*inv(MOD+1-c)%MOD);
		sum%=MOD;
        prod*=(MOD+1-c);
        prod%=MOD;
	}
	return sum*prod%MOD;
}

int main()
{
	int n;
	scanf("%d", &n);
	for(int i=1; i<=n; i++){
		scanf("%d", &pp[i]);
		v[i].push_back(pp[i]);
		v[pp[i]].push_back(i);
	}
	fill(d, d+n+1, -1);
	d[0]=0;
	dist[0].push_back(0);
	dfs(0);
	dfs2(0);
	ll p2=1;
	for(int i=0; i<=n; i++){
		p2*=2;
		p2%=MOD;
	}
	ll ans=0;
	for(int t=0; t<=dmax; t++){
		if(t==0){
			ans+=500000004;
			continue;
		}
		g.clear();
		for(auto x:dist[t]){
			dfs3(x);
		}
		ans+=dfs4(0);
		ans%=MOD;
	}
	ans*=p2;
	ans%=MOD;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 35444
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
	  result=(result*base)%modulus;
	  exponent=exponent>>1;
	  base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
string s;
ll sink[MAX];
vl g[MAX];
ll ans[MAX];
int main(){FAST;
cin>>s;
ll n =s.length();
for(ll i=0;i<n;i++){
	if(s[i] == 'R' and s[i+1] == 'L'){
		sink[i]=i+1;
		sink[i+1]=i;
	}
}
for(ll i=0;i<n;i++){
	if(s[i] == 'L'){
		if(s[i-1] == 'R')continue;
		sink[i]=sink[i-1];
	}
}
for(ll i=n-1;i>=0;i--){
	if(s[i] == 'R'){
		if(s[i+1] == 'L')continue;
		sink[i]=sink[i+1];
	}
}
for(ll i=0;i<n;i++){
	ll si = sink[i];
	ll moves = abs(sink[i]-i);
	if(moves&1){
		if(s[i] == 'R'){
			ans[si-1]++;
		}
		else{
			ans[si+1]++;
		}
	}
	else{
		ans[si]++;	
	}
}
for(ll i=0;i<n;i++){
	cout<<ans[i]<<' ';
}
return 0;
}

Measured memory_bytes: 4560
// Contest: AtCoder Beginner Contest 159 (https://atcoder.jp/contests/abc159)
// Problem: A: The Number of Even Pairs (https://atcoder.jp/contests/abc159/tasks/abc159_a)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion }}}

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

    int n, m; cin >> n >> m;
    cout << (n * (n - 1) / 2 + m * (m - 1) / 2) << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
	return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
	mem(isprime,true);
	for(ll p=2;p*p<=n;p++)
	{
		if(isprime[p]==true)
		{
			for(ll i=p*p;i<=n;i+=p)
				isprime[i]=false;
		}
	}
}
ll lcm(ll a,ll b)
{
	return (a/__gcd(a,b))*b;
}
bool cmp(pair<string,ll> a,pair<string,ll> b)
{
	if(a.first<b.first)
		return 1;
	else if(a.x==b.x)
	{
		return a.y<b.y;
	}
	return 0;
}
bool cmp(ll a,ll b)
{
	return a>b;
}
void solve()
{
	ll w,h,x,y;
	cin>>w>>h>>x>>y;
	double a=w*h;
	cout<<fixed<<setprecision(9)<<a/2;
	if(2*x==w and 2*y==h)
	{
		cout<<" "<<"1";
	}
	else
	{
		cout<<" "<<"0";
	}
}	
int main()
{
	
	IOS
	ll t;
	t=1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 256
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li		int32_t
#define lli		long long
#define ulli unsigned long long

#define pn			 printf("\n")
#define nl			 cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define elif		else if
#define mset(a,b)	memset(a,b,sizeof(a))

#define pb		push_back
#define pob		pop_back
#define itr		iterator
#define sz()	size()
#define szof    sizeof
#define lb		lower_bound
#define ub		upper_bound
#define mp		make_pair
#define vlli    vector<lli>
#define plli	pair<lli,lli>
#define vplli	vector<plli >
#define F   	first
#define S		second
#define Dup     erase(unique(V.begin(),V.end()),V.end())

#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound

#define ALL(V)  V.begin(),V.end()

#define MX1     100000
#define MX2     1000000
#define MX3     1000
#define Inf     1000000000000000
#define mod		1000000007
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    opt;
    
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/
    
    lli T,t=1;
    T=1;
    
    while(T--)
    {
        lli N,i,L;
        cin>>N>>L;
        
        lli Store=-1;
        
        vlli V(N);
        rep(i,0,N)
        {
            cin>>V[i];
        }
        
        rep(i,0,N-1)
        {
            if(V[i]+V[i+1]>=L)
            {
                Store=i;
            }
        }
        
        if(Store==-1)
        {
            cout<<"Impossible";
        }
        else
        {
            cout<<"Possible\n";
            rep(i,0,Store)
            {
                cout<<i+1<<'\n';
            }
            
            repr(i,N-2,Store)
            {
                cout<<i+1;nl;
            }
            
            cout<<Store+1;
        }
    }
    
    



 return 0;
}


Measured memory_bytes: 1664
def gcd(a, b):
	while a > 0 and b > 0:
		a, b = b, a % b
	return a + b

def st(a, b):
	if b == 0:
		return 1
	if b % 2 == 0:
		q = st(a, b // 2)
		return q * q
	return a * st(a, b - 1)

n = int(input())
a = []
for i in range(n + 1):
	x = int(input())
	a.append(x)
ans = 0
massiv = [1, 2, 3, 5, 7, 11, 13, 17, 19, 21, 23, 9, 16]
for x in massiv:
	tmp = 0
	r = st(x, n)
	for i in range(0, n + 1):
		tmp += a[i] * r
		r //= x
	ans = gcd(ans, abs(tmp))
v = []
j = 2
while j * j <= ans:
	if ans % j == 0:
		ans //= j
		v.append(j)
	else:
		j += 1
if ans != 1:
	v.append(ans)
v.sort()
for i in range(len(v)):
	if i == 0 or v[i] != v[i - 1]:
		print(v[i])


Measured memory_bytes: 3572
using System;
 
class Program
{
    static void Main()
    {
        bool[,] t = new bool[4,13];
        
        int c = int.Parse(Console.ReadLine());
        
        for (int i = 0; i < c; i++)
        {
            string[] s = Console.ReadLine().Split(' ');
            int n = (int.Parse(s[1])-1);
            
            if (s[0]=="S") { t[0,n] = true; }
            else if (s[0]=="H") { t[1,n] = true; }
            else if (s[0]=="C") { t[2,n] = true; }
            else if (s[0]=="D") { t[3,n] = true; }
        }
        
        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 13; j++)
            {
                if (!t[i,j])
                {
                    string r = "";
                    
                    if (i==0) { r = "S " + (j+1).ToString(); }
                    else if (i==1) { r = "H " + (j+1).ToString(); } 
                    else if (i==2) { r = "C " + (j+1).ToString(); } 
                    else if (i==3) { r = "D " + (j+1).ToString(); } 
                    
                    Console.WriteLine(r);
                }
            }
        }
    }
}


Measured memory_bytes: 9252
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define     PI                       acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void GO(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
const int N=1000+5;

int main(){
    GO();

    int T;
    T=1;
   // cin>>T;
    while(T--){

        ll n;
        cin>>n;
        ll cur=0;
        for(int i=1;i<=100000000;i++){
            cur*=10;
            cur+=7;
            cur%=n;
            if(cur==0){
                cout<<i<<"\n";
                return 0;
            }
        }
        cout<<"-1\n";
    }
}


















































Measured memory_bytes: 3628
from collections import deque

K = int(input())
D = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

if K <= 9:
  print(D[K])
else:
  start = 1
  K -= 9
  while True:
    d = D[start]
    start += 1
    ichi = d % 10
    if ichi == 0:
      if K == 1:
        print(d * 10 + 0)
        break
      elif K == 2:
        print(d * 10 + 1)
        break
      else:
        D.append(d * 10 + 0)
        D.append(d * 10 + 1)
        K -= 2
    elif ichi == 9:
      if K == 1:
        print(d * 10 + 8)
        break
      elif K == 2:
        print(d * 10 + 9)
        break
      else:
        D.append(d * 10 + 8)
        D.append(d * 10 + 9)
        K -= 2
    else:
      if K == 1:
        print(d * 10 + ichi - 1)
        break
      elif K == 2:
        print(d * 10 + ichi)
        break
      elif K == 3:
        print(d * 10 + ichi + 1)
        break
      else:
        D.append(d * 10 + ichi - 1)
        D.append(d * 10 + ichi)
        D.append(d * 10 + ichi + 1)
        K -= 3

Measured memory_bytes: 7592
Q = int(input().strip())

NUMS = 100000
fs = [True] * (NUMS + 1)
cs = [0] * (NUMS + 1)

for i in range(2,NUMS):
    if fs[i]:
        for j in range(i + i, NUMS,i):
            fs[j] = False
for i in range(3,NUMS,2):
    if fs[i] and fs[int((i + 1) / 2)]:
        cs[i] += 1
for i in range(3,NUMS):
    cs[i] = cs[i] + cs[i - 1]

for i in range(0,Q):
    l,r = map(int,input().strip().split())
    print(cs[r] - cs[l - 1])


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

ans = 10**40
CS = [0] * (N+1)

for i in range(N):
    CS[i+1] = CS[i] + A[i]

for j in range(1,N):
    ans = min(ans,abs(2*CS[j]-CS[N]))

print(ans)


Measured memory_bytes: 24828
#include<iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    if(m==n)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

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

long long int fact(long long int n){
	if (n == 1){
		return 1;
	}
	else {
		return n * fact(n - 1);
	}
}


int main()
{
	long long int n;
	cin >> n;
	cout << fact(n) << endl;
	return 0;
}

Measured memory_bytes: 1156
import sys

l1 = sys.stdin.readline()
A = list(l1.strip())
l2 = sys.stdin.readline()
B = list(l2.strip())

flag = False

for i in range(0, len(A)):
  C = B[i:] + B[:i]
  # print(C)
  if A == C:
    flag = True
    break
  # C = []

    
if flag == True:
  print("Yes")
else:
  print("No")




Measured memory_bytes: 38256
#https://atcoder.jp/contests/abc086/tasks/abc086_b

import math
def try_square_root_naive(n):
    m = float(n**.5)
    return True if m == m // 1 else None

a,b = map(int,input().split())

n = 10 ** len(str(b)) * a + b
#print(n)
if try_square_root_naive(n) == True:
    print('Yes')
else:
    print('No')


    

Measured memory_bytes: 2940
import java.io.*;

class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {       
                int[] x = new int[10000];
                int[] y = new int[10000];
                int a = 0, b = 0;

                while(2 > 1){
                    String line = reader.readLine();
                    String[] strAry = line.split(" ");

                    x[a] = Integer.parseInt(strAry[0]);
                    y[a] = Integer.parseInt(strAry[1]);

                    if(x[a] == 0 && y[a] == 0){
                        break;
                    }
                    a += 1;

                }


                for(int i = 0; i < a; i++){
                    if(x[i] > y[i]){
                        b = y[i];
                        y[i] = x[i];
                        x[i] = b;
                    }
                    System.out.println(x[i] + " " + y[i]);
                }
                
        } catch (IOException e) {
            //TODO: handle exception
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 26776
#include <iostream>

int N;
int A[210];

int main(int argc, char *argv[]) {
  std::cin >> N;
  for (int i = 0; i < N; ++i)
    std::cin >> A[i];

  int res = 0;

  while(true) {
    bool exist_odd = false;
    for (int i = 0; i < N; ++i)
      if (A[i] % 2 != 0) exist_odd = true;

    if (exist_odd) break;

    for (int i = 0; i < N; ++i) A[i] /= 2;
    ++res;
  }

  std::cout << res << std::endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

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

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int[] a = new int[N];
            for (int i = 0; i < N; i++) {
                a[i] = in.nextInt();
            }
            Arrays.sort(a);
            int alice = 0, bob = 0;
            for (int i = N - 1; i >= 0; i--) {
                if ((N - 1 - i) % 2 == 0) alice += a[i];
                else bob += a[i];
            }
            out.println(alice - bob);
        }

    }
}



Measured memory_bytes: 21844