akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	static long[] fibTable = new long[45];
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		 // TODO Auto-generated method stub
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        
        fibTable[0] = 1;
        fibTable[1] = 1;
        for(int i = 2; i <= 44 ; i++){
        	fibTable[i] = fibTable[i - 1] + fibTable[i - 2];
        }
        
        System.out.println(fibTable[n]);
	}
	
	static int fibonacci (int n){
		if(n == 0){
			return 1;
		}
		else if(n == 1){
			return 1;
		}
		else {
			return fibonacci(n - 1) + fibonacci(n - 2);
		}
	}

}

Measured memory_bytes: 24256
N= int(input())
A = list(map(int,input().split()))

odd_flag = 0
counter = 0
while 1:
    for i in range(N-1):
        if A[i]%2 == 1:
            odd_flag=1
        A[i] //= 2

    if odd_flag == 0:counter += 1
    else: break


print(counter)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for (ll i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--)
#define IREP(i, n) IFOR(i, n, 0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(), greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v)                                                              \
  cout << #v << "=(" << v[0];                                                  \
  FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; }                     \
  cout << ")" << endl;
#define mdebug(m)                                                              \
  cout << #m << "=" << endl;                                                   \
  REP(i_debug, m.size()) {                                                     \
    REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; }    \
    cout << endl;                                                              \
  }
#define Lower_bound(v, x)                                                      \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
// #define f first
// #define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;

template <typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) {
  REP(i, a.size()) {
    cin >> a[i];
    a[i]--;
  }
}

ll mod = 1000000007;

int main() {
  ll N, M, X;
  cin >> N >> M >> X;

  ll ans = -1;

  vec C(N);
  vector<vec> A(N, vec(M));
  REP(i, N) {
    cin >> C[i];
    REP(j, M) { cin >> A[i][j]; }
  }

  REP(k, pow(2, N)) {
    vec us_rate(M, 0);
    ll price = 0;
    REP(i, N) {
      if ((k >> i) & 1) {
        price += C[i];
        REP(j, M) { us_rate[j] += A[i][j]; }
      }
    }
    bool cleared = true;
    REP(j, M) {
      if (us_rate[j] < X)
        cleared = false;
    }
    if (cleared) {
      if (ans == -1)
        ans = price;
      else {
        ans = min(ans, price);
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4000
#include <algorithm>
        #include <bitset>
        #include <cassert>
        #include <chrono>
        #include <cmath>
        #include <complex>
        #include <cstdio>
        #include <cstdlib>
        #include <cstring>
        #include <ctime>
        #include <deque>
        #include <functional>
        #include <iomanip>
        #include <iostream>
        #include <iterator>
        #include <limits>
        #include <climits>
        #include <list>
        #include <map>
        #include <numeric>
        #include <queue>
        #include <random>
        #include <ratio>
        #include <set>
        #include <sstream>
        #include <stack>
        #include <string>
        #include <unordered_map>
        #include <unordered_set>
        #include <utility>
        #include <vector>
        using namespace std;
         
        typedef long long ll;
        typedef long double LD;
        #define int ll
        #define double LD
        #define pb push_back
        #define mp make_pair
        #define REP(i,n) for (int i = 0; i < n; i++)
        #define loop(i,n) for (int i = 0; i < n; i++)
        #define FOR(i,a,b) for (int i = a; i < b; i++)
        #define REPD(i,n) for (int i = n-1; i >= 0; i--)
        #define FORD(i,a,b) for (int i = a; i >= b; i--)
        #define remax(a,b) a = max(a,b)
        #define remin(a,b) a = min(a,b)
        #define mem(a, b) memset(a, b, sizeof a)
        #define append push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define print(x) cout << (x) << endl
        #define PRECISION(x) cout << fixed << setprecision(x)
        #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
        #define Test(){int t;cin >> t;for(int i=1;i<=t;i++){cout << "Case #" << i << ": ";solve();}}
        #define test(){int t; cin>>t; for(int i=1;i<=t;i++){solve();}}
        #define vi vector<int>
        #define vii vector<pair<int,int> > 
        #define vci vector<pair<char,int> >
        #define vic vector<pair<int,char> > 
        #define N 200005
        #define pb push_back
        const double PI=acos(-1);
        const int MOD = 1000000007;
        const int FMOD = 998244353;
		
		int vis[N];
		vi v[N];
		int cnt=0;
		void dfs(int src)
		{
			vis[src]=1;
			cnt++;
			for(auto x:v[src])
			{
				if(!vis[x])
				{
					dfs(x);
				}
			}
		}
		void solve()
		{
			int n,m;
			cin>>n>>m;
			
			map<int,int> mp1[n+1];
			loop(i,m)
			{
				int x,y;
				cin>>x>>y;
				
				if(mp1[x][y] || mp1[y][x])
				continue;
				
				v[x].pb(y);
				v[y].pb(x);
				
				mp1[x][y]=1;
				mp1[y][x]=1;
			}
			
		
			int ans=0;
			for(int i=1;i<=n;i++)
			{
				cnt=0;
				if(!vis[i])
				{
				  //  cout<<i<<endl;
					dfs(i);
					ans=max(ans,cnt);
				}
			}
			cout<<ans;
		}
		signed main()
		{
		//	test();
		solve();
		}

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

#define int long long

const int N = 1e5 + 10;
int n, ans, ar[N];
vector <int> vec;
map <int, int> cnt;

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> ar[i];
		cnt[ar[i]]++;
		vec.push_back(ar[i]);
	}
	sort(vec.begin(), vec.end());
	vec.resize(distance(vec.begin(), unique(vec.begin(), vec.end())));
	
	for (int i : vec)
		if (cnt[i] > i)
			ans += cnt[i] - i;
		else if (cnt[i] < i)
			ans += cnt[i];
	cout << ans << endl;
}

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

long long C[51][51]; // C[n][k] -> nCk
 
void comb_table(int N){ 
	for(int i=0;i<=N;++i){
		for(int j=0;j<=i;++j){
			if(j==0 or j==i){
				C[i][j]=1LL;
			}else{
				C[i][j]=(C[i-1][j-1]+C[i-1][j]);
			}
		}
	}
}

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    double v[n];
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    double mean;
    long long ans=0;
    sort(v,v+n,greater<double>());
    double sum=0;
    for(int i=0;i<a;i++){
        sum+=v[i];
    }
    mean=sum/(double)a;
    printf("%07f",mean);
    cout<<endl;
    int cntl=0,cnt=0;
    for(int i=0;i<n;i++){
        if(v[a-1]<v[i]) cntl++;
        if(v[a-1]==v[i]) cnt++;
    }

    comb_table(50);

    ans=C[cnt][a-cntl];
    if(mean==v[a-1]){
        for(int i=a+1;i<=min(b,cnt);i++){
            ans+=C[cnt][i];
        }
    }

    cout<<ans<<endl;

    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> trp;
typedef vector<ll> vi;
typedef vector<pll> vp;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define pob         pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define sc3(a,b,c)  cin>>a>>b>>c
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"YES"<<endl
#define prN         cout<<"NO"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define	mp3(a,b,c)  make_pair(a,make_pair(b,c))
#define se          second
#define fi          first 
#define sse         second.second
#define sfi         second.first
#define soA         sort(A+1,A+1+n)
#define so(A,n)     sort(A+1,A+1+n)
#define sov(v)      sort(all(v))
#define sovr(v)     sort(all(v),greater<ll>())
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	sc(n);
	//f1(i,n)sc(A[i]);
	
	pr((n+1)/2);
	
	
	
	
	
	
	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	if(fopen("locin.txt", "r"))INPUT;
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	} 		
}

