akhauriyash/Code-Regression huggingface dataset:
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif

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

    int A, B, C, D, E, F; 
    cin >> A >> B >> C >> D >> E >> F;

    // 100A*i + 100B*j + C*k + D*l <= F
    // (C*k+D*l)/(100A*i+100B*j) <= E/100

    int ansWt = 100 * A, ansSg = 0;
    REP(j,31) {
        REP(i,31) {
            int water = 100 * A*i + 100 * B*j;
            if (water > F) break;

            int SgMax = water/100 * E;
            int KMAX = SgMax / C;
            int LMAX = SgMax / D;
            REP(l,LMAX+1) {
                REP(k,KMAX+1) {
                    int sugar = C * k + D * l;

                    if (water + sugar <= F &&
                        (100+E)*(sugar) <= E*(water+sugar)){

                        // sugar/(water+sugar) > ansSg/(ansWt+ansSg)
                        if (sugar*(ansWt+ansSg) > ansSg*(water+sugar)) {
                            ansWt = water;
                            ansSg = sugar;
                        }
                    }
                }
            }
        }
    }

    cout << ansWt + ansSg << " " << ansSg << endl;

    return 0;
}


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

int main(){
	int v,d;
	while(cin >> v >> d){
		set<int> st;
		int a = 1,b = 1,t,res = 1,prev = 2;
		for(int i = 0;i < v;i++){
			t = a;
			a = (a + b) % 1001;
			b = t;
			st.insert(a);
		}
		for(auto it = st.begin();it != st.end();it++){
			if(*it - prev >= d) res++;
			prev = *it;
		}
		cout << res << endl;
	}
	return 0;
}

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

#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define fr(i,l,r) for (long long int i = l; i < r; ++i)
#define frr(i,l,r) for (long long int i = r; i >= l; --i) 
#define sortarr sort(arr,arr+n) //sorts array in asc order
#define sortarr_r sort(arr, arr+n, greater<long long int>()) //sorts array in desc order
#define make_set set<long long int>s //Set arranges in asc order
#define make_set_r set<long long int, greater <long long int>>s ////Set arranges in desc order
#define make_vector vector<long long int>v; 
#define max_heap priority_queue <int> pq; // max heap 
#define min_heap priority_queue <int, vector<int>, greater<int> > pq;  //min heap
#define make_pairVector vector<pair<long long int,long long int> > pairVector // vector of pairs
#define hashmap unordered_map<long long int, long long int>hashmap;
#define pb push_back

//transform(s.begin(), s.end(), s.begin(), ::tolower); //to convert a string entirely to lower case

//toupper(s[i]) or tolower(s[i]) // converting a character to upper or lower case

//map<pair<ll,ll>, ll > hash;          // pair,value hashmap where key is a pair
//hash[make_pair(i,j)] = 0;
//if(hash.find(make_pair(i,j)) == hash.end())


//map<ll,ll>::iterator itr;           // iterating a map
//for (itr = hash.begin();itr != hash.end(); itr++)
//{
//   itr->first = key  
//   itr->second = value
//}


// vector<string> v; //to convert vector to a set
// set<string> s(v.begin(), v.end());


// set<string>s;     // to convert set to a vector
// vector<string> v(s.begin(),s.end());


// cin >> x >> y;
// pairVector.pb(mp(x,y));


// string size = str.size()


// stack <int> s; 


// queue <int> gquiz; 


// __gcd(m, n) 

// ll arr[10e5 + 5];


// char arr[10e5 + 5];


//vec.insert(v.begin(),value)   -> to insert a value in the vector at the begin

// printf ("%.9f\n",x);
// cout << fixed << setprecision(9);

//covert integer to string :  to_string(integer)

bool sortbysec(const pair<long long int,long long int> &a, const pair<long long int,long long int> &b) 
{ 
    return (a.second < b.second); 
}
bool compare(string &s1,string &s2) 
{ 
    return s1.size() < s2.size(); 
} 
int check_key(map<long long int, long long int> m, long long int key) 
{ 
    // Key is not present 
    if (m.find(key) == m.end()) 
        return 0; 
  
    return 1; 
} 

void yes()
{
    cout << "YES" << endl;
}
void no()
{
    cout << "NO" << endl;
}

int main(void)
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll l,r,d;
    cin >> l >> r >> d;
    ll c = 0;
    for(ll i = l; i<=r; i++)
    {
        if(i%d == 0)
            ++c;
    }
    cout << c << endl;
return 0;
}   

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define fio     ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define pi      3.14159265
#define ll      long long
#define repe    ll tc,cas=0;cin>>tc;while(tc--)
#define op      freopen("output.txt", "w", stdout);

#define maxn 10000010
using namespace std;

int main()
{
    fio;
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
        cin>>b[i];


    ll sum=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]-b[i]>0)
            sum+=(a[i]-b[i]);
    }
    cout<<sum<<endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> ii;
