akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3

st = []
for _ in range(2):
    st.append(input())
S=st[0]
T=st[1]

ans=len(T)

for i in range(len(S)-len(T)+1):
    diff=0
    for j in range(len(T)):
        if S[i+j]!=T[j]:
            diff+=1
    ans=min(ans,diff)

print(ans)



Measured memory_bytes: 73116
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int a,b;
    cin>>a>>b;
    cout<<max(0ll,a-2*b)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

vector<vector<char>> g;
int main(){
    ll n;   cin >> n;
    vector<ll> a(n);
    REP(i, n)   cin >> a[i];
    sort(ALL(a), greater<ll>());
    ll res=0;
    if(n<=3){
        REP(i, n-1) res += a[i];
    }else{
        priority_queue<ll> que;
        que.push(a[0]);
        FOR(i, 1, n){
            res += que.top();
            que.pop();
            REP(j, 2)   que.push(a[i]);
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 6928
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
#define endl "\n"
//#define int long long
#define ALL(x) begin(x),end(x)
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return ((fact(i - 1)) * i) % MOD;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された
    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}

/*signed*/int main(void) {   
    string s;
    cin >> s;
    if (s.size() == 2) cout << s << endl;
    else {
        ALL(s);
        cout << s[2] << s[1] << s[0] << endl;
    }
}

Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  vector<P> vec(n);
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    vec[i].first = b;
    vec[i].second = a;
  }
  sort(vec.begin(), vec.end());
  bool ok = true;
  ll last = 0;
  for (int i = 0; i < n; ++i) {
    if (vec[i].first < last + vec[i].second) {
      ok = false;
    }
    last += vec[i].second;
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 1792
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = List.range n `To m
let (++^) n m = if n < m then List.range n `To (pred m) else []

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then Enum.empty ()
  else
    List.map (fun _ -> scan fmt f) (List.range 1 `To n)
    |> List.enum

let scan_list cnv =
  String.split_on_char ' ' @@ read_line ()
  |> List.map cnv

let scan_array cnv = Array.of_list @@ scan_list cnv

let scan_matrix n m e conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (List.range 0 `To (pred n))
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list conv);
  arr

let rec powerset e =
  match Enum.get e with
  | None -> Enum.singleton @@ Enum.empty ()
  | Some v ->
    let f = powerset e in
    let g = Enum.clone f in
    EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)
    |>  Enum.append g

let permutations l =
  let rec aux l =
    let rec interleave x = function
      | [] -> [[x]]
      | (hd::tl) as lst ->
        (x::lst) ::
        (ListL.map ~f:(List.cons hd)  @@ interleave x tl)
    in
    match l with
    | [] -> [[]]
    | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in
  let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in
  List.enum % ListL.map ~f:List.enum @@ l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let (n, q) = scan "%d %d" Tuple.Tuple2.make
let ab = List.of_enum @@ scan_lines (n-1) "%d %d" Tuple.Tuple2.make
let px = List.of_enum @@ scan_lines q "%d %d" Tuple.Tuple2.make

let () =
  let tree = Array.init n (fun _ -> []) in
  let ntree = Array.make n 0 in
  let rec cut p n =
    let cs = tree.(n) in
    tree.(n) <- ListL.filter_map cs ~f:(fun c ->
        if c = p then None
        else (cut n c; Some c))
  in
  ListL.iter ab ~f:(fun (a, b) ->
      tree.(pred a) <- (pred b)::tree.(pred a);
      tree.(pred b) <- (pred a)::tree.(pred b));
  ListL.iter tree.(0) ~f:(cut 0);
  ListL.iter px ~f:(fun (p,x) ->
      ntree.(pred p) <- ntree.(pred p) + x);
  let rec update n v =
    let w = v + ntree.(n) in
    ntree.(n) <- w;
    ListL.iter tree.(n) ~f:(fun p ->
        update p w) in
  update 0 0;
  IO.to_string (Array.print ~first:"" ~last:"\n" ~sep:" " Int.print) ntree
  |> Printf.printf "%s"


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

int main(){
  int i,j,k,N;
  long ans=0,tmp=0,tmpp=0,min=10000000000;
  
  scanf("%d",&N);
  long A[N];
  for(i=0;i<N;i++){
    scanf("%ld ",&A[i]);
    tmp+=A[i];
  }
  for(i=0;i<N-1;i++){
    tmpp+=A[i];
    if(labs(tmp-2*tmpp)<min)
      min=labs(tmp-2*tmpp);
  }
  printf("%ld\n",min);
  return 0;
}
    

Measured memory_bytes: 1664
n, q = gets.split.map(&:to_i)
time = 0
queue = {}
results = []

