akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

int per[MAXN];

vi coord[MAXN];

int per1[2][MAXN];

int solve_brute(int n){
	REP(i, 0, 2 * n - 1){
		per1[0][i] = per[i];
	}
	/*REP(j, 0, 2 * n - 1){
		printf("%3d ", per1[0][j]);
	}
	putchar('\n');*/
	REP(i, 0, n - 1){
		int ind = i & 1;
		REP(j, 0, 2 * n - 1){
			per1[ind ^ 1][j] = 0;
		}
		REP(j, i + 1, 2 * n - 1 - i - 1){
			int a[3];
			a[0] = per1[ind][j];
			a[1] = per1[ind][j - 1];
			a[2] = per1[ind][j + 1];
			sort(a, a + 3);
			per1[ind ^ 1][j] = a[1];			
		}
		/*REP(j, 0, 2 * n - 1){
			printf("%3d ", per1[ind ^ 1][j]);
		}
		putchar('\n');*/
	}
	return per1[1 ^ (n & 1)][n - 1];
}

void upd_limits(int n, int ind, int val, int &l, int &r){
	int l1 = ind, r1 = ind + 1, mid = n - 1;
	if (l1 > mid){
		r = min(r, l1);
	} else {
		l = max(l, r1);
	}
}

void upd_left_limit(int n, int val, int l, int r, int &l1){
	l1 = max(l1, l);
	for(; l1 <= r && per[l1] <= val; l1 += 2);
	l1 -= 2;
}

void upd_right_limit(int n, int val, int l, int r, int &r1){
	r1 = min(r1, r);
	for(; r1 >= l && per[r1] <= val; r1 -= 2);
	r1 += 2;
}

int solve_opt(int n){
	REPN(i, 1, 2 * n - 1){
		coord[i].clear();
	}
	
	REP(i, 0, 2 * n - 1){
		coord[per[i]].pb(i);
	}
	int mid = n - 1;
	for(int i = 1, l = 0, l1 = 0, r = 2 * n - 2, r1 = 2 * n - 2; ; i++){
		REP(j, 0, SZ(coord[i])){
			int ind = coord[i][j];
			if (ind < l || ind > r){
				continue;
			}
			if (ind > 0 && per[ind - 1] <= i){
				upd_limits(n, ind - 1, i, l, r);
			}
			if (ind < 2 * n - 2 && per[ind + 1] <= i){
				upd_limits(n, ind, i, l, r);
			}
		}
		upd_left_limit(n, i, l, r, l1);
		upd_right_limit(n, i, l, r, r1);
		if ((l + l1) / 2 >= mid || (r + r1) / 2 <= mid){
			return i;
		}
	}
}

void solve(){
	srand(time(NULL));
	REP(it, 0, 1){	
		int n;
		/*n = rand() % 40 + 5;
		REP(i, 0, 2 * n - 1){
			per[i] = i + 1;
		}
		random_shuffle(per, per + 2 * n - 1);*/
		
		scanf("%d", &n);
		REP(i, 0, 2 * n - 1){
			scanf("%d", &per[i]);
		}
		
		//int a1 = solve_brute(n);
		
		int a2 = solve_opt(n);
		
		/*if (a1 != a2){
			printf("%d\n", n);
			REP(i, 0, 2 * n - 1){
				printf("%d ", per[i]);
			}
			printf("\n%d %d\n", a1, a2);
			return;
		}*/
		
		printf("%d\n", a2);
	}
}   