typedef map<int, int> MPII;
typedef set<int> SETI;

const int mxN = 2e5;
const ld pi = 4.0 * atanl(1.0);
const int iinf = 1e9 + 10;
const int inf = 1e18 + iinf + 10;
const int mod = 1000000007;
const ld prec = .000001;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(c) c.begin(), c.end()
#define rall(c) c.end(), c.begin()

int n, m, t, a[mxN];
vi v;

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

int main() {
  fast();
  cin >> n;
  map<int, int> mp;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    mp[i + 1] = x;
  }

  int t = mp[1], ans = 0;
  set<int> s;
  bool ok = true;
  while (t != 2) {
    if (s.find(t) != s.end()) {
      ok = false;
      break;
    } else {
      s.insert(t);
      t = mp[t];
    }
    ++ans;
  }
  if (ok)
    cout << ans + 1;
  else
    cout << -1;

  return 0;
}


Measured memory_bytes: 12960
import java.util.*;
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int num = sc.nextInt();
    int ans[] = new int[num];
    for(int i = 0; i < num; i ++) {
      ans[i] = -1;
    }
    boolean ok = true;
    for(int i = 0; i < num; i ++) {
      int tmp = sc.nextInt();
      if(tmp > 1) {
        if(ans[tmp - 2] < 0) {
          ok = false;
          break;
        }
      }
      for(int j = num - 1; j >= tmp; j --) {
        ans[j] = ans[j - 1];
      }
      ans[tmp - 1] = tmp;
    }
    if(ok) {
      for(int i = 0; i < num; i ++) {
        System.out.println(ans[i]);
      }
    }else {
      System.out.println(-1);
    }
  }
}

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

int main()
{
    int a, b, q;
    cin >> a >> b >> q;
    vector<long long> s(a + 2), t(b + 2), x(q + 2);
    for(int i = 0; i < a; i++){
        cin >> s[i + 1];
    }
    for(int i = 0; i < b; i++){
        cin >> t[i + 1];
    }    
    for(int i = 0; i < q; i++){
        cin >> x[i + 1];
    }
    s[0] = -20000000000;
    t[0] = -20000000000;
    s[a + 1] = 20000000000;
    t[b + 1] = 20000000000;
    for(int i = 1; i <= q; i++){
        auto itrs = lower_bound(s.begin(), s.end(), x[i]);
        auto itrt = lower_bound(t.begin(), t.end(), x[i]);
        long long ans1 = max(*itrs - x[i], *itrt - x[i]);
        long long ans2 = max(x[i] - *(itrs - 1), x[i] - *(itrt - 1));
        long long ans3 = max(*itrs - x[i], x[i] - *(itrt - 1)) + min(*itrs - x[i], x[i] - *(itrt - 1)) * 2;
        long long ans4 = max(*itrt - x[i], x[i] - *(itrs - 1)) + min(*itrt - x[i], x[i] - *(itrs - 1)) * 2;
        cout << min(min(ans1, ans2), min(ans3, ans4)) << endl;
    }
}

Measured memory_bytes: 3712
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
    int k;
    cin>>k;
    if(k%2==0)cout<<k*k/4<<endl;
    else cout<<(k/2)*(k/2+1)<<endl;

    return 0;
}

Measured memory_bytes: 3548
n,m=gets.chomp.split.map(&:to_i)
nStrings=n.times.map{gets.chomp}
mStrings=m.times.map{gets.chomp}
(0..(n-m)).each do |yIndex|
  (0..(n-m)).each do |xIndex|
    if m.times.all?{|k| nStrings[k+yIndex][xIndex...xIndex+m] == mStrings[k]}
      puts "Yes"
      exit
    end
  end
end
puts "No"

Measured memory_bytes: 1788
#include <stdio.h>
#include <string>
#include <algorithm>
#include <map>
#include <iostream>
#include<math.h>
using namespace std;