Measured memory_bytes: 256
import string
import math

n = int(input())
alp = string.ascii_lowercase

keta = int( math.log(n * 25 + 1, 26) )

st = (26 ** keta - 1 ) // 25
n2 = n - st
ans = []
for i in range(keta):
  ans.append( alp[ n2 % 26 ] )
  n2 = n2 // 26
print(''.join(ans[::-1]))

Measured memory_bytes: 72104
import sys
readline = sys.stdin.readline

def main():
    N, K = map(int, readline().rstrip().split())
    H = [int(readline()) for _ in range(N)]
    H.sort()
    ans = 10 ** 10
    for i in range(N-K+1):
        ans = min(ans, H[i+K-1]-H[i])

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 7384
#include <bits/stdc++.h>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
   int a,b;
   cin>>a>>b;
   int c=a+b;
   if(c<10) cout<<c<<endl;
   else cout<<"error"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5+100;
const int MOD = 1e9+7;
long long a[N];
int c0,c1,tp=1,n,ans;
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;++i)
        scanf("%lld",&a[i]);
    for(int o=0;o<60;++o){
        c1=c0=0;
        for(int i=0;i<n;++i){
            if(a[i]%2) c1++;
            else c0++;
            a[i]>>=1;
        }
        ans=(ans+1LL*c0*c1%MOD*tp%MOD)%MOD;
        tp=tp*2%MOD;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long  n, m, ans=0;
  cin>>n >>m;
  vector<bool> check(n);
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  for(int i=0;i<n;i++){
    check[i]=1;
  }
  
  for(int j=0;j<m;j++){
    int a, b;
    cin >> a >> b;
    if(h[a-1]==h[b-1]){
      check[a-1]=0;
      check[b-1]=0;
    }else if(h[a-1]>h[b-1]){
      check[b-1]=0;
    }else if(h[b-1]>h[a-1]){
      check[a-1]=0;
    }
  }
  for(int i=0;i<n;i++){
    if(check[i]==1){
      ans++;
    }
  }
 
  
  cout << ans<<endl;
}


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