n.times do
  k, v = gets.split
  queue[k] = v.to_i
end

until queue.empty?
  k, v = queue.shift
  if v > q
    time += q
    v -= q
    queue[k] = v
  else
    time += v
    results << [k, time]
  end
end

results.each { |v| puts v * ' ' }



Measured memory_bytes: 16940
#include <iostream>
#include <utility>

using namespace std;

int main(){
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    if (X < Y){
        swap(A, B);
        swap(X, Y);
    }

    int min_cost = 2e9;
    for (int a = 0; a <= X; a++){
        int ab = X - a;

        int b;
        if (Y - ab > 0) b = Y - ab;
        else b = 0;

        int cost = A*a + B*b + 2*C*ab;
        if (cost < min_cost) min_cost = cost;
    }

    cout << min_cost << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using dll=double long;
const int N=3005;
int n;
dll c[N];
dll memo[N][N];
bool vis[N][N];
dll dp(int pos,int ca){
    if(pos==n){
        if(ca*2>n) return 1;
        else return 0;
    }
    if(vis[pos][ca]) return memo[pos][ca];
    dll ans;
    ans=c[pos]*dp(pos+1,ca+1) + (1-c[pos])*dp(pos+1,ca);
    vis[pos][ca]=true;
    return  memo[pos][ca]=ans;
}

int main() {
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>c[i];
    }
    cout<<setprecision(10)<<dp(0,0)<<'\n';
	return 0;
}


Measured memory_bytes: 94488
n=gets.to_i
abc=n.times.map{gets.split.map(&:to_i)}
d=Array.new(n){Array.new(3,0)}
0.upto(2){|j| d[0][j]=abc[0][j]}
0.upto(n-2){|i|0.upto(2){|j|0.upto(2){|k|
  next if j==k
  d[i+1][k]=d[i][j]+abc[i+1][k] if d[i+1][k]<d[i][j]+abc[i+1][k]
}}}
puts d[n-1].max

Measured memory_bytes: 12156
def Int():
    return int(input())
def Ints():
    return map(int,input().split())
def IntList():
    return list(Ints())
def IntMat(N):
    return [IntList() for i in range(N)]

N,M = Ints()
A = IntList()

S = sum(A)
print(max(N-S,-1))

Measured memory_bytes: 68004
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>

using namespace std;