int main() {
	int N, Q, l[100010], r[100010], a[100010] = {0};
	string s;
	cin >> N>>Q>>s;
	for (int i = 0; i < Q; i++)cin >> l[i]>>r[i];
	for (int i = 1; i < N; i++) {
		a[i] = a[i-1];
		if (s[i-1] == 'A'&&s[i] == 'C') a[i]++;	

	}
	for (int j = 0; j < Q; j++) {
		cout << a[r[j] - 1] - a[l[j] - 1] << endl;
	}

}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

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

  REP(i, 1, b){
    if((i * a) % b == c){
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}


template<typename CostType>
/// \brief 辺の情報
struct Edge{
  int      to;
  CostType cost;

  Edge(int t, CostType c): to(t), cost(c){
  }
};

template<typename CostType>
class Graph{

private:

  /// \brief adjacent_list_[n]=ノードnの隣接リストを表すvector<Edge>
  std::vector<std::vector<Edge<CostType>>> adjacent_list_;

public:

  /// \brief 頂点数
  const int NODE_SIZE_;

  /// \brief コンストラクタ
  /// \param node_size 頂点数
  explicit Graph(const int node_size): NODE_SIZE_(node_size),
                                       adjacent_list_(node_size){
  }

  /// \brief 有向グラフの辺を生やす
  /// \param from 辺の根本の頂点の番号
  /// \param to 辺の先の頂点の番号
  /// \param cost 辺のコスト
  void SetDirectedEdge(const int from, const int to, const CostType cost){
    adjacent_list_[from].push_back(Edge<CostType>(to, cost));
  }

  /// \brief 無向グラフの辺を生やす
  /// \param node_a 一方の頂点の番号
  /// \param node_b もう一方の頂点の番号
  /// \param cost 辺のコスト
  void
  SetUndirectedEdge(const int node_a, const int node_b, const CostType cost){
    SetDirectedEdge(node_a, node_b, cost);
    SetDirectedEdge(node_b, node_a, cost);
  }

  /// \brief ある頂点の隣接リストを取得
  /// \param node_num 頂点の番号
  /// \return 隣接リスト
  std::vector<Edge<CostType>> GetAdjacentList(int node_num) const{
    return adjacent_list_[node_num];
  }
};

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n,m;
  cin>>n>>m;
  Graph<int> graph(n+1);
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    graph.SetUndirectedEdge(a,b,1);
  }

  vector<bool> used(n+1,false);
  vector<int> result(n+1);
  used[1]=true;
  queue<int> q;
  q.push(1);
  while(!q.empty()){
    int curr=q.front();
    q.pop();
    for(auto e:graph.GetAdjacentList(curr)){
      int next=e.to;
      if(!used[next]){
        used[next]=true;
        q.push(next);
        result[next]=curr;
      }
    }
  }

  cout<<"Yes"<<endl;
  for(int i=2;i<=n;i++){
    cout<<result[i]<<endl;
  }





  return 0;
}




Measured memory_bytes: 12868
#include<stdio.h>

int main() {
	int a, b;
	while (1) {
		if (scanf("%d %d", &a, &b) == EOF)break;
		else {
			a = a + b;
			b = 0;
			while (a) {
				b++;
				a = a / 10;
			}
		}
		printf("%d\n", b);
	}
	return 0;
}


Measured memory_bytes: 2720
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

r = inputs[0][0]
dd = inputs[0][1]
x = inputs[0][2]

# body
if $debugFlag
  p r
  p dd
  p x
end

10.times do
  x = r*x - dd
  puts x
end


Measured memory_bytes: 1788
def main():
    S = input()
    N = len(S)
    for i in range(N):
        for j in range(N+1):
            T = S[:i] + S[i+j:]  # S[i:i+j]を取り除く
            if T == "keyence":
                return print("YES")
    print("NO")


if __name__ == '__main__':
    main()


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

int main() {
  int N;
  cin>>N;
  int a=N/100,b=(N%100)/10,c=N%10;
  if(a==7||b==7||c==7){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  
}

Measured memory_bytes: 3580
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

const int MAXN = 100010;
const int MAXP = 10000000;
const u64 MOD = 1000000007;
const f80 MI = f80(1)/MOD;
const int INF = 1000000010;

int n;
int a[111][111][111];

int main()
{
	/*
	for (int i = 0; i <= 100; ++ i)
		for (int j = 0; j <= 100; ++ j)
			for (int k = 0; k <= 100; ++ k)
			{
				if (!i && !j && !k) continue;
				if (i && !a[i-1][j][k]) a[i][j][k] = 1;
				if (j && !a[i][j-1][k]) a[i][j][k] = 1;
				if (k && !a[i][j][k-1]) a[i][j][k] = 1;
				if (i && j && !a[i-1][j-1][k]) a[i][j][k] = 1;
				if (i && k && !a[i-1][j][k-1]) a[i][j][k] = 1;
				if (j && k && !a[i][j-1][k-1]) a[i][j][k] = 1;
				if (i && j && k && !a[i-1][j-1][k-1]) a[i][j][k] = 1;
				if (i%2 == 0 && j%2 == 0 && k%2 == 0)
				{
					if (a[i][j][k]) puts("fuck");
				}
				
				if (!a[i][j][k])
				{
					assert(i%2 == 0 && j%2 == 0 && k%2 == 0);
					printf("%d %d %d\n", i, j, k);
				}
				
			}
	*/
	
	cin >> n;
	int s = 0;
	for (int i = 1; i <= n; ++ i)
	{
		int x;
		scanf("%d", &x);
		if (x&1) s ++;
	}
	puts(s > 0 ? "first" : "second");
	
	return 0;
}


Measured memory_bytes: 2304
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(vec) (vec).begin(), (vec).end()
#define SUM(...) accumulate(ALL(__VA_ARGS__),0LL)
#define DSUM(...) accumulate(ALL(__VA_ARGS__),0.0)
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 便利関数
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;}
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