int main(){
    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

int n, k;
vector<double> a;

bool c(double x){
  int cnt = 0;
  for(int i=0; i<n; i++){
    cnt += (int)(a[i]/x);
    if((int)(a[i]/x)*x == a[i])  cnt--;
  }
  return cnt <= k;
}

int main(){
  cin >> n >> k;
  a.resize(n);
  for(int i=0; i<n; i++)  cin >> a[i];

  double s = 0, t = 1e9+2;
  for(int i=0; i<1000; i++){
    double mid = (s + t) / 2.0;
    if(c(mid))  t = mid;
    else  s = mid;
  }

  int ans = (int)s;
  if(s - (double)(int)(s))  ans++;

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


Measured memory_bytes: 4788
times = []
times.append(int(input()))
times.append(int(input()))
times.append(int(input()))
times.append(int(input()))
times.append(int(input()))
times.sort(key=lambda a:-a % 10)
ans = 0
for i, time in enumerate(times):
  ans += ((time - 1) // 10 + 1) * 10 if i < len(times) - 1 else time
print(ans)

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;

/*
 * To execute Java, please define "static void main" on a class
 * named Solution.
 *
 * If you need more classes, simply define them inline.
 */

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    for(int i=1;i<=5;i++){
      if(sc.nextInt() == 0){
        System.out.println(i);
        return;
      }
    }
  }
}


Measured memory_bytes: 26964
def dfs():
    while len(stack) > 0:
        height, width = stack.pop()
        for k in range(-1, 2):
            for l in range(-1, 2):
                new_h, new_w = height + k, width + l
                if new_h < 0 or new_w < 0 or new_h >= h or new_w >= w:
                    continue
                #訪れていない場所で，そこが島だったら
                if visited[new_h][new_w] == 0 and c[new_h][new_w] == 1:
                    visited[new_h][new_w]  = 1
                    stack.append([new_h, new_w])

    return 1

#実行部分
while True:
    w, h = map(int, input().split())
    #入力が終わるとき
    if w == 0 and h == 0:
        break
    else:
        c = [list(map(int, input().split())) for _ in range(h)]
        visited = [[0] * w for _ in range(h)]
        ans = 0

        #実行部分
        for i in range(h):
            for j in range(w):
                if visited[i][j] == 0 and c[i][j] == 1:
                    visited[i][j] = 1
                    stack = [[i, j]]
                    ans += dfs()
        print(ans)


Measured memory_bytes: 5624
#include<iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
typedef long long int ll;
using namespace std;
int main(){
	string S;
	string T;
	cin >> S >> T;
	vector<int> count(26,0);
	vector<int> count1(26,0);
	vector<int> stock(26,0);
	vector<int> stock1(26,0);
	vector<int> flag(26,0);
	vector<int> flag1(26,0);
	for(int i=0; i<S.size();i++){
		if(S[i]!=T[i]){
			if(stock[(int)T[i]-97]==0){
				stock[(int)T[i]-97]=(int)S[i];
				count[(int)T[i]-97]++;
			}else{
				if(stock[(int)T[i]-97]!=(int)S[i]){
					count[(int)T[i]-97]++;
				}
			}
			if(stock1[(int)S[i]-97]==0){
				stock1[(int)S[i]-97]=(int)T[i];
				count1[(int)S[i]-97]++;
			}else{
				if(stock1[(int)S[i]-97]!=(int)T[i]){
					count1[(int)S[i]-97]++;
				}
			}
		}else{
			if(flag[(int)T[i]-97]==0){
				flag[(int)T[i]-97]++;
				count[(int)T[i]-97]++;
			}
			if(flag1[(int)T[i]-97]==0){
				flag1[(int)T[i]-97]++;
				count1[(int)T[i]-97]++;
			}
		}
			
	}
	
	for(int i=0; i<26;i++){
		if(count[i]>=2 || count1[i]>=2){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;		
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const ll co = 2019;
const ll inf = 2*1e9;

int main() {
    ll l, r;
    cin >> l >> r;

    bool ok = true;
    for (ll i = 0; i <= inf/co; i++) {
        if (co*i < l && r < co*(i+1)) {
            ok = false;
            break;
        }
    }
    if (ok) cout << 0 << endl;
    else {
        int n_l = l % co;
        int n_r = r % co;
        vector<int> tmp;
        for (int i = n_l; i <= n_r; i++) {
            tmp.push_back(i);
        }
        ll ans = inf;
        int n_tmp = tmp.size();
        rep(i,n_tmp)rep(j,i) {
            ans = min(ans,((tmp[i]%co)*(tmp[j]%co))%co);
        }
        cout << ans << endl;
    }
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i];
    if(i == SZ(s)-1) {
      cout << endl;
    } else {
      cout << " ";
    }
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  while(1) {
    int t; string s; cin >> t >> s;
    if(t == 0 && s == "0") break;
    int n = s.length();
    bool reject = false;
    int sum = -INF;
    vector<int> res;
    for(int i=0;i<(1<<(n-1));i++) {
      int stmp = 0, tmp = 0;
      bool update = false;
      vector<int> v;
      for(int j=0;j<n;j++) {
        update = true;
        tmp *= 10;
        tmp += (s[j] - '0');
        if((i>>j) & 1) {
          stmp += tmp;
          v.push_back(tmp);
          tmp = 0;
          update = false;
        }
      }
      if(update) {
        stmp += tmp;
        v.push_back(tmp);
      }
      if(stmp < sum || t < stmp) {
        continue;
      }
      if(stmp == sum) {
        reject = true;
      } else {
        reject = false;
        res = v;
        sum = stmp;
      }
    }
    if(sum == -INF) {
      cout << "error" << endl;
    } else if(reject) {
      cout << "rejected" << endl;
    } else {
      cout << sum;
      for(int i=0;i<(int)res.size();i++) {
        cout << " " << res[i];
      }
      cout << endl;
    }
  }
}



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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    string s; cin >> s;
    if(s[0]=='R'&&s[1]=='R'&&s[2]=='S') cout << 2 << endl;
    else if(s[0]=='S'&&s[1]=='R'&&s[2]=='R') cout << 2 << endl;
    else if(s[0]=='R'&&s[1]=='R'&&s[2]=='R') cout << 3 << endl;
    else if(s[0]=='R'&&s[1]=='S'&&s[2]=='R') cout << 1 << endl;
    else  cout << count(ALL(s),'R') << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstdio>
using namespace std;

#define int long long
#define INF 1e18

// signed main() {
//     string s; cin >> s;
//     int ans = INF;
//     for(int i = 0; i < s.size() - 2; i++) {
//         int tmp = abs(atoi(s.substr(i, 3).c_str()) - 753);
//         ans = min(ans, tmp);
//     }
//     cout << s.substr(0, 2) << endl;
// }

signed main() {
    string s;  cin >> s;
    int ans = INF;
    for(int i = 0; i < s.size() - 2; i++) {
        string sub = s.substr(i, 3);
        int tmp = atoi(sub.c_str());
        int diff = abs(tmp - 753);
        ans = min(ans, diff);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>

using namespace std;

struct dice{
	int q1,q2,q3,q4,q5,q6;
};

void mN(dice &d){
	int tmp=d.q1;
	d.q1=d.q2;
	d.q2=d.q6;
	d.q6=d.q5;
	d.q5=tmp;
}

void mE(dice &d){
	int tmp=d.q1;
	d.q1=d.q4;
	d.q4=d.q6;
	d.q6=d.q3;
	d.q3=tmp;
}
void mW(dice &d){
	int tmp=d.q1;
	d.q1=d.q3;
	d.q3=d.q6;
	d.q6=d.q4;
	d.q4=tmp;
}
void mS(dice &d){
	int tmp=d.q1;
	d.q1=d.q5;
	d.q5=d.q6;
	d.q6=d.q2;
	d.q2=tmp;
}

void spin(dice &d){
	int tmp=d.q2;
	d.q2=d.q3;
	d.q3=d.q5;
	d.q5=d.q4;
	d.q4=tmp;
}

int main(){
	dice z;
	int q;
	
	scanf(" %d %d %d %d %d %d", &z.q1, &z.q2, &z.q3, &z.q4, &z.q5, &z.q6);
	scanf(" %d", &q);
	
	for(int i=0; i<q; ++i){
		int a, b;
		dice x=z;
		
		scanf(" %d %d", &a, &b);
		
		if(a==x.q3 || a==x.q4) mE(x);
		while(a != x.q1) 
			mN(x);
		while(b != x.q2)
			spin(x);
		
		printf("%d\n", x.q3);	
	}
	
	return 0;
}



Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int taro = 0;
        int hanako = 0;
        int scint = sc.nextInt();
        for (int i = 0; i < scint; ++i) {
            int c = sc.next().compareTo(sc.next());
            if (c > 0) {
                taro += 3;
            } else if (c == 0) {
                taro++;
                hanako++;
            } else {
                hanako += 3;
            }
        }
        System.out.println(taro + " " + hanako);
    }
}

Measured memory_bytes: 29636
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string S;
    cin >> S;
    
        if (S == "Sunny") {
            cout << "Cloudy" << endl;
        
        }
        
        if (S == "Cloudy") {
            cout << "Rainy" << endl;
        
        }
       
        if (S == "Rainy") {
            cout << "Sunny" << endl;
        
        }    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
struct data{int to,next,wi;}e[maxn*2];
int head[maxn];
int cnt=0;
int du[maxn];
queue<int> q;
bool vis[maxn];
void ins(int u,int v,int ww)
{
	e[++cnt].to=v;
	e[cnt].next=head[u];
	e[cnt].wi=ww;
	head[u]=cnt;
}
int n,m;
int dis[maxn];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		ins(x,y,z);
		du[y]++;
	}
	for(int i=1;i<=n;i++)dis[i]=1e9+10;
	for(int s=1;s<=n;s++)
	{
		if(du[s]==0)
		{
			dis[s]=0;
			vis[s]=1;
			q.push(s);
			while(!q.empty())
			{
				int x=q.front();
				q.pop();
				for(int i=head[x];i;i=e[i].next)
				{
					int u=e[i].to;
					if(vis[u]==1&&dis[u]!=dis[x]+e[i].wi&&du[x]!=0)
					{
						puts("No");
						return 0;
					}
					if(vis[u]==0)
					{
						vis[u]=1;
						dis[u]=min(dis[u],dis[x]+e[i].wi);
						q.push(u);
					}
				}
			}
		}
	}
	for(int i=1;i<=n;i++)if(vis[i]==0){puts("No");return 0;}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 4224
n,m = map(int,input().split())
a = []
for i in range(n):
    a.append(input())
dp = [[0 for i in range(m)] for j in range(n)]
for i in range(m):
    if a[0][i]=='.':
        dp[0][i]=1
    else:
        break
for i in range(n):
    if a[i][0]=='.':
        dp[i][0]=1
    else:
        break
for i in range(1,n):
    for j in range(1,m):
        if a[i][j]=='.':
            dp[i][j]=(dp[i-1][j]+dp[i][j-1])%1000000007
print(dp[-1][-1]%1000000007)

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

int main(){
	LL n,a,b;
	cin>>n>>a>>b;
	if(b<a){
		swap(a,b);
	}
	LL ans;
	if(a%2==b%2){
		ans=(b-a)/2;
	}
	else{
		ans=min(a-1+1+(b-a-1)/2,n-b+1+(b-a-1)/2);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<int> d(N);
  rep(i,N)cin >> d[i];
  sort(all(d));
  cout << d[N/2] - d[N/2-1] << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.*;
class Main {
		public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			Set<Integer> set = new HashSet<>();
			for (int i = 0; i < N; i++) {
				int A = sc.nextInt();
				if (set.contains(A)) {
					set.remove(A);
				} else {
					set.add(A);
				}
			}
			System.out.println(set.size());
		}
}

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

#include <vector>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
using namespace std;

int main() {
  long n, m, k;
  cin >> n >> m >> k;
  long a[n], b[m];
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];
  long a_now, b_now;
  // cout << sizeof(a) / sizeof(*a) << endl;
  a_now = b_now = 0;
  long min = 0;
  long count = 0;
  long max_count = 0;

  while (min <= k && b_now < m) {
    if (min + b[b_now] <= k) {
      min += b[b_now];
      count++;
      b_now++;
    } else {
      break;
    }
  }

  while (min <= k && a_now < n) {
    if (min + a[a_now] <= k) {
      min += a[a_now];
      count++;
      a_now++;
    } else {
      break;
    }
  }
  max_count = count;
  while (b_now > 0) {
    b_now--;
    count--;
    min -= b[b_now];
    while (min <= k && a_now < n) {
      //   if (a_now + 1 < n) {
      if (min + a[a_now] <= k) {
        min += a[a_now];
        a_now++;
        count++;
      } else {
        break;
      }
      //   }
    }
    if (count > max_count) {
      max_count = count;
    }
  }
  cout << max_count << endl;
}

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

void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
    int size = sizeof...(Tail);
    cout << head;
    if (size > 0) {
        cout << " ";
    }
    print(tail...);
}

void print0() {}
template <typename Head, typename... Tail>
void print0(Head head, Tail... tail) {
    cout << head;
    print0(tail...);
}

struct edge {
    ll u;
    ll v;
    ll a;
    ll b;
};
int main() {
    ll n, m, s, t;
    cin >> n;
    cin >> m;
    cin >> s;
    cin >> t;
    vector<edge> edges;
    vector<vector<edge>> edgemap(n + 1);
    for (ll j = 0; j < m; j++) {
        edge e;
        cin >> e.u;
        cin >> e.v;
        cin >> e.a;
        cin >> e.b;
        edge ee;
        ee.u = e.v;
        ee.v = e.u;
        ee.a = e.a;
        ee.b = e.b;
        edges.push_back(e);
        edgemap[e.u].push_back(e);
        edgemap[ee.u].push_back(ee);
    }
    ll init_yen = 1000000000000000LL;

    vector<ll> min_yen(n + 1);
    for (ll j = 0; j <= n; j++) {
        min_yen[j] = init_yen + 1;
    }
    min_yen[s] = 0;
    set<ll> instack;
    instack.insert(s);
    while (!instack.empty()) {
        ll nod = (*instack.begin());
        instack.erase(nod);
        for (auto e : edgemap[nod]) {
            auto yen_cost = min_yen[nod] + e.a;
            if (min_yen[e.v] > yen_cost) {
                min_yen[e.v] = yen_cost;
                if (instack.count(e.v) == 0) {
                    instack.insert(e.v);
                }
            }
        }
    }

    vector<ll> min_snuuk(n + 1);
    for (ll j = 0; j <= n; j++) {
        min_snuuk[j] = init_yen + 1;
    }
    min_snuuk[t] = 0;
    set<ll> k_instack;
    k_instack.insert(t);
    while (!k_instack.empty()) {
        ll nod = (*k_instack.begin());
        k_instack.erase(nod);
        for (auto e : edgemap[nod]) {
            auto snuuk_cost = min_snuuk[nod] + e.b;
            if (min_snuuk[e.v] > snuuk_cost) {
                min_snuuk[e.v] = snuuk_cost;
                if (k_instack.count(e.v) == 0) {
                    k_instack.insert(e.v);
                }
            }
        }
    }

    vector<pair<ll, ll>> last_snuuk(n + 1);
    for (int i = 1; i <= n; i++) {
        last_snuuk[i] = make_pair(i, init_yen - min_yen[i] - min_snuuk[i]);
    }
    last_snuuk[0] = make_pair(0, -1);

    sort(last_snuuk.begin(), last_snuuk.end(), [](pair<ll, ll> p, pair<ll, ll> q) { return p.second > q.second; });

    ll year = 0;
    ll city = 0;
    vector<ll> result(n);
    while (year < n) {
        if (last_snuuk[city].first > year) {
            result[year] = last_snuuk[city].second;
            year++;
        } else {
            city++;
        }
    }

    for (auto r : result) {
        cout << r << endl;
    }
}


Measured memory_bytes: 21552
#include <bits/stdc++.h>
using namespace std;
// #define int long long
typedef long long ll;
typedef pair<int,int> pii;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=(int)(n);v>=0;v--)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int INF = 1e9;
const ll INFLL = 1e18;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":" ");return os;}
//------------------------------------------------------------------------------

