akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main()
{
    int k , a , b ;
    cin >> k >> a >> b ;
    if (b-a>2) {
        if (k+1<=a) cout << k+1 << endl ;
        else {
            k -= (a-1) ;
            long long ans = a ;
            long long q = k / 2 ;
            ans += q * (b-a) ;
            ans+= k%2 ;
            cout << ans << endl ;
        }
    }
    else cout << k+1 << endl ;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;


#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN
#define INF         100000000000000000
#define PI          3.1415926535897932384626433832795l



#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)






// struct mycomp {
//     bool operator() (const pair<int,int> &a, const pair<int,int> &b) const{
//         if (a.second-a.first != b.second-b.first)
//         return (a.second-a.first > b.second-b.first);
//         return a.first < b.first;
//     }
// };



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


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}


///////////////////////////BFS//////////////////////////////////
void bfs(vector<int>& distance, vector<int> a[], vector<bool>& visited, int u, vector<int>& parent)
{
	visited[u]=true;
	parent[u]=-1;
	distance[u]=0;
	queue<int> q;

	q.push(u); 
    while (!q.empty()) { 
  
        int f = q.front(); 
        q.pop(); 
  		for(int i =0; i < a[f].size(); i++)
  		{
  			if(visited[a[f][i]]==false)
  			{
  				distance[a[f][i]]=distance[f]+1;
  				parent[a[f][i]]=f;
  				visited[a[f][i]]=true;
  				q.push(a[f][i]);
  			}
  		}
    } 

}
bool cmp(const pair<pair<string, int>, int>  &a, const pair<pair<string, int>, int> &b)
{
	if(a.fi.fi!=b.fi.fi)
		return a.fi.fi<b.fi.fi;
	return a.fi.se > b.fi.se;

}

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

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	int n;
	cin>>n;
	vector<pair<pair<string, int>, int>  > v(n);



	for(int i = 0; i < n; i++)
	{
		cin>>v[i].fi.fi>>v[i].fi.se;
		v[i].se=i;
	}
	sort(v.begin(), v.end(), cmp);
	for(int i = 0; i < n; i++)
	{
		cout<<v[i].se+1<<endl;
	}

	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    ll X, Y;
    cin>>N>>M>>X>>Y;
    vec x(N+1), y(M+1);
    rep(i,N) cin>>x[i];
    rep(i,M) cin>>y[i];
    x[N] = X;
    y[M] = Y;
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    cout<<(x[N] >= y[0] ? "War" : "No War")<<endl;
}


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

using namespace std;

int main (void) {
    string S, T;
    cin >> S >> T;

    for ( int i=0; i<S.size(); i++ ) {
        if ( S.at(i) != T.at(i) ) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int,pair<int,string> > P;
int main(void){
  int n,w,l,d,f = 0;
  string t;
  while(cin >> n,n){
    if(f) cout << "\n";
    f = 1;
    vector<P> v;
    for(int i = 0;i < n; i++){
      cin >> t >> w >> l >> d;
      P p;
      p.first = w * 3 + d;
      p.second.first = n - i;
      p.second.second = t;
      v.push_back(p);
    }
    sort(v.begin(),v.end());
    for(int i = n - 1;i >= 0; i--) cout << v[i].second.second << "," << v[i].first << endl;
  }
}


Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=1e5+10;

int N;
int H[MAX];
void input(){
  cin>>N;
  rep(i,N)cin>>H[i];
}

void solve(){
  bool ans=true;
  int tmp=H[0];
  bool neg=true;
  rep1(i,N-1){
    if(neg){
      if(H[i]>=tmp){
        tmp=H[i];
      }
      else if(H[i]==tmp-1){
        tmp=H[i];
        neg=false;
      }
      else{
        ans=false;
        break;
      }
    }
    else{
      if(H[i]>tmp){
        tmp=H[i];
        neg=true;
      }
      else if(H[i]==tmp){
        continue;
      }
      else{
        ans=false;
        break;
      }
    }
  }

  if(ans)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

}

void output(){
  
}

int main(){
  input();
  solve();
  output();
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
    long long int N;
    cin >> N;
    long long int ans=0;
    for(long long int n=1; n<=N; n++) {
        if(n%15==0) {
            continue;
        } else if(n%3==0) {
            continue;
        } else if(n%5==0) {
            continue;
        } else {
            ans += n;
        }
    }
    cout << ans << endl;


    return 0;
    
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] p = new int[n];
        for(int i=0; i<n; i++) {
            p[i] = in.nextInt();
        }
        int c = 0;
        for(int i=1; i<n-1; i++) {
            if((p[i-1]<p[i] && p[i]<p[i+1]) || (p[i+1]<p[i] && p[i]<p[i-1])) {
                c++;
            }
        }
        System.out.println(c);
    }
}


