akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    string s1("");
    s1.push_back('0');
    for (int i = 1; i < n; ++i) {
        if (s1.back() == '0') {
            s1.push_back('1');  
        }
        else {
            s1.push_back('0');  
        }
    }
    string s2("");
    s2.push_back('1');
    for (int i = 1; i < n; ++i) {
        if (s2.back() == '0') {
            s2.push_back('1');  
        }
        else {
            s2.push_back('0');  
        }
    }
    int ans1 = 0, ans2 = 0;
    for (int i = 0; i < n; ++i) {
        ans1 += s[i] != s1[i];
        ans2 += s[i] != s2[i];
    }
  
    //cout << s << endl << s1 << endl << s2 << endl << endl;
    cout << min(ans1, ans2);
    return 0;
}

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

int main(){
  string str;
  cin >> str;

  int n;
  cin >> n;

  string message;
  int a,b;
  string p;
  for(int i=0;i<n;i++){
    cin >> message >> a >> b;
    if(message == "replace"){
      cin >> p;
      str.replace(a,b-a+1,p);
    }else if(message == "reverse"){
      string restr = str.substr(a,b-a+1);
      reverse(restr.begin(),restr.end());
      str.replace(a,b-a+1,restr);
    }else{
      cout << str.substr(a,b-a+1) << endl;
    }
  }


  return 0;
}



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

int n, flag = 1, cnt;

int main() {
    scanf("%d", &n);
    while (n--) {
        int a;
        scanf("%d", &a);
        if (!(a & 3))
            ++cnt;
        else if (a & 1)
            --cnt;
        else
            flag = 0;
    }
    if (flag+cnt >= 0)
        puts("Yes");
    else
        puts("No");
    return 0;
}
        


Measured memory_bytes: 3752
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)






int main() {
	int s;
	cin >> s;
	string k = "NO";
	if (s == 3 || s == 5 || s == 7) {
		k = "YES";
	}
	cout <<k<< endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int a, b;
  cin>>a>>b;
  
  for(int i=1 ; i<1010 ; i++)
  {
    if (i*8/100 == a && i/10 == b){
      cout<<i<<endl;
      return 0;
    }
    
  }
  cout << "-1" << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
Ab = []
for i in range(N):
  Ab.append([A[i], i])
  
Ab.sort(reverse=True)
#dp[i][j] Aの大きいじゅんにi個とったとき、左寄せj個、右寄せi-j個としたときのMAX
dp = [[0 for _ in range(N+5)] for _ in range(N+5)]
dp[0][0] = 0

for i in range(0,N):
  a, p = Ab[i]
  for j in range(0,i+1):
    r = i - j
    dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + a * (p-j))
    dp[i+1][j]  = max(dp[i+1][j], dp[i][j] + a * (N-r-p-1))
                      
ans = 0
for i in range(N):
  ans = max(ans, dp[N][i])
  
print(ans)
#for a in dp:
#  print(a)
                       

Measured memory_bytes: 101180
#include <bits/stdc++.h>
using namespace std;
map<int,int>k;
int main()
{
     int n,x,a[100001],ans,ansx=0;
     cin>>n;
     for(int i=1;i<=n;i++)
     {
     	cin>>a[i];
     	k[a[i]]++;
	 }
	 sort(a+1,a+n+1);
	 ans=unique(a+1,a+n+1)-a-1;
	 for(int i=1;i<=ans;i++)
	 {
	 	if(k[a[i]]<a[i]) ansx+=k[a[i]];
	 	if(k[a[i]]>a[i]) ansx+=k[a[i]]-a[i];
	 }
	 cout<<ansx<<endl;
} 