signed main() {
    vector<bool> a(30,false);
    REP(i,30) {
        int x;
        cin>>x;
        a[x-1]=true;
    }
    REP(i,30) {
        if(!a[i]) cout<<i+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vec;

#define vecc vector<vector<ll>>
#define LM LLONG_MAX
#define int long long int
 
#define ff first
#define ss second
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

#define M 1000020
#define MOD 1000000007

signed main()
{
        FAST;
        
        ll n;
        cin>>n;
        
        vec a(n),b(n);
        
        for(int i=0;i<n;i++)  cin>>a[i],    b[i]=a[i];
        
        sort(a.begin(),a.end());
        
        ll m1=a[n-1],m2=a[n-2];
        

        for(int i=0;i<n;i++)     
        {
                if(b[i]==m1)    cout<<m2<<endl;
                else            cout<<m1<<endl;
        }
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<string,int> p;
int main(){
    int n,tag=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        string s;
        cin>>s;
        p[s]++;
    }
    int mx=0;
    for(auto x:p){
        mx=max(mx,x.second);
    }
    for(auto x:p){
        if(x.second==mx){
            cout<<x.first<<endl;
        }
    }
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N;
  string S;
  cin >> N >> S;

  vector<long long> countR(N, 0), countG(N, 0), countB(N, 0);
  REVERSE(S);
  rep(i, N)
  {
    char color = S[i];

    if (i != 0)
    {
      countR[i] += countR[i - 1];
      countG[i] += countG[i - 1];
      countB[i] += countB[i - 1];
    }

    if (color == 'R')
      countR[i]++;
    else if (color == 'G')
      countG[i]++;
    else if (color == 'B')
      countB[i]++;
  }
  REVERSE(countR);
  REVERSE(countG);
  REVERSE(countB);
  REVERSE(S);

  long long ans = 0;
  rep(i, N)
  {
    if (S[i] == 'R')
      ans += countG[i] * countB[i];
    else if (S[i] == 'G')
      ans += countB[i] * countR[i];
    else if (S[i] == 'B')
      ans += countR[i] * countG[i];
  }

  rep(i, N) rep(j, N)
  {
    int ir = i;
    int ig = i + (j + 1);
    int ib = i + 2 * (j + 1);

    if (ig > N - 1 || ib > N - 1)
      continue;

    if (S[ir] == 'R' && S[ig] == 'G' && S[ib] == 'B')
      ans--;
    else if (S[ir] == 'R' && S[ig] == 'B' && S[ib] == 'G')
      ans--;
    else if (S[ir] == 'B' && S[ig] == 'G' && S[ib] == 'R')
      ans--;
    else if (S[ir] == 'B' && S[ig] == 'R' && S[ib] == 'G')
      ans--;
    else if (S[ir] == 'G' && S[ig] == 'B' && S[ib] == 'R')
      ans--;
    else if (S[ir] == 'G' && S[ig] == 'R' && S[ib] == 'B')
      ans--;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3704
"use strict";

const main = (input) => {
    const spi = input.split('\n');
    const n = Number(spi[0]);
    const a = spi[1].split(' ').map(e => Number(e));

    const array = new Array(n).fill(0);
    for (let i = 0; i < n; i++) {
        array[a[i] - 1]++;
    }

    for (let i = 0; i < n; i++) {
        console.log(array[i]);
    }
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 61856
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int[] n = new int[9];
            char[] list = sc.nextLine().toCharArray();
            for (int i : list) {
                n[i - '1']++;
            }
            List<Integer> result = new ArrayList<>();

            for (int i = 0; i < 9; i++) {
                 for (int j = 0; j < 9; j++) {
                    if (n[i] < 4 && (n[j] >= 2 || n[i] >= 1)) {
                        int[] temp = n.clone();
                        temp[i]++;
                        temp[j] -= 2;
                        for (int k = 0; k < 7; k++) {
                            if ((temp[k] == 1 || temp[k] == 4) && temp[k + 1] > 0 && temp[k + 2] > 0) {
                                temp[k]--;
                                temp[k + 1]--;
                                temp[k + 2]--;
                            }
                            if (temp[k] == 2 && temp[k + 1] >= 2 && temp[k + 2] >= 2) {
                                temp[k] -= 2;
                                temp[k + 1] -= 2;
                                temp[k + 2] -= 2;
                            }
                        }
                        boolean f = true;
                        for (int k : temp) {
                            if (k % 3 != 0) {
                                f = false;
                                break;
                            }
                        }
                        if (f) {
                            result.add(i + 1);
                            break;
                        }
                    }
                }
            }
            if (result.isEmpty()) {
                System.out.println(0);
            } else {
                for (int i = 0; i < result.size(); i++) {
                    System.out.print(i<result.size()-1?result.get(i) + " ":result.get(i)+"\n");
                }
            }
        }
    }
}


Measured memory_bytes: 25876
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define INF 1e8
#define s second
#define f first
using namespace std;
int main(){
  int t,n;
  while(cin>>t,t){
    int cy[t];
    r(i,t)cin>>cy[i];
    cin>>n;
    int d[101];
    r(i,101)d[i]=INF;
    r(i,n){
      int p1,p2;
      cin>>p1>>p2;
      d[p1]=min(d[p1],p2);
    }
    int dp[101][30];
    r(i,30)r(j,101)dp[j][i]=INF;
    dp[1][0]=0;
    for(int i=2;i<101;i++){
      dp[i][0]=dp[i-1][t-1];
      r(j,t-1)dp[i][0]=min(dp[i][0],dp[i-1][j]+1);
      for(int j=1;j<t;j++)
        if(d[i]<cy[j])dp[i][j]=INF;
        else dp[i][j]=dp[i-1][j-1];
    }
    int ans=INF;
    r(i,30)ans=min(ans,dp[100][i]);
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3092
//bismillah
//author anaksoleh
//26 Dec 2019
#include <bits/stdc++.h>
using namespace std;

const int SIZE = 1e5 + 5;
int N;
int dp[SIZE][4];
int arr[SIZE][4];

void solve()
{
    for(int i = 1 ; i <= 3 ; i++){
        dp[1][i] = arr[1][i];
    }
    for(int r = 2 ; r <= N ; r++){
        for(int col_dp = 1 ; col_dp <= 3 ; col_dp++){
            int best = 0;
            for(int c = 1 ; c <= 3 ; c++){
                 if(c == col_dp)continue;
                 best = max(best,dp[r-1][c] + arr[r][col_dp]);
            }
            dp[r][col_dp] = best;            
        }
    }
}


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> N;
    for(int i = 1 ; i <= N ; i++){
        cin >> arr[i][1] >> arr[i][2] >> arr[i][3];
    }
    solve();
    int ans = 0;
    for(int i = 1 ; i <= 3 ; i++) ans = max(ans,dp[N][i]);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3328
/*ex3_3
ryo_1129*/
#include <stdio.h>

int main(void){
	int N,K,i,division; //変数宣言
	scanf("%d %d",&N,&K); //入力整数NとK進数
	division = N; 
	i = 0; //桁数を数える変数
	//NがK以上の場合、商がK未満になるまで割る
	while(division >= K){
		division = division/K;
		i++ ; //割った回数の記録
	}
	printf("%d\n",i+1);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define inf INT_MAX/2

using namespace std;

int l[100050], r[100050], p[100050], ass[100050];
int n, t;
vector<int> adjlist[100050];
bool ans = true;

void dfs(int x, int par){
	for(auto i : adjlist[x]) if(i != par){
		if(l[x] != -inf and r[x] != inf){ // range is set
			l[i] = max(l[i], l[x]-1);
			r[i] = min(r[i], r[x]+1);
			if(p[i] == -1){
				p[i] = 1-p[x];
			}else{
				if(p[i] == 1-p[x]) ans = ans;
				else ans = false;
			}
		}
//		printf("pre %d -> %d: %d %d %d\n", x, i, l[x], r[x], p[x]);
		dfs(i, x);
		if(l[i] != -inf and r[i] != inf){
			l[x] = max(l[x], l[i]-1);
			r[x] = min(r[x], r[i]+1);
			if(p[x] == -1){
				p[x] = 1-p[i];
			}else{
				if(p[x] == 1-p[i]) ans = ans;
				else ans = false;
			}
		}
//		printf("pos %d -> %d: %d %d %d\n", x, i, l[x], r[x], p[x]);
	}
}
void cons(int x, int par){
	if(l[x] > r[x]) ans = false;
	ass[x] = l[x];
	if(abs(l[x]%2) != p[x]) ass[x]++;
	if(ass[x] > r[x]) ans = false;
	for(auto i : adjlist[x]) if(i != par){
		l[i] = max(l[i], l[x]-1);
		r[i] = min(r[i], r[x]+1);
		cons(i, x);
	}
}

int main(){
//	freopen("arc063.in","r",stdin);
	cin >> n;
	for(int i=1; i<n; ++i){
		int a, b; cin >> a >> b;
		adjlist[a].push_back(b);
		adjlist[b].push_back(a);
	}
	for(int i=1; i<=n; ++i){
		l[i] = -inf;
		r[i] = inf;
		p[i] = -1;
	}
	cin >> t;
	for(int i=1; i<=t; ++i){
		int a,b; cin >> a >> b;
		l[a] = r[a] = b;
		p[a] = b%2;
	}
//	for(int i=1; i<=n; ++i) printf("%d %d : %d\n", l[i], r[i], p[i]);
	dfs(1, -1);
	dfs(1, -1);
	cons(1, -1);
	if(ans) cout << "Yes\n";
	else{ cout << "No"; return 0; }
	for(int i=1; i<=n; ++i) cout << ass[i] << "\n";
}


Measured memory_bytes: 15744
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Iterator;
import java.util.Collections;
import java.util.Comparator;
import java.util.Random;
import java.util.Map;
import java.util.HashMap;
 
class Main{
        public static void main(String args[]){
                Scanner sc = new Scanner(System.in);
                int Q = sc.nextInt();
                int[] l = new int[Q];
                int[] r = new int[Q];
                int maxR=0;
                int minL=10000;
                for(int i=0; i<Q; i++){
                    l[i] = sc.nextInt();
                    r[i] = sc.nextInt();
                    maxR = Math.max(maxR,r[i]);
                    minL = Math.min(minL,l[i]);
                }
                ArrayList<Integer> sosu = new ArrayList<Integer>();
                //ArrayList<Integer> niteru = new ArrayList<Integer>();
                //素数を(minL+1)/2からmaxRまで列挙
                int[] ans = new int[Q];
                for(int i=0; i<Q; i++)ans[i]=0;
                boolean ch = true;
                //int start = Math.max((minL+1)/2, 3);
                //if(start % 2 ==0)start++;
                sosu.add(2);
                
                for(int i=3; i<=maxR; i+=2){
                    ch = true;
                    for(int j=1; j<sosu.size(); j++){
                        if(i%sosu.get(j)== 0){
                            ch =false;
                            break;
                        }
                    }
                    if(ch){
                    sosu.add(i);
                    if(sosu.indexOf((i+1)/2) != -1){
                        //niteru.add(i);
                        for(int k=0; k<Q; k++){
                            if(l[k]<=i && i<=r[k]){
                                ans[k] ++;
                            }
                        }
                    }
                    }
                }
                
                for(int i=0; i<Q; i++){
                    System.out.println(ans[i]);
                }
        }
}

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

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	 printf
#define sf			 scanf
#define pb(a)        push_back(a)
#define mp			 make_pair
#define ff			 first
#define ss			 second
#define for0(i,n)    for(int i=0;i<n;i++)
#define for1(i,n)    for(int i=1;i<=n;i++)
#define forab(i,a,b) for(int i=a;i<=b;i++)
#define lcm(a, b)    ((a)*((b)/gcd(a,b)))
#define sq(a)		 (a)*(a)
#define endl		     "\n"
#define abs(x)		 fabs(x)
#define all(v) 		 v.begin(),v.end()
#define pcase(z,x)   cout<<"Case "<<z<<": "<<x<<"\n"
#define mod 1000000007
#define WakandaForever     ios_base::sync_with_stdio(0); cin.tie(0);
ll fac[1000007];
ll pow_mod(ll a, ll b){
    ll res=1;
    while(b){
        if(b&1) res = (res*a)%mod;
        a = (a*a)%mod;
        b /= 2;
    }
    return res%mod;
}

int main()
{
    WakandaForever
    
    ll n;
    cin>>n;
    ll x = (pow_mod(9,n) + pow_mod(9,n))%mod;
    x = (x - pow_mod(8,n))%mod;
    ll ans = (pow_mod(10,n) - x)%mod;
    cout<<(ans+mod)%mod<<endl;


    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount



int t, n, m, k, a, b, q, l;



int32_t main(){
INIT

cin>>a>>b;
cout<<a*b;


return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cctype>
#include <queue>
#include <stdlib.h>
#include <cstdlib>
#include <math.h>
#include <set>
#include"queue"
#include <vector>
#define inf 107374182
#define M 10010001
#define ll long long
#define PII pair<int,int>
using namespace std;
const int N=200110;
ll mod=1e9+7;
int main()
{
	ll n;
	scanf("%lld",&n);
	if(n==1)
	{
		printf("%d\n",0);
		return 0;
	 } 
	ll sum1=1;
	for(int i=0;i<n;i++)
	{
		sum1=sum1*10%mod;
	}
	ll sum2=1;
	for(int i=0;i<n;i++)
	{
		sum2=sum2*9%mod;
	}
	ll sum3=1;
	for(int i=0;i<n;i++)
	{
		sum3=sum3*8%mod;
	}
	//ans=ans%mod;
    printf("%lld\n",(((sum1-2*sum2)%mod+mod)%mod+sum3)%mod);
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
ll modPow(long long a, long long n, long long p) {
  return (n == 1)? a: a * modPow(a, n - 1, p) % p;
}
int main()
{
    ll mod = 2019;
    string s;
    cin >> s;
    s += '0';
    int n = s.size();
    map<ll,ll> cnt;
    ll ans = 0;
    ll x = 0;
    int keta = 10;
    for(int i = n-1;i >= 0; i--){
        ll m = s[i] - '0';
        
        x += m*keta;
        keta *= 10;
        keta %= mod;
        x %= mod;
        if (x <0)x += mod;
        ans  += cnt[x];
        cnt[x]++;
        
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3756
#include <iostream>
using namespace std;
int main(void){
    int m,f,b;
    cin>>m>>f>>b;
    if(m>b){
        cout<<"0"<<endl;
    }else if(m+f<b){
        cout<<"NA"<<endl;
    }else{
        cout<<f-((m+f)-b)<<endl;
    }
}



Measured memory_bytes: 3100
#include <iostream>
using namespace std;
long Gcd(long m, long n);
long div(long,long,long);
int main(void){
    long A,B,C,D;
    long divC,divD,divCD;
    cin >> A >> B >> C >> D;
    divC = div(A,B,C);
    divD = div(A,B,D);
    long gc = C*D / Gcd(C,D);
    divCD = div(A,B,gc);
    cout << (B-A)+1 - (divC+divD-divCD) << endl;
}
long Gcd(long m, long n)
{
	long temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}
long div (long A,long B,long X){
    return B/X - (A-1)/X;
}


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

int a[200010];
 int ans[200010];
 int main()
 {
 int n;
 scanf("%d",&n);
 for(int i=2;i<=n;i++)scanf("%d",&a[i]);
 for(int i=2;i<=n;i++)ans[a[i]]++;
 for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
 }

Measured memory_bytes: 5320
import java.util.*;
import java.util.Calendar;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 入力値を変数に代入
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
        int d = sc.nextInt();
		// 文字列の入力
        Calendar calendar = Calendar.getInstance();
        calendar.set(2019, a-1, b);
        int day = calendar.getActualMaximum(Calendar.DATE);
        if(day == b){
          	// 出力
        	System.out.println("1");
        }
      	else{
        	// 出力
        	System.out.println("0");
        }
	}
}

Measured memory_bytes: 24016
#include <iostream>

using namespace std;

int main(){
   int n,m,k;
   int card[200];
   int tmp[200];
   cin>>n>>m;
   for(int i=0; i<200; i++) card[i] = i+1;
   for(int i=0; i<m; i++){
      cin>>k;
      if(k==0){
         int k=0;
         for(int j=0;k<n;){
            tmp[j]=card[k];
            j++;
            tmp[j]=card[n+k];
            j++;
            k++;
         }
      }else{
         for(int j=0; j<2*n-k; j++)tmp[j]=card[j+k];
         for(int j=0; j<k; j++)tmp[2*n-k+j]=card[j];
      }
      for(int j=0; j<2*n; j++)card[j]=tmp[j];
   }
   for(int i=0; i<2*n; i++){
     printf("%d\n",card[i]);
   }
   return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define pr_arr(name, a, b) \
  for (int i = (a); i < (b); i++) { \
    for (int j = (a); j < (b); j++) {\
      if (j > (a)) printf(" "); \
      printf("%lld", name[i][j]); \
    }\
    printf("\n");\
  }\

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

typedef long long ll;

int ans;
int N;
int A[20];
int x[20][20]; // [i][j] i番目の人のj番目の証言はxについていっている
int y[20][20]; // [i][j] i番目の人はj番目の証言は0か1
int t[20];

int main(void) {
    scanf("%d", &N);
    rep(i, 0, N) {
      scanf("%d", &A[i]);
      rep(j, 0, A[i]) {
        int a, b;
        scanf("%d %d", &a, &b);
        x[i][j] = a-1;
        y[i][a-1] = b;
      }
    }



    for (int i = 0; i < 1<<N; i++) {
      bool flag = true;
      for (int j = 0; j < N; j++) {
        if (i>>j & 1) t[j] = 1;
        else t[j] = 0;

        //printf("%d", t[j]);
      }
      //printf("\n");

      rep(j, 0, N) {
        if (t[j]) {
          rep(k, 0, A[j]) {
            //DEBUG_INT(y[j][x[j][k]]);
            //DEBUG_INT(t[x[j][k]]);
            if (y[j][x[j][k]] != t[x[j][k]]) flag = false;
          }
        }
      }

      int sum = 0;
      if (flag) {
        for (int j = 0; j < N; j++) {
          if (t[j]) sum++;
        }
      }

      ans = max(sum, ans);
      

    }
   

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

	return 0;
}


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

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

  ll A, B, C; cin >> A >> B >> C;
  for (int i = 0; i <= 100; i++) {
    if (A % 2 == 1 or B % 2 == 1 or C % 2 == 1) {
      cout << i << endl;
      return 0;
    }
    ll a = A, b = B, c = C;
    A = (b + c) / 2;
    B = (a + c) / 2;
    C = (a + b) / 2;
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		double N = sc.nextInt();
		double K = sc.nextInt();
		double ans = 0;
		for (double i = 1; i <= N; i++) {
			for (double j = 0; j <= 20; j++) {
				if (K <= i * Math.pow(2, j)) {
					ans += (1 / (N * (Math.pow(2, j))));
					break;
				}
			}
		}
		System.out.println(ans);

	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
int read(){ int x=0; char ch=getchar(); while (!isdigit(ch)) ch=getchar(); while (isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar(); return x; }
const int N=100005,mod=1e9+7;
int n,a[N],in[N],size[N],vis[N],cro[N]; int q[N],head,tail; int k[N],m; int r[N]; void add(int &x,int y){ if ((x+=y)>=mod) x-=mod; } int sc=0;
int Pre(int k,int n){ return k==1?n:(k-1); }
int solve(int n){
    int ans=1,f=0;
    for (int i=1;i<=n;i++){
        if (k[i]==0) continue;
        f=1; int x=Pre(i,n); while (!k[x]) x=Pre(x,n); int t=(i-x+n)%n;
        if (t==0) t+=n; if (t<k[i]) return 0; if (t>k[i]) ans=2LL*ans%mod;
    }
    if (!f) r[n]++;
    return ans;
}
int dp[N];
int main(){
    n=read();
    memset(in,0,sizeof in);
    for (int i=1;i<=n;i++){
        in[a[i]=read()]++;
        size[i]=1;
    }
    head=tail=0;
    for (int i=1;i<=n;i++){
        if (in[i]>2)
            return puts("0"),0;
        if (in[i]==0)
            q[++tail]=i;
        if (in[i]==2)
            cro[i]=1;
    }
    while (head!=tail){
        int x=q[++head],y=a[x];
        size[y]+=size[x];
        if (!(--in[y]))
            q[++tail]=y;
    }
    for (int i=1;i<=n;i++)
        if (cro[i]&&!in[i])
            return puts("0"),0;
    int ans=1;
    memset(vis,0,sizeof vis);
    for (int i=1;i<=n;i++){
        if (in[i]==0||vis[i])
            continue;
        m=0;
        for (int x=i;!vis[x];x=a[x])
            vis[x]=1,k[++m]=size[x]-1;
        ans=1LL*ans*solve(m)%mod;
    }
    for (int i=1;i<=n;i++)
        if (r[i]>0){
            dp[0]=1,dp[1]=i>1&&(i&1)?2:1;
            for (int j=2;j<=r[i];j++)
                dp[j]=(1LL*(j-1)*i%mod*dp[j-2]+dp[j-1]*(i>1&&(i&1)?2:1))%mod;
            ans=1LL*ans*dp[r[i]]%mod;
        }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#define llint long long

using namespace std;

llint n, u, v;
vector<llint> G[100005];
llint distT[100005], distA[100005];
bool used[100005];

void dfs(int v, int p, int d, llint dist[])
{
	dist[v] = d;
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] == p) continue;
		dfs(G[v][i], v, d+1, dist);
	}
}

void dfs2(int v, int p)
{
	used[v] = true;
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] == p) continue;
		if(distA[G[v][i]] <= distT[G[v][i]]) continue;
		dfs2(G[v][i], v);
	}
}


int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> u >> v;
	llint x, y;
	for(int i = 1; i <= n-1; i++){
		cin >> x >> y;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	dfs(u, -1, 0, distT);
	dfs(v, -1, 0, distA);
	dfs2(u, -1);
	
	llint ans = 0;
	for(int i = 1; i <= n; i++){
		if(used[i]) ans = max(ans, distA[i]);
	}
	cout << ans-1 << endl;
	
	return 0;
}

Measured memory_bytes: 13952
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;
typedef pair<int,int>P;

int main(){

  int n,m;cin>>n>>m;
  P num[1000010];
  rep(i,0,m)cin>>num[i].second>>num[i].first;
  sort(num,num+m);
  int mi=0,ans=0;
  rep(i,0,m){
    if(num[i].second>=mi){
      ans++;
      mi=num[i].first;
    }
  }
  out(ans);

  return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
  int n, m, R;
  cin >> n >> m >> R;

  vector<int> r(R);
  for (int i = 0; i < R; i++) {
    cin >> r[i];
    r[i]--;
  }
  sort(r.begin(), r.end());

  ll d[210][210];
  fill(d[0], d[210], 1LL << 30);
  for (int i = 0; i < n; i++) {
    d[i][i] = 0;
  }

  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    d[a][b] = d[b][a] = c;
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

  ll ans = 1LL << 30;
  do {
    ll sub = 0;
    for (int i = 0; i + 1 < R; i++) {
      sub += d[r[i]][r[i + 1]];
    }
    ans = min(ans, sub);
  } while (next_permutation(r.begin(), r.end()));
  cout << ans << endl;

  return 0;
}

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

int main(){
  bool finished = false;
  int N;
  int M;
  cin >> N;
  cin >> M;
  vector<int> A(N);
  for (int i=0 ; i < N ; i++){
    cin >> A.at(i);
  }
  vector<pair<int,int>> CB(M);
  for (int i=0 ; i < M ; i++){
    cin >> CB.at(i).second;
    cin >> CB.at(i).first;
  }
  
  sort(A.begin() , A.end());
  sort(CB.begin() , CB.end());
  reverse(CB.begin() , CB.end());
  
  vector<int> D(N);
  int j = 0;
  
  for (int k=0 ; k < M; k++){
    for (int i = 0 ; i < CB.at(k).second ; i++){
      D.at(j) = CB.at(k).first;
      j++;
      if (j == N){
        finished = true;
        break;
      }
    }
    if (finished){break;}
  }
  
  int l = 0;
  while ( D.at(l) > A.at(l) ) {
    A.at(l) = D.at(l);
    l++;
    if (l == N){break;}
  }
   
  int64_t sum;
  for (int i =0 ; i < N; i++){
    sum += A.at(i);
  }
  
  cout << sum;
}
    
    

Measured memory_bytes: 1792
#a,bの入力
a,b=map(int,input().split())
#a,bの積を演算する
a_to_b_no_seki=a*b
#a,b,の積を2で割った余りを計算し、余りが0なら偶数と出力、1なら奇数と出力
if a_to_b_no_seki%2==0:
    print("Even")
else:
    print("Odd")

Measured memory_bytes: 2940