int main() {
	int N, K;

	cin >> N >> K;

	int M;

	if (N % 2 == 0) {
		M = N / 2 ;
	}
	else {
		M = (N / 2) + 1;
	}

	if (M >= K) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

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

int main(){
    unsigned int N;
    cin >> N;
    array<long int, 100000> arr;
    for(int i=0; i<N; i++){ 
        cin >> arr[i];
    }
    sort(arr.begin(), arr.begin()+N, [](const int x, const int y){return x > y;});
    long int l1 = 0;
    long int l2 = 0;
    bool first = true;
    bool second = true;
    for(int i=1; i<N; ++i){
        if(arr[i] == arr[i-1]){
            if(first){
                l1 = arr[i];
                first = false;
                ++i;
            }else if(second){
                l2 = arr[i];
                second = false;
                break;
            }
        }
    }

    cout << l1 * l2;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	
	ll n,d,a;
	string s;
	cin>>n;
	pair<pair <string,ll>,ll> p[n+1];
	for(ll i=0;i<n;i++)
	{
		cin>>s>>a;
		p[i]=make_pair(make_pair(s,-1*a),i+1);
	}
	sort(p,p+n);
	for(ll i=0;i<n;i++)
	{
		cout<<p[i].second<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, k, s, t, a[55], sz, al;
long long ans, candi[2][18], combi[60][60], F[60][60];
vector<int> vec;

int cnt_bit(long long x)
{
	int cnt = 0;
	while (x) {
		if (x & 1) cnt++;
		x = x >> 1;
	}
	return cnt;
}

void fun(int cur, int sign, long long res, int v)
{
	if (cur == 18) {
		int tmp = cnt_bit(res);
		//cout << sign * F[tmp][k - 1] << E;
		ans += sign * F[tmp][k - 1];
	}
	else {
		if (((t >> cur) & 1) ^ ((s >> cur) & 1)) {
			if ((v >> cur) & 1) {
				fun(cur + 1, sign, res, v);
				fun(cur + 1, -sign, res & candi[1][cur], v);
			}
			else {
				fun(cur + 1, sign, res, v);
				fun(cur + 1, -sign, res & candi[0][cur], v);
			}
		}
		else fun(cur + 1, sign, res, v);
	}
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	for (int i = 1; i <= 50; i++) combi[i][0] = 1;
	combi[1][1] = 1;
	for (int i = 2; i <= 50; i++) {
		for (int j = 1; j <= i; j++) {
			combi[i][j] = combi[i - 1][j] + combi[i - 1][j - 1];
		}
	}
	for (int i = 1; i <= 50; i++) {
		F[i][0] = 0;
		for (int j = 1; j <= 50; j++) {
			F[i][j] = combi[i][j] + F[i][j - 1];
		}
	}
	cin >> n >> k;
	cin >> s >> t;
	for (int i = 0; i < n; i++) cin >> a[i];
	if (((s & t) != s) || ((s | t) != t)) {
		cout << 0 << E;
	}
	else {
		for (int i = 0; i < n; i++) {
			if ((a[i] & s) != s) continue;
			if ((a[i] | t) != t) continue;
			vec.pb(a[i]);
		}
		sz = vec.size();
		for (int i = 0; i < sz; i++) {
			if (s == t && vec[i] == t) {
				ans++;
			}
			al = i;
			memset(candi, 0, sizeof(candi));
			for (int j = 0; j < i; j++) {
				for (int u = 0; u < 18; u++) {
					candi[(vec[j] >> u) & 1][u] += 1LL << j;
				}
			}
			fun(0, 1, (1LL << al) - 1, vec[i]);
		}
		cout << ans << E;
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 3712
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# Nと空白区切の入力値を数値の配列で返却する
def gets_n_and_i_list()
  return gets.chomp.to_i, gets.chomp.split(" ").map(&:to_i)
end
n, alist = gets_n_and_i_list

e = alist.count{|a| a.even?}

puts 3 ** n - 2 ** e

Measured memory_bytes: 14580
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
string s;
set<string>st;
int k,len;
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    cin>>s;
    cin>>k;
    len=s.length();
    for(int i='a'; i<='z'; i++)
    {
        for(int j=0; j<len; j++)
        {
            if(s[j]==i)
            {
                string sub;
                int it=j,k=0;
                while(it<len && k<5){
                    sub+=s[it];
                    k++;
                    st.insert(sub);
                    it++;
                }
            }
        }
    }
    for(auto x:st)
    {
        k--;
        if(!k)
        {
            cout<<x<<endl;
            return 0;
        }

    }

    return 0;
}


Measured memory_bytes: 4780
#include <cstdio>
#include <iostream>
using namespace std;
const int M=100000+10;
int a[M],b[M];
int max(int a,int b)
{
    if(a>b) return 1;
    return 0;
}
int main()
{
    int  n,x;
    while(scanf("%d %d",&n,&x)!=EOF)
    {
        long long  sum=0;
        int mi=1000000001,y=0,i,f=0,ans=0;
        for(i=0;i<n;i++)
            scanf("%d",&a[i]),b[i]=a[i];
        if(a[0]+a[1]>=x)
        {
            sum+=a[0]+a[1]-x;
            if(x>a[0])
                a[1]=x-a[0];
            else a[1]=0;
        }
        for(i=2;i<n;i++)
        {
           // printf("b[%lld]=%lld\n",i,b[i]);
            if(a[i]>(x-a[i-1])) a[i]=x-a[i-1];
            if(b[i]>a[i])     sum+=b[i]-a[i];
        }
        printf("%lld\n",sum);
    }
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
using namespace std;
int main()
{
	char a[110];
	int i,n,j,t=0;
	gets(a);
	n=strlen(a);
	for(i=0;i<n;i++){
		if(a[i]=='C')
		{
			t++;
			break;
		}
	}
	for(j=i;j<n;j++){
		if(a[j]=='F'){
			t++;
			break;
		}
	}
	if(t==2)
	printf("Yes");
	else
	printf("No");
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

int dp[3003][3003];
int arr[3003][3003];
void init(int N,int M){
  for(int i = 0 ; i <= N ; i++){
    for(int j = 0 ; j <= M ; j++){
      dp[i][j] = 0;arr[i][j] = MAX;
    }
  }
}
string getStr(string &s,string &t,int l,int r){
  for(int i = 0 ; i < l ; i++){
    for(int j = 0 ; j < r ; j++){
      if(s[i] == t[j]){
        dp[i+1][j+1] = dp[i][j]+1;
        arr[i+1][j+1] = 0;
      }else{
        if(dp[i][j+1] < dp[i+1][j]){
          dp[i+1][j+1] = dp[i+1][j];
          arr[i+1][j+1] = -1;
        }else{
          dp[i+1][j+1] = dp[i][j+1];
          arr[i+1][j+1] = 1;
        }
      }
    }
  }
  string res;
  for(int i = l, j = r ; i > 0 && j > 0 ; ){
    if(!arr[i][j]){
      res += s[i-1];
      i--; j--;
    } else if(arr[i][j] == 1) i--;
    else j--;
  }
  reverse(res.begin(),res.end());
  return res;
}

void Main() {
  init(3001,3001);
  string s,t;
  cin >> s >> t;
  pr(getStr(s,t,s.size(),t.size()));
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

int N,L,arr[100001];

int main()
{
  cin>>N>>L;
  for (int i=0;i<N;i++)
    cin>>arr[i];
  int ans=-1;
  for (int i=0;i+1<N;i++)
    if (arr[i]+arr[i+1]>=L)
      ans=i+1;
  if (ans==-1){
    cout<<"Impossible"<<endl;
    return 0;
  }
  cout<<"Possible"<<endl;
  for (int i=1;i<ans;i++)
    cout<<i<<endl;
  for (int i=N-1;i>ans;i--)
    cout<<i<<endl;
  cout<<ans<<endl;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

const int MAX = 5e5;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
  if(n >= MAX){
    ll tmp = 1;
    rep(i,k){
      tmp *= (n-i);
      tmp %= MOD;
    }
    return tmp*finv[k]%MOD;
  }

  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll POW(ll x, ll n){
  ll ret = 1;
  while(0 < n){
    if(n%2 == 0){
      x = x*x%MOD;
      n = n >> 1;
    }
    else{
      ret = ret*x%MOD;
      n--;
    }
  }

  return ret;
}

int main(){
  ll n, a, b; cin >> n >> a >> b;
  ll ans = POW(2LL, n) - 1;
  COMinit();
  ans -= COM(n, a) + COM(n, b);
  ans %= MOD;

  while(ans < 0){
    ans += MOD;
  }

  cout << ans << endl;
}


Measured memory_bytes: 11904
#include<bits/stdc++.h>
using namespace std;
long M=1e9+7,n,k,ans=1,l,r,b=1,a[1<<18],x,y,i;
int main(){
  cin>>n>>k;
  r=n-1;
  for(i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  if(k%2)ans=a[r],r--,k--,b=(ans<0?-1:1);
  while(k){
    x=a[l]*a[l+1],y=a[r]*a[r-1];
    if(x*b>y*b)ans*=x%M,ans%=M,l+=2;
    else ans*=y%M,ans%=M,r-=2;
    k-=2;
  }
  cout<<(ans+M)%M<<endl;
return 0;
}


Measured memory_bytes: 5156
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    for(int count = 0; count < n; count++){
        int gx, gy;
        cin >> gx;
        cin >> gy;

        vector<vector <int>> ways;
        ways.resize(gy+1);
        for(int i = 0; i < gy+1; i++){
            ways[i].resize(gx+1);
        }

        vector<vector <int>> streets;
        streets.resize(gy+1);
        for(int i = 0; i < gy+1; i++){
            streets[i].resize(gx+1);
        }
        
        for(int x = 0; x < gx+1; x++){
            streets[0][x] = 1;
        }
        for(int y = 0; y < gy+1; y++){
            streets[y][0] = 2;
        }
        for(int x = 1; x < gx+1; x++){
            for(int y = 1; y < gy+1; y++){
                streets[y][x] = 3;
            }
        }

        int p;
        cin >> p;
        int x0, y0, x1, y1;
        for(int i = 0; i < p; i++){
            cin >> x0;
            cin >> y0;
            cin >> x1;
            cin >> y1;
            if(x0 == x1){
                if(y0 < y1){
                    streets[y1][x0] -= 2;
                } else {
                    streets[y0][x0] -= 2;
                }
            } else {
                if(x0 < x1){
                    streets[y0][x1] -= 1;
                } else {
                    streets[y0][x0] -= 1;
                }
            }
        }
        
        ways[0][0] = 1;
        for(int x = 1; x < gx+1; x++){
            if(streets[0][x] == 1){
                ways[0][x] = ways[0][x-1];
            } else {
                ways[0][x] = 0;
            }
        }
        for(int y = 1; y < gy+1; y++){
            if(streets[y][0] == 2){
                ways[y][0] = ways[y-1][0];
            } else {
                ways[y][0] = 0;
            }
        }

        for(int x = 1; x < gx+1; x++){
            for(int y = 1; y < gy+1; y++){
                if(streets[y][x] == 3){
                    ways[y][x] = ways[y-1][x] + ways[y][x-1];
                }
                if(streets[y][x] == 2){
                    ways[y][x] = ways[y-1][x];
                }
                if(streets[y][x] == 1){
                    ways[y][x] = ways[y][x-1];
                }
                if(streets[y][x] == 0){
                    ways[y][x] = 0;
                }
            }
        }
        if(ways[gy][gx] > 0){
            cout << ways[gy][gx] << endl;
        } else {
            cout << "Miserable Hokusai!" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1204
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];
	int g = a[0];
	repn(i, 1, n) g = gcd(g, a[i]);
	cout << g << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

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

    long long r, D, x;
    cin >> r >> D >> x;

    for (int i = 1; i <= 10; ++i) {
        x = x * r - D;
        cout << x  << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, A, B;
  cin >> N >> A >> B;
  vll X(N);
  REP(i, N){
    cin >> X[i];
  }

  ll X_init = X[0];
  ll new_0=0;

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

  REP(i, N){
    if(X[i]==X_init){
      new_0 = i;
      break;
    }
  }

  ll ans = 0;
  FOR(i, new_0+1, N){
    ll dist = X[i]-X[i-1];
    ans += min(dist*A, B);
  }
  FOR(i, 0, new_0){
    ll dist = X[i+1]-X[i];
    ans += min(dist*A, B);
  }

  ll dist1 = X[N-1]-X[new_0];
  ll dist2 = X[new_0]-X[0];
  ans += min(B, min(dist1*A, dist2*A));

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 1024
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int k,x;
  cin >> k >> x;
  if(k*500>=x) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	int dp[n];
	for(int i=1;i<n;i++)
	dp[i]=INT_MAX;
	dp[0]=0;
	for(int i=1;i<n;i++) {
		for(int j=1;j<=k;j++) {
			if(i-j<0)
			break;
			dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
		}
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	long long int a = 0;
	long long int b = 0;
	while (cin >> a, cin >> b)
	{
		long long int c = a + b;
		int d = 1;
		while (c >= 10)
		{
			c /= 10;
			d++;
		}
		cout << d << endl;
	}
	
	return 0;
}

Measured memory_bytes: 2988
from collections import Counter
n = int(input())
d = [int(x) for x in input().split()]
m = int(input())
t = [int(x) for x in input().split()]

D = Counter(d)
T = Counter(t)

ans = "YES"
for x in T.keys():
    if D[x] < T[x]:
        ans = "NO"
        break

print(ans)

Measured memory_bytes: 56928
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define int long long
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;	
}
using namespace std;
int A,B,C,D,E,F;
main()
{
	int T;re(T);
	while(T--)
	{
		re(A);re(B);re(C);re(D);
		if(A<B || D<B)
		{
			puts("No");
			continue;
		}
		if(C>=B || !D)
		{
			puts("Yes");
			continue;
		}
		E=__gcd(B,D);
		A%=E;
		C=C-B+1;
		F=C/E*E;
//		printf("%lld %lld %lld\n",E,C,F);
		if(F-E+A>=C)F=F-E+A;
		else F+=A;
		puts(F<0?"No":"Yes");
	}	
}
/*
must A>=B  A%=B
must A<=C
must D>=B  D%=B
if C>=B ok
if C<B

(A + xD)%B > C 
D> B-A
*/

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int N;
vector<vector<char>> nap(2*305, vector<char>(2*305));

bool is_ok(int h, int w){
    bool res = true;
    rep(i,N)rep(j,N){
        if(nap[h+i][w+j] != nap[h+j][w+i])res = false;
    }
    return res;
}

int main(){
    char c;
    cin >> N;
    rep(i,N)rep(j,N){
        cin >> c;
        nap[i][j] = nap[i+N][j] = nap[i][j+N] = nap[i+N][j+N] = c;
    }
    int ans = 0;
    rep(i,N){
        if(is_ok(i,0))ans += N-i;
        if(i != 0)if(is_ok(0,i))ans += N-i;
    }
    cout << ans << endl;
    //rep(i,2*N){rep(j,2*N)cout << nap[i][j]; cout << endl;}
    return 0;
}


Measured memory_bytes: 4016
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;

// Graph Templates
using Weight = ll;
// using Flow = int;
struct Edge {
    int src, dst;
    Weight weight;
    // Flow cap;
    Edge() : src(0), dst(0), weight(0) {}
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;
const Weight INF = numeric_limits<Weight>::max();

// add edge a <--(weight = w)--> b
void add_edge(Graph &g, int a, int b, Weight w) {
    g[a].push_back(Edge(a, b, w));
    g[b].push_back(Edge(b, a, w));
}

// add edge a --(weight = w)--> b
void add_arc(Graph &g, int a, int b, Weight w) { g[a].push_back(Edge(a, b, w)); }

// Dijkstra
// g is graph, s is start
vector<Weight> dijkstra(const Graph &g, int s) {
    // const Weight INF = numeric_limits<Weight>::max() / 8;
    using state = tuple<Weight, int>;
    priority_queue<state> q;
    vector<Weight> dist(g.size(), INF);
    dist[s] = 0;
    q.emplace(0, s);
    while (q.size()) {
        Weight d;
        int v;
        tie(d, v) = q.top();
        q.pop();
        d *= -1;
        /* if(v == t) return d; */
        if (dist[v] < d) continue;
        for (auto &e : g[v]) {
            if (dist[e.dst] > dist[v] + e.weight) {
                dist[e.dst] = dist[v] + e.weight;
                q.emplace(-dist[e.dst], e.dst);
            }
        }
    }
    return dist;
}

int main(){
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--;
    t--;
    Weight d;
    Graph g_yen, g_snuuk;
    vector<Weight> yen, snuuk;
    vector<int> u(m), v(m);
    vector<Weight> a(m), b(m);
    g_yen.resize(n);
    g_snuuk.resize(n);
    for (int i=0; i<m; ++i){
        cin >> u[i] >> v[i] >> a[i] >> b[i];
        u[i]--;
        v[i]--;
    }
    for (int i=0; i<m; ++i){
        add_edge(g_yen, u[i], v[i], a[i]);
        add_edge(g_snuuk, u[i], v[i], b[i]);
    }
    vector<Weight> cost_yen = dijkstra(g_yen, s);
    vector<Weight> cost_snuuk = dijkstra(g_snuuk, t);
    vector<Weight> cost(n); // s -> i -> t
    vector<Weight> ans(n, 1000000000000000);
    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> queue;
    for (int i=0; i<n; ++i){
        cost[i] = cost_yen[i] + cost_snuuk[i];
        // cout << i << " -> " << cost_yen[i] << " : " << cost_snuuk[i] << " = " << cost[i] << endl;
        queue.push(make_pair(cost[i], i));
    }
    int now_pos = -1;
    int itr = 0;
    while(itr < n){
        pair<Weight, int> p = queue.top();
        queue.pop();
        if(now_pos < p.second){
            int out_times = p.second - now_pos;
            now_pos = p.second;
            for (int i=0; i<out_times; ++i){
                ans[itr] -= p.first;
                itr++;
            }
        }
        // cout << p.first << " * " << p.second << endl;
    }
    for (int i=0; i<n; ++i){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 23676
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define F first
#define S second
//cout<<fixed<<setprecision(11);
const string nl="\n";
const ll MOD=1e9+7;
const ll ARR_MAX = 81;
const int VAL_MAX = 80*160+3;
const ll INF=1e14;
const int M=2*VAL_MAX+1;

bitset<M> dp[ARR_MAX][ARR_MAX];
//dp[i][j][k] = if there exists with signed unbalancedness as k.

void solve(){
    int h,w;cin>>h>>w;
    int mat[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>mat[i][j];
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int x;
            cin>>x;
            mat[i][j]=abs(mat[i][j]-x);
        }
    }
    dp[0][0][VAL_MAX-mat[0][0]]=1;
    dp[0][0][VAL_MAX+mat[0][0]]=1;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i<h-1){
                dp[i+1][j] = dp[i+1][j] | (dp[i][j]<<mat[i+1][j]); 
                dp[i+1][j] = dp[i+1][j] | (dp[i][j]>>mat[i+1][j]);           
            }
            if(j<w-1){
                dp[i][j+1] = dp[i][j+1] | (dp[i][j]<<mat[i][j+1]);
                dp[i][j+1] = dp[i][j+1] | (dp[i][j]>>mat[i][j+1]);
            }
        }
    }
    int mn =M;
    for(int i=0;i<M;i++){
        if(dp[h-1][w-1][i]){
            mn=min(mn,abs(VAL_MAX-i));
        }
    }
    cout<<mn<<nl;

}

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

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

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

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int[] x = new int[M];
    for (int i = 0; i < M; i++) x[i] = scanner.nextInt();
    Arrays.sort(x);

    int[] d = new int[M - 1];
    for (int i = 1; i < M; i++) d[i - 1] = x[i] - x[i - 1];
    Arrays.sort(d);

    long sum = 0;
    for (int i = 0; i < M - N; i++) sum += d[i];
    System.out.println(sum);
  }
}


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

using namespace std;

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

    int a, b;
    cin >> a >> b;

    cout << max(2 * a - 1, max(2 * b - 1, a + b));

    return 0;
}


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

int main(){
  int N, M; cin >> N >> M;
  priority_queue<int> A;
  
  for(int i = 0; i < N; i++){
    int a; cin >> a; A.push(a);
  }
  
  for(int i = 0; i < M; i++){
    int dvd = A.top(); A.pop();
    dvd /= 2;
    A.push(dvd);
  }
  
  long long ans = 0LL;
  
  for(int i = 0; i < N; i++){
    ans += A.top(); A.pop();
  }
  cout << ans << endl;
}

Measured memory_bytes: 892
#include<stdio.h>
#define MAX 500000
#define BUMP 10000000000

long long count = 0;
int L[MAX / 2 + 2], R[MAX / 2 + 2];

void marge(int A[], int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    int i, j, m;
   
    for(i = 0; i < n1; i++) L[i] = A[left + i];
    for(i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1] = R[n2] = BUMP;
    for(i = 0, j = 0, m = left; m < right; m++){
        if(L[i] <= R[j]){
            A[m] =L[i];
            i++;
        }else{
            A[m] = R[j];
            j++;
            count += n1 - i ;
        }
    }
}

void margesort(int A[], int left, int right){
    if(left + 1 < right ){
        int mid = (right + left) / 2;
        margesort(A, left, mid);
        margesort(A, mid, right);
        marge(A, left, mid, right);
    }
}

int main(void){
    int A[MAX];
    int n, i;

    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &A[i]);
    }

    margesort(A, 0, n);

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


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

int main() {
	int A, B, C; cin >> A >> B >> C;
	int K; cin >> K;
	int num=0;
	while(A >= B){
		num++;
		B *= 2;
	}
	while (B >= C) {
		num++;
		C *= 2;
	}
	if (num <= K) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3600
# -*- coding: utf-8 -*-


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    s = input()
    t = input()

    cnt = 0
    for temp_s, temp_t in zip(s, t):
        if temp_s != temp_t:
            cnt += 1

    return cnt


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 9384
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str

def solve(N: int, p: "List[int]"):

    if check(p):
        print("YES")
        return

    p1 = p.copy()
    if p[0] > p[1] and p[N-2] > p[N-1]:
        p1[0] = p[N-1]
        p1[N-1] = p[0]

    if check(p1):
        print("YES")
        return

    p2 = p.copy()
    current = p[0]
    for i in range(1, len(p)):
        if current > p[i]:
            p2[i-1] = p[i]
            p2[i] = p[i-1]
        current = p[i]

    if check(p2):
        print("YES")
        return

    p3 = p.copy()
    current = p[0]
    ind = 0
    hoge = [0] * 2

    for i in range(1, len(p)):
        if current > p[i]:
            if ind <= 1:
                hoge[ind] = i + ind - 1
                ind += 1
            else:
                print("NO")
                return
        current = p[i]

    if ind == 0 or ind == 1:
        print("NO")
        return

    p3[hoge[0]] = p[hoge[1]]
    p3[hoge[1]] = p[hoge[0]]
    if check(p3):
        print("YES")
        return
    else:
        print("NO")
        return



def check(p):
    # print(p)
    current = p[0]
    for i in range(1, len(p)):
        # print(current)
        if current > p[i]:
            return False
        current = p[i]

    return True

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    p = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, p)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
def slove():
    import sys
    input = sys.stdin.readline
    ax, ay, bx, by = list(map(int, input().rstrip('\n').split()))
    cx = cy = dx = dy = 0

    cx = bx + (ay - by)
    cy = by - (ax - bx)

    dx = cx + (ax - bx)
    dy = cy + (ay - by)

    print(cx, cy, dx, dy)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(void){
  int n;
  cin >> n;
  vector<int> t(n + 1), x(n + 1), y(n + 1);
  for(int i = 1; i < n + 1; i++) cin >> t[i] >> x[i] >> y[i];
  t[0] = x[0] = y[0] = 0;
  bool ok = true;
  for(int i = 1; i <= n; i++){
    int T = t[i] - t[i - 1];
    int D = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
    if(T < D) ok = false;
    if((T + D) % 2 == 1) ok = false;
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}


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

int main(){
	int h[10];

	for (int i = 0; i < 10; i++){
		cin >> h[i];
	}
	for (int i = 0; i < 9; i++){
		for(int j = i + 1; j < 10; j++){
			if(h[i] < h[j]){
				int temp = h[i];
				h[i] = h[j];
				h[j] = temp;
			}	
		}
	}
	for(int i = 0; i < 3; i++){
		cout << h[i] << endl;
	}

}

Measured memory_bytes: 1160
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    string s;
    cin >> s;
    int n = s.size();
    string last;
    int i=1;
    last = s.substr(0,1);
    int ans = 1;
    while (i < n){
        int k=1;

        while (last == s.substr(i,k)){
            k++;
            if (k > pow(10,7)){
                cout << ans << endl;
                exit(0);
            }
        }
        last = s.substr(i,k);

        i += k;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define test(t) int t;cin>>t;while(t--)
#define lli long long int
#define pb push_back
#define MAX 10000007
#define mod 1000000007
//a.push_back(i+'0');convert i to char;
//cout << fixed << setprecision(2) << pi ;
const lli infl=0x3f3f3f3f3f3f3f3fLL;
int prime(lli n)
{int f=1;
    for(lli i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {f=0;break;}
    }if(f==0) return 0;
    return 1;

}
int power(int a,int b)
{
   int result=1;
    while(b>0)
    {   if(b%2)
        result=(a*result)%mod;
        a=(a*a)%mod;
        b=b/2;
    }
    return result%mod;
}
int main()
{  ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
    //test(t)
    {
       lli ans=infl,c,d,x,y,z,n,w,q,m,r,f=0,i=0,j=0,odd=0,even=0;
      lli sum=0,sum1=0,sum2=0,res=0,cur,l,k,area,maxm=-infl,minm=infl,low,high=0,r1,r2,c1,c2;
       string s1,s2,s3,str,s;
       vector<int>v,u;
       cin>>n>>w;
       lli wt[n],val[n];
       lli dp[n+1][w+1];
       for(i=0;i<n;i++)
        cin>>wt[i]>>val[i];
       for(i=0;i<=n;i++)
       {
           for(j=0;j<=w;j++)
           {
              if(i==0||j==0)
              {
                  dp[i][j]=0;continue;
              }
              if(j>=wt[i-1])
              dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
              else
              dp[i][j]=dp[i-1][j];
           }
       }cout<<dp[n][w];

       cout<<endl;
    }
}


Measured memory_bytes: 82380
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  int cost;
  Edge(int src, int dst, Weight weight, int cost) :
    src(src), dst(dst), weight(weight), cost(cost) { }
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.cost != f.cost ? e.cost > f.cost :
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int prim(const Graph &g, int r = 0) {
  int n = g.size();
  Weight total = 0;

  vector<int> dist(n,INF);
  vector<bool> visited(n);
  priority_queue<Edge> Q;
  Q.push( Edge(-1, r, 0, 0) );
  dist[0] = 0;
  while (!Q.empty()) {
    Edge e = Q.top(); Q.pop();
    if (visited[e.dst]) continue;
    visited[e.dst] = 1;
    total += e.cost;
    FOR(f, g[e.dst]) {
      if (dist[f->dst] >= e.weight+f->weight) {
        dist[f->dst] = e.weight+f->weight;
        Q.push(Edge(f->src,f->dst,e.weight+f->weight,f->cost));
      }
    }
  }
  return total;
}

int main() {
  int n,m;
  while(cin>>n>>m,n||m) {
    Graph g(n);
    REP(i,m) {
      int u,v,d,c;
      cin>>u>>v>>d>>c;
      u--;v--;
      g[u].push_back(Edge(u,v,d,c));
      g[v].push_back(Edge(v,u,d,c));
    }
    cout << prim(g) << endl;
  }
}

Measured memory_bytes: 2248
#include<iostream>
#include<array>
#include<string>

int main(){
  int N,L;
  std::cin >> N >> L;
  std::string *S;
  S = new std::string [N];
  for (int i = 0; i < N; ++i){
    std::cin >> S[i];
    //std::cout << S[i] <<std::endl;
  }//標準入出力からN,L,Sを受け取る
  //std::cout << S <<std::endl;

  for (int M = 0; M < N; ++M){
    int a = M;
    for (int j = M; j < N; ++j){
      if (S[a] > S[j]){
        a = j;
      }
      else {}
    }
    //std::cout << a <<std::endl;

    std::string b;
    for (int k = N-1; k > -1; --k){
      if (k == a){
        b = S[a];//
        //std::cout << b << std::endl;
      }
      else if ((k < a)&&(k > M-1)){
        S[k+1] = S[k];//最大のxより前は１つ後ろに
        //std::cout << S[k+1] <<std::endl;
      }
      else{}//最大のxより後はそのまま

    }

    S[M] = b;//最大の文字列を先頭に出した
  //std::string T = "";
  //for (int l = 0; l < N; ++l){
  //  T = T + S[l];

  //std::cout << T << std::endl;
  }



  std::string T = "";
  for (int l = 0; l < N; ++l){
    T = T + S[l];
  }
  std::cout << T << std::endl;
  delete[] S;

  return 0;
}

Measured memory_bytes: 256