int gcd(int a, int b){
    if( b == 0 ){
        return a;
    } else if (a == 0){
        return b;
    } else {
        return gcd(b, a % b);
    }
}
int main(){
    int n, k;
    cin>>n>>k;
    int a[n];
    for(int i = 0;i<n;i++){
        cin>>a[i];
    }
    int ans = abs(k-a[0]);
    for(int i = 0; i < n;i++){
        ans = gcd(ans, abs(k - a[i]));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    ll N, Q;
    cin >> N >> Q;
    dsu uf(N);

    rep(_, Q){
        ll t, u, v;
        cin >> t >> u >> v;

        if(t == 0){
            uf.merge(u, v);
        }else{
            cout << (uf.same(u, v) ? 1 : 0) << '\n';
        }
    }
}

Measured memory_bytes: 4048
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#include <assert.h>
#include <bitset>
#define Endl endl
#define mp make_pair
#define ll long long 
#define ull unsinged long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
template <typename T1,typename T2> inline void chmin(T1 &x,T2 b) {if(b<x) x=b;}
template <typename T1,typename T2> inline void chmax(T1 &x,T2 b) {if(b>x) x=b;}
const int inf=1039074182;
const ll llinf=1LL*inf*inf;
using namespace std;

int main()
{
//	freopen("input.txt","r",stdin);
	ll n,m;
	cin>>n>>m;
	if(n==1)
	{
		cout<<1<<endl;
	}
	else if(m==1)
	{
		cout<<1<<endl;
	}
	else if((n*m)&1)
	{
		cout<<(n*m+1)/2<<endl;
	}
	else
	{
		cout<<n*m/2<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

bool inrange(int x,int y){
	if(x<0||y<0||x>11||y>11) return false;
	else return true;
}

int data[20][20];
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};

void search(int x,int y){
	REP(i,4){
		int nx = x + dx[i];
		int ny = y + dy[i];
		if(!inrange(nx,ny)) continue;
		if(data[nx][ny]==1) {
			data[nx][ny] = 0;
			search(nx,ny);
		}
	}
}

int main(){
	while(1){
		string str;
		REP(i,12){
			cin >> str;
			REP(j,12){
				data[i][j] = str[j] - '0';
			}
		}
		
		if(cin.eof()) break;
		ll int cnt = 0;
		REP(i,12){
			REP(j,12){
				if(data[i][j]==1){
					search(i,j);
					cnt++;
				}
			}
		}
		cout << cnt << endl;
		
	}
	return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    char c;
    for (int i = 0 ; i < 9 ; i++) {
        cin >> c;
        if(i == 0 || i == 4 || i == 8){
        	cout << c;
        }
    }
}

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

int main()
{
	int fig[11][11];
	int n;
	while(cin >> n){
		if(!n)
			break;
		int ans = 0;
		for(int i=0;i<n;i++){
			int sum = 0;
			for(int j=0;j<n;j++){
				cin >> fig[i][j];
				sum += fig[i][j];
			}
			fig[i][n] = sum;
			ans += sum;
		}
		for(int j=0;j<n;j++){
			int sum = 0;
			for(int i=0;i<n;i++){
				sum += fig[i][j];
			}
			fig[n][j] = sum;
		}
		fig[n][n] = ans;
		for(int i=0;i<=n;i++){
			for(int j=0;j<=n;j++){
				cout << setw(5) << fig[i][j];
			}
			cout << endl;
		}
	}
	return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
int S, W;
	cin >> S >> W;
	if (S<=W) {
		ce("unsafe")
	}
	else {
		ce("safe")
	}

    return 0;
}



Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}

ll N;
vector<vector<ll>> edge;
vector<ll> ord;
ll m;
bool jd;

bool judge(ll sz,ll used,const vector<ll> &beet){
  for(int i=0;2*i+2<sz;i++){
    ll lf=(i>=used?beet[i+1]:beet[i]);
    ll rg=((sz-i-2)>=used?beet[sz-i-2+1]:beet[sz-i-2]);
    if(lf+rg+1>m){return false;}
  }
  return true;
}

ll dfs(ll u,ll p){
  vector<ll> beet(ord[u]+1);
  ll sz=0;
  for(auto &v:edge[u]){
    if(v!=p){
      beet[sz++]=dfs(v,u);
    }
  }
  sort(beet.begin(),beet.begin()+sz,greater<ll>());
  if((sz&1)==0){
    beet[sz++]=0;
    if(p==-1){jd&=judge(sz,sz-1,beet); return 0;}
  }
  ll lf=0,rg=sz;
  while(rg-lf>1){
    ll mid=(lf+rg)>>1;
    if(judge(sz,mid,beet)){lf=mid;}
    else{rg=mid;}
  }
  jd&=judge(sz,lf,beet);
  jd&=(beet[lf]+1<=m);
  return beet[lf]+1;
}

bool judge2(ll mid){
  m=mid;
  jd=true;
  dfs(0,-1);
  return jd;
}

int main(){
  cin>>N;
  edge.resize(N);
  ord.resize(N,0);

  for(int i=1;i<N;i++){
    ll a,b;
    cin>>a>>b;
    a--; b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
    ord[a]++;
    ord[b]++;
  }

  ll cnt=0;
  for(auto &I:ord){cnt+=(I-1)/2;}
  
  ll l=0,r=N;
  while(r-l>1){
    ll mid=(l+r)>>1;
    if(judge2(N-mid)){l=mid;}
    else{r=mid;}
  }
  cout<<cnt+1<<" "<<N-l-1<<endl;

  return 0;
}


Measured memory_bytes: 18432
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	map<char,string> atoc;
	{
		char a[]={
			'A','B','C','D','E','F','G','H',
			'I','J','K','L','M','N','O','P',
			'Q','R','S','T','U','V','W','X',
			'Y','Z',' ','.',',','-','\'','?',
		};
		string c[]={
			"00000", "00001", "00010", "00011", "00100", "00101", "00110", "00111",
			"01000", "01001", "01010", "01011", "01100", "01101", "01110", "01111",
			"10000", "10001", "10010", "10011", "10100", "10101", "10110", "10111",
			"11000", "11001", "11010", "11011", "11100", "11101", "11110", "11111",
		};
		rep(i,32)
			atoc[a[i]]=c[i];
	}
	map<string,char> ctoa;
	{
		string c[]={
			"101", "000000", "000011", "10010001", "010001", "000001", "100101", "10011010",
			"0101", "0001", "110", "01001", "10011011", "010000", "0111", "10011000",
			"0110", "00100", "10011001", "10011110", "00101", "111", "10011111", "1000",
			"00110", "00111", "10011100", "10011101", "000010", "10010010", "10010011", "10010000",
		};
		char a[]={
			' ','\'',',','-','.','?','A','B',
			'C','D','E','F','G','H','I','J',
			'K','L','M','N','O','P','Q','R',
			'S','T','U','V','W','X','Y','Z',
		};
		rep(i,32)
			ctoa[c[i]]=a[i];
	}
	
	for(string a;getline(cin,a);){
		string c;
		rep(i,a.size())
			c+=atoc[a[i]];
		
		string res;
		for(int i=0;;){
			bool found=false;
			foreach(j,ctoa){
				if(j->first==c.substr(i,j->first.size())){
					res+=j->second;
					i+=j->first.size();
					found=true;
					break;
				}
			}
			if(!found)
				break;
		}
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 920
N = int(input())
H = list(map(int, input().split()))


for i in range(1, N):
    if H[i] - H[i-1] > 0:
        H[i] -= 1

flag = True
now = H[0]
for i in range(1, N):
    if now > H[i]:
        flag = False
        break
    else:
        now = H[i]

if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 15020
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	int N;
	cin >> N;

	set<string> S;
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		S.emplace(s);
	}

	cout << S.size() << "\n";



	return 0;
}

