akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <string.h>
#include <sstream>
#include <cctype>
#include <climits>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <vector>
#include <iterator>
#include <algorithm>
#include <stack>
#include <functional>
using namespace std;
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
const double EULER = 0.577215664901532860;
const double PI = 3.1415926535897932384626;
const double E = 2.71828182845904523536028;
typedef long long LL;
LL pow_mod(LL a,LL b,LL m){
    LL d,t;
    d = 1;
    t = a;
    while (b > 0){
        if (b % 2 == 1)
            d = (d * t) % m;
        b /= 2;
        t = (t * t) % m;
    }
    return d;
}

LL gcd(LL a,LL b){return b == 0 ? a : gcd(b, a % b);}

// ios::sync_with_stdio(false);
// cin.tie(0);
//==============Code starts here================//
char arr[110][110];
int n,m;
int ans;

void dfs(int x, int y, char c){
	if(x < 0 || x >= n || y < 0 || y >= m || arr[x][y] != c){
		return;
	}
	arr[x][y] = '6';
	dfs(x+1,y,c);
	dfs(x-1,y,c);
	dfs(x,y+1,c);
	dfs(x,y-1,c);
	
 }
int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(cin >> n >> m && n && m){
        for(int i = 0; i < n; i++){
        	for(int j = 0; j < m; j++){
        		cin >> arr[i][j];
			}
		}
		ans = 0;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				if(arr[i][j] != '6'){
					ans++;
					dfs(i,j,arr[i][j]);
				}
			}
		}
		cout << ans << endl;
	}

    return 0;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

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

    int abs_i = -1;
    int abs_val = 0;
    REP(i, N) {
        int a;
        scanf("%d", &a);
        if(abs_i == -1 || abs(abs_val) < abs(a)){
            abs_val = a;
            abs_i = i;
        }
    }

    if(abs_val == 0) {
        cout << 0 << endl;
        return 0;
    }

    cout << 2 * N - 2 << endl;
    REP(i, N) {
        if(abs_i == i) continue;
        printf("%d %d\n", abs_i + 1, i + 1);
    }

    if(abs_val < 0) {
        for(int i = N; i > 1; i--){
            printf("%d %d\n", i, i - 1);
        }
    } else {
        for(int i = 1; i < N; i++){
            printf("%d %d\n", i, i + 1);
        }
    }

    return 0;
}


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

int main() {
  int N, H;
  int a[100000], b[100000];
  cin >> N >> H;
  int max_a = 0;
  for(int i = 0; i < N; i++) {
    cin >> a[i] >> b[i];
    if(a[i] > max_a) max_a = a[i];
  }
  sort(b, b + N);
  reverse(b, b + N);
  int cnt = 0;
  for(int i = 0; i < N; i++){
    if(b[i] > max_a){
      cnt++;
      H -= b[i];
    }
    if(H <= 0){
      cout << cnt << endl;
      return 0;
    }
  }
  if(H % max_a == 0) cout << cnt + H / max_a << endl;
  else cout << cnt + H / max_a + 1 << endl;
  return 0;
}


Measured memory_bytes: 1024
n = int(input()) 

cnt = [[0] * 10 for i in range(10)]

for i in range(n+1):
    a = int(str(i)[0])
    b = int(str(i)[-1])
    if a == 0 or b == 0:
        continue
    cnt[a][b] += 1

ans = 0
for i in range(n+1):
    a = int(str(i)[0])
    b = int(str(i)[-1])
    ans += cnt[b][a]
print(ans)

Measured memory_bytes: 9196
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	int N;
	int[] T;
	boolean[][][] dp;

	public void solve() {
		N = nextInt();
		T = new int[N];
		int sum = 0;
		for(int i = 0;i < N;i++){
			T[i] = nextInt();
			sum += T[i];
		}

		dp = new boolean[N + 1][2500 + 1][2500 + 1];
		dp[0][0][0] = true;

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

			for(int j = 0;j < 2500 + 1;j++){

				for(int k = 0;k < 2500 + 1;k++){

					if(!dp[i][j][k])continue;

					if(j + T[i] < 2500)dp[i + 1][j + T[i]][k] = true;

					if(k + T[i] < 2500)dp[i + 1][j][k + T[i]] = true;

					dp[i + 1][j][k] = true;

				}

			}

		}

		int ans = Integer.MAX_VALUE;

		for(int i = 0;i < 2500 + 1;i++){
			for(int j = 0;j < 2500 + 1;j++){
				if(dp[N][i][j]){
					ans = Math.min(ans, Math.max(sum - i - j,Math.max(i, j)));
				}

			}
		}

		out.println(ans);
	}
	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 438004
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};
int dyy[]={0,-1,0,1};
int dxx[]={-1,0,1,0};