// 出力
void print() { std::cout << '\n'; }
template <class T>void print(const T &x) {std::cout << x <<'\n';}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}

const string YES = "YES";
const string NO = "NO";

void solve(long long A, long long B, long long C){
    if (C % gcd(A, B) == 0) print(YES);
    else print(NO);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


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

li_w = list(map(int, input().split()))

li_w_a = list()
li_w_b = list()

for l in li_w:
    if len(li_w_a) == 0:
        li_w_a.append(l)
    else:
        li_w_a.append(li_w_a[-1] + l)


for m in li_w[::-1]:
    if len(li_w_b) == 0:
        li_w_b.append(m)
    else:
        li_w_b.insert(0, li_w_b[0] + m)


w_min = max(li_w)
for idx in range(n - 1):
    w_min = min(w_min, abs(li_w_a[idx] - li_w_b[idx + 1]))
print(w_min)


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

using namespace std;

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


#define pb push_back
#define ff first
#define ss second
#define SIZE 200001
#define INF int(2e9 + 9)
#define BIG_INF ll(4e18 + 9)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define _sz(v) int((v).size())
#define sqr(x) (x) * (x)
#define cube(x) (x) * (x) * (x)
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout)
//#pragma GCC optimize("Ofast")

const int mod = 1e9 + 7;

ll binpow(ll a, ll b, ll mod = BIG_INF)
{
    ll res = 1;
    while(b)
    {
        if(b & 1)
            res *= a;
        a *= a;
        b >>= 1;
        a %= mod;
        res %= mod;
    }
    res %= mod;
    return res;
}




int T = 1, n, m, k, a[SIZE], cnt[SIZE], lst = 0;
vector<int> v;
string s;

ll ans = 0;

bool comp(const int& x, const int& y)
{
    return x > y;
}

void solve()
{
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i];

    sort(a, a + n, comp);
    cnt[0] = 1;
    for(int i = 1; i < n; i++)
    {
        cnt[i] = 2;
    }
    n--;
    while(n--)
    {
        ans += a[lst];
//        cout << a[lst] << '\n';
        cnt[lst]--;
        if(cnt[lst] == 0) lst++;
    }

    cout << ans;

}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
//    filein; fileout;

//    cin >> T;

    while(T--)
    {
        solve();
    }




    return 0;
}


Measured memory_bytes: 5176
#include <iostream>
using namespace std;
#define ll long long 
#define N 100
#define W 100000
ll dp[N+1][W+1];
ll knapsack(ll wt[],ll val[],ll w,ll n)
{
	if(n==0 || w==0)
	{
		return 0;
	}
	if(dp[n][w]!=-1)
	{
		return dp[n][w];
	}
	if(wt[n-1]<=w)
	{
		dp[n][w]=max(knapsack(wt,val,w-wt[n-1],n-1)+val[n-1],knapsack(wt,val,w,n-1));
	}
	else
	{
		dp[n][w]=knapsack(wt,val,w,n-1);;
	}
	return dp[n][w];
}
void solve()
{
	ll n,w;
	cin >> n >> w;
	ll wt[n],val[n];
	for(ll i=0;i<n;i++)
	{
		cin >> wt[i] >> val[i];
	}
	for(ll i=0;i<=n;i++)
	{
		for(ll j=0;j<=w;j++)
			dp[i][j]=-1;
	}
	cout << knapsack(wt,val,w,n) << "\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll t=1;
	// cin >> t;
	while(t--)
	{
		solve();
	}
	return 0;
}

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

int main( void ){
  int N, A, B, M[3] = {0};
  cin >> N >> A >> B;
  for( int i = 0; i < N; i++ ){
    int P;
    cin >> P;
    if(  P <= A ) M[0]++;
    else if( P <= B ) M[1]++;
    else M[2]++;
  }
  if( M[0] < M[1] && M[0] < M[2] ) cout << M[0] << endl;
  else if( M[1] < M[2] ) cout << M[1] << endl;
  else cout << M[2] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <stdio.h>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <queue>

using namespace std;

#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define sz(a) int((a).size())
#define pb push_back
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();i++)
#define mem(a, b) memset(a, b, sizeof(a))
#define MP make_pair
#define EPS      1e-9
#define F        first
#define S        second
#define sc(x)     scanf("%d",&x)
#define scl(x)     scanf("%I64d",&x)
#define sq(x)     (x)*(x)
#define INF (1000000000)
#define oo (1ll<<60)
#define PI acos(-1)
#define POW(x) ((x)*(x))

typedef stringstream ss;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef pair<int, int> ii;
typedef vector<int> rows;
typedef vector<rows> matrix;

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