Measured memory_bytes: 5120
/**In the name of Allah, the Most Merciful, the Most Merciful.**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define INF 9223372036854775806
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define PI 2*acos(0.0)
#define EPS 1e-9
ll max(ll a,ll b) {if(a>b) return a; else return b;}
ll min(ll a,ll b) {if(a<b) return a; else return b;}
map<int,int> cnt;
int main()
{
    int n;
    cin>>n;
    int a[n+1];
    ll sum=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
        cnt[a[i]]++;
    }
    int q;
    cin>>q;
    while(q--){
        ll x,y;
        cin>>x>>y;
        ll a=cnt[x]*x;
        ll b=cnt[x]*y;
        cnt[y]+=cnt[x];
        cnt[x]=0;
        sum-=a;
        sum+=b;
        cout<<sum<<endl;
    }

    return 0;
}




Measured memory_bytes: 8412
#include<cstdio>
#include<algorithm>
using namespace std;
#define P 2019
int main(){
	int L,R;
	scanf("%d%d",&L,&R);
	int ans=P;
	for(int i=L;i<=min(L+P,R);i++){
		if(i+P<=R)ans=min(ans,(int)(1ll*i*i%P));
		for(int j=i+1;j<=min(i+P,R);j++){
			ans=min((int)(1ll*i*j%P),ans);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
import itertools
N,M=map(int,input().split())
s=[[int(i)-1 for i in input().split()][1:] for i in range(M)]
k=[len(i) for i in s]
p=[int(i) for i in input().split()]
t=[[] for i in range(N)]
for i in range(M):
    for j in s[i]:
        t[j].append(i)
ans=0
for seq in itertools.product([0,1],repeat=N):
    q=[0 for i in range(M)]
    for i in range(N):
        if seq[i]==1:
            for j in t[i]:
                q[j]^=1
    flag=1
    for i in range(M):
        if p[i]!=q[i]:
            flag=0
            break
    if flag:
        ans+=1
print(ans)


Measured memory_bytes: 42204
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

bool isPrime(int x) {
    if (x < 2)
      return false;
    else if (x == 2)
      return true;
    else if (x % 2 == 0)
      return false;

    double sq = sqrt(x);
    for (int i = 3; i <= sq; i += 2) {
      if (x % i == 0) {
        return false;
      }
    }
    return true;
}

int n;
bool used[55555];
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n;
    vector<int> a;
    rep(i, 10, 55556) {
        if (isPrime(i) && i%5 == 1) {
            a.pb(i);
        }
    }
    rep(i, 0, n) {
        cout << a[i];
        if (i != n-1) cout << " ";
        else cout << endl;
    }
    return 0;
}

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

using namespace std;

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

  int N; cin>>N;

  constexpr long MOD = 998244353;
  constexpr int MAX = 1e7;
  vector<long> fact(MAX+1);
  fact[0] = 1;
  for (long i = 1; i <= MAX; i++) {
    fact[i] = fact[i-1]*i%MOD;
  }
  auto mod_pow = [](long x, long y) {
    long t = 1;
    long u = x;
    while (y) {
      if (y & 1) {
        t *= u;
        t %= MOD;
      }
      u *= u;
      u %= MOD;
      y >>=1;
    }
    return t;
  };
  auto mod_inv = [&](long x) {
    return mod_pow(x, MOD-2);
  };
  vector<long> ifact(MAX+1);
  ifact[MAX] = mod_inv(fact[MAX]);
  for (long i = MAX-1; i >= 0; i--) {
    ifact[i] = ifact[i+1] * (i+1) % MOD;
  }
  auto comb = [&](long x, long y) {
    return fact[x] * ifact[y] % MOD * ifact[x-y] % MOD;
  };

  auto U = mod_pow(3, N);

  long ans = U;
  for (int i = N; i > N/2; i--) {
    auto pat = comb(N, i) * mod_pow(2, N-i) % MOD;
    ans = ans + MOD - pat + MOD - pat;
    ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 156544
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main{
	private static void selection(String a[]){
		int count=0;
		int mini=0;
		for(int i = 0 ; i < a.length-1 ; i++){
			mini=i;
			for(int j = i+1;j<a.length;j++){
				if((int)a[j].charAt(1)<(int)a[mini].charAt(1)){
					mini=j;			
				}
			}
			if(mini!=i){
				String temp=a[i];
				a[i]=a[mini];
				a[mini]=temp;
				count++;
			}
		}
	}
	private static void bubble(String a[]){
		int count=0;
		for(int i = 0 ; i < a.length-1 ; i++){
			for(int j = a.length-1;j>i;j--){
				if((int)a[j].charAt(1)<(int)a[j-1].charAt(1)){
					String temp=a[j];
					a[j]=a[j-1];
					a[j-1]=temp;
					count++;
				}
			}
		}
	}
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();		
		String[] card = new String[N];
		for(int i = 0 ; i < N ; i ++){
			card[i]=scan.next();
		}
		String[] cardC = card.clone();
		bubble(card);
		selection(cardC);
		for(int i = 0 ; i < N ; i ++){
			System.out.print((i+1==N)?card[i]:card[i]+" ");
		}
		System.out.println("");
		System.out.println("Stable");
		for(int i = 0 ; i < N ; i ++){
			System.out.print((i+1==N)?cardC[i]:cardC[i]+" ");
		}
		System.out.println("");
		System.out.println((Arrays.equals(card, cardC))?"Stable":"Not stable");
	}	
}

Measured memory_bytes: 17388
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n, i, tmp, res=0;
    vector<int> p;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> tmp;
        p.push_back(tmp);
    }
    for(i=1;i<n-1;i++){
        if(max({p[i-1],p[i],p[i+1]}) !=p[i] && min({p[i-1],p[i],p[i+1]}) !=p[i]){
            res++;
        }
    }
    cout << res << endl;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

ll mp[333][333];

int main(){

	int n;cin>> n;
	REP(i,n)REP(j,n)cin >> mp[i][j];

	ll ans = 0;
	for(int i = 0;i < n;i++){
		for(int j = i + 1;j < n;j++){
			bool flag = true;
			for(int k = 0;k < n;k++){
				if(k == i || k == j)continue;
				if(mp[i][j] > mp[i][k] + mp[k][j]){
					cout << -1 << endl;
					return 0;
				}
				if(mp[i][j] == mp[i][k] + mp[k][j])flag = false;
			}
			if(flag)ans += mp[i][j];
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N = inp()
aa = inpl()


n = N
ans = [0]*(N+1)
cnts = [0]*(N+1)

for a in reversed(aa):
    #print(a,n,cnts,ans)
    if cnts[n]%2 == a:
        ans[n] = 0
    else:
        ans[n] = 1
        r = 1
        while r <= math.sqrt(n):
            if n%r == 0:
                cnts[r] += 1
                if r != n//r:
                    cnts[n//r] += 1
            r += 1
    n -= 1


tmp = sum(ans)
if tmp == 0:
    print(0)
else:
    print(tmp)
    fans = []
    for i,x in enumerate(ans):
        if x == 1:
            fans.append(str(i))
    print(' '.join(fans))


Measured memory_bytes: 78116
n = int(input())
s = input()

def Z_algo(S):
    n = len(S)
    LCP = [0]*n
    i = 1
    j = 0
    c = 0
    for i in range(1, n):
        if i+LCP[i-c] < c+LCP[c]:
            LCP[i] = LCP[i-c]
        else:
            j = max(0, c+LCP[c]-i)
            while i+j < n and S[j] == S[i+j]: j+=1
            LCP[i] = j
            c = i
    LCP[0] = n
    return LCP
  
ans = 0
for i in range(n):
  z = Z_algo(s[i:])
  for i,zi in enumerate(z):
    ans = max(ans,min(i,z[i]))
    
print(ans)

Measured memory_bytes: 52316
n,a,b,c = map(int,input().split())
l = list(int(input()) for _ in range(n))

answer = 3000
container = [0]*n
for _ in range(4**n):
    abcx = [0,0,0,0]
    for i in range(n):
        container[i] += 1
        if container[i] == 4:
            container[i] = 0
        else:
            break
    for i in range(n):
        for j in range(4):
            if container[i] == j:
                if j == 3:
                    abcx[j] += 1
                else:
                    abcx[j] += l[i]
    if abcx[0] == 0 or abcx[1] == 0 or abcx[2] == 0:
        continue
    else:
        need_mp = (n-3-abcx[3])*10 + abs(abcx[0]-a) + abs(abcx[1]-b) + abs(abcx[2]-c)
        if need_mp < answer:
            answer = need_mp

print(answer)


Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MAX_V=114514LL;
//const ll MAX = 510000LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};

int main(){
  string t;cin>>t;
  ll n=t.size();
  rep(i,n){
    if(t[i]=='?')t[i]='D';
  }
  ll ans=0;
  rep(i,n){
    if(t[i]=='D')ans++;
  }
  rep(i,n-1){
    if(t[i]=='P'&&t[i+1]=='D')ans++;
  }
  cout<<t<<endl;
}

Measured memory_bytes: 3756
import java.util.*;

public class Main {
    static public void main(String[] args) {
        String s, p;
        Scanner sc = new Scanner(System.in);

        s = sc.next();
        p = sc.next();
        
        s += s;
        if (s.indexOf(p) != -1) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}



Measured memory_bytes: 26216
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;

const int INF = 1e9 ;
const int maxN = 1e3 + 5;

int n,h,w;
char a[maxN][maxN];
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
ll ans = 0;
int vis[maxN][maxN]; 
int flag = 0;
int bl = 0,wt = 0;
void check(int x,int y)
{
	vis[x][y] = 1;
	if(a[x][y] == '#')
	{
		bl++;
	}
	else
	{
		wt++;
	}
	for(int i=0;i<4;i++)
	{
		int tx = x + dx[i];
		int ty = y + dy[i];
		if(tx<1 || tx >h || ty<1 || ty >w) continue;
		if(vis[tx][ty]) continue;
		if(a[x][y] != a[tx][ty])
		{
			check(tx,ty);
		}
	}
}
int main()
{
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++)
	{
		scanf("%s",a[i]+1);
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			bl=0,wt=0;
			if(!vis[i][j])
			{
				check(i,j);
			}
			ans += ((ll)wt*bl);
		}
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 11648
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		String des[] = {"S", "H", "C", "D"};
		String str = ("");
		boolean have[][] = new boolean[des.length][13];
		int i, j, k;
		int num = 0;
		try (Scanner sc = new Scanner(System.in)) {
			for(j = 0; j < des.length; j++) {
				for(k = 0; k < 13; k++) {
					have[j][k] = true;
				}
			}
			int n = sc.nextInt();
			for(i = 0; i < n; i++) {
				str = sc.next();
				num = sc.nextInt() - 1;
				for(j = 0; j < des.length; j++) {
					for(k = 0; k < 13; k++) {
						if(des[j].equals(str) && num == k) {
						have[j][k] = false;
						}
					}
				}
			}
			for(j = 0; j < des.length; j++) {
				for(k = 0; k < 13; k++) {
					if(have[j][k]) {
						System.out.println(String.format(des[j] + " " + (k + 1)));
					}
				}
			}
		}
	}
}



Measured memory_bytes: 26344
#include<bits/stdc++.h>
using namespace std;
int main(){
  char s[200000];
  cin >> s;
  bool b;
  for(char i='a';i<='z';i++){
    b=false;
    for(int j=0;j<strlen(s);j++){
      if(s[j]==i){
        b=true;
        break;
      }
    }
    if(!b){
      cout << i << endl;
      return 0;
    }
  }
  if(b)cout << "None";
}


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

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pp;
typedef pair<ll,pair<ll,ll> > ppp;

#define mk make_pair
#define all(a) (a).begin(), (a).end()
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define parr(A,n) for(int xxx=0;xxx<n;xxx++){cout<<A[xxx]<<" ";}cout << "\n";
#define MOD 1000000007
#define endl "\n"
inline ll power(ll x, ll y)
{
    ll res = 1;x = x % MOD;
    while (y > 0){if (y & 1) res = (res*x) % MOD;y = y>>1;x = (x*x) % MOD;}
    return res%MOD;
}
inline ll sum(ll a, ll b){b = ((b%MOD) + MOD)%MOD;a = ((a%MOD) + MOD)%MOD;return ((a+b)%MOD + MOD)%MOD;}
inline ll mul(ll a, ll b){return ((a*b)%MOD + MOD)%MOD;}
typedef struct node{
    node *next[2];
    int count[2];
    node(){
        next[0] = NULL;
        next[1] = NULL;
        count[0] = count[1] = 0;
    }
}node;

void add(node *root, ll num){
    node *temp = root;
    for(ll i=0;i<32;i++){
        ll ind = num & (1 << (31-i));
        ind = ind >> (31-i);
        if(temp->next[ind]==NULL){
            temp->next[ind] = new node();
            
        }
        temp->count[ind]++;
        temp = temp->next[ind];
    }
}

ll eval(node *root, ll num, ll k){
    ll ans = 0;
    node *temp = root;
    for(ll i=0;i<32;i++){
        ll ind = (num & (1 << (31-i)));
        ind = ind >> (31-i);
        ll tar = (k & (1 << (31-i)));
        tar = tar >> (31-i);
        if(tar==1){
        	if(ind == 0){
        		ans+=temp->count[0];
        		if(temp->next[1])
        			temp = temp->next[1];
        		else return ans;
        	}
        	else{
        		ans+=temp->count[1];
        		if(temp->next[0])
        			temp = temp->next[0];
        		else return ans;	
        	}
        }
        else{
        	if(ind == 0){
        		if(temp->next[0])
        			temp = temp->next[0];
        		else return ans;
        	}
        	else{
        		if(temp->next[1])
        			temp = temp->next[1];
        		else return ans;	
        	}	
        }
    }
    return ans;
}

ll solve(vector<int> a, int k) {
    int n = a.size();
    node *root = new node();
    add(root,0);
    ll ans = 0;
    ll curr = 0;
    for(int i=0;i<n;i++){
        curr = curr^a[i];
        ll temp = eval(root,curr,k);
        // cout << temp << endl;
        ans += temp;
        add(root,curr);
    }
    return ans;
}
int main() {
	ll n;
	cin >> n;
	string A[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> A[i];
	}
	unordered_map<string,bool> mp;
	for(int i=0;i<n;i++){
		if(mp.find(A[i])!=mp.end()){
			cout << "No" << endl;
			return 0;
		}
		if(i >0 && A[i-1][A[i-1].size()-1] != A[i][0]){
			cout << "No" << endl;
			return 0;
		}
		mp[A[i]] = true;
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


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

  #ifndef ONLINE_JUDGE
      if(fopen("INPUT.txt","r"))
      {
      freopen ("INPUT.txt" , "r" , stdin);
      freopen ("OUTPUT.txt" , "w" , stdout);
      }
  #endif  

      int n,l;
      cin>>n>>l;
      int a[n];
      for(int i=0;i<n;i++)
      		cin>>a[i];
      int ind=-1;
      for(int i=0;i<n-1;i++)
      {
      	if(a[i]+a[i+1]>=l)
      	{
      		ind=i;
      	}
      }
      if(ind==-1)
      		cout<<"Impossible";
      else
      {
      	cout<<"Possible\n";
      	for(int i=1;i<=ind;i++)
      	{
      		cout<<i<<"\n";
      	}
      	for(int i=n-1;i>=ind+2;i--)
      			cout<<i<<"\n";
      	cout<<ind+1;
      }
}


Measured memory_bytes: 1664
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int kaisu = 3;
		int[] num = new int[kaisu];

		for(int i = 0; i < kaisu ; i++) {
			num[i] = scan.nextInt();
		}
		num = up_down_sort(num);
		for(int i = 0 ; i < kaisu ; i++) {
			if(i != kaisu - 1) System.out.print(num[i] + " ");
			else System.out.println(num[i]);
		}
	}
	
	public static int[] up_down_sort (int[] numbers) {
		int up_number ;
		int down_number ;
		int yousosu = numbers.length;
		for(int i = yousosu-1 ; i >= 0 ; i--) {
			for(int j = i ; j <= yousosu  ; ++j) {
				if(j+1 == yousosu) break;
				if(numbers[j] < numbers[j+1]) {
					break;
				}
				if(numbers[j] > numbers[j+1]) {
					up_number = numbers[j+1];
					down_number = numbers[j];
					numbers[j] = up_number;
					numbers[j+1] = down_number;
				}
			}
		}
		return numbers;
	
		/*else System.out.println("No");
		if(a < b) System.out.println("a < b");
		else if(a > b) System.out.println("a > b");
		else System.out.println("a == b");
		int[] time_get = henkan(scan.nextInt());
	
		for(int i = 0; i < 3; i++) {
			if(i != 2) System.out.print(time_get[i] + ":" );
			else System.out.println(time_get[i]);
		}

	}

	static int[] henkan(int time_input) {
		int[] times = new int[3];
		times[0] = time_input / 3600;
		time_input = time_input - times[0] * 3600;
		times[1] = time_input /60;
		times[2] = time_input - times[1] * 60;
		
		return times;*/
	}
}