/*#define int ll*/
signed main(){
    int n,k;
    cin>>n>>k;
    if(n%k==0)cout<<'0'<<endl;
    else cout<<"1"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <string>
#include <tuple>
#include <random>

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

int main()
{
  int n;
  cin >> n;
  vector<int> w(n);
  int sum = 0;
  for (auto &e : w)
    cin >> e, sum += e;
  int t = 0, ans = 1000000;
  for (int i = 0; i < n; ++i)
  {
    t += w[i];
    ans = min(ans, (int)abs(t - (sum - t)));
  }
  cout << ans << endl;

  return 0;
}


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

int main()
{
    int a, b, k;
    scanf("%d %d", &a, &b);
    if((a+b)%2==1)
    {
        printf("IMPOSSIBLE");
        //return 0;
    }
    else 
    {
        printf("%d",(a + b) / 2);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll N; cin >> N;
    int M = 1e9+7;
    vector<int> dp[4][4][4];
    rep(i, 4) rep(j, 4) rep(k, 4) {
        dp[i][j][k] = vector<int>(N + 1, 0);
    }

    rep(i, 4) rep(j, 4) rep(k, 4) {
        if(!((i == 0 && j == 1 && k == 2) || (i == 0 && j == 2 && k == 1) || (i == 1 && j == 0 && k == 2))) {
            dp[i][j][k][3] = 1;
        }
    }

    for (int n = 3; n < N; n++) {
        for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) for (int k = 0; k < 4; k++) {
            if (j == 0 && k == 2) {
                dp[j][k][0][n + 1] = (dp[j][k][0][n + 1] + dp[i][j][k][n]) % M;
                dp[j][k][2][n + 1] = (dp[j][k][2][n + 1] + dp[i][j][k][n]) % M;
                dp[j][k][3][n + 1] = (dp[j][k][3][n + 1] + dp[i][j][k][n]) % M;
            } else if ((i == 0 && k == 1) || (i == 0 && j == 1) || (j == 0 && k == 1) || (j == 1 && k == 0)) {
                dp[j][k][0][n + 1] = (dp[j][k][0][n + 1] + dp[i][j][k][n]) % M;
                dp[j][k][1][n + 1] = (dp[j][k][1][n + 1] + dp[i][j][k][n]) % M;
                dp[j][k][3][n + 1] = (dp[j][k][3][n + 1] + dp[i][j][k][n]) % M;
            } else {
                for (int m = 0; m < 4; m++) {
                    dp[j][k][m][n + 1] = (dp[j][k][m][n + 1] + dp[i][j][k][n]) % M;
                }
            }
        }
    }

    ll res = 0;
    rep(i, 4) rep(j, 4) rep(k, 4) res = (res + dp[i][j][k][N]) % M;
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
K, N = map(int, input().split())
An = list(map(int, input().split()))
##大きい順に並べ替える
##sort関数はnoneが返ってくるのでこっち
Bn = sorted(An)

##ここが一番遠いと仮定する
C = K-(Bn[N-1]-Bn[0])

##１つ１つの差を計算してリストへ入れて最大を探す
for i in range(N-1):
    C = max(C, Bn[i+1]-Bn[i])

print(K-C)


Measured memory_bytes: 25452
#include <bits/stdc++.h>
            #include<iostream>
            #include<cstdio>
            #include<vector>
            #include<queue>
            #include<map>
            #include<cstring>
            #include<string>
            #include <math.h>
            #include<algorithm>
        //    #include <boost/multiprecision/cpp_int.hpp>
            #include<functional>
          #define int long long
            #define inf  1000000007
            #define pa pair<int,int>
    #define ll long long
            #define pal pair<ll,ll>
            #define ppa pair<int,pa>
            #define  mp make_pair
            #define EPS (1e-10)
            #define equals(a,b) (fabs((a)-(b))<EPS)
     
            using namespace std;
     
            class Point{
            	public:
            	double x,y;
            	Point(double x=0,double y=0):x(x),y(y) {}
            	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
            	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
            	Point operator * (double a) {return Point(x*a,y*a);}
            	Point operator / (double a) {return Point(x/a,y/a);}
            	double absv() {return sqrt(norm());}
            	double norm() {return x*x+y*y;}
            	bool operator < (const Point &p) const{
            		return x != p.x ? x<p.x: y<p.y;
            	}
            	bool operator == (const Point &p) const{
            		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
            	}
            };
            typedef Point Vector;
     
            struct Segment{
            Point p1,p2;
            };
     
        double hen(Vector a){
        if(fabs(a.x)<EPS && a.y>0) return acos(0);
        else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
        else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
        else if(fabs(a.y)<EPS && a.x>0) return 0.0;
        else if(a.y>0) return acos(a.x/a.absv());
        else return 2*acos(0)+acos(-a.x/a.absv());
     
        }
     
            double dot(Vector a,Vector b){
            	return a.x*b.x+a.y*b.y;
            }
            double cross(Vector a,Vector b){
            	return a.x*b.y-a.y*b.x;
            }
        
            //----------------kokomade temple------------
int n,m,k,x;
    signed main(){
 string s;
    	int ans=0;
    	cin>>s;
    	int l=s.length();
    	for(int i=1;i<l;i++){
    		if(s[i]!=s[i-1]) ans++;
    	}
    	cout<<ans<<endl;
    //	printf("%.10f\n",ans);
    	return 0;
    }

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

int main(void) {
    char *buf;
    char *p;

    int pcnt = 0,gcnt = 0;
    int i = 0;

    buf = calloc(1,100002);

    p = fgets(buf, 100002, stdin);
    while(1){
        if(buf[i] == 'g')
            gcnt++;
        else if(buf[i] == 'p') pcnt++;
        else break;
        i++;
    }
    
    printf("%d\n", (gcnt - pcnt)/2);
    free(buf);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int x, y, i, j;
    scanf("%d", &x);
    for(i=x;i>0;i++){
        int p=0;
        for(j=1;j<=i;j++){
            if(i%j==0)
            {
                p++;
            }
        }
        if(p==2)
        {
            printf("%d", i);
            break;
        }
    }
}






Measured memory_bytes: 1728
#include "bits/stdc++.h"
using namespace std;

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(ll i=0; i<(n); i++)
#define REPj(n) for(ll j=0; j<(n); j++)
#define REPinit(i,a,n) for(ll i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(ll j=(a); j<(n); j++)

//algorithm
#define SORT(c) sort((c).begin(),(c).end())
#define CONTAINER_ALL(a) a.begin(),a.end()

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


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

    vector<int> abc(3, 0);
    REPinit(i, 0, 3) {
        cin >> abc[i];
    }

    sort(ALL(abc));

    cout << (abc[0] + abc[1]) << endl;


    return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>
using namespace std;

struct Node {
	int key;
	Node* parent = NULL, *left = NULL, *right = NULL;
};

class Tree {
private:
	Node * root = NULL;
	void In_rec(Node*);
	void Pre_rec(Node*);
	bool Find_rec(Node*, int);
	void In();
	void Pre();
public:
	void Insert(Node*);
	void Print();
	void Find(int);
};

void Tree::Insert(Node* z)
{
	Node* y{}, *x{ this->root };
	while (x != NULL)
	{
		y = x;
		if (z->key < x->key)
			x = x->left;
		else
			x = x->right;
	}
	z->parent = y;

	if (y == NULL)
		this->root = z;
	else if (z->key < y->key)
		y->left = z;
	else
		y->right = z;
	return;
}

void Tree::In()
{
	In_rec(this->root);
	printf("\n");
	return;
}

void Tree::In_rec(Node* n)
{
	if (n)
	{
		In_rec(n->left);
		printf(" %d", n->key);
		In_rec(n->right);
	}
	return;
}

void Tree::Pre()
{
	Pre_rec(this->root);
	printf("\n");
	return;
}

void Tree::Pre_rec(Node* n)
{
	if (n)
	{
		printf(" %d", n->key);
		Pre_rec(n->left);
		Pre_rec(n->right);
	}
	return;
}

void Tree::Print()
{
	this->In();
	this->Pre();
}

void Tree::Find(int k)
{
	if (this->Find_rec(this->root, k))
		printf("yes\n");
	else
		printf("no\n");
}

bool Tree::Find_rec(Node* n, int k)
{
	if (!n)
		return false;
	else if (n->key == k)
		return true;
	else if (k < n->key)
		return Find_rec(n->left, k);
	else
		return Find_rec(n->right, k);
}

int main()
{
	int n, tmpkey;
	char tmp[16];
	Tree tree;
	scanf("%d", &n);
	Node* node = new Node[n];

	for (int i = 0; i < n; i++)
	{
		scanf("%s", tmp);
		if (tmp[0] == 'i')
		{
			scanf("%d", &node[i].key);
			tree.Insert(node + i);
		}
		else if (tmp[0] == 'p')
			tree.Print();
		else
		{
			scanf("%d", &tmpkey);
			tree.Find(tmpkey);
		}
	}



	delete[] node;
	return 0;
}


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

//long long型(64bit整数)
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    ll a[210000];
    for(ll i=0; i<n; i++){
        cin >> a[i];
        a[i] -= (i+1);
    }
    sort(a, a + n);
    ll ans = 0;
    for(ll i=0; i<n; i++){
        ans += abs(a[i] - a[n/2]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
import numpy as np

S = input()
MOD = 2019
dp = np.zeros(MOD, dtype=np.int64)
dp[0] = 1

def hoge(dp, s):
    T = dp.copy()
    dp[s:] = T[:-s]
    dp[:s] = T[-s:]

ans = 0
for i, s in enumerate(S[::-1]):
    hoge(dp, (int(s) * pow(10, i, MOD)) % MOD)
    ans += dp[0]
    dp[0] += 1
print(ans)


Measured memory_bytes: 26924
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	N := readInt()
	K := readInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = readInt()
	}
	F := make([]int, N)
	for i := 0; i < N; i++ {
		F[i] = readInt()
	}

	sort.Ints(A)
	sort.Sort(sort.Reverse(sort.IntSlice(F)))

	l := -1
	r := A[N-1]*F[0] + 1
	for l+1 < r {
		m := (l + r) / 2
		isOk := func(x int) bool {
			result := 0
			for i := 0; i < N; i++ {
				t := A[i] - x/F[i]
				if t > 0 {
					result += t
				}
			}
			return result <= K
		}
		if isOk(m) {
			r = m
		} else {
			l = m
		}
	}
	fmt.Println(r)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 6656
import sys
import math
import numpy as np
import copy

def main():
    s = input()

    a, b, c, d = "dream", "dreamer", "erase", "eraser"
    ra, rb, rc, rd = a[::-1], b[::-1], c[::-1], d[::-1]
    rs = s[::-1]

    while rs:
        flag = False
        for ele in [ra, rb, rc, rd]:
            if rs.startswith(ele):
                rs = rs.replace(ele, "", 1)
                flag = True
        if not flag:
            print("NO")
            return 0
    
    print("YES")
    return 0

if __name__ == '__main__':
    sys.exit(main())

Measured memory_bytes: 13216
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IPT1_2A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] StrNum = Console.ReadLine().Split(' ');
            int Num0 = int.Parse(StrNum[0]);
            int Num1 = int.Parse(StrNum[1]);
            if (Num0 > Num1) Console.WriteLine("a > b");
            else if (Num0 < Num1) Console.WriteLine("a < b");
            else Console.WriteLine("a == b");
        }
    }
}