const int MOD = 1000000007;
const int N = 1e5 + 10;

int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
#endif
	string s, t;
	cin >> s >> t;
	bool f = 0;
	string cpy = s;
	string ans;
	for (int i = 0; i < sz(s) - sz(t)+1; ++i) {
		for (int j = 0; j < sz(t); ++j) {
			if (s[i+j] != t[j] && s[i+j] != '?')
				break;
			if (j == sz(t) - 1) {
				f = 1;
				for (int k = 0; k < sz(t); k++)
					s[i + k] = t[k];
				for (int k = 0; k < sz(s); ++k)
					if (s[k] == '?')
						s[k] = 'a';
				if (sz(ans) == 0 || ans > s)
					ans = s;
				s = cpy;
			}

		}
	}

	puts(f ? ans.c_str() : "UNRESTORABLE");
	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
typedef long long ll;

#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REPI(x,y)	for (i=(x);i<(y);i++)
#define REPJ(x,y)	for (j=(x);i<(y);i++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;

int a,b;

int main() {
	cin >> a >> b;

	cout << (((a+b)%2)? (a+b)/2+1 : (a+b)/2);

	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >>c;
    if(a==c){
        cout << b << endl;
    }
    if(a==b){
        cout << c << endl;
    }
    if(b==c){
        cout << a << endl;
    }
}

Measured memory_bytes: 256
a,b,c = map(int,input().split())
k = int(input())

if b>a and c> b:
    print("Yes")
    exit()

for i in range(k+1):
    if b*2**i > a and c*2**(k-i) > b*2**i:
        print("Yes")
        exit()

print("No")


Measured memory_bytes: 9168
#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++)
using namespace std;
using P = pair<int,int>;
typedef long long ll;

int  main()
{
	int a,b,k; cin >> a >> b >> k;
	set<int> st;
	for(int i = a; i <= b; i++)
	{
		if (i < a + k)
		{
			cout << i << endl;
			st.insert(i);
		}
	}
	for (int j = b - k; j <= b; j++)
	{
		if (!st.count(j) && j > b - k)
		{
			if (j >= a && j <= b)
				cout << j << endl;
		}
	}
	return (0);
}


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

int main(){
    int n,x,i,j,k;
    int a = 0;

    while(1){
        cin >> n >> x ;
        if(n == 0 && x == 0)break;
        for(i = 1; i <= n; i++){
            for(j = 1; j < n; j++){
                for(k = 1; k < n-1; k++){
                    if(i + j + k == x && i > j && j > k ){
                        a += 1;
                    }
                }
            }
        }
        cout << a << endl;
        a = 0 ;
    }
    return 0;
}




Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
//#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef vector<ll>Vl;
typedef pair<ll,ll>PII;
typedef vector<PII>Vll;
typedef vector<pair<ll,pair<ll,ll> > >Vlll;
typedef priority_queue<ll>PQL;
typedef map<ll,ll>MP;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) scanf("%lld",&n)
#define pl(n) printf("%lld",n)
const ll mod=1e9+7;
const ll sze=4;
int main(){
	ll N;
	string S,T;
	sl(N);
	cin>>S>>T;
	ll i=0,j=0,cnt=1;
	
	while(cnt<=2*N){
		if(cnt%2==1){
			cout<<S[i];
			i++;
		}
		else{
			cout<<T[j];
			j++;
		}
		cnt++;
	}
	
	
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

ll k, a, b;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> k >> a >> b;
    ll cur = 1;
    ll aa = min(a, 1 + k);
    k -= aa - 1;
    cur = aa;
    if(b - a >= 2){
        ll kk = k / 2;
        cur += kk * (b - a);
        k %= 2;
    }
    cur += k;
    cout << cur << endl;
}


Measured memory_bytes: 256
from itertools import combinations

S=input()
Sl=len(S)

def cin(pt):
    r=[]
    s=0
    for i in pt:
        t=s,i
        r.append(t)
        s=i
    t=s,Sl
    r.append(t)
    return r

def calc(pt):
    r=0
    for s,e in cin(pt):
        r+=int(S[s:e])
    return r

pl=[i for i in range(1,Sl)]
ans=0
for pn in range(Sl):
    for pt in combinations(pl,pn):
        ans+=calc(pt)
print(ans)

Measured memory_bytes: 3064
InputIntList = lambda : list(map(int, input().split()))
InputStrList = lambda : list(input().split())

import numpy as np

N, M = InputIntList()
A = InputIntList()