Measured memory_bytes: 19272
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
h,w = map(int,input().split())
a=[input() for _ in range(h)]
mod=10**9+7
dp=[[0]*w for _ in range(h)]
dp[0][0]=1
for i in range(h):
      for j in range(w):
            if i+1<h and a[i+1][j]=='.':
                  dp[i+1][j]+=dp[i][j]%mod
            if j+1<w and a[i][j+1]=='.':
                  dp[i][j+1]+=dp[i][j]%mod
print(dp[-1][-1]%mod)


Measured memory_bytes: 52720
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long a,b,re1=0,h,w,count=0;
    string s;
    cin>>s;
    rep(i,3){
        if(s[i]=='1'){
            count++;
        }
    }
    cout<<count<<'\n';
}

Measured memory_bytes: 764
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include <chrono>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
vint adj[100001];
int p[100001];
int num[100001]={};
bool visited[100001]={};
vint edgedepth[100001];
int depthmax=0;
map<pint,bool> usededge;
void dfs(int u,int depth){
	visited[u]=1;
	edgedepth[depth].push_back(u);
	depthmax=max(depthmax,depth);
	int flag=0;
	rep(i,adj[u].size()){
		int v=adj[u][i];
		if(visited[v]==0){
			flag=1;
			p[v]=u;
			usededge[{u,v}]=1;
			usededge[{v,u}]=1;
			dfs(v,depth+1);
		}
	}
}
int main(){
	int N,M;
	int a[100001],b[100001];
	scan(N>>M);
	rep(i,M){
		scan(a[i]>>b[i]);
		a[i]--; b[i]--;
		adj[a[i]].push_back(b[i]);
		adj[b[i]].push_back(a[i]);
	}
	if(M%2) prin(-1);
	else{
		p[0]=-1;
		dfs(0,0);
		vpint ans;
		rep(i,M){
			if(usededge[{a[i],b[i]}]==0){
				num[a[i]]^=1;
				ans.push_back({a[i],b[i]});
				//printf("unused: %d %d\n",a[i]+1,b[i]+1);
			}
		}
		for(int d=depthmax;d>=1;d--){
			rep(i,edgedepth[d].size()){
				int u=edgedepth[d][i];
				int v=p[u];
				if(num[u]){
					ans.push_back({u,v});
					//printf("u to v: %d %d\n",u+1,v+1);
				}
				else{
					ans.push_back({v,u});
					num[v]^=1;
					//printf("v to u: %d %d\n",v+1,u+1);
				}
			}
		}
		rep(i,ans.size()){
			printf("%d %d\n",ans[i].first+1,ans[i].second+1);
		}
	}
	return 0;
}


