akhauriyash/Code-Regression huggingface dataset:
// Last Change: 04/13/2019 22:21:49.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

ll N, K;
string S;

ll Solve() {
  ll ans = 0;
  S = 'a' + S;

  vector<vector<ll>> r(2, vector<ll>(N + 1, 0));

  r[0][0] = 0;
  for (ll i = 1, cnt = 0; i <= N; ++i) {
    if (S[i - 1] != '0' and S[i] == '0') {
      ++cnt;
    }
    r[0][i] = cnt;
  }

  for (ll i = 0, cnt = 0; i < N; ++i) {
    if (S[i] == '0' and S[i + 1] == '1') {
      ++cnt;
    }
    r[1][i] = cnt;
  }

  for (ll right = 1, left = 1; right <= N; ++right) {
    while (r[0][right] - r[1][left - 1] > K) {
      ++left;

      if (left > right) {
        cout << "error" << endl;
        return -1;
      }
    }

    ans = max(ans, right - left + 1);
  }

  return ans;
}

int main() {
  cin >> N >> K >> S;
  ll ans = Solve();
  cout << ans << endl;

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 2812
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, a[20], x[20][20], y[20][20];

    cin >> n;

    REP(i, n)
    {
        cin >> a[i];

        REP(j, a[i])
        {
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }

    int res = 0;

    for (int i = 0; i < (1 << n); i++)
    {
        int cnt = 0;
        bool ok = true;
        REP(j, n)
        {
            if (i & (1 << j))
            {
                cnt++;

                REP(k, a[j])
                {
                    int b;
                    if (i & (1 << x[j][k]))
                        b = 1;
                    else
                        b = 0;
                    if (y[j][k] != b)
                        ok = false;
                }
            }
        }

        if (ok)
            res = max(res, cnt);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.*
import java.util.*

const val NO = "UNRESTORABLE"
fun solve(S: String, T: String) {
    val s = S.length
    val t = T.length
    for (i in s - t downTo 0) {
        val subStr = S.slice(i until i + t)
        if (subStr.replace('?', '.').toRegex().matches(T)) {
            val ans = S.slice(0 until i).replace('?', 'a') + T + S.slice(i + t until s).replace('?', 'a')
            println(ans)
            return
        }
    }
    println(NO)
    return
}

fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val S = sc.next()
    val T = sc.next()
    solve(S, T)
}


Measured memory_bytes: 33480
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,q;
	cin>>n>>q;
	vl ans(n);
	vvl g(n);
			ll a,b;
	rep(i,n-1){
		cin>>a>>b;
		g[a-1].push_back(b-1);
	}
	while(q--){
		cin>>a>>b;
		ans[a-1]+=b;
	}
	queue<ll> qu;
	qu.push(0);
	while(!qu.empty()){
		int t=qu.front();qu.pop();
		for(auto x:g[t]){
			ans[x]+=ans[t];
			qu.push(x);
		}
	}
	cout<<ans<<endl;

	
}


Measured memory_bytes: 16512
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(x, max(y, z))
#define MIN(x, y, z) min(x, min(y, z))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll D;
  cin >> D;
  vll C(26);
  rep(i, 26) cin >> C[i];
  vvll S(D, vll(26));
  rep(i, D) rep(j, 26) cin >> S[i][j];
  vll last(26, 0);
  ll ans = 0;
  rep(i, D + 1) {
    if (i == 0) continue;
    ll t;
    cin >> t;
    t--;
    ans += S[i - 1][t];
    last[t] = i;
    rep(j, 26) {
      ans -= C[j] * (i - last[j]);
    }
    COUT(ans);
  }

  return 0;
}

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

using namespace std;

#define ll long long
#define pb push_back
#define sz size()
#define S second
#define F first
#define all(x) x.begin(), x.end()

typedef vector < int >  vi;
typedef vector < vector < int > >  vvi;

void solve(){
    int n, sum = 0;
    cin >> n;
    while(sum < n){
        sum += 1000;
    }
    cout << sum - n;
}

signed main() {
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
        cout << "\n";
    }
}




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

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	int n;cin>>n;
	vc<pi> lr;
	const int inf=LLONG_MAX/3;
	int mx=-inf,mn=inf;
	rep(i,n){
		int l,r;cin>>l>>r;
		l--;
		chmax(mx,l);
		chmin(mn,r);
		lr.eb(l,r);
	}
	
	int ans=0;
	for(auto z:lr){
		chmax(ans,max(int(0),mn-mx)+z.b-z.a);
	}
	vc<pi> t;
	rep(i,n){
		int a=max(int(0),mn-lr[i].a);
		int b=max(int(0),lr[i].b-mx);
		t.eb(b,-a);
	}
	sort(all(t));
	int w=inf;
	rep(i,n){
		auto z=t[i];
		z.b=-z.b;
		if(i)
			chmax(ans,w+z.a);
		chmin(w,z.b);
	}
	cout<<ans<<endl;
}

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