A = np.array(A)
All = A.sum()
if len(A[A >= All / 4 / M]) >= M:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14044
#include<stdio.h>
#define N 101
int main(){
  int total,A[N],B[N][N],i,j,a,b,c;
    scanf("%d",&total);
  for(i=1;i<=total;++i) {
    scanf("%d%d",&A[i-1],&A[i]);
  }
  for(i=1;i<=total;++i){
    B[i][i] = 0;
  }
  for(b=2;b<=total;++b){
    for(i=1;i<=total-b+1;++i){
      j = i+b-1;
      B[i][j] = 100000000;
      for(a=i;a<j;a++){
        c = B[i][a]+B[a+1][j]+A[i-1]*A[a]*A[j];
        B[i][j] = (B[i][j]>c) ? c : B[i][j];
      }
    }
  }

  printf("%d\n",B[1][total]);

  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
int MOD = 1000000007; //10^9 + 7


int main() {
	int n;
	cin >> n;

	vector<pair<int, int>> town(n);
	rep(i, n) {
		int x, y;
		cin >> x >> y;
		town.at(i) = { x,y };
	}

	double d = 0;
	rep(i,n) {
		rep(j, i) {
			pair<int, int> a, b;
			a = town.at(i);
			b = town.at(j);
			d += sqrt(pow(a.first - b.first, 2) + pow(a.second - b.second, 2));
		}
	}

	printf("%.10f", (2.0 * d) / (n * 1.0));
}

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

int main() {

	int N,x;
	std::cin >> N >> x;
	std::vector< int> a(N);
	for (int i = 0; i < N; i++)std::cin >> a[i];
	std::sort(a.begin(), a.end());
	int ans = 0;
	long long res = 0;
	long long sum = std::accumulate(a.begin(), a.end(),0LL);
	if (sum < x) ans = N - 1;
	else {
		for (int i = 0; i < N; i++) {
			res += a[i];
			if (res > x) break;
			else ans++;
		}
	}

	std::cout << ans << std::endl;
		}

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

using namespace std;

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

const int INF = 1000000000; //
const ll LINF = (ll) 4000000000000000000; //
const ll MOD = (ll) 1000000007; //
const double PI = acos(-1.0); //

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())

//------------------------------------------------------