Measured memory_bytes: 21844
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)

struct Shop {
  ll price;
  ll num;
};

int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> A;
  vector<ll> B;
  vector<Shop*> shops;
  rep(i, N) {
    ll a;
    ll b;
    cin >> a >> b;
    A.push_back(a);
    B.push_back(b);
    Shop* shop = new Shop();
    shop->price = a;
    shop->num = b;
    shops.push_back(shop);
  }

  // cout << "before" << endl;
  // rep(i, N) { cout << shops[i]->price << " " << shops[i]->num << endl; }

  sort(shops.begin(), shops.end(),
       [](const Shop* a, const Shop* b) { return a->price < b->price; });

  // cout << "after" << endl;
  // rep(i, N) { cout << shops[i]->price << " " << shops[i]->num << endl; }

  ll buy = 0;
  ll wantNum = M;
  rep(i, N) {
    ll price = shops[i]->price;
    ll num = shops[i]->num;
    if (num < wantNum) {
      buy += price * num;
      wantNum -= num;
    } else {
      buy += price * wantNum;
      wantNum -= wantNum;
    }
  }

  cout << buy << endl;

  return 0;
}


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

void change(int& num) {
	if (num == 1) {
		num = 9;
	}
	else {
		num = 1;
	}
}

int main() {
	int N;
	cin >> N;
	int a, b, c; // aはNの100の位, bは10, cは1

	a = N / 100;
	b = (N - 100 * a) / 10;
	c = N - 100 * a - 10 * b;

	change(a);
	change(b);
	change(c);

	cout << 100 * a + 10 * b + c << endl;

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC142_D
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var a = ab[0];
            var b = ab[1];

            var ap = Factors(a).Distinct();
            var bp = Factors(b).Distinct();

            var ans = 1;
            foreach (var i in ap)
            {
                if (bp.Contains(i) && IsPrime(i)) ans++;
            }

            Console.WriteLine(ans);
        }

        public static IEnumerable<long> Factors(long n)
        {
            long i = 2;
            long tmp = n;

            while (i * i <= n)
            {
                if (tmp % i == 0)
                {
                    tmp /= i;
                    yield return i;
                }
                else
                {
                    i++;
                }
            }
            if (tmp != 1) yield return tmp;
        }

        public static bool IsPrime(long num)
        {
            if (num < 2) return false;
            else if (num == 2) return true;
            else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

            double sqrtNum = Math.Sqrt(num);
            for (int i = 3; i <= sqrtNum; i += 2)
            {
                if (num % i == 0)
                {
                    // 素数ではない
                    return false;
                }
            }

            // 素数である
            return true;
        }
    }
}


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

using namespace std;

int main()
{
  int n;
  cin>>n;
  string s,t;
  cin>>s>>t;
  for(int i=0;i<n;i++)
  {
    cout<<s[i]<<t[i];
  }
  return 0;
}

Measured memory_bytes: 3584
class PriorityQueue
  def initialize
    @h = [] # min-heap
  end

  def enq v
    @h << v
    up_heap
  end
  alias :push :enq

  def deq
    min, last = @h[0], @h.pop
    unless @h.empty?
      @h[0] = last
      dn_heap
    end
    return min
  end
  alias :pop :deq

  def empty?
    @h.empty?
  end

  private
  def up_heap
    i, up = @h.size-1, @h[-1]
    while 0 <= (iP = (i-1)/2)
      break unless up < @h[iP]
      @h[i], i = @h[iP], iP
    end
    @h[i] = up
  end

  def dn_heap
    i, dn, size = 0, @h[0], @h.size
    while (iC = 2*i+1) < size
      iC += 1 if iC+1 < size and @h[iC+1] < @h[iC]
      break unless @h[iC] < dn
      @h[i], i = @h[iC], iC
    end
    @h[i] = dn
  end
end

MAX_V = 50 # 制約の最大値。
MAX_S = MAX_V * 50 + 5
INF   = Float::INFINITY

#　頂点
Edge = Struct.new(:to, :a, :b)
#　両替所
Exchange = Struct.new(:v, :s, :x) do
  include Comparable
  def <=>(other)
    self.x <=> other.x
  end
end

g    = Array.new(MAX_V) { Array.new { Edge.new } }
dist = Array.new(MAX_V) { Array.new(MAX_S + 5) { INF } }

def input
  gets.split.map &:to_i;
end

# メイン
n, m, s = input
#　都市の入力
m.times do
  u, v, a, b = input
  u          = u.pred
  v          = v.pred
  g[u] << Edge.new(v, a, b)
  g[v] << Edge.new(u, a, b)
end