Measured memory_bytes: 8872
import scala.io.StdIn.readLine

object Main {

  def pow(x:Long, y:Long, z:Long):Long = {

    def multi(m:Long, n:Long) = { ( (m%z) * (n%z) ) % z }

    def pow2(m:Long, n:Long, odd:Long, b:Long):Long = {
      n match {
        case 0 => 1
        case 1 => multi(m, odd)
        case _ =>
          val t = if(n%2 == 1) multi(odd, b) else odd
          pow2(multi(m,m), n/2, t, multi(b,b))
      }
    }
    pow2(x, y, 1, x)
  }

  def main(args: Array[String]) = {
    val l = readLine().split(" ").map(_.toLong)
    val (m, n) = (l(0), l(1))
    println(pow(m,n,1000000007))
  }
}

Measured memory_bytes: 43820
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

int n,q;
string s;
set<int> chara[26];
vector<int> ans;
int main(){
    cin >> n >> s >> q;
    rp(i,n){
        chara[s[i]-'a'].insert(i);
    }
    rp(i,q){
        int t;
        cin >> t;
        if(t==1){
            int a;
            char c;
            cin >> a >> c;
            a--;
            int cint=c-'a';
            int bef=s[a]-'a';
            if(s[a]==c) continue;
            s[a]=c;
            chara[bef].erase(a);
            chara[cint].insert(a);
            
        }
        if(t==2){
            int l,r;
            cin >> l >> r;
            l--; r--;
            int ctr=0;
            rp(j,26){
                auto ite=chara[j].lower_bound(l);
                if(ite!=chara[j].end()&&*ite<=r) {ctr++;}
            }
            ans.push_back(ctr);
        }
    }
    /*auto it=chara[3].begin();
    print(*it);
    print(s);*/
    for(auto an:ans){
        cout << an << endl;
    }
    return 0;
}