Measured memory_bytes: 17344
/*@author hussein zayed ;
    ___  ___
   |\  \|\  \
   \ \  \_\  \
    \ \   ___ \USSEIN
     \ \  \\ \ \
      \ \__\\ \_\
       \|__| \|__|
****************************************
*/

#include <bits/stdc++.h>
using namespace std;
#define fr for(int i=0;i<n;++i)
#define fr1 for(int i=1;i<=n;++i)
#define cinA for(int i=0;i<n;++i){cin>>arr[i];}
#define cinA1 for(int i=1;i<=n;++i){cin>>arr[i];}
#define coutA for(int i=0;i<n;++i){cout<<arr[i]<<" ";}
#define ll long long
#define lnarray sizeof(arr)/sizeof(*arr)
#define vi vector<int>
#define vs vector<string>
void Fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int RD()
{
    int i ;
    cin>>i;
    return i;
}

inline float RF()
{
    float i ;
    cin>>i;
    return i;
}

inline double RDO()
{
    double i ;
    cin>>i;
    return i;
}

inline string RS()
{
    string i ;
    cin>>i;
    return i;
}

inline ll RLL()
{
    ll i ;
    cin>>i;
    return i;
}

int cm[200000];

ll sumSet(ll n)
{
    return (1ll*n*(n+1))/2;
}
string s;