int main(void) {

  int q;
  double x_n;

  while(1) {

    scanf("%d",&q);

    if(q==-1) break;

    x_n=(double)q/2.0;

    while(fabs(x_n*x_n*x_n-q)>=0.00001*q) x_n=x_n-(x_n*x_n*x_n-q)/(3*x_n*x_n);

    printf("%lf\n",x_n);

  }

  return 0;

}
 

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
const int d = 365;
//const int d = 5;
int c[26];
int s[d][26];

int score(vector<int> t){
    vector<int> last(26,0);
    int ans = 0;
    rep(i,d){
        ans += s[i][t[i]-1];
        last[t[i]-1] = i+1;
        rep(j,26) ans -= c[j] * (i + 1 - last[j]);
        cout << ans << endl;
    }
    return ans;
}

int main(){
    int tmp;
    cin >> tmp;
    rep(i,26) cin >> c[i];
    rep(i,d)rep(j,26) cin >> s[i][j];
    vector<int> t(d);
    rep(i,d) cin >> t[i];
    score(t);
    return 0;
}

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

bool pallin(string &s,int i,int j)
{
  while(i<j)
  {
    if(s[i]!=s[j]) return false;
    i++; j--;
  }
  return true;
}

int main()
{

    string s; cin>>s;
    int mid=(s.size())/2;
    if(pallin(s,0,s.size()-1) &&pallin(s,0,mid-1) &&pallin(s,mid+1,s.size()-1))
      cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $k, $s);
$exists = 0;

for ($x = 0; $x <= $k; $x++) {
  for ($y = 0; $y <= $k; $y++) {
    $z = $s - $x - $y;
      if ($z >= 0 && $z <= $k) {
        $exists++;
    }
  }
}
printf("%d\n", $exists);
?>