Measured memory_bytes: 39928
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define pb push_back
#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fs(s) for(ll i=0;s[i]!='\0';i++)
#define fr(i,a,b) for(ll i=a;i>=b;i--)
#define gcd(a,b) __gcd(a,b)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define c1(x) __builtin_popcountll(x)
#define setprs(x) cout << fixed << setprecision(x);
#define endl '\n'
const ll mod=1e9 + 7;
const ll sz=1e5 + 100;
const double PI =3.14159265;
ll power(ll a, ll b, ll m = mod){if(b==0)return 1;else if(b==1)return a%m;else{ll t=power(a,b>>1,m);t=((t%m)*(t%m))%m;if(b&1)return ((t%m)*(a%m))%m;else return t%m;}}
 
//--------------------------------------------------------

#define int ll

void solve()
{
    int n;
    cin >> n;
    int a[sz], b[sz], c[sz];
    f(i,0,n)cin >> a[i] >> b[i] >> c[i];
    int dpa[sz], dpb[sz], dpc[sz];
    dpa[n-1] = a[n-1], dpb[n-1] = b[n-1], dpc[n-1] = c[n-1];
    fr(i,n-2, 0){
        dpa[i] = a[i] + max(dpc[i+1], dpb[i+1]);
        dpb[i] = b[i] + max(dpc[i+1], dpa[i+1]);
        dpc[i] = c[i] + max(dpa[i+1], dpb[i+1]);
    }
    cout << max(dpa[0], max(dpb[0], dpc[0]));
} 
 