inline ll fact(int n)
{
    ll sum=1;
    for(int i=1; i<=n; ++i)
    {
        sum*=i;
    }
    return sum;
}
ll permtution(string s)
{
    ll tot=1;
    int arr[26]= {};
    for(int i=0; i<s.size(); ++i)
    {
        arr[s[i]-'a']++;
    }
    for(int i=0; i<26; ++i)
    {
        if(arr[i]>1)
            tot*=fact(arr[i]);
    }
    int sz=s.size();
    ll per =fact(sz);
    ll ans=per/tot;
    return ans;
}

bool isPrime(int n)
{
    if(n==1)
        return false;
    for(int i=2; i*i<=n; ++i)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
int sumDigit(int n){
int sum =0;
  while (n != 0)
    {
        sum+= + n % 10;
        n = n / 10;
    }
    return sum;
}

ll power2(int n){
  ll ans=(1<<n);
  return ans;
}

ll sumpow2(ll n){
 ll sum=(n*(n+1)*(2*n-1))/6;
 return sum;
}



int arr[100005];
int main(){
    Fast();
//freopen("output.txt" , "w" , stdout);
//freopen("wall.in" , "r" , stdin);

 int A=RD(),B=RD();
 if(A<=8&&B<=8)
 cout<<"Yay!";
 else
 cout<<":(";
}









Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int tmp = sc.nextInt();
		int tmp2 = tmp;
		List<Integer> list = new ArrayList<>();
		if(N == 1) {
			list.add(tmp);
		}
		boolean up = false, down = false;
		for(int i = 1; i < N; i++) {
			tmp2 = sc.nextInt();
			if(tmp2 > tmp) {
				if(!up) {
					list.add(tmp);
				}
				up = true;
				down = false;
			} else if(tmp2 < tmp) {
				if(!down) {
					list.add(tmp);
				}
				down = true;
				up = false;
			}
			if(i == N - 1) {
				list.add(tmp2);
			}
			tmp = tmp2;
		}
		int ans = list.get(0);
		int high = list.get(0);
		list.remove(0);
		while(!list.isEmpty()) {
			if(high < list.get(0)) {
				ans += list.get(0) - high;
			}
			high = list.get(0);
			list.remove(0);
		}
		System.out.println(ans);
	}

}


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