int main() {
    ll N;
    cin >> N;

    repll2(h, 3500) {

        repll2(n, 3500) {
            if (4 * h * n - N * h - N * n > 0 && (N * h * n) % (4 * h * n - N * h - N * n) == 0) {
                cout << h << " " << n << " " << (N * h * n) / (4 * h * n - N * h - N * n) << endl;
                return 0;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 256
N,M=map(int,input().split())
S = [list(map(int, input().split())) for i in range(N)]
S.sort()
a=0
for i in range(N):
        if M>S[i][1]:
                a+=S[i][1]*S[i][0]
                M-=S[i][1]
        else:
                a+=M*S[i][0]
                break
print(a)

Measured memory_bytes: 60760
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "begin", long, "end");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long a, b, m;
    scan(a, b, m);
    auto refrigator = aryread();
    auto microwave = aryread();
    auto value = new long[](0);
    foreach(_; iota(m))
    {
        long x, y, c;
        scan(x, y, c);
        value ~= (refrigator[x - 1] + microwave[y - 1] - c);
    }
    value ~= refrigator.reduce!(min) + microwave.reduce!(min);
    writeln(value.reduce!(min));
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 9276
import java.util.*;

public class Main{
    public static void run(){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        Map<Integer,Integer> d = new HashMap<Integer,Integer>();
        for(int i = 0; i < n; i++){
            int di = sc.nextInt();
            if(d.containsKey(di)){
                d.put(di,d.get(di) + 1);
            }else{
                d.put(di, 1);
            }
        }
        int m = sc.nextInt();
        for(int i = 0; i < m; i++){
            int t = sc.nextInt();
            if(d.containsKey(t)){
                d.put(t, d.get(t)- 1);
                if(d.get(t) <= 0){
                    d.remove(t);
                }
            }else{
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }

    public static void main(String[] args){
        run();
    }
}


Measured memory_bytes: 138580
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        for (int i = 0 ; i < k ; i++) {
            if (i % 2 == 0) {
                if (a % 2 == 1) {
                    a -= 1;
                    b += a/2;
                    a /= 2;
                } else {
                    b+= a/2;
                    a /= 2;
                }
            } else {
                if (b % 2 == 1) {
                    b -= 1;
                    a += b/2;
                    b /= 2;

                } else {
                    a += b/2;
                    b /= 2;
                }
            }
        }
        System.out.println(String.valueOf(a) + " " + String.valueOf(b));
    }

}


Measured memory_bytes: 22736
#include <iostream>
using namespace std;
const int maxn = 1e5;
int h[maxn];
int dp[maxn];
int N;

int main(int argc, char const *argv[])
{
    cin >> N;
    for(int i = 0 ; i<N ; i++){
        cin >> h[i];
    }
    dp[0] = 0;
    dp[1] = dp[0] + abs(h[0] - h[1]);
    for(int i = 2 ; i<N ; i++){
        int t1 = dp[i-2] + abs(h[i-2] - h[i]);
        int t2 = dp[i-1] + abs(h[i-1] - h[i]);
        dp[i] = min(t1, t2);
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 3900
#include<bits/stdc++.h>
#define MSET(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
#define ll long long
#define ld long double
#define INF 1e18
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;


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

    ll n = s.size(), d = t.size(), ans = INF;

    for (ll i = 0; i <= n-d; i++) {
        ll ans1 = 0;
        for (ll j = 0; j < d; j++) {
            if (s[i + j] == t[j]) continue;
            else ans1++;
        }
        ans = min(ans, ans1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
    long long N; cin >> N;
    long long ans = 10000000000000;
    
    for (long long i = 1; i <= sqrt(N)+1; i++) {
        if (N % i == 0) {
            ans = min(ans, i-1 + (N/i)-1);
        }
    }

    cout << ans;
    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

using namespace std;
int H,W;
char board[51][51];
int dist[100][100];
const int dx[] = {0,1,-1,0};
const int dy[] = {1,0,0,-1};

void bfs(){
  deque<pair<int,int>> q;
  pair<int,int> current;
  q.push_back(make_pair(0,0));

  rep(i,100)rep(j,100) dist[i][j] = -1;

  dist[0][0] = 1;
  while(q.empty() == false){
    current = q.front();
    q.pop_front();
    rep(i,4){
      int nextY  = current.first + dy[i]; //first = y
      int nextX = current.second + dx[i];//second = x
      //cout << nextY << ' ' << nextX << endl;
      //cout << board[nextY][nextX] << endl;
      if(nextY >= 0 && nextY < H && nextX >= 0 && nextX < W && board[nextY][nextX] != '#' && dist[nextY][nextX] == -1){
        //cout << board[nextY][nextX] << endl;
        dist[nextY][nextX] = dist[current.first][current.second] + 1;
        q.push_back(make_pair(nextY,nextX));
      }
    }
  }
}
int main(){
  cin >> H >> W;
  rep(i,H)rep(j,W) cin >> board[i][j];
  int cnt = 0;
  rep(i,H)rep(j,W) if(board[i][j] == '#') cnt++;
  bfs();
  //rep(i,H){rep(j,W){ cout << board[i][j] << ' ';} cout << endl;}
  if(dist[H-1][W-1] == -1) cout << -1 << endl;
  else{
    cout << H * W - cnt - dist[H-1][W-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
#define int lint
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
signed main()
{
    int n, m;
    cin >> n >> m;
    vi v(m, 0);
    rep(i, n)
    {
        int k;
        cin >> k;
        rep(j, k)
        {
            int a;
            cin >> a;
            a--;
            v[a]++;
        }
    }
    int ans = 0;
    rep(i, m)
    {
        if (v[i] == n)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
namespace AtCoder.ARC096
{
    public class ARC096A
    {
        public static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int priceA = int.Parse(input[0]);
            int priceB = int.Parse(input[1]);
            int priceC = int.Parse(input[2]);
            int requiredA = int.Parse(input[3]);
            int requiredB = int.Parse(input[4]);

            int max = Math.Max(requiredA, requiredB);
            int min = GetPrice(priceA, priceB, priceC, requiredA, requiredB, 0);
            int price = 0;
            int numA = 0, numB = 0;
            for (int numC = 0; numC <= max * 2; numC += 2)
            {
                numA = Math.Max(requiredA - numC / 2, 0);
                numB = Math.Max(requiredB - numC / 2, 0);
                price = GetPrice(priceA, priceB, priceC, numA, numB, numC);
                if (price < min)
                {
                    min = price;
                }
            }
            Console.WriteLine(min);
        }

        private static int GetPrice(int priceA, int priceB, int priceC, int numA, int numB, int numC)
        {
            return priceA * numA + priceB * numB + priceC * numC;
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,x) for (register int (i)=(1);(i)<=(x);(i)++)
#define repd(i,x) for (register int (i)=(x);(i)>=(1);(i)--)
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
using namespace std;
int n,i,s;
int main()
{
	cin>>n;
	rep(i,n/2)if(i+i!=n) s++;
	cout<<s<<endl;
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    
    vector<ll> a(n);
    ll x=0;
    rep(i,n) {
        cin >> a[i];
        x ^= a[i];
    }

    rep(i,n){
        cout << (a[i] ^ x) << " ";
    }
    cout << endl;

    return 0;
}

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

int a, b, c;
int ord2(int n){
  int ret = 0;
  while(n%2==0){
    n /= 2;
    ret++;
  }
  return ret;
}

int main(void){
  cin >> a >> b >> c;
  if (a==b && b==c && a%2==0) {cout << -1 << endl; return 0;}
  int ans = 0;
  while(a%2 + b%2 + c%2 == 0){
    int na = (b+c)/2, nb = (c+a)/2, nc = (a+b)/2;
    a = na; b = nb; c = nc;
    ans++;
  }
  cout << ans << endl; return 0;
}

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

int main(void){
	int s, n, d;
	while(cin >> d){
		s = 0;
		for(int i=d; i<=600-d; i+=d) s += i*i*d;
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <sstream>  // istringstream
#include <vector>

using namespace std;

int main()
{
	std::string S;

	cin >> S;

	int len = S.size();

	// string result("");
	int maxlen = 0;
	for (int i = 1; i < len / 2; ++i){
		string s1 = S.substr(0, i);
		string s2 = S.substr(i, i);
		if (s1 == s2){
			maxlen = i;
			//result = s1 + s2;
		}
		
	}
	cout << maxlen * 2;

	return 0;
}


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

struct Node {
    int key;
    Node *prev, *next;
};

Node *nil;

void init() {
    nil = (Node *)malloc(sizeof(Node));
    nil->prev = nil; 
    nil->next = nil; 
}

void insert(int x) {
    Node *node = (Node *)malloc(sizeof(Node));
    nil->next->prev = node;
    node->next = nil->next;
    nil->next = node;
    node->prev = nil;
    node->key = x;
}

void delete_node(Node *node) {
    if (node == nil) {
        return;
    }

    node->prev->next = node->next;
    node->next->prev = node->prev;
    free(node);
}

void delete_key(int x) {
    Node *node = nil->next;
    while(node != nil) {
        if (node->key == x) {
            delete_node(node);
            break;
        } 
        node = node->next;
    }
}

void delete_first() {
    delete_node(nil -> next);
}

void delete_last() {
    delete_node(nil -> prev);
}

int main() {
    int n;
    cin >> n;
    string command;
    int target;
    init();
    for (int i = 0; i < n; i++) {
        cin >> command;
        if (command == "insert") {
            cin >> target; 
            insert(target);
        } else if (command == "delete") {
            cin >> target;
            delete_key(target);
        } else if (command == "deleteFirst") {
            delete_first();
        } else {
            delete_last();
        }
    }

    Node *node = nil->next;
    while(node != nil) {
        if (node != nil->next) cout << " ";
        cout << node->key;
        node = node->next;
    }
    cout << endl;
}



Measured memory_bytes: 34352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N,X;
    cin >> N >>X;
    int count = 1;
    vector<int> L(N);
    REP(i,N)cin >> L[i];
    int now = 0;
    REP(i,N){
        now += L[i];
        if(now <= X)count++;
    }
    cout << count << "\n";
}

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


using namespace std;

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

	if (0>= b-a) {
		cout <<"delicious" <<endl;
	}
	else if (x >= b - a) {
		cout << "safe" << endl;
	}
	else {
		cout << "dangerous" << endl;
	}





}

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

int main(){
	int apart[4][3][10];
	for (int i = 0; i < 4; i++){
		for (int j = 0; j < 3; j++){
			for (int k = 0; k < 10; k++){
				apart[i][j][k] = 0;
			}
		}
	}
	int n;
	cin >> n;
	int i, j, k, p;
	for (int c = 0; c < n; c++){
		cin >> i >> j >> k >> p;
		apart[i - 1][j - 1][k - 1] += p;
	}
	for (int i = 0; i < 4; i++){
		for (int j = 0; j < 3; j++){
			for (int k = 0; k < 10; k++){
				cout <<" "<< apart[i][j][k];
			}
			cout << endl;
		}
		if (i!=3)
			cout << "####################" << endl;
	}


	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll an[100010],am[100010];
int main()
{int a,b,c;
cin>>a>>b>>c;
if(b-a==c-b)
{cout<<"YES"<<endl;}
else
{cout<<"NO"<<endl;}
 return 0;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())

sum = 0
for n in range(N + 1):
    wa = 0
    sn = str(n)
    size = len(sn)
    for s in range(size):
        wa += int(sn[s])
    if A <= wa and B >= wa:
        sum += n
print(sum)

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

int main() {
  int n,k;
  cin>>n>>k;
 int a=0;
  while(n>0){
    n/=k;
    a++;
  }
  
  cout<<a<<endl;
  
}


Measured memory_bytes: 256
//
// Created on 2020/04/09.
//

#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {

    ll a,b;
    ll k;
    cin>>a>>b>>k;

    if(k > a){
        k -= a;
        a = 0;
        if(k > b){
            b = 0;
        }else{
            b -= k;
        }
    }else{
        a = a - k;
        k = 0;
    }

    cout<<a<<" "<<b<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef long long lint;

int main(){
    int n; cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    int cnt = 0;
    rep(i, n)if(i+1 == a[a[i]-1]) cnt++;
    cout << cnt / 2 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;

int main(){
  string s,t;
  cin >> s>>t; 
 int count=0;
  r(i,s.length()){
    if(s.at(i)==t.at(i))count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256