int32_t main()
{
    fastio
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 8304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
ll N;
ll u[100010], v[100010], w[100010];
vector<lpair> tree[100010];
ll d[100010] = {};

void dfs(ll cur, ll par, ll v){
    d[cur] = v;
    for(auto &e: tree[cur]){
        if(e.first == par) continue;
        if(v == 0){
            if(e.second == 0){
                dfs(e.first, cur, 0);
            }else{
                dfs(e.first, cur, 1);
            }
            
        }else{
            if(e.second == 0){
                dfs(e.first, cur, 1);
            }else{
                dfs(e.first, cur, 0);
            }

        }



    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    rep(i,0,N-1){
        cin >> u[i] >> v[i] >> w[i];
        u[i]--; v[i]--;
        tree[u[i]].push_back(make_pair(v[i], w[i] % 2));
        tree[v[i]].push_back(make_pair(u[i], w[i] % 2));
    }
    memset(d, -1, sizeof(d));
    dfs(0,-1, 0);
    rep(i,0,N) print(d[i]);





    
}

Measured memory_bytes: 12544
import math

def keta(num):
  b = num
  count=0
  while b >= 1 :
    count+=1
    b= b//10
  return count

n = int(input())

min_f = keta(n)
for i in range(1, int(math.sqrt(n))+1):
  if n%i==0:
    f = max(keta(n//i),keta(i))
    if min_f > f:
      min_f = f
print(min_f)      
    


Measured memory_bytes: 3316
N = int(input())
P = [list(map(int, input().split())) for _ in range(N)]

ans = 'Yes'
for t, x, y in P:
    if x + y > t:
        ans = 'No'
        break
    if (x + y) % 2 != t % 2:
        ans = 'No'
        break

print(ans)

Measured memory_bytes: 27380
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int a=0,b=0;
  scanf("%d %d",&a,&b);
  if (a+b>=10) {
    printf("error\n");
  }else{
    printf("%d\n",a+b);
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int n, a[100001], dp[100001];
int main() {
	cin >> n;
	rep(i, n)  cin >> a[i];
	fill(dp, dp + n, 2000000001);
	dp[0] = 0;
	rep(i, n) {
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(a[i + 1] - a[i]));
		dp[i + 2] = min(dp[i + 2], dp[i] + abs(a[i + 2] - a[i]));
	}
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
let m = 950527

let split str delim =
  let open String in
  let rec doit s acc =
    match
      try Some (rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i -> doit (sub s 0 i) (sub s (i + 1) (length s - i - 1) :: acc) in
  doit str []

let to_key s =
  let char_to_x c =
    if c = 'A' then 1
    else if c = 'C' then 2
    else if c = 'G' then 3
    else if c = 'T' then 4
    else 0 in
  let n = String.length s in
  let rec doit i p acc =
    if i = n then acc
    else doit (i + 1) (5*p) (acc + p*(char_to_x s.[i])) in
  doit 0 1 0

let to_h1 k = k mod m
let to_h2 k = 1 + (k mod (m - 1))

let insert s t =
  let k = to_key s in
  let h1 = to_h1 k in
  let h2 = to_h2 k in
  let rec doit i =
    let h = (h1 + h2*i) mod m in
    if t.(h) = s then ()
    else if t.(h) = "\000" then t.(h) <- s
    else doit (i + 1) in
  doit 0

let find s t =
  let k = to_key s in
  let h1 = to_h1 k in
  let h2 = to_h2 k in
  let rec doit i =
    let h = (h1 + h2*i) mod m in
    if t.(h) = s then true
    else if t.(h) = "\000" then false
    else doit (i + 1) in
  doit 0

let () =
  let n = read_int () in
  let t = Array.make m "\000" in
  let rec doit i =
    if i < n then begin
      begin match split (read_line ()) ' ' with
      | ["insert"; s] -> insert s t
      | ["find"; s] -> print_endline (if find s t then "yes" else "no")
      | _ -> ()
      end;
      doit (i + 1)
    end in
  doit 0

Measured memory_bytes: 20048
n, k = map(int, input().split())
a = [int(x) for x in input().split()]

lo = 1
hi = max(a)


def ceildiv(a, b):
    return (a + b - 1) // b

def ok(x):
    cuts = 0
    for log in a:
        cuts += ceildiv(log, x) - 1

    if cuts <= k:
        return True

    return False

while lo < hi:
    mid = (lo + hi) // 2

    if ok(mid):
        hi = mid
    else:
        lo = mid + 1

print(lo)



Measured memory_bytes: 30760
//#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#define MAX_INT 2100000000
using namespace std;
typedef long long int ll;
#ifdef COMPILE_IN_VCPP
#include <windows.h>
HWND GetConsoleHwnd(void)
{
#define MY_BUFSIZE 1024 // Buffer size for console window titles.
	HWND hwndFound;         // This is what is returned to the caller.
	char pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated// WindowTitle.
	char pszOldWindowTitle[MY_BUFSIZE]; // Contains original// WindowTitle.
	// Fetch current window title.
	GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE);
	// Format a "unique" NewWindowTitle.
	wsprintf(pszNewWindowTitle, "%d/%d",GetTickCount(),GetCurrentProcessId());
	// Change current window title.
	SetConsoleTitle(pszNewWindowTitle);
	// Ensure window title has been updated.
	Sleep(40);
	// Look for NewWindowTitle.
	hwndFound = FindWindow(NULL, pszNewWindowTitle);
	// Restore original window title.
	SetConsoleTitle(pszOldWindowTitle);
	return(hwndFound);
}
#endif
int main()
{
#ifdef COMPILE_IN_VCPP
	SetWindowPos(GetConsoleHwnd(), HWND_TOPMOST, 0, 0, 0, 0,
		(SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW));
#endif
	int a, b,ans;
	cin >> a >> b;
	if (a <= 5) ans = 0;
	else if (a >= 6 && a <= 12) ans = b / 2;
	else ans = b;
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

//! get the number of p's included in n!
LL g(LL n, LL p) 
{
    if (n < p) return 0;
    LL q = n/p;
    return q + g(q, p);
}

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

    LL N;
    cin >> N;
    cout << ((N%2) ? 0 : g(N/2, 5)) << endl;

    return 0;
}


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

int main() {
  string s;
  cin >> s;
  int n      = s.size();
  int c      = 0;
  bool lower = true;
  for (int i = 1; i < n; i++) {
    if (i >= 2 && i <= n - 2) {
      if (s[i] == 'C') {
        c++;
        continue;
      }
    }
    if (s[i] >= 'A' && s[i] <= 'Z') {
      lower = false;
      break;
    }
  }
  if (s[0] == 'A' && c == 1 && lower) {
    cout << "AC" << endl;
  } else {
    cout << "WA" << endl;
  }
}

Measured memory_bytes: 256
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import numpy as np
import copy
from collections import defaultdict, Counter
from itertools import product # 全探索
from bisect import bisect_left, bisect_right

def s_inpl(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))

S = input()

def dfs(s):
    if len(s) == 1:
        return [s]
    def add(l, r):
        return [l+ri for ri in r]
    return add(s[0], dfs(s[1:])) + add(s[0] + "+", dfs(s[1:]))

print(sum(map(eval,dfs(S))))


Measured memory_bytes: 15732
#include <iostream>
using namespace std;
const int MAX_N =1000000;
int main(){
	bool sosu[MAX_N]={};//false:sosu
	for(int i=2;i<MAX_N;i++){
		if(!sosu[i]){
			for(int j=2;j*i<MAX_N;j++){
				sosu[j*i]=true;
			}
		}
	}
	for(int n;cin>>n;){
		int ans=0;
		for(int i=2;i<=n;i++){
			if(!sosu[i])ans++;
		}
		cout<<ans<<endl;
	}
    return 0;
}

Measured memory_bytes: 2140
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int dp[101][100][301];
int w[100];
int v[100], vsort[100];

int main()
{
	int N, W, base;
	int ans = 0;

	cin >> N >> W;
	rep(i, N) cin >> w[i] >> v[i];
	rep(i, N) vsort[i] = v[i];
	sort(vsort, vsort + N, greater<int>());

	base = w[0];
	rep(i, N) w[i] -= base;

	repc(num, 1, N) {
		repc(n, 0, num) rep(i, N) rep(j, 301) dp[n][i][j] = 0;

		int WW = W - base * num;
		if (WW < 0) break;
		else if (WW > 300) {
			int sum = 0;
			rep(i, num) sum += vsort[i];
			ans = max(ans, sum);
			continue;
		}

		repc(n, 1, num) rep(i, N) repc(j, 0, WW) {
			if (n == 1) {
				if (i == 0) dp[n][i][j] = v[i];
				else {
					dp[n][i][j] = dp[n][i - 1][j];
					if (w[i] <= j) dp[n][i][j] = max(dp[n][i][j], v[i]);
				}
			}
			else if (i == 0) continue;
			else {
				dp[n][i][j] = max(dp[n][i][j], dp[n][i - 1][j]);
				if (j >= 1) dp[n][i][j] = max(dp[n][i][j], dp[n][i][j - 1]);
				if (j >= w[i]) dp[n][i][j] = max(dp[n][i][j], dp[n - 1][i - 1][j - w[i]] + v[i]);
			}
		}

		ans = max(ans, dp[num][N - 1][WW]);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 12160
#include <iostream>
using namespace std;
 
int main(void){
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    if(n-i*4 >= 0 && (n-i*4)%7 == 0){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int I=X;I<Y;I++)
#define REP(I,X,Y) for(int I=Y-1;I>=X;I--)
#define INF 1000000007
using namespace std;

bool DP[30000];

int main(){
  int N,s;
  cin >> N;
  DP[10000] = 1;
  FOR(i,0,N){
    cin >> s;
    REP(i,10000,20000)if(DP[i])DP[i+s] = 1;
  }
  REP(i,10000,20000){
    if(DP[i] && i%10){
      cout << i-10000 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define LONG 100
#define N 100000000
int  A[LONG];
int B[LONG][LONG];
int atama,ketu;
int d[LONG];
int total;
void enqueue(int x){
  A[ketu] = x;
  ketu = (ketu+1) % LONG;
}
int dequeue(){
  int  x = A[atama];
  atama = (atama+1)%LONG;
  return x;
}
int enpty(){
  if(ketu == atama)return 1;
  else return 0;
}
void ooh(int s){
  int i,u,v;
   enqueue(s);
  for(i=0;i<total;i++){
    d[i] = N;
  }
  d[s] = 0;
  while(!enpty()){
    u = dequeue();
    for(v=0;v<total;v++){
      if(B[u][v] == 0)continue;
      if(d[v] != N)continue;
      d[v] = d[u] + 1;
      enqueue(v);
    }
  }
  for(i=0;i<total;i++){
    printf("%d %d\n",i+1,((d[i] == N)? -1 : d[i]));
  }
}
int main(){
  int k,u,v,i,j;
   scanf("%d",&total);
  for(i=0;i<total;i++){
    for(j=0;j<total;j++){
      B[i][j] = 0;
    }
  }
  for(i=0;i<total;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      B[u][v] = 1;
    }
  }
  ooh(0);
  return 0;
}


Measured memory_bytes: 2064
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dj[8] = {1, 1, 0, -1, -1, -1, 0, 1};

signed main(){
    
    int n, m; cin >> n >> m;
    vector<vector<int> > a(n + 2, vector<int> (m + 2, 0));
    for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++){
        char in; cin >> in;
        if(in == '#') a[i][j] = -1;
    }

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(a[i][j] != -1) continue;
            for(int h = 0; h < 8; h++){
                int ni = i + di[h];
                int nj = j + dj[h];
                if(a[ni][nj] == -1) continue;
                a[ni][nj]++;
            }
        }
    }

    for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++){
        if(a[i][j] == -1) cout << '#';
        else cout << a[i][j];

        if(j == m) cout << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define pb push_back
#define mod 1000000007
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int dx8[]={1,-1,0,0,1,1,-1,-1};
int dy8[]={0,0,1,-1,1,-1,1,-1};

ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

 // void dfs(ll node){
 // 	vis[node]=1;
 // 	res.pb(node);
 //    vector<ll> ans;


 // 	for(auto i:v[node]){
 // 		if(!vis[i]){
 // 			ans.pb(i);

 // 		}
 // 	}
 // 	sort(ans.begin(),ans.end());

 // 	for(auto i:ans){
 // 		if(!vis[i])
 // 			dfs(i);
 // 	}




 // }
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
bool sortbyme(const pair<int,int> &a, 
              const pair<int,int> &b){
	return (a.first+a.second > b.first+b.second);

}
ll ans=INT_MAX;
// ll check(vector<ll> v,n,ll flag,ll count,ll )

void solve(){

ll n;
cin>>n;
vector<ll> a(n),b(n);
for(ll i=0;i<n;i++)cin>>a[i];
for(ll i=0;i<n;i++)cin>>b[i];

reverse(b.begin(),b.end());
ll flag=0;
ll curr;
ll maxs=INT_MIN;
ll mins=INT_MAX;


ll lpt = 0, rpt = n - 1;
	
	for (ll i = 0; i < n; i++) {
		if (a[i] == b[i]) {
			if (b[lpt] != b[i] && a[lpt] != b[i]) {
				swap(b[i], b[lpt]);
				++lpt;
			} else if (b[rpt] != b[i] && a[rpt] != b[i]) {
				swap(b[i], b[rpt]);
				--rpt;
			} else {
				cout << "No"<<endl;
				return;
			}
		}
	}
	
	for (ll i = 0; i < n; i++) {
		if (a[i] == b[i]) {
			cout << "No"<<endl;
			return;
		}
	}
	
	cout << "Yes"<<endl;
	for (ll i = 0; i < n; i++) {
		cout << b[i] << " ";
	}
	cout <<endl;

return;
}



int main()
{  
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
    fast;
    

    ll t;
    t=1;
    //cin>>t;
    while(t--){
    	solve();
    }
    
   
  



#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
return 0;
}

Measured memory_bytes: 6344
import java.util.Scanner;


public class Main{
    public static void main(String[] args){

        Scanner sc=new Scanner(System.in);

        int N=sc.nextInt();
        String ans="";

        if(N==0){
            
        }
        while(N!=0){
            if(N%2==0){   
                ans="0"+ans;
                N/=-2;
            }else{
                ans="1"+ans;
                N=(N-1)/(-2);
            }
        }
        if(ans.isEmpty()){
            System.out.println("0");
        }else{
            //ans.reverse();
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 21844
import 'dart:io';

void main() {
  int n = int.parse(stdin.readLineSync());
  List list = [];
  for (int i = 1; i <= n; i++) {
    int l = i;
    int count = 0;
    list.add({"i": i, "count": count});
    // if ((l / 2).floor() == 0) continue; //次のiにいく
    while (true) {
      if (l % 2 != 0) {
        list[i - 1] = {"i": i, "count": count};
        break;
      }
      if (l % 2 == 0) {
        count++;
        l = (l / 2).floor();
      }
      if (l < 2) {
        list[i - 1] = {"i": i, "count": count};
        break;
      }
    }
  }
  // print(list);
  List test = list..sort((b, a) => a["count"].compareTo(b["count"]));
  print(test[0]["i"]);
}

Measured memory_bytes: 13184
#include<iostream>
using namespace std;
int main()
{
long n;
long nn[]={1,4,10,20,35,56,84,120,165,220,282,348,415,480,540,592,633,660,670,
660,633,592,540,480,415,348,282,220,165,120,84,56,35,20,10,4,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
for(;;){
cin>>n;
if(cin.eof())break;
cout<<nn[n]<<endl;
}
return 0;
}

Measured memory_bytes: 1160
n = gets.chomp.to_i
ac = 0
wa = 0
tle = 0
re = 0

Array.new(n){gets.chomp}.each do |s|
  case s
  when "AC"
    ac += 1
  when "WA"
    wa += 1
  when "TLE"
    tle += 1
  when "RE"
    re += 1
  end
end

puts "AC x #{ac}"
puts "WA x #{wa}"
puts "TLE x #{tle}"
puts "RE x #{re}"

Measured memory_bytes: 20584
#include<bits/stdc++.h>
#define ll long long int 
#define w(x) int x; cin>>x; while(x--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
using namespace std;
int main(){
#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll a,b;
	cin>>a>>b;
	ll c=1,d=0;
	while(c<b){
		c=c+a-1;
		d++;
	}
	cout<<d;
}

Measured memory_bytes: 3600