using ull = unsigned long long;

int main() {

    ull n;

    cin >> n;

    ull ketaCount = 0;
    ull x, y;
    string ans = "";


    while(1) {

        y = n%26;
        x = n/26;

        if(y != 0)
            ans = (char)('a' + y - 1) + ans;
        else
            ans = 'z' + ans;

        if(y == 0)
            x--;

        n = x;

        if(n <= 0)
            break;
        
    }


    cout << ans << endl;

    return 0;


}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define X begin()
#define Y end()
#define N 41
using namespace std;
typedef long long ll;
ll n,m,a,b,p,q,d[N];
vector<ll> v[2],x[2];

int main(){
  cin>>n>>m>>a>>b>>p>>q;
  ll ans=m;
  if(a==1&&b==1){
    ll ti=min(n,m/(p+q));
    ans=min(ans,min(m-ti*(p+q),abs(min(ti+1,n)*(p+q)-m)));
  }
  ll A=1,B=1,T=min((ll)N,n);
  for(int i=0;i<T;i++){
    d[i]=p*A+q*B;
    if(i<T/2)v[0].push_back(d[i]);
    else v[1].push_back(d[i]);
    if(d[i]>m)break;
    A*=a,B*=b;
  }
  int len[2]={v[0].size(),v[1].size()};
  for(int i=0;i<2;i++){
    v[i].push_back(0);
    for(int j=0;j<(1<<len[i]);j++){
      ll sum=0;
      for(int k=0;k<len[i];k++)
	if((j&(1<<k)))sum+=v[i][k];
      x[i].push_back(sum);
    }
    sort(x[i].X,x[i].Y);
  }
  for(int i=0;i<x[0].size();i++){
    ll S=m-x[0][i];
    vector<ll>::iterator r=lower_bound(x[1].X,x[1].Y,S);
    if(r!=x[1].Y)ans=min(ans,(*r)-S);
    if(r!=x[1].X)ans=min(ans,S-(*(r-1)));
  }
  cout<<ans<<endl;
  return 0;
}

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

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

    int i, j,
        cnt = 0;
    for(i = 0; i < k + 1; i++) {
        for(j = 0; j < k + 1; j++) {
            if (0 <= s - (i + j) && s - (i + j) <= k) {
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
//by azidoazideazide(c2n14)
#include<iostream>
#include<cmath>
#include<vector>
#include<queue>
#include<climits>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define INF INT_MAX

//1
struct Edge{
	int from,to,capacity;
};

//2
struct Mxflow{
	int size, st, end;
	vector< vector<int> > e_index;
	vector<Edge> e_info;
	
	//5&6
	vector<int> dist;
	vector<int> lomo;
	//5
	int bfs(){
		dist.assign(size, INF);
		lomo.assign(size, -1);
		
		queue<int> q;
		dist[st]=0;
		q.push(st);
		while(!q.empty()){
			int u=q.front();
			q.pop();
			
			for(int tt:e_index[u]){
				Edge ttt=e_info[tt];
				if(ttt.capacity<=0) continue;
				int v=ttt.to;
				if(dist[v]==INF){
					dist[v]=dist[u]+1;
					lomo[v]=tt;
					q.push(v);
				}
			}
		}
		return dist[end];
	}
	
	public:
		//2.2
		Mxflow(int t1, int t2, int t3) : size(t1), st(t2), end(t3), e_index(t1) {}
		
		//3
		void add_edge(Edge tt){
			Edge forward={tt.from, tt.to, tt.capacity};
			Edge backward={tt.to, tt.from, 0};
			e_index[tt.from].pb(e_info.size());
			e_index[tt.to].pb(e_info.size()+1);
			e_info.pb(forward);
			e_info.pb(backward);
		}
		
		//6
		int augment_flow(){
			//backtracking
			int cur_flow=INF;
			for(int u=end;lomo[u]!=-1;u=e_info[lomo[u]].from) cur_flow=min(cur_flow, e_info[lomo[u]].capacity);
			for(int u=end;lomo[u]!=-1;u=e_info[lomo[u]].from){
				e_info[lomo[u]].capacity-=cur_flow;
				e_info[lomo[u]^1].capacity+=cur_flow;
			} 
			return cur_flow;
		}
		
		//4
		int get_mx_flow(){
			int val=0;
			while(bfs()!=INF){
				val+=augment_flow();
			}
			return val;
		}
};

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n,m;
	cin>>n>>m;
	Mxflow ans(n,0,n-1);
	
	for(int i=0,u,v,c;i<m;i++){
		cin>>u>>v>>c;
		//3
		ans.add_edge({u,v,c});
	}
	
	cout<<ans.get_mx_flow()<<endl;
}



Measured memory_bytes: 3228
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}

void solve() {
    ll n;
    cin >> n;
    vector<string> s(n);
    for(ll i = 0;i < n;i++){
        cin >> s[i];
        sort(s[i].begin(),s[i].end());
    }

    sort(s.begin(),s.end());

    string tmp = s[0];
    ll count = 0;
    ll ans = 0;

    for(int i = 1;i < n;i++){
        if(s[i] == tmp){
            count++;
        }else{
            ans += count*(count+1)/(ll)2;
            tmp = s[i];
            count = 0;
        }
        if(i == n-1){
            ans+=count*(count+1)/(ll)2;
        }
    }

   cout << ans << endl;
}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}


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