# プライオリティキューのライブラリを利用
# s = [s, MAX_S].min
s = MAX_S if MAX_S < s
# プライオリティーキュー
q =PriorityQueue.new
# 入力用ラムダ
push = lambda { |v, s, x|
  return if s < 0
  return if dist[v][s] <= x

  dist[v][s] = x
  q.push(Exchange.new(v, s, x))
}

c = []
d = []
n.times do |i|
  cc, dd = input
  c[i]   = cc
  d[i]   = dd
end
push.call(0, s, 0)
until q.empty?
  hoge = q.pop
  v    = hoge.v; s = hoge.s; x = hoge.x
  next if dist[v][s] != x

  ns = [s + c[v], MAX_S].min
  push.call(v, ns, x + d[v])

  g[v].each do |e|
    push.call(e.to, s - e.a, x + e.b)
  end
end


(1 ... n).each do |i|
  ans = INF
  (0 ... (MAX_S + 5)).each do |j|
    # ans = [ans, dist[i][j]].min
    ans = dist[i][j] if dist[i][j] < ans
  end
  puts ans
end

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

int main(){
    string str;
    cin >> str;
    vector<int> num(26, 0);
    for(int i=0; i<(int)str.length(); i++){
        num[str[i]-'a']++;
    }
    bool flag = true;;
    for(int i=0; i<26; i++){
        if(num[i]%2!=0){
            flag = false;
            break;
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/* When Talent doesn't work, Hard work beats Talent*/

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include"bits/stdc++.h"

using namespace std;

#define Fast_D cout<<fixed<<setprecision(2);
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define sp " "
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define scanstr(s) cin>>ws; getline(cin,s);

const double PI=3.141592653589793;

int a[26];

void solve()
{
	string s;
	cin>>s;
	for(char i : s)
	{
		int x = i - 'a';
		a[x]++;
	}
	for(int i : a)
	{
		if(i%2==1)
		{
			cout << "No\n";
			return ;
		}
	}
	cout << "Yes\n";
}

int32_t main()
{
	FastIO;
	Fast_D;
	int T;
	T=1;
	while(T--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 3672
import sys
mod = 7 + 10 ** 9

def solve():
    N, K = map(int,input().split())
    count = [0] * (K + 1)
    ans = 0
    for i in reversed(range(1, K + 1)):
        upper = K // i
        count[i] += pow(upper, N, mod)
        count[i] %= mod
        ans += (count[i] * i) % mod
        ans %= mod
        for j in range(2, i + 1):
            if j ** 2 > i: break
            if i % j == 0:
                count[j] += (mod - count[i])
                count[j] %= mod
                if j ** 2 != i:
                    count[i // j] += (mod - count[i])
                    count[i // j] %= mod
        count[1] += (mod - count[i])
        count[1] %= mod
    print(ans)
        
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 69440
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


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


    int n,k;

    cin>>n>>k;

    while(true){
        int m;
        if(n>=k) m=n%k;
        else m=abs(n-k);
        if(n>m){
            n=m;
        }else break;
    }

    cout<<n<<endl;

}

Measured memory_bytes: 256
//#pragma GCC optimize (2)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(v) v.begin(),v.end()
ll quick_pow(ll base, ll n) {
    ll ans = 1;
    while (n ) {
        if (n & 1 )
            ans *= base;
        base *= base;
        n >>= 1;
    }
    return ans;
}
void solve();
int main() {
    int T=1;
    //cin>>T;
    while (T--){
        solve();
    }
    return 0;
}

int a[100050];
void solve(){
    ll n,sum=0,temp;
    cin>>n;
    for (int i = 0; i < n; ++i) {
        cin>>temp;
        a[temp]++;
        sum+=temp;
    }
    int k;
    cin>>k;
    int t,p;
    for (int i = 0; i < k; ++i) {
        cin>>t>>p;
//        cout<<t<<' '<<p;
        if (a[t]!=0) {
            temp = a[t];
            a[t] = 0;
            sum = sum - temp * t + temp*p;
            a[p] += temp;
        }
        cout<<sum<<'\n';
    }
}

Measured memory_bytes: 4024
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0LL);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }


int main() {
	int n, m;
	cin >> n >> m;
	vector<int> v(n+1);

	int u1 = 1+m;
	int d1 = 1;
	int u2=  n;
	int d2 = n - m + 1;
	 
	int c = 0;

	while (u1 > d1 && c < m) {
		cout << d1 << " " << u1 << endl;
		d1++; u1--;
		c++;
	}
	while (u2 > d2 && c < m) {
		cout << d2 << " " << u2 << endl;
		d2++; u2--;
		c++;
	}
}




Measured memory_bytes: 3860
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		StringBuilder ret = new StringBuilder();
		for(char c : S.toCharArray()) {
			int ci = c - 'A';
			ci = (ci + N) % 26;
			ret.append((char)('A' + ci));
		}
		System.out.println(ret);
	}
}


Measured memory_bytes: 22996
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 998244353

def solve():
    def comb(n,k):
        return f[n]*inv[k]*inv[n-k]%mod
    n,m,k = LI()
    if k == 0:
        print(m*pow(m-1,n-1,mod)%mod)
    else:
        f = [1]
        N = 10**6
        for i in range(1,N+1):
            f.append(f[-1]*i%mod)
        inv = [None]*(N+1)
        inv[N] = pow(f[N],mod-2,mod)
        for i in range(N)[::-1]:
            inv[i] = inv[i+1]*(i+1)%mod
        s = m
        dk = m
        p = m-1
        for i in range(n-1):
            s *= m
            s %= mod
            if i >= k:
                s -= dk
                s %= mod
                dk *= m-1
                dk += comb(i,k-1)*m*p%mod
                dk %= mod
                p *= m-1
                p %= mod
        print(s)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 161840
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define INF 1e18
#define N 1000100
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%MOD;
    if(b&1)
        ans=(a*ans)%MOD;
    return ans;
}
ll inv(ll a)
{
    return power(a,MOD-2,MOD);
}
//code begins



signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    cin.sync_with_stdio(false);
    ll t;
    t=1;
//    cin>>t;
    while(t--)
    {
        ll h;cin>>h;
        ll x=log2(h);
        ll ans=power(2,x+1)-1;
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    static int n, k;
    static long[] a;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        k = sc.nextInt();
        a = new long[n];
        for(int i=0; i<n; i++){
            a[i] = sc.nextLong();
        }
        sc.close();

        Arrays.sort(a);

        if(checkNeed(0)){
            System.out.println(0);
            return;
        }
        if(!checkNeed(n-1)){
            System.out.println(n);
            return;
        }


        int l = 0, r = n-1;
        while(r-1>l){
            int m = (l+r)/2;
            if(checkNeed(m)){
                r = m;
            }else{
                l = m;
            } 
        }
        System.out.println(l+1);
    }

    static boolean checkNeed(int pos){
        if(a[pos] >= k) return true;

        boolean[][] dp = new boolean[n][k+1];
        dp[0][0] = true;
        if(pos != 0) dp[0][(int)a[0]] = true;
        for(int i=1; i<n; i++){
            for(int j=0; j<k+1; j++){
                dp[i][j] = dp[i-1][j];
            }
            if(i == pos) continue;
            for(int j=0; j<k+1 - a[i]; j++){
                if(dp[i-1][j]) dp[i][j+(int)a[i]] = true;
            }
        }

        for(int i=k-(int)a[pos]; i<k; i++){
            if(dp[n-1][i]) return true;
        }
        return false;
    }
}