Measured memory_bytes: 24452
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};


int main(){
  int a,b; cin>>a>>b;
  if(a<b){
    rep(i,b)
    cout<<a;
  }else{
    rep(i,a)
    cout<<b;
  }
  cout<<endl;


  return 0;
}


Measured memory_bytes: 256
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
#文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
#文字列として取得
def ST(): return sys.stdin.readline().rstrip()
def LST(): return sys.stdin.readline().rstrip().split()
def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)

N  = I()
A = LI()
sum = [0]*(N+2)
sum[N] = A[N]
for i in range(N-1,-1,-1):
    sum[i] = sum[i+1]+A[i]

if N==0:
    if A[0]==1:
        print(1)
    else:
        print(-1)
else:
    if A[0]!=0:
        print(-1)
    else:
        ans = 1
        b = 1
        for i in range(1,N+1):
            a = A[i]
            b_ = sum[i+1]
            if b_<b-a or 2*b-a<0:
                print(-1)
                break
            b_ = min(b_, 2*b-a)
            ans += a+b_
            b = b_
        else:
            print(ans)


Measured memory_bytes: 86260
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;



int main()
{
  set<int> s;
  int m1=0, m2=0;
  int n;cin>>n;
  for(int i=0;i<n;i++)
    {
      int a;cin>>a;
      if(s.find(a)==s.end())
	s.insert(a);
      else if(a>m2)
	{
	  s.erase(a);
	  m2=m1;
	  m1=max(a,m1);
	  m2=min(m2,a);
	}
    }
  printf("%lld\n",(long long)m1*(long long)m2);
  return 0;
}


Measured memory_bytes: 4992
import copy
N=int(input())
A=[int(input()) for _ in range(N)]
l=[]
for i in range(N):
    l.append([A[i],i])
l.sort(key=lambda x:x[0],reverse=True)
#print(l)
excep=l[0][1]

for i in range(N):
    if i==excep:
        print(l[1][0])
    else:
        print(l[0][0])




