akhauriyash/Code-Regression huggingface dataset:
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int k = 0;
	string t, s; cin >> s >> t;

	rep(i, s.size()){
		if(s[i] != t[i]) k++;
	}

	cout << k << endl;

	return 0;
}


Measured memory_bytes: 3920
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		
		A = root(A);
		B = root(B);
		if (A == B) {
			
			return false;
		}
		if (size(A) < size(B)) swap(A, B);
		
		Parent[A] += Parent[B];
		Parent[B] = A;

		return true;
	}
};

int main() {

	int n, k, l;
	cin >> n >> k >> l;
	UnionFind R(n), T(n);

	rep(i, k) {
		int a, b;
		cin >> a >> b;
		R.connect(a - 1, b - 1);
	}

	rep(i, l) {
		int a, b;
		cin >> a >> b;
		T.connect(a - 1, b - 1);
	}

	map<pair<int, int>, int> mp;

	rep(i, n) {
		mp[pair<int,int>(R.root(i), T.root(i))]++;
	}
	rep(i, n) {
		cout << mp[pair<int,int>(R.root(i), T.root(i))] << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 13568
#include <iostream>
using namespace std;
#define rep(i,q) for(int i = 0; (q) > i; i++)
int main(){
  int H,W;cin>>H>>W;
  char a[H][W];
  rep(i,H){
    rep(j,W){
      cin>>a[i][j];
    }
  }
  string kekka = "Yes";
  rep(i,H){
    rep(j,W){
      bool ok = false;
      if(a[i][j] == '#'){
        if(i != 0 && a[i-1][j] == '#')ok = true;
        if(j != 0 && a[i][j-1] == '#')ok = true;
        if(i != H-1 && a[i+1][j] == '#')ok = true;
        if(j != W-1 && a[i][j+1] == '#')ok = true;
        if(!ok)kekka = "No";
      }
    }
  }
  cout << kekka << endl;
}

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

#define int long long

#define pb push_back
#define F first
#define S second
#define I insert
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()

#define debug1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define debug2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define debug3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"

#define INF (int)10000000000000000
#define PI (double)3.14159265358979
// #define M 421412341324321
#define MOD 1000000007

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

    int n, k;
    cin>>n>>k;
    n%=k;
    if (k>=n)
    {
	    int ans = n;
	    ans = min(ans, abs(k-n));
	    n = abs(n-k);
	    ans = min(ans, abs(k-n));
	    cout<<ans;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double dd;
const int N = 2e5+5;
const dd eps = 1e-8;
const int mod = 1e9+7;
ll a[N],n,ans;
priority_queue<pair<ll,ll> > qu;
int main(){
  // freopen("input.txt","r",stdin);
  cin>>n;
  for(int i = 1;i <= n;i++) cin>>a[i];
  sort(a+1,a+1+n,[](ll p1,ll p2){return p1>p2;});
  qu.push({a[2],a[1]});
  qu.push({a[2],a[1]});
  ans = a[1];
  for(int i = 3;i <= n;i++){
    pair<ll,ll> now = qu.top();
    ans += now.first;
    qu.pop();
    qu.push({a[i],now.first});
    qu.push({a[i],now.second});
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 8912
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstdio>
#include<queue>
#include<functional>
#include <tuple>
#include<iomanip>
#include<stack>
#include<cmath>
#define ll long long
#define N 1000000007
using namespace std;
int main() {
	int n; cin >> n;
	int a[15],x[15][15],y[15][15];
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		for (int j = 0; j < a[i]; ++j) {
			cin >> x[i][j] >> y[i][j];
		}
	}
	int m = pow(2, n),ans=0;
	for (int i = m - 1; i >= 0; --i) {
		int cp = i, data[15], flag = 1,cnt=0;
		for (int j = n - 1; j >= 0; --j) {
			data[j] = cp % 2;
			if (cp % 2) ++cnt;
			cp /= 2;
		}
		for (int j = 0; j < n; ++j) {
			for (int k = 0; k < a[j]; ++k) {
				if (data[j]) {
					if (data[x[j][k] - 1] != y[j][k]) flag = 0;
				}
				/*else {
					if (data[x[j][k] - 1] == y[j][k]) flag = 0;
				}*/
			}
		}
		if (flag) ans = max(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	
	public Main() {
		FastScanner scanner = new FastScanner();
		String N = scanner.next();
		
		int sum = 0;
		for (int i = 0; i < N.length(); i++) {
			sum += Integer.valueOf(N.charAt(i) - '0');
		}
		
		if (sum % 9 ==  0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
	
	public static void main(String[] args) {
		new Main();
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	
	private int readByte() {
		if (hasNextByte()) return buffer[ptr++];
		else return -1;
	}
	
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
		return hasNextByte();
	}
	
	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 33780
#include<iostream>

using namespace std;

long long gcd(long long a, long long b){
  if(b==0)return a;
  return gcd(b, a%b);
}

int main(){
  int n, lcm, a[12];
  cin >> n;
  for(int i=0;i<n;i++)cin >> a[i];
  lcm = a[0];
  for(int i=1;i<n;i++){
    long long lgcd = gcd(lcm, a[i]);
    lcm = lcm*a[i]/lgcd;
  }
  cout << lcm <<endl;
}


Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <map>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define INF 1e10
typedef long long ll;
typedef long double ld;
int main(){
    ll a,b,c;cin>>a>>b>>c;
    vector<ll> v={a,b,c};
    a=a%2, b=b%2, c=c%2;
    if(a*b*c==0)cout<<0<<endl;
    else{
        sort(ALL(v));
        cout<<v[0]*v[1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3596
import heapq
import math
import random
import sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, namedtuple, UserDict
from functools import cmp_to_key, lru_cache, reduce
from itertools import (chain, combinations, combinations_with_replacement,
                       permutations, product)
import numpy as np


sys.setrecursionlimit(10**6+1)
write = sys.stdout.write
input = sys.stdin.buffer.readline

MOD = 10**9 + 7


if __name__ == "__main__":
    n = int(input())
    arr = sorted(enumerate(map(int, input().split()), 1),
                 key=lambda x: x[1], reverse=True)
    dp = np.zeros(n+1, dtype=np.int)

    for k, (i, a) in enumerate(arr, 1):
        ndp = dp.copy()
        
        add_left = np.abs(np.arange(1, k+1) - i) * a
        ndp[1:k+1] = np.maximum(ndp[1:k+1], dp[:k] + add_left)
        
        add_right = np.abs(np.arange(n-k+1, n+1) - i) * a
        ndp[:k] = np.maximum(ndp[:k], dp[:k] + add_right)

        dp = ndp

    print(dp.max())


Measured memory_bytes: 27832
class Ruisekiwa:
    def __init__(self,lst):
        s = 0
        self.r = [0]
        for i,_ in enumerate(lst):
            self.r.append(s+lst[i])
            s += lst[i]

    def query(self,a,b):
        #リスト内の半開区間[a,b)の総和
        return self.r[b] - self.r[a]

def main():
    mod = 10**9+7
    n,k = map(int,input().split())
    num_lst = list(range(n+1))
    ruisekiwa = Ruisekiwa(num_lst)
    answer = 0
    for i in range(k,n+2):
        mx = ruisekiwa.query(n-i+1,n+1)
        mn = ruisekiwa.query(0,i)
        #print(num_lst[:i],num_lst[-i:],mn,mx)
        answer += mx - mn + 1
        answer %= mod

    print(answer)




if __name__ == '__main__':
    main()


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

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()

void boost(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void solve(){
	int n,w;
	cin>>n>>w;
	pii item[n];
	fr(i,0,n)
	cin>>item[i].first>>item[i].second;
	ll ans=0;
	ll dp[n+1][w+1];
	fr(i,0,n){
		fr(j,0,w+1)
		dp[i][j]=-1;
	}
	fr(j,0,w+1)
	dp[0][j]=0;
	fr(i,0,n){
		fr(j,0,w+1)
		dp[i+1][j]=dp[i][j];
		for(int j=0;j<=w-item[i].first;j++){
			if(dp[i][j]!=-1){
				dp[i+1][j+item[i].first]=(dp[i+1][j+item[i].first]==-1)?dp[i][j]+item[i].second:max(dp[i+1][j+item[i].first],dp[i][j]+item[i].second);
				ans=max(ans,dp[i+1][j+item[i].first]);
			}
		}
	}
	cout<<ans<<endl;
	return;
}

int main()
{
	boost();
	
	int tc=1;
	//cin>>tc;
	while(tc--)
		solve();
	return 0;
}

Measured memory_bytes: 82480
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(long long i = a; i < (b); ++i)
typedef long long ll;
ll gcd(ll a, ll b)
{
   if (b == 0)
   {
       return a;
   }
    return gcd(b, a%b);
}

vector<ll> factorize(ll n){
    vector<ll> res;
    for(ll i = 2; i*i<=n; i++){
        if(n%i)continue;
        while (n%i == 0) {
            n /= i;
        }
        res.push_back(i);
    }
    if(n!=1) res.push_back(n);
    return res;
}

int main() {
    ll a,b;
    cin >> a >> b;
    ll gcdn = gcd(a, b);
    auto f = factorize(gcdn);
    ll ans = f.size() + 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		// 半径rの入力
		int r = Integer.parseInt(sc.nextLine());
		// 半径1の円の面積の何倍になるか出力する
		System.out.println(r*r);
	}
}


Measured memory_bytes: 21588
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
#include <map>
using namespace std;

void solve(){
  int a, b; cin >> a >> b;
  cout << max(a + b, max(a - b, a * b)) << endl;
  return;
}
int main(){
  solve();
  return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    int sum = 0;
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) sum += A[i];
    int count = 0;
    for (int i = 0; i < N; i++) {
        if (sum <= A[i] * 4 * M) count++;
    }
    if (M <= count) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n;
char b[2][52];
ll dp[55][3][3];

int main(){
    cin >> n;
    rep(i,2) {
        rep(j,n) {
            cin >> b[i][j];
        }
    }
    if(b[0][0] == b[1][0]) {
        for(int i = 0; i < 3; i++) dp[0][i][i] = 1;
    } else {
        for(int i = 0; i < 3; i++) {
            for(int j = 0; j < 3; j++) {
                if(i == j) continue;
                dp[0][i][j] = 1;
            }
        }
    }
    for(int i = 1; i < n; i++) {
        if(b[0][i] != b[0][i-1]) {
            if(b[0][i] == b[1][i]) {
                for(int j = 0; j < 3; j++) {
                    for(int u = 0; u < 3; u++) {
                        for(int v = 0; v < 3; v++) {
                            if(j == u || j == v) continue;
                            dp[i][j][j] += dp[i-1][u][v];
                        }
                    }
                    dp[i][j][j] %= MOD;
                }
            } else{
                for(int j = 0; j < 3; j++) {
                    for(int k = 0; k < 3; k++) {
                        if(j == k) continue;
                        for(int u = 0; u < 3; u++) {
                            for(int v = 0; v < 3; v++) {
                                if(j == u || k == v) continue;
                                dp[i][j][k] += dp[i-1][u][v];
                            }
                        }
                        dp[i][j][k] %= MOD;
                    }
                }
            }
        } else {
            for(int j = 0; j < 3; j++) {
                for(int k = 0; k < 3; k++) {
                    dp[i][j][k] = dp[i-1][j][k];
                }
            }
        }
    }
    ll ans = 0;
    rep(i,3) rep(j,3) ans += dp[n-1][i][j];
    ans %= MOD;
    cout << ans << endl;
}
































Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int X;
  
  std::cin >> X;

  if (X == 3 || X == 5 || X == 7) {
    std::cout << "YES" << std::endl;
  }
  else {
    std::cout << "NO" << std::endl;
  }

  return 0;
}


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

int main(){
    int n,l; cin>>n>>l;
    int minj=200;
    int mini,sum=0;
    rep(i,n){
        if(abs(l+i)<minj){
            minj=abs(l+i);
            mini=l+i;
        }
        sum+=l+i;
    }
    cout<<sum-mini<<endl;
    return 0;
}


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

int main(void)
{
  int n;
  scanf("%d", &n);

  long int a[n];
  for(int i=0;i<n;i++){
    scanf("%ld", &a[i]);
  }

  long int ans=0;
  for(int i=0;i<n-1;i++){
    if(a[i]>a[i+1]){
      ans += a[i] - a[i+1];
      a[i+1] = a[i];
    }
  }

  printf("%ld\n", ans);
  
  return 0;
}


Measured memory_bytes: 3292
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n, m;
multiset<II> s;
multiset<int> ss;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> m;
    FOR(i,1,m) {
        s.insert(II(i,i));
        ss.insert(0);
    }
    FOR(k,1,n) {
        int goDown = k;
        int L, R;
        cin >> L >> R;
        II pick = II(-1, -1);
        while (1) {
            auto it = s.lower_bound(II(L,0));
            if (it == s.end() || it->FI > R) break;
            if (pick.SE < it->SE) pick = *it;
            ss.erase(ss.find(it->FI - it->SE));
            s.erase(it);
        }
        if (pick.FI != -1 && R+1 <= m) {
            s.insert(II(R+1, pick.SE));
            ss.insert(R+1-pick.SE);
        }
        if (!SZ(ss)) cout << "-1\n";
        else cout << *ss.begin() + goDown << "\n";
    }
    return 0;
}


Measured memory_bytes: 22340
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <bitset>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
template<class T> inline void chmax(T& a, T b) {if (a<b) a=b; }
inline void print() { cout << endl; }
template <class Head, class... Tail> inline void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...);}
template <class T> inline void print(vector<T>& vec) { for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " "; } cout << endl;}
template <class T> inline void print(vector<vector<T>>& df) { for (auto& vec : df) { print(vec); }}
const unsigned int BIT_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_7 = (1 << 7); // 0000 0000 1000 0000

typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;

bool myComparison(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
       return a.second>=b.second;
}

int main() { 
    int N, M; cin >> N >> M;
    vector<ll> A(N);
    REP(i, N) {
        ll a; cin >> a;
        A[i] = a;
    }

    vector<pair<ll, ll>> big; // (A.idx, val)
    int maxBit = 63;
    REP(s, maxBit) {
        int shift = maxBit-s;
        REP(i, N) {
            if(A[i] & (1 << shift)) {
                // print("shift", shift);
                // big.push_back(make_pair(i, A[i]));
                big.push_back(make_pair(A[i], i));
            }
        }
        // print(A);


        if(big.size() > 0) {
            // print("----");
            // sort(big.begin(), big.end(), myComparison);//greater<pair<int, int>>());
            sort(big.begin(), big.end(), greater<pair<int, int>>());
            // REP(i, big.size()) {
            //     print("====", big[i].first, big[i].second);
            // }

            REP(i, big.size()) {
                // print("i=", i, "big v=", big[i].second, "A idx=", big[i].first);
                // A[big[i].first] = A[big[i].first] >> 1;
                A[big[i].second] = A[big[i].second] >> 1;
                // print("new A[big[i].first]=", A[big[i].first]);
                // print(A);
                M--;
                // print("M=", M);
                if(M<=0) {
                    break;
                }
            }
        }
        if(M<=0) {
            break;
        }
        big.clear();
    }

    ll res = 0;
    REP(i, N) {
        res += A[i];
    }
    cout << res << endl;;

    return 0;
}

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    ll N, K;
    cin >> N >> K;

    if (N == K) cout << 0 << endl;
    else if (N < K) {
        ll ans = min(N, abs(N - K));
        cout << ans << endl;
    }
    else {
        ll d = N / K;
        N = N - d * K;
        ll ans = min(N, abs(N - K));
        cout << ans << endl;
    }
    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 112345;

int nxt[MAX_N][26];

int main2() {
  string s, t; cin >> s >> t;

  int N1 = s.size();
  CLR(nxt, -1);

  REP(i, N1) {
    int c = s[i] - 'a';
    for (int p = i - 1; ; p--) {
      int q = (p % N1 + N1) % N1;
      if (nxt[q][c] != -1) break;
      nxt[q][c] = i;
      if (s[q] == s[i]) break;
    }
  }

  // cout << s << endl;
  // cout << t << endl;
  // REP(i, N1)
  //   pv(nxt[i], nxt[i]+3);

  ll ans = 0;
  int pos = N1-1;
  REP(i, t.size()) {
    int c = t[i] - 'a';
    if (nxt[pos][c] == -1) {
      ans = -1;
      break;
    }
    int d = nxt[pos][c] - pos;
    if (d <= 0) d += N1;
    ans += d;
    pos = nxt[pos][c];
  }

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

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 12032
#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 - 1; 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 VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    ll h, w;
    cin >> h >> w;
    ll n;
    cin >> n;
    ll a;
    vll s(n + 1);
    REP(i, n) {
        cin >> a;
        s[i + 1] = s[i] + a;
    }
    ll num = 1, cnt = 0, id = 1;
    vvll res(h, vll(w));
    REP(i, h) {
        REP(j, w) {
            if (i % 2 == 0) res[i][j] = num;
            else res[i][w - 1 - j] = num;
            cnt++;
            if (cnt == s[id]) {
                num++;
                id++;
            }
        }
    }

    REP(i, h) {
        REP(j, w) {
            cout << res[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

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

class ABC_129_D
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int H = int.Parse(input[0]);
        int W = int.Parse(input[1]);

        char[,] grid = new char[H, W];
        for (int i = 0; i < H; i++)
        {
            string input2 = Console.ReadLine();
            for (int j = 0; j < W; j++)
            {
                grid[i, j] = input2[j];
            }
        }

        int[,] gridCountH = new int[H, W];
        for (int i = 0; i < H; i++)
        {
            int cnt = 0;
            for (int j = 0; j < W; j++)
            {
                if(grid[i, j]=='#')
                {
                    for (int k = 0; k < cnt; k++)
                    {
                        gridCountH[i, j-k-1] = cnt;
                    }
                    cnt = 0;
                }
                else
                {
                    cnt++;
                    if(j==W-1)
                    {
                        for (int k = 0; k < cnt; k++)
                        {
                            gridCountH[i, j-k] = cnt;
                        }
                    }
                }
            }
        }

        int[,] gridCountV = new int[H, W];
        for (int i = 0; i < W; i++)
        {
            int cnt = 0;
            for (int j = 0; j < H; j++)
            {
                if (grid[j, i] == '#')
                {
                    for (int k = 0; k < cnt; k++)
                    {
                        gridCountV[j-k-1, i] = cnt;
                    }
                    cnt = 0;
                }
                else
                {
                    cnt++;
                    if (j == H-1)
                    {
                        for (int k = 0; k < cnt; k++)
                        {
                            gridCountV[j-k, i] = cnt;
                        }
                    }
                }
            }
        }

        int max = 0;
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                int sum = gridCountH[i, j] + gridCountV[i, j] - 1;
                max = Math.Max(sum, max);
            }
        }
        Console.WriteLine(max);
    }
}

Measured memory_bytes: 54088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
// const ll MAXN = 

ll n, ct ,ca;
/********** Good Luck :) **********/
int main()
{
    TIME(main);
    IOS();

    ct = ca = 1;
    cin >> n;

    REP (i, n) {
        ll t, a;
        cin >> t >> a;
        ll r1 = (t + ct - 1) / t, r2 = (a + ca - 1) / a;
        if (r1 > r2) {
            ct = t * r1;
            ca = r1 * a;
        } else {
            ct = r2 * t;
            ca = r2 * a;
        }
        debug(ct, ca);
    }

    cout << ct + ca << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main() {
  int n, k;
  std::cin >> n >> k;

  int a;
  std::cin >> a;
  int maxA = a;
  int gcd = a;
  bool anyEquals = a == k;
  while (std::cin >> a) {
    maxA = std::max(a, maxA);
    anyEquals = anyEquals || (a == k);
    if (!anyEquals) {
      gcd = boost::math::gcd(a, gcd);
    }
  }
  bool const found = anyEquals || (maxA > k && k % gcd == 0);
  std::cout << (found ? "POSSIBLE" : "IMPOSSIBLE") << std::endl;
  return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
--import Data.Array.Unboxed
import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
-- templete

rjudge f
  | any (all (=='b')) f = Just "b"
  | any (all (=='w')) f = Just "w"
  | otherwise = Nothing

cjudge = rjudge . transpose 

djudge f
  | all (=='b') $ zipWith (!!) f [0,1,2] = Just "b"
  | all (=='w') $ zipWith (!!) f [0,1,2] = Just "w"
  | all (=='b') $ zipWith (!!) f [2,1,0] = Just "b"
  | all (=='w') $ zipWith (!!) f [2,1,0] = Just "w"
  | otherwise = Nothing

main = do
    lh <- getLine
    unless (lh=="0") $ do
        lt <- replicateM 2 getLine
        let field = lh : lt
        putStrLn $ fromMaybe "NA" $ getFirst $ Foldable.foldMap First $ map ($field) [rjudge, cjudge, djudge]
        main


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

template <class T = long long int>
class Bit {
    private:
    T len;
    T *arr;

    public:
    Bit(T l, T initialValue = 0) : len(l) {
        arr = new T[l+1];
        for (T i = 0; i <= l; i++) {
            arr[i] = initialValue;
        }
    }
    ~Bit() {
        delete[] arr;
    }
    void update(T a, T newval) {
        for (T x = a; x <= len; x += x & -x) arr[x] += newval;
    }
    T query(T a) const {
        T ret = 0;
        for (T x = a; x > 0; x -= x & -x) ret += arr[x];
        return ret;
    }
};

int main() {
    long long n, k;
    std::cin >> n >> k;
    std::vector<long long> a(n + 1);
    for (int i = 1; i <= n; i++) {
        std::cin >> a[i];
        a[i] -= k;
        a[i] += a[i - 1];
    }
    auto c(a);
    std::sort(c.begin(), c.end());
    c.erase(std::unique(c.begin(), c.end()), c.end());
    auto m = 0ll;
    for (int i = 0; i <= n; i++) {
        a[i] = std::lower_bound(c.begin(), c.end(), a[i]) - c.begin() + 1;
        m = std::max(m, a[i]);
    }

    Bit<> b(m);
    auto ret = 0ll;
    for (int i = 0; i <= n; i++) {
        ret += b.query(a[i]);
        b.update(a[i], 1);
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>

int main(){
	char a[18]="CODEFESTIVAL2016", b[18];
	int c=0,i;
	scanf("%s",b);
	for(i=0;i<16;i++){
		if(a[i]!=b[i]){
			c++;
		}
	}
	printf("%d",c);
	
}

Measured memory_bytes: 128
n,m = map(int,input().split())
A = [-int(x) for x in input().split()]

from heapq import heapify, heappush, heappop

heapify(A)

for _ in range(m):
    x = -heappop(A)
    x //= 2
    heappush(A, -x)

print(-sum(A))



Measured memory_bytes: 14252
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<cmath>
 
#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
 
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9
#define MOD 1000000007
 
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; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
 
 
using namespace std;

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

    ll ans = 0;
    if(a+b>=2*c){
        ll p0 = 0;
        ll p1 = 0;
        if(x>=y) {p0 += (x-y)*a; p1 += 2*x*c;}
        else {p0 += (y-x)*b; p1 += 2*y*c;}
        p0 += 2*min(x, y)*c;
        ans = min(p0, p1);
    }else{
        ans += x*a + y*b;
    }
    cout << ans;
}

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

using namespace std;

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

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

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

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

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

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
ll a[125252], b[125252];
ll s[125252];

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%lld%lld",a+i,b+i);
  ll sumb = accumulate(b,b+n,0ll);
  REP(i,n)s[i] = a[i]+b[i];
  sort(s,s+n);
  reverse(s,s+n);
  ll ans = -sumb;
  REP(i,n)if(i%2==0)ans += s[i];
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 2560
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <vector>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

int main() {
    int S;
    cin >> S;
    cout << S / 3600 << ":" << S / 60 % 60 << ":" << S % 60 << endl;
}


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

using namespace std;

#define ll long long
#define int ll
#define pb(x) push_back(x)
#define mp(x) make_pair(x)
#define fi first
#define se second
#define mod 2019
int32_t main() {
    int t=1;
    //cin>>t;
    while(t--)
    {
       string s;
       cin>>s;
       map<int,int >M;
       M[0]=1;
       int  modulo=0;
       int curr=1;
       int cnt=0;
       for(int j=s.size()-1;j>=0;j--)
       {
           modulo=(modulo+((s[j]-'0')*curr)%mod)%mod;
           curr*=10;
           curr%=2019;
           cnt+=M[modulo];
           M[modulo]++;
       }
       cout<<cnt;
       
    }

    return 0;
    
}

Measured memory_bytes: 3756
def f(n):
    ps = list(map(float, input().split()))
    dp = [[1] * (n + 1) for _ in range(n + 1)]
    dpi1 = dp[0]
    for i, p in enumerate(ps):
        i+=1
        dpi = dp[i]
        dpi[0] = dpi1[0] * (1 - p)
        for j in range(1, i):
            dpi[j] = dpi1[j - 1] * p + dpi1[j] * (1 - p)
        dpi[i] = dpi1[i - 1] * p
        dpi1 = dpi
    print(sum(dp[-1][n // 2 + 1:]))

n = int(input())
f(n)


Measured memory_bytes: 180980
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

int main(int argc, const char * argv[]) {

    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, l; cin >> n >> l;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    
    bool can = false;
    int knot_ind;
    for (int i = 0; i < n - 1; i++) {
        if (a[i] + a[i + 1] >= l) {
            can = true;
            knot_ind = i + 1;
            break;
        }
    }
    
    if (can) {
        cout << "Possible" << endl;
        for (int i = 1; i < knot_ind; i++) cout << i << endl;
        for (int i = n - 1; i > knot_ind; i--) cout << i << endl;
        cout << knot_ind << endl;
    } else {
        cout << "Impossible" << endl;
    }
    

    return 0;
}


Measured memory_bytes: 1280
// AOJ ALDS1_2_C Stable Sort
// 2018.4.27 bal4u

#include <stdio.h>
#include <string.h>

typedef struct { char c; int a; int id; } data;

void bubble_sort(int n, data *a)
{
	int i, f;
	data x;

	do {
		f = 0;
		for (i = n-1; i > 0; i--) {
			if (a[i].a < a[i-1].a) {
				x = a[i], a[i] = a[i-1], a[i-1] = x;
				f = 1;
			}
		}
	} while (f);
}

void selection_sort(int n, data *a)
{
	int i, j, minj;
	data x;

	for (i = 0; i < n; i++) {
		minj = i;
		for (j = i; j < n; j++) {
			if (a[j].a < a[minj].a) minj = j;
		}
		if (i != minj) {
			x = a[i], a[i] = a[minj], a[minj] = x;
		}
	}
}


//#define getchar_ed()  getchar()
int in()
{
	int n = 0, c = getchar();
	do n = 10*n + (c & 0xf), c = getchar(); while (c >= '0');
	return n;
}

data a[102], b[102];

int main()
{
	int N, i, f;

	N = in();
	for (i = 0; i < N; i++) {
		a[i].c = getchar();
		a[i].a = getchar();
		a[i].id = i;
		getchar();			// skip
	}
	memcpy(b, a, sizeof(data)*N);

	bubble_sort(N, a);
	f = 0;
	putchar(a[0].c), putchar(a[0].a);
	for (i = 1; i < N; i++) {
		putchar(' ');
		putchar(a[i].c), putchar(a[i].a);
		if (a[i-1].a == a[i].a && a[i-1].id > a[i].id) f = 1;
	}
	putchar('\n');
	puts(f? "Not stable": "Stable");

	selection_sort(N, b);
	f = 0;
	putchar(b[0].c), putchar(b[0].a);
	for (i = 1; i < N; i++) {
		putchar(' ');
		putchar(b[i].c), putchar(b[i].a);
		if (b[i-1].a == b[i].a && b[i-1].id > b[i].id) f = 1;
	}
	putchar('\n');
	puts(f? "Not stable": "Stable");
	return 0;
}



Measured memory_bytes: 2088
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;
#define y1        y114514
#define pb        push_back
#define mkp       make_pair
#define fi        first
#define se        second
#define all(a)    a.begin(), a.end()
#define add(a, b) a = (a + b) % M

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

const int M = 998244353;

char s[305];
int  t;

int f[305][305][305];

int main() {
    scanf("%s%d", s + 1, &t);
    int n    = strlen(s + 1);
    s[n + 1] = '0';
    int m    = 0;

    for (int i = 1; i <= n; ++i)
        if (s[i] == '1') ++m;

    t = min(m, t);

    f[0][0][0] = 1;
    int last = 0, cur = 0, pre = 0;
    for (int i = 1; i <= n + 1; ++i) {
        if (s[i] == '1') {
            ++cur;
            continue;
        }
        for (int j = last; j <= m; ++j)
            for (int p = 0; p <= min(t, j); ++p)
                if (f[pre][j][p]) {
                    //del
                    for (int k = max(j, last + cur); k <= min(m, j + cur); ++k) {
                        int d = cur - (k - j);
                        add(f[i][k][p + d], f[pre][j][p]);
                    }
                    //add
                    for (int k = j + cur + 1; k <= m; ++k) {
                        add(f[i][k][p], f[pre][j][p]);
                    }
                }
        last += cur;
        cur = 0;
        pre = i;
    }

    int ans = 0;
    for (int p = 0; p <= t; ++p)
        add(ans, f[n + 1][m][p]);

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 28600
/**
 * author  : UshanGhosh
 * created : 2020-09-19 17:28:11
**/ 

#include<bits/stdc++.h>
using namespace std;

#define    ll      long long
#define    pii     pair<int,int>
#define    vii     vector<int>
#define    vcc     vector<char>
#define    pll     pair<long long, long long>
#define    mem     memset
#define    sof     sizeof
#define    co1     __builtin_popcountll
#define    PB      push_back
#define    UB      upper_bound
#define    LB      lower_bound
#define    MP      make_pair
#define    TS      to_string
#define    F       first
#define    S       second
#define    pi      acos(-1)
#define    mod     (int)1e9+7
#define    inf     (long long)1e18
#define    endl    '\n'

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long a,b,c,d,e,f,i,j,k,m,n,o,x,y;
    cin>>n;
    string s = TS(n);
    ll div = 0;
    for(char c:s){
        div += (c-'0');
    }
    if(n%div == 0) cout<<"Yes\n";
    else cout<<"No\n";
}

Measured memory_bytes: 3716
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h, n;
    cin >> h >> n;
    VP vec(n);
    rep(i,n){
        cin >> vec[i].F >> vec[i].S;
    }
    VV dp(n+1, V(h + 1,INF));
    dp[0][h] = 0;
    rep3(i,1,n+1){
        for(ll j=h;j>=0;j--){
            chmin(dp[i][j], dp[i - 1][j]);
           // cout<<"hello同列"<<endl;
        }
        for(ll j=h;j>=0;j--){
            chmin(dp[i][max(j-vec[i-1].F,(ll)0)],dp[i][j]+vec[i-1].S);
        }
        
    }
  /*  rep(i,dp.size()){
        rep(j,dp[i].size()){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    cout << dp[n][0] << endl;
}


Measured memory_bytes: 78592
#include<bits/stdc++.h>
using namespace std;
const int N=1010;
typedef long long ll;
int p[N],n,cnt,x[N],cmt,Y[N],*y=Y+N/2;
ll b[N][N];
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=2;cnt<2*n+2;++i){
		int flag=1;
		for(int j=1;j<=cnt;++j)
			if(i%p[j]==0){flag=0;break;}
		if(flag)p[++cnt]=i;
	}
	for(int i=1,j=n+1;i<=j;){
		x[cmt]=p[j--],cmt+=2;
		if(i<=j)x[cmt]=p[i++],cmt+=2;
	}
	cmt=-(n/2*2);
	for(int i=n+2,j=cnt;i<=j;){
		y[cmt]=p[j--],cmt+=2;
		if(i<=j)y[cmt]=p[i++],cmt+=2;
	}
	for(int i=1;i<=n;i+=2)
		for(int j=1;j<=n;++j)
			if(j&1)b[i][j]=x[i+j]*y[i-j],b[i+1][j]=(ll)x[i+j]*y[i-j]*x[i+j+2]*y[i+2-j]+1;
			else b[i+1][j]=x[i+j+1]*y[i+1-j],b[i][j]=(ll)x[i+j+1]*y[i+1-j]*x[i+j-1]*y[i-j-1]+1;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)cout<<b[i][j]<<" \n"[j==n],assert(b[i][j]<=1e15);
	return 0;
}



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

using namespace std;

int main(void)
{
    int n;
    cin >> n;
    
    vector<int> a(n);
    long double b = 0;

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        
        b += (1.0 / a[i]);
    }
    
    cout << 1.0 / b;
    return 0;
}


Measured memory_bytes: 888