#define _ << " _ " <<
#define TRACE(x) cout << #x << " = " << x << endl

typedef long long ll;

int n, k;
ll a[1010];
set<ll> sums;

const int Log = 50;

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

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

    for (int i = 0; i < n; i++) {
        ll sum = 0;
        for (int j = i; j < n; j++) {
            sum += a[j];
            sums.insert(sum);
        }
    }

    long long sol = 0;

    for (int i = Log; i >=0; i--) {
        int cnt = 0;
        for (auto it : sums) cnt += !!(it & (1LL << i));

        if (cnt >= k) {
            sol += 1LL << i;
            for (auto it = sums.begin(); it != sums.end(); ) {
                if (!(*it & (1LL << i))) it = sums.erase(it);
                else ++it;
            }
        }
    } 

    cout << sol;


    return 0;
}



Measured memory_bytes: 23680
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>

void c(std::istream& in)
{
    unsigned long long A;
    long double B;
    in >> A >> B;

    unsigned long long mul = static_cast<unsigned long long>(A * B);

    std::cout << mul;
}

int main(int, char* [])
{
    c(std::cin);
    return 0;
}



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

int main(){
	int a,b,x,count=0;
	int d[5];
	cin >> a >> b;
	for(int i=a;i<=b;i++){
		x=i;
		for(int j=0;j<5;j++){
			d[j]=x%10;
			x=(x-d[j])/10;
		}
		if((d[0]==d[4])&&(d[1]==d[3])) count++;
	}
	cout << count <<endl;
	return 0;
}

Measured memory_bytes: 256
class UnionFind:
    __slots__ = ["_size", "_first_idx", "_parents"]

    def __init__(self, size: int, first_index: int = 0) -> None:
        self._size = size
        self._first_idx = first_index
        self._parents = [-1] * (size + first_index)

    def find(self, x: int) -> int:
        if self._parents[x] < 0:
            return x
        self._parents[x] = self.find(self._parents[x])
        return self._parents[x]

    def same(self, x: int, y: int) -> bool:
        return self.find(x) == self.find(y)

    def unite(self, x: int, y: int) -> None:
        """Unite two groups of vertices x and y."""
        x, y = self.find(x), self.find(y)
        if x == y:
            return
        if self._parents[x] > self._parents[y]:
            x, y = y, x
        self._parents[x] += self._parents[y]
        self._parents[y] = x

    def size(self, x: int) -> int:
        """Get the size of the group vertex x belongs"""
        return -self._parents[self.find(x)]
n,m,k=map(int,input().split())
from sys import stdin 
input=stdin.readline
friend=[0]*(n+1)
uf=UnionFind(n,1)
for i in range(m):
    a,s=map(int,input().split())
    uf.unite(a,s)
    friend[a]+=1
    friend[s]+=1
anti=[set() for i in range(n+1)]
for i in range(k):
    a,b=map(int,input().split())
    anti[a].add(b)
    anti[b].add(a)
print(*[uf.size(i)-1-sum(uf.same(i,b) for b in anti[i])-friend[i] for i in range(1,n+1)],sep=" ")

Measured memory_bytes: 43616
//#pragma GCC target ("avx2,sse2")
//#pragma GCC optimization ("Ofast")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree <pair <ll, int>, null_type, less <pair <ll, int> >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define db double
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define fi first
#define se second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define endl "\n"

#define left fsdsdfoisf
#define sum dpsdfioppsf
#define assign xcvjlkdjfio
#define trie fksdfkjkfnjuiv
#define next sidlfjsfkl
#define merge sdfksdkfsldf

#define int long long

using namespace std;

void dout() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 1e5 + 7;
int n, MOD, up[N];
vector <int> q[N];
map <int, int> p[N], s[N];

void dfs(int v, int par) {
    int x = 0;
    p[v][0] = 1;
    for (auto i : q[v]) {
        if (i == par) {
            continue;
        }
        dfs(i, v);
        x++;
        int t = sz(q[i]) - 1;
        p[v][x] = p[v][x - 1] * (p[i][t] + 1) % MOD;
    }
    s[v][x + 1] = 1;
    for (int i = sz(q[v]) - 1; i >= 0; i--) {
        int to = q[v][i];
        if (to == par) {
            continue;
        }
        int t = sz(q[to]) - 1;
        s[v][x] = s[v][x + 1] * (p[to][t] + 1) % MOD;
        x--;
    }
}