Measured memory_bytes: 4728
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define SI size()
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PF push_front
#define PB push_back
#define VE vector<int>
#define VP vector<PA>
#define LL long long
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int MOD=1e9+7;
const int INF=1e9+7;
//
int N,K;
long long A[100000];
int B[100000];
long long S=0;
//
int main(){
  cin>>N>>K;
  FOR(i,0,N){
    cin>>A[i];
    if(A[i]>0){
      S+=A[i];
      B[i]=1;
    }
  }
  long long P=S;
  long long M=0;
  FOR(i,0,K){
    if(B[i]){
      S-=A[i];
    }
  }
  M=S;
  FOR(i,K,N){
    if(B[i]){
      S-=A[i];
    }
    if(B[i-K]){
      S+=A[i-K];
    }
    M=max(M,S);
  }
  S=P;
  FOR(i,0,K){
    if(B[i]==0){
      S+=A[i];
    }
  }
  M=max(M,S);
  FOR(i,K,N){
    if(B[i]==0){
      S+=A[i];
    }
    if(B[i-K]==0){
      S-=A[i-K];
    }
    M=max(M,S);
  }
  cout<<M<<endl;
  return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
int colocaMaiorNaFrente(const void*x,const void*y){
    const int*a = x,*b = y;

    if(*a>*b){
        return -1;
    }
    if(*a<*b){
        return 1;
    }else{
        return 0;
    }
}

int main(){
    int n,k;
    int c = 0;
    scanf("%d %d",&n,&k);

    int varetas[n];

    for(int i = 0; i<n; ++i){
        scanf("%d",&varetas[i]);
    }
    qsort(varetas,n,sizeof(varetas[0]),colocaMaiorNaFrente);

    for(int i = 0; i<k; ++i){
        c += varetas[i];
    }

    printf("%d\n",c);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int a,p;
  cin>>a>>p;
  cout<<((a*3)+p)/2<<endl;
  

  return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define sum accumulate
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 998244353LL;
int main(){
	int a,b;
	std::cin >> a>>b;
	if(a>b)std::cout << "a > b" << std::endl;
	else if(a<b)std::cout << "a < b" << std::endl;
	else std::cout << "a == b" << std::endl;
}


Measured memory_bytes: 3096
#include <stdio.h>
#include <stdint.h>
int main(void){
    int16_t n; /* candy */
    int16_t tmp;
    
    scanf("%d",&n);
    for(int16_t i = 1; i<=n; i++){
        tmp = tmp + i;
    }
    printf("%d\n",tmp);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  int a,b;
  cin>>a>>b;
  if((a+1)/2>=b) co("YES");
  else co("NO");
  
  return 0;
}

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

int main(int argc, const char * argv[]) {
    
    int a,b,k;
    int x,n;
    
    cin >> a >> b >> k;
    
    //cout << b << endl;
    x=(b-a)/2;
    if(x<k){
        for(int i=0;i<b-a+1;i++){
            cout << a+i << endl;
        }
        
    }
    else{
        
        for(int i=0;i<k;i++){
            cout << a+i << endl;
        }
        n=k-1;
        //cout << b << endl;
        for(int i=0;i<k;i++){
            cout << b-n << endl;
            n--;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
x,y = map(int,input().split())

a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]
if x in a and y in a:
    print('Yes')
    import sys
    sys.exit()
if x in b and y in b:
    print('Yes')
    import sys
    sys.exit()
if x in c and y in c:
    print('Yes')
    import sys
    sys.exit()
print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int x,a,b;
    cin>>x>>a>>b;
    cout<<(x-a)%b<<endl;
}

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

int main() {
	int min=1000000;
	int max=-1;
	int n;
	cin>>n;
	while(n--) {
		int x;
		cin>>x;
		if(x<min) min=x;
		if(x>max) max=x;
	}
	cout<<max-min;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int main()
{
	ll a,b; cin>>a>>b; cout<<a*b<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
main(){
  int i,j,sum,n,ans;
  int a[5000];
  while(1){
    scanf("%d",&n); ans= -100000000;
    if(n == 0)break;
    for(i=0;i<n;i++){
      scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++){
      sum=0;
      for(j=i;j<n;j++){
	sum += a[j];
	if(sum>ans){
	  ans = sum;
	}
      }
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 620
#include<iostream>
#include<cstdio>
#include<cstring>
#define MAXN 100
using namespace std;
int dis[3][MAXN+5], n;
int main()
{
	scanf("%d", &n);
	for(int i=1; i<=2; i++)
		for(int j=1; j<=n; j++)
			scanf("%d", &dis[i][j]);
	dis[1][n] += dis[2][n];
	for(int i=2; i>=1; i--)
		for(int j=n-1; j>=1; j--)
			if(i==2)
				dis[i][j] +=dis[i][j+1];
			else
				dis[i][j] += max(dis[i][j+1], dis[i+1][j]);
	printf("%d", dis[1][1]);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		String prev = sc.next();
		sc.close();

		if (prev.contentEquals("ABC")) {
			System.out.println("ARC");
		} else {
			System.out.println("ABC");
		}

	}

}


Measured memory_bytes: 35612
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <cassert>
#include <queue>
#include <ctime>
#include <string>
#include <cstring>
#define mp make_pair
#define pb push_back
#define NAME ""
#define y1 y1_423
#define list lista

using namespace std;

typedef long long ll;
typedef long double ld;

template<typename T>
ostream& operator << (ostream& cout, const vector<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "()");
	}
	cout << "(" << a[0];
	for (int i = 1; i < (int)a.size(); i++) {
		cout << "; " << a[i];
	}
	return (cout << ")");
}

template<typename T>
ostream& operator << (ostream& cout, const set<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T>
ostream& operator << (ostream& cout, const multiset<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T1, typename T2>
ostream& operator << (ostream& cout, const pair<T1, T2> &a) {
	return cout << "(" << a.first << "; " << a.second << ")";
}

const int nmax = 2000 * 1000;
const int inf = 2000 * 1000 * 1000;
const ll infl = 1000ll * 1000ll * 1000ll * 1000ll * 1000ll * 1000ll;
const int mod = 1000 * 1000 * 1000 + 7;
const ld pi = acos(-1.0);

string s, s1;

int main() {
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	//freopen(NAME".in", "r", stdin);freopen(NAME".out", "w", stdout);
	getline(cin, s);
	reverse(s.begin(), s.end());
	int ind = 0;
	while (ind < (int)s.length()) {
		s1 = "";
		if (s[ind] == 'r') {
			for (int i = ind; i < min((int)s.length(), ind + 6); i++) {
				s1 += s[i];
			}
			reverse(s1.begin(), s1.end());
			if (s1 == "eraser" || (s1 == "reamer" && (ind + 6 < (int)s.length() && s[ind + 6] == 'd'))) {
				ind += (s1 == "eraser" ? 6 : 7);
			} else {
				cout << "NO\n";
				return 0;
			}
		} else {
			for (int i = ind; i < min((int)s.length(), ind + 5); i++) {
				s1 += s[i];
			}
			reverse(s1.begin(), s1.end());
			if (s1 == "dream" || s1 == "erase") {
				ind += 5;
			} else {
				cout << "NO\n";
				return 0;
			}
		}
	}
	cout << "YES\n";
	return 0;
}

Measured memory_bytes: 512
import java.util.*;
public class Main{

    public static void main(String[] args) {
        Scanner input=new Scanner(System.in);
        String z,x,v;
        z=input.next();
        x=input.next();
        boolean m=false;
        for(int i=0,o=z.length()-1;i<z.length();i++,o--)
        {
            if(z.charAt(o)==x.charAt(i))
                m=false;
            else 
            {
                m=true;
                break;
            }
        }
        if(!m)
            System.out.println("YES");
        else System.out.println("NO");
    }
    
}


Measured memory_bytes: 27012
#coding:utf-8

c_list = []
t_list = []

N, T = map(int, input().split())
for i in range(N):
    c, t = map(int, input().split())
    c_list.append(c)
    t_list.append(t)

minval = 'TLE'
for c, t in zip(c_list, t_list):
    if t <= T:
        if minval == 'TLE':
            minval = c
        if c < minval:
            minval = c
print(minval)


Measured memory_bytes: 3060
arr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split('')
n = gets.to_i
s = gets.chomp.split('')
map = {}
arr.each_with_index do |a, i|
  map[a] = arr[(i + n) % arr.count]
end
r = ''
s.each do |a|
  r += map[a]
end
puts r

Measured memory_bytes: 19836
#include <cstdio>
#include <queue>
#include <utility>

using namespace std;

priority_queue<pair<int, int> > h;
int X, Y, Z, A, B, C, x;
long long ans;

int main() {
    scanf("%d%d%d%d%d", &X, &Y, &A, &B, &C);
    while (A--) {
        scanf("%d", &x);
        h.push(make_pair(x, 1));
    }
    while (B--) {
        scanf("%d", &x);
        h.push(make_pair(x, 2));
    }
    while (C--) {
        scanf("%d", &x);
        h.push(make_pair(x, 0));
    }
    Z = X + Y;
    while (Z) {
        pair<int, int> now = h.top();
        h.pop();
        if (now.second == 0) {
            ans += now.first;
            --Z;
        } else if (now.second == 1 && X) {
            ans += now.first;
            --X;
            --Z;
        } else if (now.second == 2 && Y) {
            ans += now.first;
            --Y;
            --Z;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 6512
using System;
using System.Collections.Generic;

public class CSharp{
    public static void Main(){
        Kyopuro chokudai = new Kyopuro();
	    chokudai.AtCoder();
	}
}

public class Kyopuro{

	int n;
  	int[] p;
	
    public void AtCoder(){
        string[] input;
		input = Console.ReadLine().Split(' ');
		n = int.Parse(input[0]);
      	input = Console.ReadLine().Split(' ');
      	p = new int[n];
		for (int i=0; i<n; i++) {
          p[i] = int.Parse(input[i]);
        }
      	int c = 0;
      	for (int i=1; i<=n; i++) {
          if (p[i - 1] != i) c++;
        }
      	
      	if (c == 0 || c == 2) Console.WriteLine("YES");
      	else Console.WriteLine("NO");
		
		
    }
    public static void DebugWL(object x){ System.Diagnostics.Debug.WriteLine(x); }
}


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

using ll = long long;

void solve(long long R, long long C, long long K, std::vector<long long> r, std::vector<long long> c, std::vector<long long> v){
    vector<vector<vector<ll>>> dp(R, vector<vector<ll>>(C, vector<ll>(4)));
    vector<vector<ll>> V(R, vector<ll>(C));
    for(int i = 0;i < K;i++){
        V[r[i] - 1][c[i] - 1] = v[i];
    }
    for(int i = 0;i < R;i++){
        for(int j = 0;j < C;j++){
            for(int k = 0;k < 4;k++){
                ll v = V[i][j];
                if(i + 1 < R)dp[i + 1][j][0] = max(dp[i][j][k], dp[i + 1][j][0]);
                if(j + 1 < C)dp[i][j + 1][k] = max(dp[i][j][k], dp[i][j + 1][k]);
                if(v != 0 && k != 3){
                    if(i + 1 < R)dp[i + 1][j][0] = max(dp[i][j][k] + v, dp[i + 1][j][0]);
                    if(j + 1 < C)dp[i][j + 1][k + 1] = max(dp[i][j][k] + v, dp[i][j + 1][k + 1]);
                }
            }
        }
    }
    for(int i = 2;i >= 0;i--){
        ll v = V[R-1][C-1];
        dp[R-1][C-1][i + 1] = max(dp[R-1][C-1][i + 1], dp[R-1][C-1][i] + v);
    }
    cout<<*max_element(dp[R - 1][C - 1].begin(), dp[R-1][C-1].end())<<endl;
}

int main(){
    long long R;
    scanf("%lld",&R);
    long long C;
    scanf("%lld",&C);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> r(K);
    std::vector<long long> c(K);
    std::vector<long long> v(K);
    for(int i = 0 ; i < K ; i++){
        scanf("%lld",&r[i]);
        scanf("%lld",&c[i]);
        scanf("%lld",&v[i]);
    }
    solve(R, C, K, std::move(r), std::move(c), std::move(v));
    return 0;
}


Measured memory_bytes: 710628
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int X;
    cin >> X;
    int a = X/100, b = X%100;
    printf("%d\n", (a*5 >= b) ? 1 : 0);
    return 0;
}


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

#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)

using ll = long long;
#define INF 1e9
const int mod = 1e9+7;
ll N, X;
vector<ll> P(51,0), PB(51,0);

ll solve(int L, ll ray){
  if(L==0){
    if(ray <= 0){
      return 0;
    }
    else{
      return 1;
    }
  }
  else if(ray <= 1+PB[L-1]){
    return solve(L-1, ray-1);
  }
  else{
    return P[L-1] + 1 + solve(L-1, ray-2-PB[L-1]);
  }
}

int main(){
  cin >> N >> X;
  P[0] = PB[0] = 1;
  FOR(i, 1, 51){
    P[i] = P[i-1]*2+1;
    PB[i] = PB[i-1]*2+3;
  }

  cout << solve(N, X) << endl;

  
  return 0;
}


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

int main() {
    //freopen("sample.in", "r", stdin);
    string s;
    cin >> s;
    for(int i = 0; i < s.length(); i++) {
        if (i % 2 == 0 && s[i] != 'R' && s[i] != 'U' && s[i] != 'D') return cout << "No" << endl, 0;
        if (i % 2 == 1 && s[i] != 'L' && s[i] != 'U' && s[i] != 'D') return cout << "No" << endl, 0;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
import heapq
n,m=map(int,input().split())
A=list(map(int,input().split()))
H=[]
for a in A:
    heapq.heappush(H,-a)
for i in range(m):
    heapq.heappush(H,-(-heapq.heappop(H)//2))
print(-sum(H))

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

public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n =sc.nextInt();
        int m =sc.nextInt();
        double[][] p = new double[n][3];
        for (int i = 0; i < n; i++) {
            p[i][0]=sc.nextDouble();
            p[i][1]=sc.nextDouble();
            p[i][2]=sc.nextDouble();
        }

        double ans = 0;
        for (int i = 0; i < 1<<n; i++) {
            if(Integer.bitCount(i)!=m)continue;
            ans=Math.max(ans, a(p,i));
        }
        System.out.println(ans);
    }
    static double a(double[][] p, int bit){
        int[] num = new int[Integer.bitCount(bit)];
        int cnt=0;
        for (int i = 0; bit!=0; i++) {
            if(bit%2==1){
                num[cnt]=i;
                cnt++;
            }
            bit = bit >> 1;
        }
        double res = 0.0;
        for (int i = 0; i < num.length; i++) {
            for (int j = i+1; j < num.length; j++) {
                double x1 = p[num[i]][0];
                double y1 = p[num[i]][1];
                double z1 = p[num[i]][2];
                double x2 = p[num[j]][0];
                double y2 = p[num[j]][1];
                double z2 = p[num[j]][2];
                x1 -=x2;
                y1 -=y2;
                z1 -=z2;
                x1*=x1;
                y1*=y1;
                z1*=z1;
                res += (x1+y1+z1);
            }
        }
        return res;
    }
}

Measured memory_bytes: 32572
#include<bits/stdc++.h>
using namespace std;
int main()
{
    vector<int>vec;
    int n,a;
    cin>>n>>a;
    while(a--)
    {
        int q;
        cin>>q;
        for(int i=1;i<=q;i++)
        {
            int p;
            cin>>p;
            vec.push_back(p);
        }

    }
    int i=1,p=0;
    while(i<=n)
    {
        int count=0;
        for(int j=0;j<vec.size();j++)
        {
            if(i!=vec[j])count++;
        }
        if(count==vec.size())
        {
            p++;
        }
        i++;
    }
    cout<<p<<endl;
}


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

using namespace std;

int a, b, c, d;

int main() {

    cin >> a >> b >> c >> d;

    if (abs(b - a) <= d && abs(c - b) <= d || abs(c - a) <= d)
        cout << "Yes\n";
    else
        cout << "No\n";
}


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

int main() {
  int N, K, D[10] = {};
  cin >> N >> K;
  for (int i = 0; i < K; i++) {
    int tmp;
    cin >> tmp;
    D[tmp] = 1;
  }
  while (true) {
    int x = N, f = 1;
    while (x > 0) {
      if (D[x % 10]) f = 0;
      x /= 10;
    }
    if (f) {
      cout << N << endl;
      return 0;
    }
    N++;
  }
}


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

void Main()
{
	int A, B;
	char op;
	cin >> A >> op >> B;
	if (op == '+') cout << A + B << endl;
	else cout << A - B << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 100000
using namespace std;
int n, l, r, pr[N+5], v[N+5], s[N+5];
int main() {
	int i, j;
	for(i=2; i<N; i++) pr[i] = 1;
	for(i=2; i<N; i++) {
		if(pr[i]) {
			for(j=i*2; j<N; j+=i) pr[j]=0;
		}
	}
	for(i=1; i<N; i+=2) {
		if(pr[i] && pr[(i+1)/2]) v[i] = 1;
	}
	for(i=3; i<N; i+=2) {
		s[i] = s[i-2] + v[i];
	}
	scanf("%d", &n);
	while(n--) {
		scanf("%d%d", &l, &r);
		if(l==1) l=3;
		printf("%d\n", s[r] - s[l-2]);
	}
	return 0;
}


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

using namespace std;

#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i, n) for(int i = 1; i <= n; ++i)

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

const int N = 200200;
const int mod = 1e9 + 7;

int n, m, a[303][303];
int iter[303];
int ans = 1e9;
int used[303];
int cnt[303];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m;
	fo(i, n) 
		fo(j, m)
			cin >> a[i][j];
	fo(i, n) iter[i] = 1;
	fo(sports_cnt, m)
	{
		fo(sport, m)
			cnt[sport] = 0;
		fo(i, n)
			cnt[a[i][iter[i]]]++;
		int res = -1;
		fo(sport, m)
		{
		   if(used[sport]) continue;
			if(res == -1 || cnt[sport] > cnt[res])
				res = sport;
		}
		if(res == -1) break;
		ans = min(ans, cnt[res]);
		used[res] = 1;
		fo(i, n)
			while(iter[i] < m && used[a[i][iter[i]]]) ++iter[i];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 640
n,k=map(int,input().split())
a=list(map(int,input().split()))
s=set(a)
a.sort()
if k>=len(set(a)):
    print(0)
else:
    cnt=[a[0]]
    ans=[]
    for i in range(1,n):
        if a[i]!=a[i-1]:
            ans.append(cnt)
            cnt=[]
            cnt.append(a[i])
        else:
            cnt.append(a[i])
        if i==n-1 and cnt!=[]:
            ans.append(cnt)
    for j in range(len(ans)):
        ans[j]=len(ans[j])
    ans.sort()
    answ=0
    for i in range(len(set(s))-k):
        answ+=ans[i]
    print(answ)

Measured memory_bytes: 42776
local n, m = io.read("*n", "*n")
local t = {}
for i = 1, n do t[i] = {} end
for i = 1, m do
  local a, b = io.read("*n", "*n")
  t[a][b], t[b][a] = true, true
end
local mult = 1
for i = 2, n - 1 do
  mult = mult * i
end
local cnt = 0
for i = 0, mult - 1 do
  local rem = {}
  local resarray = {1}
  for j = 2, n do rem[j - 1] = j end
  local it = i

  local tmpmult = mult
  for j = n - 1, 1, -1 do 
    local divfactor = tmpmult / j
    local pos = 1 + math.floor(it / divfactor)
    table.insert(resarray, rem[pos])
    table.remove(rem, pos)
    tmpmult = divfactor
    it = it % divfactor
  end
  local isok = true
  for j = 1, n - 1 do
    if(not t[resarray[j]][resarray[j+1]]) then
      isok = false
      break
    end
  end
  if(isok) then cnt = cnt + 1 end
end
print(cnt)


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

using ll = int_fast64_t;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define repr(i,n) for(int i{n};i-->0;)

signed main(){

  int h,w;
  cin>>h>>w;
  vector a(h,vector(w,0));
  vector b(h,vector(w,0));
  rep(i,h)rep(j,w)cin>>a[i][j];
  rep(i,h)rep(j,w)cin>>b[i][j];

  vector c(h,vector(w,0));
  rep(i,h)rep(j,w)c[i][j] = abs(a[i][j]-b[i][j]);

  constexpr int dmax = 80;
  constexpr int szmax = 80;
  constexpr int mvmax = szmax*2;
  constexpr int offset = dmax*mvmax + 1;
  using vecbool = bitset<offset*2+1>;

  vector dp (h+1,vector<vecbool>(w+1));
  dp[0][0].set(offset);
  rep(i,h)rep(j,w){
    dp[i+1][j] |= dp[i][j]<<c[i][j];
    dp[i+1][j] |= dp[i][j]>>c[i][j];
    dp[i][j+1] |= dp[i][j]<<c[i][j];
    dp[i][j+1] |= dp[i][j]>>c[i][j];
  }

  vecbool reachable = dp[h-1][w]|dp[h][w-1];
  int ans = offset;
  rep(i,offset*2)
    if(reachable[i])
      ans = min(ans,abs(i-offset));
  cout<<(ans)<<endl;
    

}

Measured memory_bytes: 24372
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	void solve(Supplier<String> sc) {
		int A = Integer.parseInt(sc.get());
		int B = Integer.parseInt(sc.get());
		System.out.println(A <= 8 && B <= 8 ? "Yay!" : ":(");
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		new Solver().solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

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

using namespace std;

#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define pb push_back
#define mod 1000000007
#define db(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

const int N = 21;

int a[N][N], n, memo[N][1ll << N];

int dp(int i, int mask) {
	if (i == n) return 1;
	int &ans = memo[i][mask];
	if (ans != -1) return ans;
	ans = 0;
	for (int j = 0; j < n; j++) {
		if ((mask >> j) & 1ll) continue;
		if (a[i][j] == 0) continue;
		ans += dp(i + 1, mask | (1ll << j));
		ans %= mod;
	}
	return ans;
}

void solve() {
	int i, j, k, m, ans = 0, cnt = 0, sum = 0;
	cin >> n;
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	memset(memo, -1, sizeof(memo));
	cout << dp(0, 0);
	return ;
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// int t; cin >> t; while (t--)
	solve();
	return 0;
}

Measured memory_bytes: 344320
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class C
{
	public static void Main()	
	{
		int N = GetInt();
		long x = GetLong();
		long[] a = new long[N];
		for(int i = 0; i < N; i++)
			a[i] = GetLong();

		long ans = 0;
		for(int i = 0; i < N - 1; i++)
		{			
			long numOver = a[i] + a[i + 1] - x;
			if(numOver <= 0)
				continue;
			ans += numOver;
			a[i + 1] -= Math.Min(numOver, a[i + 1]);
		}

		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 30044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_N 20000
#define MAX_M 16

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n, b, t;
double y, r;
vector< pair<double, int> > vpd;

int main(){
	while (cin >> n&&n){
		cin >> y;
		int ans;
		double MAX = -1;
		REP(i, n){
			cin >> b >> r >> t;
			if (t == 1){
				if (MAX < 1 + y*(r / 100)){
					MAX = 1 + y*(r / 100);
					ans = b;
				}
			}
			else{
				if (MAX < pow(1 + r / 100, y)){
					MAX = pow(1 + r / 100, y);
					ans = b;
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1316
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,L;
    ll a[100010];
    cin >> N >> L;
    rep(i,0,N){
        cin >> a[i];
    }
    ll sum[100010] = {};
    rep(i,0,N){
        sum[i+1] = sum[i] + a[i];
    }
    ll val = sum[N];
    // print(val);
    ll rv = N-1;
    ll lv = 0;
    vector<ll> ans;
    ll cnt = 0;
    bool is_ok = false;
    ll pos = -1;
    rep(i,0,N-1){
        if(a[i] + a[i+1] >= L){
            is_ok = true;
            pos = i;
        }
    }
    // print(pos);
    if(!is_ok){
        print("Impossible");
        return 0;
    }
    print("Possible");
    rep(i,0,pos){
        print(i+1);
    }
    for(int i = N-2; i >= pos+1; i--){
        print(i+1);
    }
    print(pos+1);

}


Measured memory_bytes: 1664
#include<stdio.h>
int x[99];
int main(){
	int i,j,p,q,n,f;
	while(scanf("%d%d",&p,&q)!=EOF){
		p=p*10;
		n=0;
		while(p!=0){
			for(i=0;i<n;i++){
				if(x[i]!=0 && x[i]==p)goto nex;
			}
			printf("%d",(int)(p/q));
			x[n++]=p;
			p=(p%q)*10;
		}
		nex:
		printf("\n");
		if(p!=0){
			f=0;
			for(i=0;i<n;i++){
				if(f==0){
					if(x[i]==p)f=1,printf("^");
					else printf(" ");
				}else printf("^");
			}
			printf("\n");
		}
	}
	return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

bool is_good(vll& A, int w) {
    for(int i=0;i<w;i++) {
        if (A[i] != A[0] || A[i+w] != A[w] || A[i+2*w] != A[2*w]) {
            return false;
        }
    }
    return true;
}

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

    int N;
    cin >> N;

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

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

    if (N % 3 != 0) {
        if (A[0] == A[N-1] && A[0] == 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        int w = N/3;
        int a = A[0];
        int b = A[w];
        int c = A[2*w];

        if((a ^ b ^ c) == 0 && is_good(A, w)) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        
    }

    return 0;
}


Measured memory_bytes: 1024
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"8 + 5"# => r#"13"#,
r#"1 - 8"# => r#"-7"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        a: i64,
        op: String,
        b: i64,
    }

    if op == "+" {
        a + b
    } else {
        a - b
    }.to_string()
}

Measured memory_bytes: 4352
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;

int main(){
	
	double x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	
	double vx = x2 - x1, vy = y2 - y1;
	double norm = vx * vx + vy * vy;
	
	int q;
	cin >> q;
	
	for(int loop = 0; loop < q; loop++){
		double x, y, vx2, vy2;
		cin >> x >> y;
		vx2 = x - x1;
		vy2 = y - y1;
		double inn = vx * vx2 + vy * vy2;
		double qx = x1 + vx * inn / norm;
		double qy = y1 + vy * inn / norm;
		
		printf("%.10f %.10f\n", 2 * qx - x, 2 * qy - y);
	}
	
	return 0;
}


Measured memory_bytes: 3284
a = []
for _ in range(5):
    i = int(input())
    if i %10 == 0:
        q = 10
    else:
        q = i%10
    a.append([q, i])
a.sort()
count = 0
for i in range(1,5):
    if a[i][1] % 10 != 0:
        count += (a[i][1]//10)*10 + 10
    else:
        count += a[i][1]
print(count+a[0][1])

Measured memory_bytes: 3064
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	s = readline() |> chomp
	t = Char[]
	u = Char[]
	l = length(s)
	for i in 1:l
		if s[i] != 'x'
			push!(t,s[i])
		end
		if s[l+1-i] != 'x'
			push!(u,s[l+1-i])
		end
	end
	if t != u
		println(-1)
	else
		p = Int[]
		now = 0
		for i in 1:length(t)
			now += 1
			k = 0
			while s[now] != t[i]
				now += 1
				k += 1
			end
			push!(p,k)
		end
		push!(p,l-now)
		z = sum(p)
		q = length(p)
		for i in 1:q
			p[i] = max(p[i],p[q+1-i])
		end
		println(sum(p)-z)
	end
end
main()


Measured memory_bytes: 127724
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
int mod = 998244353;
int mul(int a, int b){
    return ((a%mod) * (b%mod))%mod;
}
int power(int a, int b){
    int z = 1; int x = a;
    while(b>0){
        if (b&1)z = mul(z, x);
        x = mul(x, x);
        b >>= 1;
    }
    return z;
}
int32_t main()
{
    int n, k;
    cin>>n>>k;
    int x = log2(n);
    vector<int> v(n);
    for (int i=0; i<n; i++)cin>>v[i];
    for (int i=1; i<=min(41LL, k); i++){
        vector<int> temp(n+1);
        for (int j=0; j<n; j++){
            int l = max(0LL, j-v[j]);
            int r = min(n-1, j+v[j]);
            temp[l]++, temp[r+1]--;
        }
        for (int j=1; j<=n; j++)temp[j] = temp[j-1] + temp[j];
        assert(temp[n] == 0);
        for (int j=0; j<n; j++)v[j] = temp[j];
    }
    for (int i=0; i<n; i++)cout<<v[i]<<" ";
}


Measured memory_bytes: 6444
#include <algorithm>
#include <cstdio>
#include <queue>
const int N=200005;
struct info{int l,r;}a[N];
bool cmp(info a,info b){
	return a.l<b.l;
}
std::priority_queue<int> q;
int main(){
	int n,m,ans=0,cnt=0;
	scanf("%d%d\n",&n,&m);
	for (int i=1;i<=n;i++) scanf("%d%d\n",&a[i].l,&a[i].r);
	std::sort(a+1,a+n+1,cmp);
	for (int i=m,j=n;i>=0;i--){
		for (;j && a[j].l==i;j--) q.push(a[j].r);
		if (i && !q.empty()) q.pop(),cnt++;
	}
	for (int i=m;i>cnt && !q.empty();){
		if (q.top()<=i) i--;
			else ans++;
		q.pop();
	}
	printf("%d\n",ans+q.size());
}

Measured memory_bytes: 2936