akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int a,b,c,x; cin>>a>>b>>c>>x;

    int ans=0;
    REP(i,a+1) REP(j,b+1) REP(k,c+1){
        int sum=500*i+100*j+50*k;
        if(sum==x) ans++;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline



N, K = map(int, input().split())
A = list(map(int, input().split()))

def determine(L):
    if L == 0:
        return False
    ret = 0
    for a in A:
        k = a // L
        if k * L == a:
            k -= 1
        ret += k

    if ret <= K:
        return True

    else:
        return False



L = 0
R = 10 ** 9

while L + 1 < R:
    mid = (L + R) // 2
    if determine(mid):
        R = mid
    else:
        L = mid

print(R)

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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  ll t1, t2;
  cin >> t1 >> t2;

  ll a1, a2, b1, b2;
  cin >> a1 >> a2 >> b1 >> b2;

  ll p = (a1 - b1) * t1;
  ll q = (a2 - b2) * t2;
  if (p > 0) {
    p *= -1;
    q *= -1;
  }

  if (p + q < 0) {
    cout << 0 << '\n';
    return 0;
  } else if (p + q == 0) {
    cout << "infinity" << '\n';
    return 0;
  }

  ll s, t;
  s = -p / (p + q);
  t = -p % (p + q);

  if (t != 0) {
    cout << s * 2 + 1 << '\n';
  } else {
    cout << s * 2 << '\n';
  }

  return 0;
}

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

using namespace std;

typedef long long ll;
const int mxn = 1e5;
ll N, D, X, Y;

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

  cin >> N >> D;
  int res = 0;

  for (int i = 0;i<N;i++) {
    cin >> X >> Y;
    if (sqrt(pow(X,2)+pow(Y,2))<=D) res++;
  }
  cout << res <<endl;

}