Measured memory_bytes: 96600
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){

    ll N, A, B;
    cin >> N >> A >> B;
    if((B - A) % 2 == 0){
        cout << (B - A) / 2 << endl;
        return 0;
    }

    ll tmp = A, a = 1, b = B - tmp;
    ll ans = tmp + (b - a) / 2;

    tmp = N + 1 - B;
    a = A + tmp;
    b = N;
    chmin(ans, tmp + (b - a) / 2);
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,a,b,num,digit,ns=0,ds;
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++)
	{
		num=i;
		ds=0;
		while(num!=0)
		{
			digit=num%10;
			ds+=digit;
			num=num/10;
		}
		if(ds>=a&&ds<=b)
		ns+=i;
	}
	cout<<ns;
	return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop
from typing import List, Tuple
import sys


if __name__ == "__main__":
    num_vertices = int(input())
    adj_list: List[List[Tuple[int, int]]] = [[] for _ in range(num_vertices)]

    for _ in range(num_vertices):
        vertex, adj_num, *adjs = map(lambda x: int(x), input().split())
        for i in range(adj_num):
            # (cost, adj)
            adj_list[vertex].append((adjs[2 * i + 1], adjs[2 * i]))

    distances: List[int] = [sys.maxsize] * num_vertices
    distances[0] = 0
    que: List[Tuple[int, int]] = []
    heappush(que, (0, 0))

    while [] != que:
        base_distance, parent = heappop(que)
        for cost, adj in adj_list[parent]:
            distance = base_distance + cost
            if distance < distances[adj]:
                distances[adj] = distance
                heappush(que, (distance, adj))

    for vertex, distance in enumerate(distances):
        print(f"{vertex} {distance}")



Measured memory_bytes: 70240
N=int(input())
*A,=map(int, input().split())
from collections import Counter
C=Counter(A)
ca=-1
E=sorted(C.items(), key=lambda x:x[0], reverse=True)
for k,v in E:
    if ca >= 0:
        if v >= 2:
            print(ca*k)
            exit()
    else:
        if v >= 4:
            print(k*k)
            exit()
        elif v >= 2:
            ca = k
print(0)

Measured memory_bytes: 74648
#!/usr/bin/env python3
a, b, c, d = map(int, input().split())
arr = [0] * 101

for i in range(a, b + 1):
    arr[i] += 1

for j in range(c, d + 1):
    arr[j] += 1

ans = len([cnt for cnt in arr if cnt >= 2])

print(ans - 1 if ans != 0 else 0)



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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	string x, s = "Sunny", c = "Cloudy";
	cin >> x;
	if(x == s) cout << "Cloudy";
	else{
		if(x == c) cout << "Rainy";
		else cout << "Sunny";
	}

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long int lld;
#define sq(x) (x*x*x*x*x)
#define fr(i,m,n) for(i=m;i<n;i++)
#define vec vector<int>
#define sint set<int>
#define qint queue<int>
#define mip map<int,int>
#define pint priority_queue<int>
#define pb push_back
#define pp pop_back()
#define ft first
#define sd second
#define full(v) v.begin(),v.end()
int main()
{
    lld i,j,k,a,b,c,x,y,z,n,m,t;
    string s,u,v;
    cin>>c;bool ans=false;
    fr(i,0,1000){
        x=sq(i);z=x-c;
        fr(j,0,1000){
            y=sq(j);
                if(y==abs(z)){ans=true;break;}
                else if(y>abs(z)) break;
        }
        if(ans) break;
    }
    if(z>=0) cout<<i<<" "<<j<<endl;
    else cout<<i<<" "<<-j<<endl;
}

Measured memory_bytes: 3604
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(
					System.in));

			int[][] house = new int[12][10];

			for (int[] rooms : house) {
				for (int room : rooms) {
					room = 0;
				}
			}

			int n = Integer.parseInt(br.readLine());
			String[] strs;

			for (int i = 0; i < n; i++) {
				strs = br.readLine().split("\\s");
				house[(Integer.parseInt(strs[0]) - 1) * 3
						+ Integer.parseInt(strs[1]) - 1][Integer
						.parseInt(strs[2]) - 1] += Integer.parseInt(strs[3]);
			}

			for (int i = 0; i < house.length; i++) {
				for (int j = 0; j < house[i].length; j++) {
					if (j != 0 || j != house[i].length - 1)
						System.out.print(" " + house[i][j]);
				}
				System.out.println();
				if (i != 0 && i != house.length - 1 && (i + 1) % 3 == 0)
					System.out.println("####################");
			}
			br.close();
		} catch (Exception e) {
			System.err.println(e);
		}
	}
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

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

#define MAX 100005
#define INF INT_MAX

string x, y;
vector < vector<int> > memo;

int lcs(int xs, int ys)
{
    if (xs == 0 || ys == 0) return 0;
    if (memo[xs][ys]) return memo[xs][ys];

    int res;
    if (x[xs-1] == y[ys-1]) {
        res = lcs(xs-1, ys-1) + 1;
    } else {
        res = max(lcs(xs,ys-1), lcs(xs-1,ys));
    }
    memo[xs][ys] = res;
    return res;
}