Measured memory_bytes: 159968
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>


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

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long

int N,K;
//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> N >> K;
  vector<int> p;
  p.resize(N);
  REP(i,N){
    cin >> p[i];
  }
  /*
  for(int i = N - K; i < N; i++){
    ans += (double)(p[i] + 1)/2.0;
  }
  */
  vector<double> section_sum(N);
  for(int l = 0; l + K <= N; l++){
    if(l == 0){
      for(int i = l; i < l + K; i++){
        section_sum[l] += (double)(p[i] + 1)/2.0;
      }
    }
    else{
      section_sum[l] = section_sum[l - 1] + (double)(p[l + K - 1] + 1)/2.0 - (double)(p[l - 1] + 1)/2.0;
    }
  }

  cout << setprecision(10) <<  *max_element(all(section_sum)) << endl;

  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll max3(ll x,ll y,ll z){
  ll max;
  if(x>y){
    max=x;
  }else{
    max=y;
  }
  if(max<z){
    max=z;
  }
  return max;
}
int main(void){
  ll a,b,c,ans;
  cin>>a>>b>>c;
  ll max=max3(a,b,c);
  max*=3;
  ll sum=a+b+c;
  if((max%2)==(sum%2)){
    ans=(max-sum)/2;
  }else{
    ans=(max-sum+3)/2;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
signed main(){
  string s;
  ll a=0,b=0;
  cin>>s;
  for(ll i=0;i<s.size();i++){
    if(s[i]=='0'){
      a++;
    }else{
      b++;
    }
  }
  cout<<min(a,b)*2<<"\n";
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;
constexpr i64 MOD = 1e9 + 7;

i64 modpow(i64 a, i64 n, i64 mod) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        i64 t = modpow(a, n / 2, mod);
        return t * t % mod;
    }
    return a * modpow(a, n - 1, mod) % mod;
}

i64 modinv(i64 a, i64 mod) {
    // mod is prime
    return modpow(a, mod - 2, mod);
}

struct Combination {
    const int MAX_N = 1 << 21;
    vi fact = vi(MAX_N);
    vi factinv = vi(MAX_N);

    Combination() {
        fact[0] = 1;
        for (int i = 1; i < MAX_N; i++) {
            fact[i] = fact[i - 1] * i % MOD;
        }
        factinv[MAX_N - 1] = modinv(fact[MAX_N - 1], MOD);
        for (int i = MAX_N - 2; i >= 0; i--) {
            factinv[i] = factinv[i + 1] * (i + 1) % MOD;
        }
    }

    i64 ncr(i64 n, i64 r) {
        if (r < 0 || r > n) return 0;
        return fact[n] * factinv[r] % MOD * factinv[n - r] % MOD;
    }

    i64 npr(i64 n, i64 r) {
        if (r < 0 || r > n) return 0;
        return fact[n] * factinv[n - r] % MOD;
    }

    i64 nhr(i64 n, i64 r) {
        if (n == 0 && r == 0) return 1;
        return ncr(n + r - 1, r);
    }
};

int main() {
    int n, k;
    cin >> n >> k;
    Combination comb;
    cout << comb.ncr(n - 1, k - 1) << endl;
}


Measured memory_bytes: 35584
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int count = 1;
		int max = 0;
		String[] S = new String[N];
		for(int i = 0;i < N;i++){
			S[i] = sc.next();
		}
		Arrays.sort(S);
		Map<String,Integer> map = new TreeMap<>();
		for(int i = 0;i < N - 1;i++){
			if(S[i + 1].equals(S[i])){
				count++;
				if(i == N - 2){
					map.put(S[i],count);
					max = Math.max(max,count);
				}
			}else{
				map.put(S[i],count);
				max = Math.max(max,count);
				count = 1;
				if(i == N - 2){
					map.put(S[i + 1],count);
					max = Math.max(max,count);
				}
			}
		}
		for(String key : map.keySet()){
			if(map.get(key) == max){
				System.out.println(key);
			}
		}
	}
}