Measured memory_bytes: 3668
class comb():
  F = [1, 1]
  Fi = [1, 1]
  I = [0, 1]
  def __init__(self, num, mod):
    self.MOD = mod
    for i in range(2, N + 1):
      self.F.append((self.F[-1] * i) % mod)
      self.I.append(mod - self.I[mod % i] * (mod // i) % mod)
      self.Fi.append(self.Fi[-1] * self.I[i] % mod)
  def com(self, n, k):
    if n < k: return 0
    if n < 0 or k < 0: return 0
    return self.F[n] * (self.Fi[k] * self.Fi[n - k] % self.MOD) % self.MOD

N, A, B, K = list(map(int, input().split()))
MOD = 998244353
com = comb(N, MOD)

if A > B:
  A, B = (B, A)
Rk = min(N, K // A)

Ans = 0
for i in range(Rk + 1):
  R = i
  if (K - (A * R)) % B != 0:
    continue
  C = (K - (A * R)) // B
  if C > N:
    continue
  Rc = com.com(N, R)
  Cc = com.com(N, C)
  Ans += (Rc * Cc) % MOD

print(Ans % MOD)

Measured memory_bytes: 38948
#coding: UTF-8
N = int(input())
#print(N)

a = [0]*N

a = list(map(int, input().split()))
#print(a)
cnt = 0

#マスの番号が奇数＝配列偶数個目
for i in range(N):
  if i%2==1:
    continue
  
  #数字が奇数
  if a[i]%2==1:
    cnt += 1


print(cnt)

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

#define fi first
#define se second

const int N = 5050;
const long long mod = 998244353;

using namespace std;

int n;
int a, b;
long long d[N][N];

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(0);

        cin >> n >> a >> b;
        for(int i = 0; i < N; i++){
                for(int j = 0; j < N; j++){
                        d[i][j] = 1e18;
                }
        }
        d[0][0] = 0;
        for(int i = 1; i <= n; i++){
                int x;
                cin >> x;
                for(int j = 0; j <= n; j++){
                        if(j > x)
                                d[i][j] = min(d[i][j], d[i - 1][j] + b);
                        if(j < x)
                                d[i][x] = min(d[i][x], d[i - 1][j]);
                        if(j < x)
                                d[i][j] = min(d[i][j], d[i - 1][j] + a);
                }
        }
        long long res = 1e18;
        for(int i = 0; i <= n; i++){
                res = min(res, d[n][i]);
        }
        cout << res << "\n";
}


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

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

using namespace std;

int main() {
  while(1){
    int n;
    cin>>n;
    if(!n)break;
    vector<vector<int>> o(31);
    REP(i,n){
      int f;
      cin>>f;
      REP(j,f){
        int d;
        cin>>d;
        o[d].push_back(i);
      }
    }
    int mind = 31;
    for(int i=30;i>0;--i){
      REP(j,n){
        set<int> s;
        s.insert(j);
        for(int k=i;k>0;--k){
          bool ok=false;
          for(int p:o[k]){
            if(s.find(p)!=end(s))
              ok=true;
          }
          if(ok){
            for(int p:o[k]){
              s.insert(p);
            }
          }
        }
        if(s.size() == n){
          mind=min(mind,i);
        }
      }
    }
    if(mind<=30)
      cout<<mind<<endl;
    else
      cout<<-1<<endl;
  }
  return 0;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, A[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];
	sort(A, A + N, greater<int>());

	ll ans = A[0];
	rep(i, 0, N - 2) ans += 1LL * A[i / 2 + 1];
	cout << ans << endl;
}







Measured memory_bytes: 4340
n = gets.to_i
a = gets.chomp.split.map(&:to_i)
f = a[0]
1.step(n - 1) do |i|
  f ^= a[i]
end
res = []
0.step(n - 1) do |i|
  res << (a[i] ^ f)
end
puts res.join(" ")

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, l[20];
	cin>>n;
	REP(i, n){
		cin>>l[i];
	}
	sort(l, l+n);
	int len=0;
	REP(i, n-1){
		len+=l[i];
	}
	cout<<(l[n-1]<len ? "Yes" : "No")<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 998244353
typedef long long ll;

using namespace std;

ll N, A, B, K;
vector<ll> fact;
vector<ll> invs;

vector<ll> Factorial(){
    vector<ll> v{1};
    ll f = 1;
    for(ll i = 1; i <= N; ++i){
        f *= i;
        f %= MOD;
        v.push_back(f);
    }
    return v;
}

ll Pow(ll a,ll b){
    ll res = 1;
    while(b){
        if(b % 2) res = (res * a) % MOD;
        a = (a * a) % MOD;
        b >>= 1;
    }
    return res;
}

vector<ll> Reciprocal(){
    ll inv = Pow(fact[N], MOD - 2);
    vector<ll> v(N + 1, 1);
    v[N] = inv;
    for(ll i = N; i > 1; --i){
        inv *= i;
        inv %= MOD;
        v[i - 1] = inv;
    }
    return v;
}

ll nCr(ll n, ll r){
    if(r > n) return 0;
    return (fact[n] * invs[r] % MOD) * invs[n - r] % MOD;
}

int main(void){
    
    cin >> N >> A >> B >> K;
    
    fact = Factorial();
    invs = Reciprocal();
    
    ll result = 0;
    for(ll a = 0; a <= N; ++a){
        ll b = K - a * A;
        if(b < 0) break;
        if(b % B == 0) result = (result + nCr(N, a) * nCr(N, b / B)) % MOD;
    }
    
    printf("%lld\n", result);
    
    return 0;
}

Measured memory_bytes: 6636
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  int64_t ans=0;
  for(int i=1;i<n;i++){
    if(a.at(i-1)>a.at(i)){
      ans+=a.at(i-1)-a.at(i);
      a.at(i)=a.at(i-1);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4048
n=gets.to_i
d=(1..n).map{|i| [i]<<gets.split}
d.map!{|e|[e[0],e[1][0],e[1][1].to_i]}
d.sort!{|s,t|
    if s[1] != t[1]
        s[1]<=>t[1]
    else
        t[2]<=>s[2]
    end
}
d.each{|e|p e[0]}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;


int n;
int a[100011];


int cnt[4];

int main(){
   //ios::sync_with_stdio(0);
    //freopen("in.in","r",stdin);
    //freopen("out_1.out","w",stdout);
    
    cin>>n;
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    
    
       
    for(int i=0;i<n;i++){
        if(a[i] % 4 == 0)
            cnt[2]++;
        else if(a[i] % 2 == 0)
            cnt[1]++;
        else
            cnt[0]++;
    }
    
    int ok = 0;
    
    
    if(cnt[2] >= cnt[0])
        ok = 1;
    
    if(cnt[2] == cnt[0] - 1 && cnt[1] == 0){
        ok = 1;
    }
    
    
    
    if(ok )
        printf("Yes\n");
    else
        printf("No\n");
    
    
}

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

dic = {}

for i in range(n):
  word = input()
  if word not in dic:
    dic[word] = 1
  else:
    dic[word] += 1
    
max_num = max(dic[word] for word in dic)
l = []
for word in dic:
  if dic[word]==max_num:
    l.append(word)
    
l = sorted(l)
for i in range(len(l)):
  print(l[i])

Measured memory_bytes: 32988
#include <iostream>
using namespace std;
int main (){
	int A,B,C;
	cin >> A >> B >> C ;
	if((A==7 && B==5 && C==5)||
		(A==5 && B==7 && C==5)||
		(A==5 && B==5 && C==7)){
		cout << "YES\n";
	}else{
		cout << "NO\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int p[1001],x,n;
int main(){
  scanf("%d%d",&x,&n);
  for(int i=1;i<=n;i++){
    int a;scanf("%d",&a),p[a]=1;
  }
  for(int i=0;i<=1001;i++){
    if(x-i>=0){
      if(!p[x-i])return printf("%d\n",x-i)&0;
    }
    if(!p[x+i])return printf("%d\n",x+i)&0;
  }
}

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

int main()
{
  int n; cin>>n;
  cout << 0 << endl;

  string t; cin >> t;
  if (t == "Vacant") return 0;

  int l = 1;
  int r = n;
  while (true) {
    int m = (l+r)/2;
    cout << m << endl;

    string s; cin>>s;
    if (s=="Vacant") {
      return 0;
    }

    if (m%2) {
      if (t==s) r = m;
      else l = m;
    } else {
      if (t==s) l = m;
      else r = m;
    }
  }

  return 0;
}


Measured memory_bytes: 852
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,K,S;
int A[100010];

signed main(){
	cin>>N>>K>>S;
	if(S==1){
		REP(i,N){
			if(i<K){
				A[i]=1;
			}
			else{
				A[i]=2;
			}
		}
	}
	else{
		REP(i,N){
			if(i<K){
				A[i]=S;
			}
			else{
				A[i]=S-1;
			}
		}
	}
	REP(i,N){
		cout<<A[i];
		if(i<N-1)cout<<" ";
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<cstdio>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<string>
#include<list>
#include<utility>
#include<tuple>
#include<map>
#include<unordered_map>
#include<complex>
using namespace std;
typedef long long llong;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
string S;
int ANS = 0;
int main() {
	cin >> S;
	for (int i = 1; i < S.length(); i++) {
		if (S[i - 1] != S[i]) ANS++;
	}
	cout << ANS << endl;
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

int main() {
	int hill[10];
	int i,j;			/*[vpÏ*/
	int answer[3]={0,0,0};		/*ñpAãÊR*/
	int rank;

	for(i=0;i<10;i++){
		scanf("%d",&hill[i]);
	}
	for(i=0;i<10;i++){
		for(j=0,rank=0;j<10;j++){	/*rank=0 àÁÆàlª¢*/
			if(hill[i] < hill[j]){
				rank++;				/*Êðº°é*/
			}
		}
		if(rank<1 && answer[rank+1]==hill[i]){	/*¯ÌêÌP(êÊhill[i])*/
			answer[rank+2]=hill[i];				/*hill[i]ð2ÊÉ·éB*/
			rank++;
		}
		if(rank<2 && answer[rank]==hill[i]){	/*¯ÌêÌQiñÊhill[i]j*/
			answer[rank+1]==hill[i];			/*hill[i]ð3ÊÉ·éB*/
			rank++;
		}
		if(rank < 3){
			answer[rank] = hill[i];
		}
	}
	printf("%d\n%d\n%d\n",answer[0],answer[1],answer[2]);
	
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
// import java.io.*;
// import java.time.*;

public class Main {
    static StringBuilder sb;

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

        int num = sc.nextInt();

        ArrayList<Integer> array = new ArrayList<>();
        for (int i = 0; i < num; i++) {
            array.add(sc.nextInt());
        }

        int query = sc.nextInt();

        for (int i = 0; i < query; i++) {
            int key = sc.nextInt();
            int lower_bound = LowerBound(array, key);
            if (lower_bound < 0) sb.append(num).append(" ");
            else sb.append(lower_bound).append(" ");
            int upper_bound = UpperBound(array, key);
            if (upper_bound < 0) sb.append(num).append("\n");
            else sb.append(upper_bound).append("\n");
        }

        System.out.print(sb);
        
        sc.close();
    }

    public static int LowerBound(List<Integer> list, int key) {
        int lower = -1;
        int middle = -1;
        int upper = list.size();

        while (upper > lower + 1) {
            middle = lower + (upper - lower) / 2;
            if (list.get(middle) > key - 1) upper = middle;
            else lower = middle;
        }

        return upper;
    }

    public static int UpperBound(List<Integer> list, int key) {
        int lower = -1;
        int middle = -1;
        int upper = list.size();

        while (upper > lower + 1) {
            middle = lower + (upper - lower) / 2;
            if (list.get(middle) > key) upper = middle;
            else lower = middle;
        }

        return upper;
    }
}



Measured memory_bytes: 113560
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define REP(i,a) for(int i=0;i<(a);i++)
#define REPR(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<long long>;
using vvl = vector<vl>;
using vs = vector<string>;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

int main() {
  string s=ss();
  if (s=="A")ps("T");
  if (s=="C")ps("G");
  if (s=="G")ps("C");
  if (s=="T")ps("A");
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
	unsigned long long int N, M, ans = 0;
	cin >> N >> M;
	
	if (N > 1) N -= 2;
	if (M > 1) M -= 2;

	cout << N*M << endl;

	return 0;
}

Measured memory_bytes: 256
/*
░░░░░░░▄▀▀▀▀▀▀▀▄▄░░░░░░
░░░░░░▐░░░▄▄▄▄▄░ ▀▀▄
░░░░░▐░$░▐▀░░░░▀▀▀▀▄▀
░░░░░▌░░▐░░░░░░░░░░▄▄
░░░░▐░░░░▀▄▄▄▄▄▄▀▀▀░▄▀
░░░░▌▒░▒░▒░▒░░░▄▄▄▀▀
░░░░▌▒▒░▒▒▒▒▄▄▀▀
░░░▐░░▒▒▒▄▀▀░░░░░░░
░░░▐░▒▒▒▐░░░░░░░░░
░░░▐▒▒▒▒▌░░░░░░░░
░░░▐▒▒▒░▐░░░░░░░░░▄▀▄
░░░▐▒▒░▒▐▄▄▀▀▀▀▄▄▄▀░▌
░░░▐░▒▒░▄▄▄▄▀▀▄▄▄▄▄▀
░░▐▒▒▄▒▒▀▄▄▄▄▄▀░░░▄▌░░
░░▌▒▐░▀▀▄▄▄▄▄▄▄▀▀▀░░░░
░▐▒▒▌░░░░░░░░░░░░░ 
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 1e5 + 7;

int deg[N];
int cnt[N];
int kek[N];

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
#else
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    vector <pair <int, int> > e;
    for (int i = 1; i < n; i++)
    {
        int u, v;
        cin >> u >> v;
        e.push_back({u, v});
        deg[u]++;
        deg[v]++;
    }
    for (auto c : e)
    {
        int u = c.first, v = c.second;
        if (deg[v] == 1)
        {
            cnt[u]++;
        }
        if (deg[u] == 1)
        {
            cnt[v]++;
        }
    }
    for (int i = 1; i <= n; i++)
    {
        if (cnt[i] > 1)
        {
            cout << "First\n";
            return 0;
        }
        else
        {
            if (cnt[i] == 1)
            {
                kek[i] = 1;
            }
        }
    }
    for (int i = 1; i <= n; i++)
    {
        cnt[i] = 0;
    }
    for (auto c : e)
    {
        int u = c.first, v = c.second;
        cnt[u] += kek[v];
        cnt[v] += kek[u];
    }
    for (int i = 1; i <= n; i++)
    {
        if (deg[i] == 1)
        {
            continue;
        }
        if (!kek[i] && cnt[i] == deg[i])
        {
            cout << "First\n";
            return 0;
        }
    }
    if (n % 2 == 0)
    {
        cout << "Second\n";
    }
    else
    {
        cout << "First\n";
    }
}


Measured memory_bytes: 2292
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
const int mod = 1e9 + 7;
int main() {
	int n;
	cin >> n;
	ll ans = 0;
	ll temp = 1;
	for (int i = 0; i < n; ++i)
		temp *= 10, temp %= mod;
	ans += temp;
	temp = 2;
	for (int i = 0; i < n; ++i)
		temp *= 9, temp %= mod;
	ans -= temp;
	ans += mod;
	temp = 1;
	for (int i = 0; i < n; ++i)
		temp *= 8, temp %= mod;
	ans += temp;
	ans %= mod;
	cout << ans << endl;
}

Measured memory_bytes: 3660
fn main() {
    proconio::input! {
        n: usize,
        s: proconio::marker::Bytes,
    }
    let mut r = Vec::new(); r.resize(n+1, 0);
    let mut g = r.clone();
    let mut b = r.clone();
    for i in 1..=n {
        r[i]=r[i-1];
        g[i]=g[i-1];
        b[i]=b[i-1];
        match s[i-1] {
            b'R' => r[i]+=1,
            b'G' => g[i]+=1,
            b'B' => b[i]+=1,
            _ => assert!(false),
        }
    }
    let mut t:u64=0;
    for i in 0..n-2 { for j in i+1..n-1 { if s[i]!=s[j] {
        let k=j+j-i;
        for c in "RGB".bytes() { if c!=s[i]&&c!=s[j] {
            let a = match c {
                b'R' => &r,
                b'G' => &g,
                _ => &b,
            };
            t+=a[n]-a[j+1];
            if k<n {
                t-=a[k+1]-a[k];
            }
        }}
    }}}
    println!("{}",t);
}

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



int main(){
    ll n;
    cin >> n;
    string s[n];
    ll counta=0,countb=0,countab=0,count=0;
    for(ll i=0;i<n;i++){
        cin >> s[i];
        if(s[i][0]=='B') countb++;
        if(s[i][s[i].size()-1]=='A') counta++;
        if(s[i][0]=='B'&&s[i][s[i].size()-1]=='A') countab++;
        for(ll j=0;j<(ll)s[i].size()-1;j++){
            if(s[i][j]=='A'&&s[i][j+1]=='B') count++;
        }
    }
    if(countab>0&&countab==counta&&countab==countb) cout << count+counta-1 << endl;
    else cout << count+min({counta,countb,n-1}) << endl;
    return 0;
}  


Measured memory_bytes: 3944
/**
 * @author karayuu
 */

fun main(args:Array<String>) {
    val map = mutableMapOf<Char, MutableList<Char>>()

    ('a'..'c').map { map[it] = readLine()!!.toMutableList() }

    var whoPlay = 'a'

    while (true) {
        val stock = map[whoPlay]!!
        if (stock.size == 0) {
            print(whoPlay.toUpperCase())
            break
        }

        whoPlay = stock[0]
        stock.removeAt(0)
    }
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
int a[100000];

int main() {
    scanf("%d", &n);
    forn(i, n) scanf("%d", a + i);
    int i = 0;
    int ans = 0;
    while (i < n) {
        ++i;
        int aa = 1, b = 1;
        while (i < n) {
            if (a[i] > a[i - 1]) {
                aa = 0;
            }
            if (a[i] < a[i - 1]) {
                b = 0;
            }
            if (!aa && !b) {
                break;
            }
            ++i;
        }
        ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * (n + 1)

    def add(self, i, x=1):
        i += 1
        while i <= self.n:
            self.data[i] += x
            i += i & -i

    def get_sum(self, i):
        i += 1
        x = 0
        while i > 0:
            x += self.data[i]
            i -= i & -i
        return x

    # Return sum for [l, r)
    def get_sum_range(self, l, r):
        return self.get_sum(r - 1) - self.get_sum(l - 1)


def main():
    N = int(readline())
    S = readline().strip()
    Q = int(readline())

    S = list(S)
    base = ord('a')

    tree = [BIT(N) for _ in range(26)]
    for i, c in enumerate(S):
        tree[ord(c) - base].add(i)

    ans = []
    for _ in range(Q):
        n, a, b = readline().split()
        if n == '1':
            i = int(a) - 1
            if S[i] != b:
                tree[ord(S[i]) - base].add(i, -1)
                tree[ord(b) - base].add(i, 1)
                S[i] = b
        else:
            l, r = int(a) - 1, int(b)
            tmp = 0
            for i in range(26):
                if tree[i].get_sum_range(l, r) > 0:
                    tmp += 1
            ans.append(tmp)

    print('\n'.join(map(str, ans)))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 202168
while True :
    n = int(input())
    if n == 0 :
        break
    
    S = 1
    for i in range(n) :
        S *= (i+1)
    
    ans = 0
    while True :
        if S % 10 != 0 :
            break
        else :
            S = S // 10
            ans += 1
    print(ans)
        



Measured memory_bytes: 5632
package main

import(
	"fmt"
)

func main() {
	var ku [3]int
	fmt.Scanf("%d %d %d", &ku[0], &ku[1], &ku[2])

	five := 0
	seven := 0

	for _, v := range ku {
		if v == 5 {
			five++
		} else if v == 7 {
			seven++
		}
	}

	if five == 2 && seven == 1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;

int main()
{
    char str[1010];
    int w;
    int len;
    while(cin>>str>>w)
    {
        len=strlen(str);
        for(int i=0;i<len;i++)
        {
            if(i%w==0)
                printf("%c",str[i]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


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


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

int dx4[4] = { 1,0,0,-1 };
int dy4[4] = { 0,1,-1,0 };
int dx2[2] = { 1,0 };
int dy2[2] = { 0,1 };

/******************************************************************************************/

vector<int> G[2005];

int dist[2005][2005];

vector<int> bfs(int n, int st) {

	vector<int> d(n+10, INF);
	queue<int> que;
	que.push(st);
	d[st] = 0;
	
	while (!que.empty()) {

		int now = que.front();
		que.pop();
		if (d[now] == INF)continue;

		for (auto nxt : G[now]) {

			if (d[nxt] > d[now] + 1) {
				d[nxt] = d[now] + 1;
				que.push(nxt);
			}
		}
	}

	return d;
}


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);


	ll n, x, y;
	cin >> n >> x >> y;

	for (int i = 0; i < n; i++)
	{
		G[i].emplace_back(i + 1);
		G[i + 1].emplace_back(i);
	}
	--x;
	--y;
	G[x].emplace_back(y);
	G[y].emplace_back(x);

	for (int i = 0; i < n; i++)
	{
		vector<int> d = bfs(n,i);
		for (int j = 0; j < n; j++)
		{
			dist[i][j] = dist[j][i] = d[j];
		}
	}

	vector<int> ans(n + 10, 0);
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			ans[dist[i][j]]++;
		}
	}

	for (int i = 1; i < n; i++)
	{
		cout << ans[i] << endl;
	}

	return 0;
}



Measured memory_bytes: 16000
object Main extends App {
	val strAry = io.StdIn.readLine().split(' ')
	val num1 = strAry(0).toInt
	val num2 = strAry(1).toInt
	
	val result = (num1, num2) match {
		case (a, b) if a == b => s"""a == b"""
		case (a, b) if a > b => s"""a > b"""
		case (a, b) if a < b => s"""a < b"""
	}
	
	println(result)
}


Measured memory_bytes: 43764
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
ll a[200005],b[200005][2],c[200005];

int main(){
	int n;
	sc(n);
	rep(i,1,n){
		b[i][0]=b[i-1][0];
		b[i][1]=b[i-1][1];
		scl(c[i]);
		if(i%2==1)b[i][1]+=c[i];
		else b[i][0]+=c[i];
	}a[1]=0;a[2]=max(c[1],c[2]);
	rep(i,3,n){
		if(i%2==1){
			a[i]=b[i-2][1];//取i-2的；
			a[i]=max(a[i],a[i-3]+c[i-1]);//取i-1的； 
			a[i]=max(a[i],a[i-2]+c[i]);//取i的；
		}
		else {
			a[i]=b[i-1][1];//取i-1的；
			a[i]=max(a[i],a[i-2]+c[i]);//取i的； 
		}	
	}pf("%lld\n",a[n]); 
}

Measured memory_bytes: 9992
N=int(input())
bo=[0]
for n in range(N):
    a=int(input())
    bo.append(a)
map=1
count=0
ans=0
for n in range(1,N+1):
    map=bo[map]
    count+=1
    if map==2:
        ans=1
        print(count)
        break
if ans==0:
    print(-1)


Measured memory_bytes: 7080
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll n;
    cin >> n;
    ll h[n+1];
    for (ll i=0;i<n;i++){
        cin >> h[i];
    }
    h[n]=0;
    ll count=0;
    while(true){
        count++;
        ll c;
        for (ll i=0;;i++){
            if (h[i]>0){
                c=i;
                break;
            }
            if (i==n-1){
                cout << count-1 << endl;
                return 0;
            }
        }
        while(h[c]>0){
            h[c]=h[c]-1;
            c++;
            
        }
    }
    return 0;
}


Measured memory_bytes: 256
n, m, s, t = gets.strip.split(/ /).collect{|x| x.to_i}

a_table = {}
b_table = {}
(1..n).each{|i|
	a_table[i] = {}
	b_table[i] = {}
}

m.times{|i|
	u, v, a, b = gets.strip.split(/ /).collect{|x| x.to_i}
	
	a_table[u][v] = a_table[v][u] = a
	b_table[u][v] = b_table[v][u] = b
}

#p a_table
#p b_table

def calc_min(table, s)
	ret = []
	ret[s] = [0, 0]
	queue = [s]
	while cur = queue.shift
		price, hop = ret[cur]
		table[cur].each{|next_v, pay|
			next_price = price + pay
			if (last_pair = ret[next_v]) == nil || last_pair[0] > next_price
				ret[next_v] = [next_price, hop + 1]
				queue << next_v
			end
		}
	end
	ret
end

data_a = calc_min(a_table, s)
data_b = calc_min(b_table, t)

data = []

(1..n).each{|i|
	p_a, h_a = data_a[i]
	p_b, h_b = data_b[i]
	data << [p_a + p_b, h_a, i]
}

#p data

data = data.sort_by{|price, hop, year|
	price
}

#p data

total = 10 ** 15
i = 0
n.times{|j|
	d = data[i]
	while j >= d[2]
		i += 1
		d = data[i]
	end
	puts total - d[0]
}



Measured memory_bytes: 109476
#include <bits/stdc++.h>
#define ll long long
#define INF INT_MAX 
#define mod 1000000007
using namespace std;
int main(){
    ll N;
    cin >> N;
    ll A[N];
    if(N%2==0){
        for(int i=0;i<N;i++){
            cin >> A[i];
            if(A[i]%2==0){
                cout << 0 << endl;
                return 0;
            }
        }
    }else{
        for(int i=0;i<N;i++){
            cin >> A[i];
            if(A[i]%2==1){
                cout << 0 << endl;
                return 0;
            }
        }
    }
    sort(A,A+N);
    int count = 0;
    for(int i=N%2;i<N;i++){
        if(A[i]==A[i+1]){
            count++;
        }else{
            if(count!=1){
                cout << 0 << endl;
                return 0;
            }
            count = 0;
        }
    }
    ll ans = 1;
    for(int i=0;i<N/2;i++){
        ans = (ans*2)%mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main() {
	//入力
	int N;
	cin >> N;
	vector<int> vec(N);

	for (int i = 0; i < N; i++) {
		cin >> vec[i];
	}
	
	//処理
	int ans = 0;
	for(int i = 0; i < N; i++) {
		bool flag = true;

		for (int j = 0; j < i; j++) {
			if (vec[j] > vec[i]) flag = false;
		}
		if (flag) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H, A, x;
  cin >> H >> A;
  
  for (int i=1; i<100000; i++) {
    if (H<=i*A) {
      x=i;
      break;
    }
  }
  
  cout << x << endl;
  return 0;
  
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int m = sc.nextInt();
      int x = sc.nextInt();
      int[] a = new int[m];
      for(int i = 0;i < m;i++)a[i] = sc.nextInt();
      int sum1 = 0;
      int sum2 = 0;
      int x1 = x;
      int x2 = x;
      for(int i = 0;i<m;i++){
      	if(a[i]<x)sum1++;
      }
      for(int i = 0;i < m;i++){
      	if(x<a[i])sum2++;
      }
      System.out.println(Math.min(sum1,sum2));
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vvi cnt(10, vi(10));
    for (int i = 1; i <= n; ++i) {
        string s = to_string(i);
        int a = s.front() - '0';
        int b = s.back() - '0';
        if (a == 0 || b == 0) continue;
        cnt[a][b]++;
    }
    ll ans = 0;
    for (int i = 1; i <= 9; ++i) {
        for (int j = 1; j <= 9; ++j) {
            ans += (ll)cnt[i][j] * cnt[j][i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define MOD 1e9 + 7
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }


int main() {
    int a,b,c,k;
    vector<int> ans;
    
    cin >> a >> b >>k;
    
    for(int i = min(a,b); i >= 1; --i ){
        if(a%i == 0 && b%i == 0){
            --k;
        }
        if(k == 0){
            cout << i << endl;
            break;
        }
    }
   return 0;
}



Measured memory_bytes: 256
def paint(arr)
	arr.each{|i|
		a = []
		i.each{|j|
			a << j
		}
		a[0].times{
			img = ""
			a[1].times{
				img << "#"
			}
			puts img
		}
		puts ''
	}
end

input_arr = []
while input = gets
	h, w = input.split(' ').map(&:to_i)
	break if (h == 0 && w == 0)
	input_arr << [h, w]
end

paint(input_arr)

Measured memory_bytes: 8764
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=100000;
int n;
int a[N+2],b[N+1];
signed main(){
	scanf("%lld",&n);
	for(int i=1;i<=n+1;i++)scanf("%lld",a+i);
	for(int i=1;i<=n;i++)scanf("%lld",b+i);
	int ans=0;
	for(int i=1;i<=n;i++)
		if(b[i]<=a[i])ans+=b[i];
		else if(b[i]<=a[i]+a[i+1])ans+=b[i],a[i+1]-=b[i]-a[i];
		else ans+=a[i]+a[i+1],a[i+1]=0;
	printf("%lld",ans);
	return 0;
}
/*1
2
3 5 2
4 5
*/
/*2
3
5 6 3 8
5 100 8
*/
/*3
2
100 1 1
1 100
*/

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

int n[100000];
int q[100000][3];
int n1,q1;
int minx;
int i;

void search1() {
	minx = 2147483647;
	for (int j = q[i][1]; j <= q[i][2]; j++) {
		minx = min(minx, n[j]);
	}
	cout << minx << endl;
}

void update1() {
	n[q[i][1]] = q[i][2];
}

int main() {
	for (int i = 0; i < 100000; i++) {
		n[i] = 2147483647;
	}
	cin >> n1;
	cin >> q1;
	for (i = 0; i < q1; i++) {
		cin >> q[i][0] >> q[i][1] >> q[i][2];
		if (q[i][0] == 1) {
			search1();
		}
		else {
			update1();
		}
	}
	return 0;
}

Measured memory_bytes: 4652
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 8/23/2018
 
 22:05-22:18 analysis
 
 */

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
const int MAX_N=1e5+1;
int N;
LL L;
LL A[MAX_N];

const string yes="Possible",no="Impossible";
void solve() {
  int x=-1;
  REP(i,N-1) if(A[i]+A[i+1]>=L) {
    x=i;
    break;
  }
  if(x==-1) {
    cout<<no<<endl;
    return;
  }
  cout<<yes<<endl;
  REP(i,x) cout<<i+1<<endl;
  for(int i=N-2; i>=x; --i) cout<<i+1<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N>>L;
  REP(i,N) cin>>A[i];
  solve();
  return 0;
}


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

string DIR = "RLUD";
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int64_t chmax(int64_t& a, int64_t b){
    a = max(a, b);
}
int64_t chmin(int64_t& a, int64_t b){
    a = min(a, b);
}

int main(){
    int N;
    vector<int64_t> X[4], Y[4];
    cin >> N;
    for(int i=0; i<N; i++){
        int64_t x, y;
        char c;
        cin >> x >> y >> c;
        x *= 2;
        y *= 2;
        int d = DIR.find(c);
        X[d].push_back(x);
        Y[d].push_back(y);
    }
    vector<int64_t> xs, ys;
    for(int k=0; k<4; k++){
        if(X[k].size()){
            xs.push_back(*max_element(X[k].begin(), X[k].end()));
            xs.push_back(*min_element(X[k].begin(), X[k].end()));
            ys.push_back(*max_element(Y[k].begin(), Y[k].end()));
            ys.push_back(*min_element(Y[k].begin(), Y[k].end()));
        }
    }

    vector<int64_t> cand;
    for(int64_t x1 : xs) for(int64_t x2 : xs){
        int64_t d = abs(x1-x2);
        cand.push_back(d);
        cand.push_back(d/2);
    }
    for(int64_t y1 : ys) for(int64_t y2 : ys){
        int64_t d = abs(y1-y2);
        cand.push_back(d);
        cand.push_back(d/2);
    }

    const int64_t INF = 1e9;
    int64_t ans = 1e18;
    for(int64_t d : cand){
        int64_t xmax = -INF, ymax = -INF, xmin = INF, ymin = INF;
        for(int k=0; k<4; k++) for(int i=0; i<X[k].size(); i++){
            int64_t x = X[k][i] + dx[k] * d;
            int64_t y = Y[k][i] + dy[k] * d;
            chmax(xmax, x);
            chmin(xmin, x);
            chmax(ymax, y);
            chmin(ymin, y); 
        }
        int64_t res = (xmax-xmin) * (ymax-ymin);
        chmin(ans, res);
    }
    double Ans = (double) ans / 4;
    cout << fixed << setprecision(10) << Ans << endl;
    return 0;
}


Measured memory_bytes: 2256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define rall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	int A, B, C, K, ans = 0;
	cin >> A >> B >> C >> K;
	if(A >= K){
		cout << K << endl;
		return 0;
	}
	ans += A;
	K -= A;
	if(B >= K){
		cout << ans << endl;
		return 0;
	}
	K -= B;
	cout << ans - K << endl;


	return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>
int main(){
  int i, j, tmp;
  int a[3];
  for (i = 0; i < sizeof(a) / sizeof(int); i++) {
    scanf ("%d",&a[i]);
  }

  for (i = 0; i < sizeof(a) / sizeof(int) - 1; i++) {
    for (j = 1; j < sizeof(a) / sizeof(int); j++) {
      if (a[i] > a[j]) {
        tmp = a[i];
        a[i] = a[j];
        a[j] = tmp;
      }
    }
  }

  printf ("%d %d %d\n", a[0], a[1], a[2]);

  return 0;
}


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

#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define per(i,n) for (int i=(int)(n)-1;i>=0;i--)
#define For(i,n) for (int i=1;i<=(int)(n);i++)
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define all(x) (x).begin(),(x).end()
#define Max(a,b,c) max(a,max(b,c))
#define Min(a,b,c) min(a,min(b,c))
#define pii pair<int,int>
#define vi vector <int>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define pb push_back
#define re return
#define se second
#define fi first
const int INF=0x7fffffff;
const int MAXN=100+3;

int n,k,a[MAXN];
bool f[100003];

int main(){
	cin>>n>>k;
	rep(i,n){
		cin>>a[i];
	}
	for (int i=a[0];i<=k;i++){
		rep(j,n){
			if (i-a[j]<0) break;
			f[i]|=(!f[i-a[j]]);
		}
	}
	cout<<(f[k]?"First":"Second")<<endl;
	re 0;
}

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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    int N; cin >> N;
    int A[N]; rep(i, N) cin >> A[i];
    int left, right;
    int acc_sum = 0;
    int acc_xor = 0;
    ll ans = 0;
    for(left = 0, right = 0; left < N; left++){
        while(right < N && (acc_xor^A[right]) == (acc_sum + A[right])){
            acc_xor ^= A[right];
            acc_sum += A[right];
            ans += (ll) (right-left+1);
            //cout << left << " " << right << endl;
            right++;
        }

        acc_sum -= A[left];
        acc_xor ^= A[left];
    }
    cout << ans << endl;
    return 0;
}

void solve(){}

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

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] inputstr;
        int N = Integer.parseInt(br.readLine().trim());
        int[][] F = new int[N][10];
        int[][] P = new int[N][11];
        for(int i=0; i<N; i++){
            inputstr = br.readLine().trim().split(" ");
            F[i][0] = Integer.parseInt(inputstr[0]);
            F[i][1] = Integer.parseInt(inputstr[1]);
            F[i][2] = Integer.parseInt(inputstr[2]);
            F[i][3] = Integer.parseInt(inputstr[3]);
            F[i][4] = Integer.parseInt(inputstr[4]);
            F[i][5] = Integer.parseInt(inputstr[5]);
            F[i][6] = Integer.parseInt(inputstr[6]);
            F[i][7] = Integer.parseInt(inputstr[7]);
            F[i][8] = Integer.parseInt(inputstr[8]);
            F[i][9] = Integer.parseInt(inputstr[9]);
        }
        for(int i=0; i<N; i++){
            inputstr = br.readLine().trim().split(" ");
            for(int j=0; j<11; j++){
                P[i][j] = Integer.parseInt(inputstr[j]);
            }
        }
        int a = 1;
        String a_bin;
        int maxprofit = Integer.MIN_VALUE;
        int temp;
        int[] count = new int[N];
        for(a=1; a<= 1024; a++){
            temp = 0;
            for(int i=0; i<count.length; i++){
                count[i] = 0;
            }
            a_bin = Integer.toBinaryString(a);
            while(a_bin.length() < 10){
                a_bin = "0" + a_bin;
            }
            for(int i=0; i<10; i++){
                if(a_bin.charAt(i) == '1'){
                    for(int j=0; j<N; j++){
                        if(F[j][i] == 1) count[j]++;
                    }
                }
            }
            for(int i=0; i<N; i++){
                temp += P[i][count[i]];
            }
            maxprofit = Math.max(maxprofit, temp);
        }
        System.out.println(maxprofit);
    }
}

Measured memory_bytes: 22692