int main(int, char**)
{
    int q;
    cin >> q;

    vector<int> ans;
    rep(i,q) {
        cin >> x >> y;
        int xs = x.size();
        int ys = y.size();
        memo.assign(xs+1, vector<int>(ys+1,0));
        ans.push_back(lcs(xs,ys));
    }

    rep(i,q) cout << ans[i] << endl;
    return 0;
}



Measured memory_bytes: 6952
import scala.math._

object Main {
  def main(args: Array[String]) {
    val sc = new java.util.Scanner(System.in)
    val T = sc.nextInt()
    for (i <- 1 to T) {
      var xa, ya, xb, yb = sc.nextInt()
      xb -= xa
      yb -= ya
      val theta = atan2(yb, xb)
      val n = sc.nextInt()
      val xlist = (
        for {
          j <- 1 to n
          xs_ = sc.nextInt(); ys_ = sc.nextInt();
          xt_ = sc.nextInt(); yt_ = sc.nextInt();
          o = sc.nextInt(); l = sc.nextInt();
          (xs, ys) = rot(xs_ - xa, ys_ - ya, -theta)
          (xt, yt) = rot(xt_ - xa, yt_ - ya, -theta)
          if ys*yt < 0
        } yield ((xs*yt-xt*ys)/(yt-ys), o, l)
      ).toList.sortWith(_._1 < _._1).filter(_._1 > 0).filter(_._1 < pow(xb*xb+yb*yb,0.5))

      println(min(count(0, xlist), count(1, xlist)))
    }
  }
  def rot(x: Double, y: Double, theta: Double) = {
    val c = cos(theta)
    val s = sin(theta)
    (c*x - s*y, s*x + c*y)
  }
  def count(l_ : Int, xlist: List[(Double, Int, Int)]): Int = {
    if (xlist.size == 0) {
      0
    } else {
      val (x, o, l) = xlist.head;
      if((l == l_ && o == 1) || (l != l_ && o == 0)) {
        1 + count(if(l_ == 1) 0 else 1, xlist.tail)
      } else {
        count(l_ , xlist.tail)
      }
    }
  }
}

Measured memory_bytes: 271976
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;
#define all(a) a.begin(), a.end()
#define eall(a) a.begin()+1, a.end()
#define show(ans)  cout << ans << endl;

long s[11][11];
long relate[11][11];
int main(){
long N, M, tmp, Ptmp;
string Stmp;

cin >> N >> M;
vector<long> k(M+1);
erep(i, M){
    cin >> k[i];
    erep(j, k[i]){
        cin >> s[i][j];
        relate[i][s[i][j]] = 1;
    } 
}
// erep(i, M){
//     erep(j, N) show(relate[i][j]);
// }
vector<long> p(M+1);
vector<long> tmpp(M+1);
erep(i, M) cin >> p[i];

long cnt = 0;
rep(sw, pow(2, N)){
    erep(i, M) tmpp[i] = 0;
    // long sw = 2;
    erep(j, M){
        rep(i, N){
            if(((sw >> i) & 1) && (relate[j][i+1] == 1)){
                tmpp[j] = tmpp[j] ^ 1;
            }
            // show(tmpp[j] << sw);
        }
        if(tmpp[j] != p[j]) break;
        if(j == M) cnt++;
    }
}
show(cnt);

return 0;
}

Measured memory_bytes: 256
//#include <atcoder/all>
#include <bits/stdc++.h>
//using namespace atcoder;
using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; 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;
}


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll x; cin >> x;
  
  ll ans = 0;
  ll k = x / 11;
  ans += k * 2;
  x -= k * 11;
  if(x > 6) ans += 2;
  else if(x == 0) {}
  else ans += 1;
  
  
  cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
using namespace std;
int p[101],r[101];
void makeset(int x){
    for(int i=0;i<x;++i){
        p[i]=i;
        r[i]=0;
    }
}
int root(int a){
    if(a!=p[a])
        p[a]=root(p[a]);
    return p[a];
}
bool same(int a,int b){
    return (root(a)==root(b));
}
void link(int a,int b){
    if(r[a]>r[b]){
        p[b]=a;
    }
    else{
        p[a]=b;
        if(r[a]==r[b]){
            r[b]++;
        }
    }
}
void unite(int a,int b){
    link(root(a),root(b));
}
struct Edges{int cost,src,dst;}edges[10010];
bool operator<(const Edges &x,const Edges &y){return x.cost<y.cost;}
int main(){
    int N,M=0;
    int A[101][101];
    cin>>N;
    makeset(N);
    for(int r=0;r<N;++r){
        for(int c=0;c<N;++c){
            cin>>A[r][c];
        }
        for(int c=r+1;c<N;++c){
            if(A[r][c]>-1){
                edges[M].cost=A[r][c];
                edges[M].src=r;
                edges[M].dst=c;
                M+=1;
            }
        }
    }
    sort(edges,edges+M);
    int total=0,num=0,flag=0;
    for(int i=0;i<M;++i){
        if(same(edges[i].src,edges[i].dst)){continue;}
        else{
            unite(edges[i].src,edges[i].dst);
            total+=edges[i].cost;
            num++;
        }
        if(num==N-1){
            flag=1;
            break;
        }
    }
    if(flag){
        cout<<total<<endl;
    }
}