void calc(int v, int par) {
    int x = 0;
    for (auto i : q[v]) {
        if (i == par) {
            continue;
        }
        x++;
        int t = sz(q[i]) - 1;
        int tmp = p[v][x - 1] * s[v][x + 1] % MOD;
        up[i] = (up[v] * tmp % MOD + 1) % MOD;
        calc(i, v);
    }
}

void solve(int tc) {
    // check for (int i = 0; i < n; j++)
    cin >> n >> MOD;
    for (int i = 1; i <= n - 1; i++) {
        int x, y;
        cin >> x >> y;
        q[x].pb(y);
        q[y].pb(x);
    }
    dfs(1, 1);
    up[1] = 1;
    calc(1, 1);
    for (int i = 1; i <= n; i++) {
        int t = sz(q[i]) - 1;
        if (i == 1) {
            t++;
        }
        cout << p[i][t] * up[i] % MOD << endl;
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int tc = 1;
//    cin >> tc;
    for (int i = 0; i < tc; i++) {
        solve(i);
//        cleanup();
    }
}


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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 1005;

int H, W;
char c;
int grid[MX][MX];
bool used[MX][MX];

int ans = 0;

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

void solve() {
    cin >> H >> W;
    
    queue<i_i> q;
    
    for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> c;
			if (c == '#') {
				q.push({i, j});
				used[i][j] = true;
				grid[i][j] = 0;
			}
		}
	}
	
	while (!q.empty()) {
		i_i v = q.front();
		q.pop();
		for (int i = 0; i < 4; i++) {
			int a = v.first + dy[i], b = v.second + dx[i];
			if (a < 0 || a >= H || b < 0 || b >= W) continue;
			if (used[a][b]) continue;
			q.push({a, b});
			used[a][b] = true;
			grid[a][b] = grid[v.first][v.second] + 1;
			chmax(ans, grid[a][b]);
		}
	}
	cout << ans;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 13328
#include<bits/stdc++.h>
using namespace std;
const int maxn = 105;
int mp[maxn][maxn];
int n,w,h,x,a[100005];
int main(){
    scanf("%d%d",&h,&w);
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    x=1;
    for(int i=1;i<=h;i++){
        if(i%2==1){
            for(int j=1;j<=w;j++){
                if(a[x]){
                    mp[i][j]=x;
                    a[x]--;
                }else{
                    while(a[x]==0)x++;
                    mp[i][j]=x;
                    a[x]--;
                }
            }
        }else{
            for(int j=w;j>=1;j--){
                if(a[x]){
                    mp[i][j]=x;
                    a[x]--;
                }else{
                    while(a[x]==0)x++;
                    mp[i][j]=x;
                    a[x]--;
                }
            }
        }
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cout<<mp[i][j]<<" ";
        }
        cout<<endl;
    }
}

Measured memory_bytes: 384
data = list(map(lambda x: int(x), input().split()))
     
if __name__ == "__main__":
  if data[0] < 10:
    if data[1] < 10:
      answer = data[0]*data[1]
    else:
      answer = -1
  else:
    answer = -1
    
  print(answer)

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