Measured memory_bytes: 82896
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }


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

    // ifstream fin(".in");
    // ofstream fout(".in");
    i64 n,m;
    cin>>n>>m;
    i64 ans=0;
    ans+=n*(n-1)/2;
    ans+=m*(m-1)/2;
    cout<<ans;




    return 0;
  }


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
 
using namespace std;
 
int main(){
    int H,W;
    while(true){
        scanf("%d %d",&H,&W);
        if(H == 0 && W == 0) break;
        for(int i = 0; i < W; i++) printf("#");
        printf("\n");
 
        for(int i = 1; i < H-1; i++){
            printf("#");
            for(int j = 1; j < W-1; j++) printf(".");
            printf("#\n");
        }
 
        if(H > 1){
            for(int i = 0; i < W; i++) printf("#");
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2568
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();
            Stack<int> stk = new Stack<int>();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                int n = int.Parse(input);

                if (n != 0) stk.Push(n);
                else sb.AppendLine(stk.Pop().ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 10024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

class Program
{
    static void Main()
    {

        string S = Console.ReadLine();
        string T = Console.ReadLine();

        string TT = T + T;

        if (TT.Contains(S))
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No") ;
        }


    }
    
}



static class MathUtil
{
    public static IEnumerable<IEnumerable<int>> GetPermutation(int n)
    {
        if (n == 0)
        {
            yield return Single(0);
            yield break;
        }

        for (int i = 0; i <= n; i++)
        {
            foreach (var x in GetPermutation(n - 1))
            {
                yield return Single(i).Concat(x.Select(itm => itm < i ? itm : itm + 1));
            }
        }
    }

    private static IEnumerable<int> Single(int x)
    {
        yield return x;
    }

    public static IEnumerable<int> EnumeratePrimeNumbers()
    {
        List<int> primes = new List<int>() { 2 };
        yield return 2;

        for (int i = 3; i < int.MaxValue; i++)
        {
            bool isPrime = true;
            int Sqrt = (int)Math.Sqrt(i) + 1;

            foreach (var prime in primes)
            {
                if (prime > Sqrt)
                {
                    break;
                }
                if (i % prime == 0)
                {
                    isPrime = false;
                    break;
                }
            }

            if (isPrime)
            {
                primes.Add(i);
                yield return i;
            }
        }
    }
}



Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int>pii;
typedef vector<int>vi;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define fi first
#define se second
#define de(x) cout<<#x<<"="<<x<<"\n"
#define dd(x) cout<<#x<<"="<<x<<" "
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define lowbit(a) ((a)&-(a))
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
const int N=2e6+5;
ll n;
vector<ll> p,q;
int main()
{
	cin>>n;
	ll ans = 1;
	for(ll i = 2;i*i<=n;++i){
		if(n%i == 0){
			p.pb(i);
			if(i*i!=n)p.pb(n/i);
		}
	}
	for(auto v:p){
		ll tmp = n;
		while(tmp%v == 0)tmp/=v;
		if(tmp%v == 1)ans++;
	}
	if(n > 2)ans++;
	n--;
	for(ll i = 2;i*i<=n;++i){
		if(n%i == 0){
			ans ++;
			if(i*i!= n)
			ans++; 
		}
	}
	cout<<ans<<"\n";
	return 0;
}



Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;



namespace CSharpSample01
{

    
      
    class Program
    {
        
        static void Main(string[] args)
        {
            //入力1(N)
            int N = int.Parse(Console.ReadLine());

            Console.WriteLine((long)N * (N - 1) / 2);

        }
    }

}

Measured memory_bytes: 13140
nums = []
for i in range(10):
    for j in range(10):
        for k in range(10):
            nums.append(str(i) + str(j) + str(k))
n = input()
S = input()

ans = 0
for num in nums:
    index = 0
    for s in S:
        if s==num[index]:
            index+=1
        if index==3:
            ans+=1
            break
print(ans)


Measured memory_bytes: 41308
N = int(input())
T, A = map(int, input().split())
Hs = list(map(int, input().split()))

index = -1
min_temp = 10**9
for i in range(N):
  now_temp = abs(T-Hs[i]*0.006-A)
  if min_temp > now_temp:
    min_temp = now_temp
    index = i+1
print(index)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
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; }
const int INF = 1000100100;

int main() {
    ll K, A, B, C;
    cin >> A >> B >> C >> K;

    ll ans = (A - B)*pow(-1, (K % 2));
    if(ans > 1e18) {
        cout << "Unfair" << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define INF 1e9
#define all(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define max(v) *max_element(v.begin(), v.end())
#define min(v) *min_element(v.begin(), v.end())
using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, s;
    cin>>n;
    int a[n], b[n];
    rep(i, n){
        cin>>a[i];
        b[a[i]-1] = i+1;
    }
    rep(i, n){
        cout<< b[i]<<" ";
    }
    cout<<endl;
    
    return 0;
}

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

int A[2000];

 int search(int n,int A[],int i,int m){
  
  if(m==0) return 1;

  else if(i>=n) return 0;
  
  return (search(n, A, i + 1, m) || search(n, A, i + 1, m - A[i]));
}


extern void solve(int n,int A[],int q,int M[]){
  int i;
  for(i=0;i<q;i++){
    if(search(n,A,0,M[i])==1)
      printf("yes\n");
    else
      printf("no\n");
  }
  }

int main(){
  int n,*M,i,q;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
   M=(int*)malloc(sizeof(q));
 for(i=0;i<q;i++){
    scanf("%d",&M[i]);
  }

  solve(n,A,q,M);
 
 return 0;
}



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

int main() {
  string s,t; cin >> s >> t;
  bool flag = false;
  int N = s.size();
  for(int i=0;i<N;i++){
    s = s[N-1] + s.substr(0,N-1);
    if(s==t){
      flag = true;
      break;
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, m;
    cin >> n >> m;

    priority_queue<pair<ll, ll>> prQ;
    rep(i, n) {
        ll a;
        cin >> a;
        prQ.push(make_pair(a, 1));
    }
    rep(i, m) {
        ll b, c;
        cin >> b >> c;
        prQ.push(make_pair(c, b));
    }

    ll ans = 0;
    rep(loop, n) {
        auto p = prQ.top();
        prQ.pop();
        ans += p.first;
        p.second--;
        if(p.second > 0) {
            prQ.push(p);
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 6384
class Check:
    def __init__(self, H, W):
        self.H = H
        self.W = W
    
    def draw(self):
        for h in range(self.H):
            s =""
            for w in range(self.W):
                if h % 2 == 0:
                    if w % 2 == 0:
                        s += "#"
                    else:
                        s += "."
                else:
                    if w % 2 == 0:
                        s += "."
                    else:
                        s += "#"
            print(s)
            

li = []
while 1:
    H, W = map(int,input().split())
    if H == W == 0:
        break
    else:
        li.append(Check(H, W))

for l in li:
    l.draw()
    print("")




Measured memory_bytes: 5628
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
typedef long long int ll;
using namespace std;
#define REP(i,n) for(int i=0;i<signed(n);i++)
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
const ll MOD = 1000000007;
const ll INF = 9e9;
ll N,M,ans=INF;
ll A[300010],S[301000];

int main(){
    std::ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N){
        cin>>A[i];
        S[i]+=A[i];
        S[i+1]=S[i];
    }
    //a:右半分の区切り i:真ん中 b:左半分
    //s:右の和 t:左の和
    ll a=0,b=2,s,t;
    REP(i,N-2){
        if(i==b)b++;
        s=(S[i]-S[a])-S[a];
        t=(S[N-1]-S[b])-(S[b]-S[i]);
        bool f=true;
        if(i==0)continue;
        while(f){
            f=false;
            if(a+1==i)continue;
            if(abs(s)>abs(s-A[a+1]*2)){
                s-=A[a+1]*2;
                a++;f=true;
            }
        }
        f=true;
        while(f){
            f=false;
            if(b+1==N-1||b==N-1)continue;
            if(abs(t)>abs(t-A[b+1]*2)){
                t-=A[b+1]*2;
                b++;f=true;
            }
        }
        ans=min( ans,( max({S[a],S[i]-S[a],S[b]-S[i],S[N-1]-S[b]})
        -min({S[a],S[i]-S[a],S[b]-S[i],S[N-1]-S[b]}) ) );
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3840
#include <cstdio>
#include <vector>
#include <functional>
#include <algorithm>

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  std::vector<std::pair<int, int>> a(n);
  std::vector<std::pair<int, int>> b(m);
  std::vector<int> xs;
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &a[i].first, &a[i].second);
    xs.push_back(a[i].first);
  }
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &b[i].first, &b[i].second);
  }
  std::sort(xs.begin(), xs.end());
  m = xs.size() + 1;
  std::vector<int> value(m + 2);
  for (auto &x: a) {
    int p = std::lower_bound(xs.begin(), xs.end(), x.first) - xs.begin();
    value[p + 1] = x.second;
  }
  std::vector<std::vector<std::pair<int, int>>> edges(m + 1);
  for (size_t i = 0; i < b.size(); ++i) {
    int u = std::lower_bound(xs.begin(), xs.end(), b[i].first) - xs.begin();
    int v = std::upper_bound(xs.begin(), xs.end(), b[i].second) - xs.begin(); 
    edges[u].emplace_back(v, i);
    edges[v].emplace_back(u, i);
  }

  std::vector<int> ret, mark(m + 1);
  std::function<int(int)> dfs = [&](int u) {
    if (mark[u]) return 0;
    mark[u] = 1;
    int cnt = 0;
    for (auto &e: edges[u]) {
      if (dfs(e.first)) ret.push_back(e.second), cnt ^= 1;
    }
    if (value[u] ^ value[u + 1]) cnt ^= 1;
    return cnt;
  };

  for (int i = 0; i <= m; ++i) {
    int r = dfs(i);
    if (r == 1) { puts("-1"); return 0; }
  }
  std::sort(ret.begin(), ret.end());
  printf("%d\n", (int)ret.size());
  for (auto &x: ret) printf("%d ", x + 1);
  puts("");
  return 0;
}


Measured memory_bytes: 18680
#include <iostream>
using namespace std;
int main(void){
    int i,t,n;
    for(i=0; i<4; i++){
        cin >> t >> n;
        if(t==1){
            cout << 6000*n << endl;
        }
        else if(t==2){
            cout << 4000*n << endl;
        }
        else if(t==3){
            cout << 3000*n << endl;
        }
        else if(t==4){
            cout << 2000*n << endl;
        }
    }
}



Measured memory_bytes: 3104
#include<stdio.h>
#include<string.h>
#define maxn 60
#define N 1010
char map[maxn][maxn];
long long nt,ti;
bool use[maxn][maxn];
int n,m,q;
struct task
{
    int r,c;
}s[N];
struct visit
{
    int cnt;
    long long int ti[N];
}vis[maxn][maxn];
struct mat
{
    long long int keep;
    long long int on;
    long long int off;
}cost[maxn][maxn];
int dr[4]={-1,1,0,0};
int dc[4]={0,0,-1,1};
long long min(long long a,long long b)
{
    return a>b?b:a;
}
void readin()
{
    for (int i=1;i<=n;i++)
        scanf("%s",map[i]+1);
    for (int i=1;i<=n;i++)
        for (int j=1;j<=m;j++)
            scanf("%lld",&cost[i][j].keep);
    for (int i=1;i<=n;i++)
        for (int j=1;j<=m;j++)
            scanf("%lld",&cost[i][j].on);
    for (int i=1;i<=n;i++)
        for (int j=1;j<=m;j++)
            scanf("%lld",&cost[i][j].off);
    for (int i=1;i<=q;i++)
        scanf("%d %d",&s[i].r,&s[i].c),s[i].r++,s[i].c++;
}
bool ok(int r,int c)
{
    if (r<1||r>n||c<1||c>m)return false;
    if (map[r][c]=='#')return false;
    return use[r][c];
}
bool dfs (int r,int c,task end,long long  tim)
{
    if (r==end.r&&c==end.c)
    {
        nt=tim;
        return true;
    }
    use[r][c]=0;
    vis[r][c].ti[++vis[r][c].cnt]=tim;
    for (int i=0;i<=4;i++)
    {
        int nr=r+dr[i];
        int nc=c+dc[i];
        if (ok(nr,nc))
        {
            if (dfs(r+dr[i],c+dc[i],end,tim+1))return true;
        }
    }
    use[r][c]=1;
    vis[r][c].cnt--;
    return false;
}
void work()
{
    nt=0ll;
    for (int i=1;i<=n;i++)
        for (int j=1;j<=m;j++)
            vis[i][j].cnt=0;
    for (int i=1;i<q;i++)
    {
        memset(use,1,sizeof use);
        dfs(s[i].r,s[i].c,s[i+1],nt);
    }
    vis[s[q].r][s[q].c].ti[++vis[s[q].r][s[q].c].cnt]=nt;
    long long ans=0;
    for (int i=1;i<=n;i++)
    {
        for (int j=1;j<=m;j++)
        {
            long long sum=0;
            //printf("cnt=%d : ",vis[i][j].cnt);
            for (int k=1;k<vis[i][j].cnt;k++)
            {
                sum+=min(cost[i][j].on+cost[i][j].off,cost[i][j].keep*(vis[i][j].ti[k+1]-vis[i][j].ti[k]));
                //printf("%lld ",vis[i][j].ti[k]);
                //printf("\n");
            }
            if (vis[i][j].cnt)sum+=cost[i][j].off+cost[i][j].on;
            ans+=sum;
        }
    }
    printf("%lld\n",ans);
}
int main()
{
    while (scanf("%d %d %d",&n,&m,&q)!=EOF)
    {
        readin();
        work();
    }
    return 0;
}
/*
3 3 5
***
*##
**#
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 0
2 1
0 2
2 0
0 0
*/

Measured memory_bytes: 15000
#include <iostream>
#include <queue>
#include <string>
#include <map>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <vector>
#include <stack>
#include <algorithm>
#include <string.h>
#include <set>
#include <cstdlib>
#include <iostream>
#include <bits/stdc++.h>
#define pii pair<int,int> 
#define ll long long int 
#define sl(n) scanf("%lld",&n)
#define s(n) scanf("%d",&n)
#define f(i,n) for(int i=0;i<n;++i)
#define fo(i,n) for(int i=1;i<=n;++i)
#define fnm(n,m) for(ll i=n;i<m+1;++i)
#define pb push_back
#define pf printf
#define F first
#define S second
#define srt(v) sort(v.begin(),v.end());
#define srtc(v,cmp) sort(v.begin(),v.end(),cmp);
#define srta(v,n) sort(v,v+n);
const ll LL_INF=0x3f3f3f3f3f3f;
const ll MOD=1073741824;


using namespace std;


int T,m=0;
string s,d,ans;
pii mx;
int dp[3005][3005];


void gen(){
    fo(i,s.size()){
        fo(j,d.size()){
            if(s[i-1]==d[j-1]){
                dp[i][j]=1+dp[i-1][j-1];
                if(dp[i][j]>m){
                    m=dp[i][j];
                    mx.F=i;
                    mx.S=j;
                    // pf("%c\n",s[i-1]);
                }
            }
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
}

void sol(int i,int j,string x){
    if(i==0||j==0)return;
    if(s[i-1]==d[j-1]){
        x+=s[i-1];  
        ans=x;
        sol(i-1,j-1,x);
    }
    else{
        if(dp[i-1][j]>dp[i][j-1])sol(i-1,j,x);
        else sol(i,j-1,x);
        
    }
}

int main(){
    // pf("\t\t\t***************************************************************************\n\n");
    // pf("\t\t\t***************************************************************************\n\n");
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    cin>>s>>d;
    memset(dp,0,sizeof dp);
    gen();
    // fo(i,s.size()){
    //     fo(j,d.size())pf("%d  ",dp[i][j]);
    //     pf("\n");
    // }
    sol(mx.F,mx.S,"");
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
    return 0;
} 

Measured memory_bytes: 43264
N,M = map(int,input().split())
s = []
for i in range(M):
    dp = [0]*(N)
    tmp = list(map(int,input().split()))
    for j in tmp[1:]:dp[j-1]=1
    s.append(dp)
p = list(map(int,input().split()))
ans = 0
for i in range(1<<N):
    tmp = 0
    dp = [0]*M
    for I in range(M):
        for j in range(N):
            t = i>>j&1
            dp[I] += s[I][j] * t
    for e,i in enumerate(dp):
        dp[e] = i%2
    if dp == p:
        ans+=1
print(ans)





Measured memory_bytes: 3064