Measured memory_bytes: 3212
import sys
INF = 10**9
sys.setrecursionlimit(INF)


def main():
    n, m, x, *ca = map(int, open(0).read().split())
    ca = [ca[(1 + m) * _i:(1 + m) * (_i + 1)] for _i in range(n)]

    ans = INF
    # bit全探索
    for i in range(1 << n):
        tmp_ca = [0] * (m + 1)
        for j in range(n):
            if i >> j & 1:
                tmp_ca = [_i + _j for _i, _j in zip(ca[j], tmp_ca)]
        is_true = all([True if _i >= x else False for _i in tmp_ca[1:]])
        if is_true:
            if tmp_ca[0] < ans:
                ans = tmp_ca[0]

    if ans == INF:
        ans = -1

    print(ans)
    return(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9148
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define rep(x, s, t) for(int x = s; x <= t; x++)

using namespace std;

int n;
string s;
vector<int> lvec, rvec;

int main(void)
{
	cin >> n;
	cin >> s;
	
	rep(i, 0, n-1){
		if(s[i] == '<') lvec.push_back(i);
		if(s[i] == '>') rvec.push_back(i);
	}
	
	int ans = 0;
	rep(i, 0, n-1)
	{
		int lnum = lower_bound(rvec.begin(), rvec.end(), i) - rvec.begin();
		int rnum =  lvec.end() - lower_bound(lvec.begin(), lvec.end(), i+1);
		//cout << i << ' ' << lnum << ' ' << rnum << endl;
		if(lnum > rnum || lnum == rnum && s[i] == '>'){
			if(s[i] == '<') rnum++;
			ans = max(ans, n-rvec[lnum-rnum]);
		}
		else{
			if(s[i] == '>') lnum++;
			ans = max(ans, lvec[(int)lvec.size()-rnum+lnum-1]+1);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3736
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var par []int

func main() {
	var N, M, K int
	fmt.Scan(&N, &M, &K)

	makeSet(N)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	dame := make([][]int, N)
	for i := 0; i < M; i++ {
		var a, b int
		sc.Scan()
		a, _ = strconv.Atoi(sc.Text())
		sc.Scan()
		b, _ = strconv.Atoi(sc.Text())
		a--
		b--
		dame[a] = append(dame[a], b)
		dame[b] = append(dame[b], a)
		unite(a, b)
	}
	for i := 0; i < K; i++ {
		var c, d int
		sc.Scan()
		c, _ = strconv.Atoi(sc.Text())
		sc.Scan()
		d, _ = strconv.Atoi(sc.Text())
		c--
		d--
		if root(c) != root(d) {
			continue
		}
		dame[c] = append(dame[c], d)
		dame[d] = append(dame[d], c)
	}
	for i := 0; i < N; i++ {
		total := -par[root(i)] - 1
		total -= len(dame[i])
		fmt.Printf("%d ", total)
	}
	fmt.Println()
}

func makeSet(N int) {
	par = make([]int, N)
	for i := range par {
		par[i] = -1
	}

}

func root(x int) int {
	if par[x] < 0 {
		return x
	}
	par[x] = root(par[x])
	return par[x]
}

func unite(x, y int) {
	x = root(x)
	y = root(y)
	if x == y {
		return
	}
	if par[x] > par[y] {
		x, y = y, x
	}
	par[x] += par[y]
	par[y] = x
}


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

int main() {
  int a, b;
  char op;
  while (true) {
    cin >> a >> op >> b;
    switch (op) {
    case '+': cout << (a + b) << endl; break;
    case '-': cout << (a - b) << endl; break;
    case '*': cout << (a * b) << endl; break;
    case '/': cout << (a / b) << endl; break;
    case '?': return 0;
    }
  }
}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

LL sum[100010];
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  LL N, L; cin >> N >> L;
  vector<LL> xs(N);
  REP(i,N){
	cin >> xs[i];
  }

  int ok = -1;
  REP(i,N-1)
	if(xs[i] + xs[i+1] >= L){
	  ok = i;
	}

  if(ok < 0) cout << "Impossible" << endl;
  else{
	cout << "Possible" << endl;
	REP(i,ok){
	  cout << i+1 << endl;
	}
	for(int i=N-2;i>=ok;--i)
	  cout << i+1 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 1664
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Pattern;

public class Main {
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		int n = Integer.parseInt(reader.readLine());
		Pattern pattern = Pattern.compile("that|this");
		while (n-- > 0) {
			String result = reader.readLine();
			String a = result;
			loop: for (int i = 1; i < 26; i = i + 2) {
				for (int j = 0; j < 26; j++) {
					a = rep(result, i, j);
					
					if (pattern.matcher(a).find()) {
						builder.append(a).append('\n');
						break loop;
					}
				}
			}
		}
		System.out.print(builder);
	}

	private static String rep(String a, int i, int j) {
		char[] chs = new char[a.length()];
		for (int k = 0; k < a.length(); k++) {
			if ('a' <= a.charAt(k) && a.charAt(k) <= 'z') {
				int b = a.charAt(k) - 97;
				chs[k] = (char) ((b * i + j) % 26 + 97);
			}
			else{
				chs[k] = a.charAt(k);
			}
		}
		return String.valueOf(chs);
	}
}

Measured memory_bytes: 21656
#include <iostream>

using namespace std;

int main() {
	long long int n, k;

	cin >> n >> k;

	if (k % 2 == 0) {
		long long int ans = n / k;
		long long int ans2 = n / k;
		if (ans2*k + k / 2 <= n) {
			ans2++;
		}
		cout << ans * ans * ans + ans2 * ans2 * ans2 << endl;
	}
	else {
		long long int ans = n / k;
		cout << ans * ans * ans << endl;
	}

	return 0;
}

/*

a + b = p * k
a + c = q * k

b + c = (p+q)*k - 2*a



*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<string> key,str;
string t,s;
int ind;

void getkey(){
  int x=0;
  for(int i=1;i<t.size();i++)
    if(!x&&t[i]!='.')x=i;
    else if(t[i]=='.')
      key.push_back(t.substr(x,i-x)),x=0;
}

void getstr(){
  int f=0; ind=0;
  string a;
  for(int i=0;i<s.size();i++)
    if(!f&&s[i]==' ')ind++;
    else f=1;
  for(int i=ind;i<s.size();i++){
    if(s[i]!=' ')a+=s[i];
    else{
      if(a[a.size()-1]==':')str.push_back(a.substr(0,a.size()-1)),a="";
      else{
	str.push_back(a+s.substr(i,s.size()-i));
	a="";
	break;
      }
    }
  }
  if(a!=""){
    if(a[a.size()-1]!=':')str.push_back(a);
    else str.push_back(a.substr(0,a.size()-1));
  }
}

int main(){
  cin>>t; t+='.';
  getkey();
  getline(cin,s);
  int x=-1,y=0,f=0;
  while(getline(cin,s)){
    str.clear();
    getstr();
    if(x<ind&&y!=key.size()&&str[0]==key[y]){
      x=ind;
      y++;
      if(y==key.size()){
	if(!f&&str.size()==2)cout<<"string \""<<str[1]<<"\""<<endl;
	else if(!f)cout<<"object"<<endl;
	f=1;
      }
    }
  }
  if(!f)cout<<"no such property"<<endl;
  return 0;
}

Measured memory_bytes: 1316
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>

using namespace std;

/* 

   O(n log log n) だいたい線形。 10万とかは余裕
 */
template<typename T>
std::vector<T> sieve(T n)
{
    std::vector<T> primes;
    std::vector<bool> is_prime(n, true);
    is_prime[0] = is_prime[1] = false;

    for (T i = 2; i <= n; ++i) {
        if (is_prime[i]) {
            primes.push_back(i);
            for (T j = 2 * i; j <= n; j += i) {
                is_prime[j] = false;
            }
        }
    }
    return primes;
}


int main()
{
    size_t Q;
    std::cin >> Q;

    const auto primes = sieve<int64_t>(100000);

    std::vector<int64_t> ss;
    for (auto& p : primes) {
        auto pos = std::find(std::begin(primes), std::end(primes), (p+1)/2);
        if (pos != std::end(primes)) {
            ss.push_back(p);
        }
    }

    for (size_t i = 0; i < Q; ++i) {
        int64_t l, r;
        std::cin >> l >> r;
        auto n = std::count_if(std::begin(ss), std::end(ss), [l, r](auto p) {
                return (l <= p) && (p <= r);
            });

        std::cout << n << std::endl;

    }

    return 0;
}


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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int ans;
  if (A * N < B) {
    ans = N * A;
  } else {
    ans = B;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mod 1000000007
#define ll long long int
#define pi 3.141592653589793238
const int N = 1e5 + 10;
int main(){
    FAST;
    ll t=1;
    // cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int cnt=0;
        bool f=false;
        while(n--)
        {
            int x,y;
            cin>>x>>y;
            if(x==y)
                cnt++;
            else
                cnt=0;
            if(cnt==3)
                f=true;
        }
        if(f)
            cout<<"Yes";
        else
            cout<<"No";
        }
    return 0;
}


Measured memory_bytes: 3656
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

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

int main(){
	string s, t;
	cin >> s >> t;
	sort(begin(s), end(s), [](char a, char b){return a < b; });
	sort(begin(t), end(t), [](char a, char b){return a > b; });
	if (s < t){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
 	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    bool flag = true;
    if (a == b && a != c) flag = false;
    if (a == c && b != c) flag = false;
    if (c == b && b != a) flag = false;

    cout << (flag ? "No" : "Yes") << endl;

    return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  dsu D(N);
  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    A--;
    B--;
    D.merge(A, B);
  }
  auto G = D.groups();
  int ans = G.size();
  ans--;
  cout << ans << endl;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  cin >> N;

  cout << (N + 1) / 2 << endl;

  return 0;
}


Measured memory_bytes: 256