int main() {
    int N;
    long long M, ans = 0;
    cin >> N >> M;
    vector<long long> A(N);
    vector<long long> sum(N+1, 0);
    map<long long, int> C;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum[i+1] = (sum[i] + A[i]);
    }
    
    for (auto &s : sum) {
        s %= M;
        ans += C[s]++;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n, ret = 0; cin >>n;
  long long d, x, y; cin >>d;
  long long d2 = d * d;
  for (int i = 0; i < n; i++) {
    cin >>x >>y;
    if (x*x+y*y <= d2) ret++;
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <deque>

using namespace std;

int main(){
    int n;
    int mode;
    int a;
    int x;
    deque<int> deq;

    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> mode;
        switch(mode){
            case 0:
                cin >> a >> x;
                if(a == 0) deq.emplace_front(x);
                else deq.emplace_back(x);
                break;
            case 1:
                cin >> a;
                cout << deq[a] << endl;
                break;
            case 2:
                cin >> a;
                if(a == 0) deq.pop_front();
                else deq.pop_back();
                break;
        }
    }
    return 0;
}


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

int p,q,a,n;

int rec(int x,int y,int num,int d){

  if(x*p==y*q)return 1;
  if(x*p<y*q)return 0;
  if(d==n)return 0;

  int res=0;
  for(int i=num;i<=a/x;i++)res+=rec(i*x,i*y+x,i,d+1);
  return res;
}

int main()
{
  while(1){
    cin>>p>>q>>a>>n;
    if(p+q+a+n==0)break;
    cout<<rec(1,0,1,0)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define fastIO                        \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
// g++ -std=c++11 -O2 -Wall *.cpp -o *
#define eps 1e-9
#define MAX 10000001
#define MOD 998244353
#define Fi first
#define Se second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef pair<int, int> pr_int;



int main()
{
	int n;
	cin >> n;
	int m = 0;
	for (int i = 1; i < 10; ++i)
		if (n % i == 0)
			m = n / i;
	if (m > 0 && m < 10)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}


Measured memory_bytes: 256
'''
Created on 2020/09/08

@author: harurun
'''
def floor_sum(n,m,a,b):
  ans=0
  if a>=m:
    ans+=(n-1)*n*(a//m)//2
    a%=m
  if b>=m:
    ans+=n*(b//m)
    b%=m
  
  y_max=(a*n+b)//m
  x_max=y_max*m-b
  
  if y_max==0:
    return ans
  ans+=(n-(x_max+a-1)//a)*y_max
  ans+=floor_sum(y_max,a,m,(a-x_max%a)%a)
  return ans



def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  ansl=[]
  T=int(pin())
  for j in range(T):
    N,M,A,B=pin().split()
    ansl.append(str(floor_sum(int(N),int(M),int(A),int(B))))
  ans="\n".join(ansl)
  print(ans)
  return
main()

Measured memory_bytes: 17396
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {

		//?????£?????????
		int intx = 0;
		int inty = 0;
		int intWork = 0;

		try {
			//??\????????????
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			while (true) {
				String strLine = br.readLine();

				if (strLine != null) {
					String[] strNumList = strLine.split(" ", 0);

					intx = Integer.parseInt(strNumList[0]);
					inty = Integer.parseInt(strNumList[1]);

					if(intx != 0 || inty != 0){
						if (intx > inty) {
							intWork = intx;
							intx = inty;
							inty = intWork;
						}
						System.out.println(intx + " " + inty);
					}else{
						break;
					}
				}else {
					break;
				}
			}
		}catch(IOException e1){
			System.out.println(e1);
		}catch (NumberFormatException e2) {
			System.out.println(e2);
		}
	}
}

Measured memory_bytes: 26956
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>


using namespace std;

string findSum(string str1, string str2)
{
    // Before proceeding further, make sure length
    // of str2 is larger.
    if (str1.length() > str2.length())
        swap(str1, str2);

    // Take an empty string for storing result
    string str = "";

    // Calculate length of both string
    int n1 = str1.length(), n2 = str2.length();

    // Reverse both of strings
    reverse(str1.begin(), str1.end());
    reverse(str2.begin(), str2.end());

    int carry = 0;
    for (int i=0; i<n1; i++)
    {
        // Do school mathematics, compute sum of
        // current digits and carry
        int sum = ((str1[i]-'0')+(str2[i]-'0')+carry);
        str.push_back(sum%10 + '0');

        // Calculate carry for next step
        carry = sum/10;
    }

    // Add remaining digits of larger number
    for (int i=n1; i<n2; i++)
    {
        int sum = ((str2[i]-'0')+carry);
        str.push_back(sum%10 + '0');
        carry = sum/10;
    }

    // Add remaining carry
    if (carry)
        str.push_back(carry+'0');

    // reverse resultant string
    reverse(str.begin(), str.end());

    return str;
}
int main ()
{
    int n,k;
    cin>>n>>k;
    int h[n];

    for(int i=0; i<n; i++)
    {
        cin>>h[i];
    }
    sort(h,h+n);

    string s="0";
    for(int i=0; i<n-k; i++)
    {
        //s+=h[i];
        stringstream ss;
        ss << h[i];
        string temp = ss.str();
    //    cout<<temp<<endl;
        s=findSum(temp,s);
    }
    cout<<s;
    //int i = 123;
    /*stringstream ss;
    ss << i;
    string s = ss.str();
    cout << s << "\n";*/
    return 0;
}


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

int main() {
	
	int n, k, s; cin >> n >> k >> s;
	for (int i = 0; i < n; i++) {
		if (i < k) cout << s << endl;
		else {
			if (s == 1000000000)	cout << 1 << endl;
			else cout << s + 1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define pf push_front
#define ulli unsigned long long int
#define what_is(x) cerr << #x << " is " << x << endl;
#define pi 2*acos(0.0)
#define F  first
#define S  second
#define endl '\n'
#define all(x) x.begin(),x.end()
using namespace std;

bool sortbysec(const pair<lli,lli> &a,
              const pair<lli,lli> &b)
{
    return (a.second < b.second);
}

lli modulo(string num, lli a)
{
    lli res = 0;
    for (lli i = 0; i < num.length(); i++)
         res = (res*10 + (int)num[i] - '0') %a;

    return res;
}

lli SieveOfEratosthenes(lli n,vector<lli> &v)
{
    lli ans=0,p1,p2,p3;
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (lli p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (lli i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (lli p=2; p<=n; p++)
    {
       if (prime[p])
          v.pb(p);
    }
}

int main()
{
//cout.precision(9);
//cout.setf(ios::fixed,ios::floatfield);
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
	lli T=1;
    //cin>>T;
	while(T--)
	{
        lli n,z,i,j,k,l,r,d,ans=2019;
        cin>>l>>r;
        if(l==0)
        {
            cout<<"0"<<endl;
            return 0;
        }
        if(r-l>673)
        {
            cout<<"0"<<endl;
            return 0;
        }
        for(i=l;i<r;i++)
        {
            for(j=i+1;j<=r;j++)
            {
                if(ans>(i*j)%2019)
                {
                    ans=(i*j)%2019;
                }
            }
        }
        cout<<ans<<endl;
    }
}
/*
5 4
1 2 3 4 5
1 2 10 5
*/


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

int main(void){

    int n, m;
    cin >> n >> m;

    int i, count, sum;
    vector<int> a(n);

    sum = 0;
    count = 0;

    for (i=0; i<n; i++){
        cin >> a.at(i);
    }

    for (i=0; i<n; i++){
        sum += a.at(i);
    }

    for (i=0; i<n; i++){
        if (a.at(i) >= ((double)sum/((double)(4*m)))){
            count++;
        }
    }

    if (count >= m){
//        cout << sum << " " << count  << " " << (sum/(4*m)) << endl;
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

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

long long unsigned int a[1000], ans = 1;

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

	for (int i = 2; i <= n; i++) {
		int k = i;
		for (int j = 2; j <= k; j++) {
			while (k % j == 0) {
				a[j]++;
				k /= j;
			}
		}
	}

	for (int i = 2; i <= n; i++)ans = ans * (a[i] + 1) % 1000000007;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256