akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

ll N;

void solve() {
	cin >> N;

	ll bin = 0;
	rep(i, N) {
		ll input;
		cin >> input;
		bin |= input;
		debug(bin);
	}

	ll ans = 0;
	while (1) {
		if (bin & 1 == 1) break;
		ans++;
		bin >>= 1;
	}

	cout << ans;

}

int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	cout << endl;
	return 0;
}


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

int main(){
        ll n;
        scanf("%lld", &n);
        bool denkyu[n];
        for(ll i=0; i<n; i++) scanf("%d", &denkyu[i]);

        vector<ll> a(n);
        bool prev = !denkyu[0];
        ll cnt = 0, len = 0;
        for(ll i=0; i<n; i++){
                if(denkyu[i]==prev){
                        a[len] = cnt;
                        len++;
                        cnt = 1;
                }else{
                        cnt++;
                }
                prev = denkyu[i];
        }
        a[len] = cnt; len++;

        if(len==1){
                printf("%lld\n", a[0]);
                return 0;
        }

        ll ans = a[0]+a[1];
        for(ll i=1; i<len-1; i++) ans = max(ans, a[i-1]+a[i]+a[i+1]);
        printf("%lld\n", ans);

        return 0;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
const LL INF = 1LL << 60;
LL V = 1e5;

int main(){
    LL N, W;
    cin >> N >> W;
    vector<LL>  w(N+1), v(N+1);
    for(int i = 1;i <= N;i++)   cin >> w[i] >> v[i];
    vector<vector<LL>>  dp(N+1, vector<LL>(V, INF));
    for(int i = 0;i <= N;i++)   dp[i][0] = 0;
    for(int i = 1;i <= N;i++){
        for(int j = 1;j <= V;j++){
            if(j-v[i] < 0){
                dp[i][j] = min(dp[i-1][j], w[i]);
            }else{
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]]+w[i]);
            }
        }
    }
    for(int i = 1;i <= V;i++){
        if(dp[N][i] > W){
            cout << i-1 << endl;
            break;
        }
        if(i == V)  cout << V << endl;
    }
}

Measured memory_bytes: 80256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <list>
#include <climits>

using namespace std;

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

     if(N <= 1)
     {
         cout << "0\n";
         return 0;
     }

  	int K = 2;
  	cin >> K;
  
	vector<int> h(N);
	vector<int> dp(N, INT_MAX);
	dp[0] = 0;

 	for(int i = 0; i < N; ++i)
		cin >> h[i];

	for(int i = 0; i < N; ++i)
	{
		for(int j = i + 1; j <= i + K && j < N; ++j)
		{
			dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]));
		}
	}

	cout << dp[N - 1] << "\n";

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

using namespace std;
typedef vector<int> VI;

int main() {
	int n, m;
	while (cin >> n >> m) {
		VI A(m);
		for (auto& x : A) {cin >> x; --x; }
		VI used(n, 0);
		VI sol;
		reverse(A.begin(), A.end());
		for (int x : A) {
			if (!used[x]) {
				sol.push_back(x);
				used[x] = 1;
			}
		}
		for (int i = 0; i < n; ++i) {
			if (!used[i]) sol.push_back(i);
		}
		for (auto x : sol) cout << x+1 << '\n';
	}
}

Measured memory_bytes: 5076
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		int count = 0;
		for (char c : arr) {
			if (c == 'x') {
				count++;
			}
		}
		if (count >= 8) {
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}
	}
}


Measured memory_bytes: 23636
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

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

	int A, B;
	cin >> A >> B;
	puts(max(A + B, max(A - B, A*B)));
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int solve(int,int);

int A[2000],n;

int main(){
  int i,q,m[2000];

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

    for (i = 0; i < q; i++){
      if(solve(0,m[i])==1)
	printf("yes\n");
      else printf("no\n");
  }

    return 0;

}

int solve(int i,int m){
  int res;
  if(m == 0)
    return 1;
  if(i >= n)
    return 0;
  res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
#define sort(a) sort(a.begin(), a.end())
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n; ll w, uu, v;
    cin>>n>>w;

    vector<ll> dp(w+1);
    dp[0] = 0;
    loop(n){
        cin>>uu>>v;
        ll from = w - uu;
        for(from; from>=0; from--){
            dp[from+uu] = max(dp[from+uu], dp[from]+v);
        }        
    }
    ll ans = 0;
    loop(w+1) ans = max(ans, dp[i]);
    cout<<ans<<"\n";
    return 0;
}

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

void Main() {
  ll r,d,x;
  cin >> r >> d >> x;
  rep(i,10) {
    x=r*x-d;
    pr(x);
  }
}

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


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	REP(i, N) {
		int a, b, c;
		cin >> a >> b >> c;

		int ans = 0;
		ans = min(a, min(b, c));
		a -= ans;
		b -= ans;
		c -= ans;
		ans += min(a / 2, b);
		a -= min(a / 2, b)*2;
		b-= min(a / 2, b);
		ans += a / 3;
		cout << ans << endl;
	}
	
	return 0;
}




Measured memory_bytes: 3168
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define INF 1100000000
#define LLINF 1100000000000000000
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair

using namespace std;
typedef long long ll;

int F(ll a, ll b)
{
  int ca = 0, cb = 0;
  while (a > 0) ca++, a /= 10;
  while (b > 0) cb++, b /= 10;
  return max(ca, cb);
}

int main()
{
  ll N; cin >> N;
  int ans = INF;
  for (ll A = 1; A*A <= N; A++) {
    if (N % A != 0) continue;
    ll B = N / A;
    ans = min(ans, F(A, B));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
            
	public static void main(String[] args) {
		
           Scanner sc = new Scanner(System.in);                                                            
         
           String S = String.valueOf(sc.nextInt());
           
           if(S.charAt(0) == S.charAt(2)){
                 System.out.println("Yes"); 
           }else{
                 System.out.println("No");                
           }
           
        }
        
}       


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

using Row = vector<int64>;
using Mat = vector<Row>;

template<typename T>
class Matrix{
private:
	using mat = vector<vector<T>>;
	const int64 mod = 1e9+7;
	mat m;
public:
	uint32 col=0, row=0;
	Matrix(){}
	Matrix(mat&& m):m(m){ row = m.size(); col = m[0].size(); }
	Matrix(Matrix<T>&& rhs){ m = rhs.m; row = rhs.row; col = rhs.col;}
	Matrix(int32 row, int32 col, bool isIdentity=false):row(row),col(col){
		m = mat(row, vector<T>(col, 0));
		if(isIdentity && row == col){
			for(int32 i = 0;i < row;i++)	m[i][i] = 1;
		}
	}

	Matrix<T> pow(int64 x){
		if(x == 0) return Matrix(row, col, 1);
		if(x&1) return (*this)*pow(x-1);
		Matrix<T> ret = pow(x/2);
		return ret*ret;
	}

	Matrix<T> operator+(const Matrix<T>& rhs){
		Matrix<T> ret = *this;
		if(row != rhs.row || col != rhs.col){
			cerr << "Error happened in operator+:the number of lhs's col & row is not the number of rhs's" << endl;
			exit(-1);
		}
		for(int32 i = 0;i < row;i++){
			for(int32 j = 0;j < col;j++){
				ret[i][j] = m[i][j]+rhs[i][j];
				ret[i][j] %= mod;
			}
		}
		return ret;
	}

	Matrix<T> operator*(T x){
		Matrix<T> ret = m;
		for(int32 i = 0;i < row;i++){
			for(int32 j = 0;j < col;j++){
				ret[i][j] = m[i][j]*x;
				ret[i][j] %= mod;
			}
		}
		return ret;
	}

	Matrix<T> operator*(const Matrix<T>& rhs){
		Matrix<T> ret = mat(row, vector<T>(rhs.col, 0));
		if(col != rhs.row){
			cerr << "Error happened in operator*:the number of lhs's col is not the number of rhs's" << endl;
			exit(-1);
		}

		for(int32 i = 0;i < row;i++){
			for(int32 j = 0;j < rhs.col;j++){
				for(int32 k = 0;k < col;k++){
					ret[i][j] = ret[i][j]+m[i][k]*rhs[k][j];
					ret[i][j] %= mod;
				}
			}
		}
		return ret;
	}

	Matrix<T>& operator=(mat&& rhs){ m = rhs; row = rhs.size(); col = rhs[0].size(); return (*this);}
	Matrix<T>& operator=(Matrix&& rhs){ m = rhs.m; row = rhs.row; col = rhs.col; return (*this);}
	const vector<T>& operator[](int32 x) const{ return m[x];}
	vector<T>& operator[](int32 x){return m[x];}

};


int main(void){
	int64 N, K;
	cin >> N >> K;
	Matrix<int64> mat(N, N), mat2(1, N);
	REP(i, N){
		REP(j, N){
			cin >> mat[i][j];
		}
		mat2[0][i] = 1;
	}
	mat = mat.pow(K);
	int64 res = 0;
	REP(i, N){
		REP(j, N){
			res = (res+mat[i][j])%mod;
		}
	}
	cout << res << endl;
}


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

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
#ifdef sweety_candy
	freopen("input.txt","rt",stdin);
	freopen("ouput.txt","w",stdout);
#endif	
	double a, b;
	cin >> a >> b;
	double ans = (double) (a/b);
	cout << fixed << setprecision(10) << ans;			
#ifdef sweety_candy
	cout << " Time elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


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

int main() {
  
 int n;
 cin >> n;
  vector<int> p(n);
  
  
    for (int i = 0;i < n;i++) cin >> p[i];
    int count = 0;
    for (int i = 1;i < n - 1;i++) {   
      if((p[i-1] < p[i]) && (p[i] < p[i+1])) count++;
      else if((p[i-1] > p[i]) && (p[i] > p[i+1])) count++;
      }
  cout << count << endl;
  return 0;
}




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

using namespace std;

void Main() {
    int x;
    cin >> x;
    x = (x == 0) ? 1 : 0;
    cout << x << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <set>
using namespace std;
int main(int argc, char* argv[])
{
	int a,b,c;
	cin>>a>>b>>c;
	set<int> S;
	S.insert(a);
	S.insert(b);
	S.insert(c);
	cout<<S.size()<<endl;
	return 0;
}

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

using namespace std;

//#define FILE_IO

typedef pair<int, int> pii;
typedef pair<pii, pii> p4i;

int N, M, K;
vector <p4i> v;
int par[500005];

bool onBorder(int a1, int b1) { return (a1 == 0 || a1 == N || b1 == 0 || b1 == M); }

class Normalizator
{
public:
    map<int, int> mp;
    vector <int> ord;

    void add(int x)
    {
        if(mp.count(x)) return;
        mp[x];
        ord.push_back(x);
    }

    void normalize()
    {
        sort(ord.begin(), ord.end());
        for(int i = 0; i < ord.size(); i++)
            mp[ ord[i] ] = i + 1;
    }

    int get(int x) { return mp[x]; }
} nrmX, nrmY;

int getValue(int x, int y)
{
    if(x == 1)  return y;
    if(y == M)  return x - 1 + M;
    if(x == N)  return (M - y) + N + M - 1;
    if(y == 1)  return (N - x) + N + M + M - 2;
    return -1;
}

void yes() { printf("YES"); exit(0); }
void no() { printf("NO"); exit(0); }

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d%d", &N, &M);
    scanf("%d", &K);
    for(int i = 1; i <= K; i++)
    {
        int a1, b1, a2, b2;
        cin >> a1 >> b1 >> a2 >> b2;

        if( onBorder(a1, b1) && onBorder(a2, b2) )
            v.push_back( { {a1, b1}, {a2, b2} } );
    }

    nrmX.add(0);
    nrmX.add(N);
    nrmY.add(0);
    nrmY.add(M);
    for(auto s: v)
    {
        nrmX.add(s.first.first);
        nrmX.add(s.second.first);
        nrmY.add(s.first.second);
        nrmY.add(s.second.second);
    }

    nrmX.normalize();
    nrmY.normalize();

    N = nrmX.get(N);
    M = nrmY.get(M);

    for(auto it = begin(v); it != end(v); it++)
    {
        (*it).first.first = nrmX.get( (*it).first.first );
        (*it).first.second = nrmY.get( (*it).first.second );
        (*it).second.first = nrmX.get( (*it).second.first );
        (*it).second.second = nrmY.get( (*it).second.second );
    }

    int id = 0;
    for(auto x: v)
    {
        id++;
        int val1 = getValue(x.first.first, x.first.second);
        int val2 = getValue(x.second.first, x.second.second);
        if(val1 > val2) swap(val1, val2);

        par[val1] = id;
        par[val2] = -id;
    }

    stack<int> stv;
    for(int i = 0; i <= 2 * (N + M); i++)
        if(par[i] != 0)
        {
            if(par[i] > 0)  stv.push(par[i]);
            else
            {
                if(stv.empty()) no();
                if(-par[i] == stv.top()) stv.pop();
                else    no();
            }
        }
    yes();

    return 0;
}


Measured memory_bytes: 13680
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <cstdlib>

using namespace std;

typedef long long ll;
#define rep(i, n) for(long long int (i) = 0; (i) < (long long int) (n); (i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const ll LINF = 1e18;

int printYes() {
    cout << "Yes" << endl;
    return 0;
}

int printNo() {
    cout << "No" << endl;
    return 0;
}

int main(int argc, char const *argv[])
{
    int N, M;
    cin >> N >> M;
    
    vector<int> vec(M);
    rep(i, M) {
        cin >> vec[i];
    }
    sort(ALL(vec));
    vector<int> sub(M-1);
    rep(i, M -1) {
        sub[i] = vec[i + 1] - vec[i];
    }
    sort(ALL(sub));
    int ans = 0;
    rep(i, M - N) {
        ans += sub[i];
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  bool a = false;
  for(int i=0;i<26;i=i+1){
    for(int j=0;j<15;j=j+1){
      int sum = 4*i + 7*j;
      if(sum == N){
        a = true;
        goto SKIP;
      }
    }
  }
  SKIP:  
  if(a)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <string.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <math.h>
#include <set>
#include <vector>
#include <algorithm>
#include <map>


using namespace std;

typedef long long ll;
#define PI 3.1415927
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

bool buy[105];

int main(){
    ios::sync_with_stdio(false);

    int i, j;
    memset(buy, 0, sizeof(buy));
    for(i = 0; 4*i <= 100; i++){
        for(j = 0; 4*i+7*j <= 100; j++){
            buy[4*i+7*j] = 1;
        }
    }
    int N;
    while(scanf("%d", &N) != EOF){
        if(buy[N])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }

    return 0;
}

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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES\n")
#define Yes puts("Yes\n")
#define NO  puts("NO\n")
#define No  puts("No\n")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }



signed main() {

	int N;
	cin >> N;
	vector<int> A(N), B(N);
	rep(i, N) cin >> A[i];
	rep(i, N) cin >> B[i];

	int ans = 0;
	while (true) {
		priority_queue<P> q;

		rep(i, N) q.push({ B[i],i });

		int difmax = -INF;
		rep(i, N){
			int diff = B[i] - A[i];
			if (diff > difmax)difmax = diff;
		}

		if (difmax == 0) break;
		if (difmax < 0) { cout << -1 << endl; return 0; }

		bool f = false;
		while (!q.empty()) {
			pair<int, int> t = q.top();
			q.pop();

			int idx = t.second;
			int d = t.first;

			int div = (B[idx] - A[idx]) / (B[(idx - 1 + N) % N] + B[(idx + 1) % N]);
			if (div != 0) f = true;
			B[idx] -= (B[(idx - 1 + N) % N] + B[(idx + 1) % N]) * div;
			ans += div;
//			rep(i, N) cerr << B[i] << " ";
//			cerr << endl;
		}
		if (f == false) { cout << -1 << endl; return 0; }
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 12852
a = input()
if a=="SUN":
  print(7)
elif a=="MON":
  print(6)
elif a=="TUE":
  print(5)
elif a=="WED":
  print(4)
elif a=="THU":
  print(3)
elif a=="FRI":
  print(2)
elif a=="SAT":
  print(1)   

Measured memory_bytes: 9112
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

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

	Int N, A;
	cin >> N >> A;

	vector<Int> x(N);
	for (Int i = 0; i < N; i++) {
		cin>>x[i];
	}

	vector<vector<vector<Int>>> dp(N + 1, vector<vector<Int>>(N + 1, vector<Int>(2501)));
	dp[0][0][0] = 1;

	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j < N; j++) {
			for (Int k = 0; k < 2501; k++) {
				//選ばない
				dp[i + 1][j][k] += dp[i][j][k];
				//選ぶ
				if (k - x[i] >= 0) {
					dp[i + 1][j + 1][k] += dp[i][j][k - x[i]];
				}
			}
		}
	}

	Int ans = 0;
	for (Int j = 1; j <= N; j++) {
		ans += dp[N][j][A * j];
	}
	cout << ans << "\n";
}

Measured memory_bytes: 52224
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    while(true){
        int H, W;
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        for(int i=0; i<H; i++){
            if(i == 0 || i == H-1){
                for(int j=0; j<W; j++) cout << '#';
            }else{
                cout << '#';
                for(int j=1; j<W-1; j++){
                    cout << '.';
                }
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3072
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N;
	in >> N;
	std::vector<LL>A(N);
	rep(i, N) in >> A[i];

	LL ans = 0, min = 1145148101919, cnt = 0;
	rep(i, N) ans += std::abs(A[i]);
	rep(i, N)
	{
		min = std::min(min, std::abs(A[i]));
		if (A[i] == 0)
		{
			out << ans << std::endl;
			return 0;
		}
		if (A[i] < 0) ++cnt;
	}
	if (cnt % 2 == 1) ans -= min * 2;

	out << ans << std::endl;
}


Measured memory_bytes: 1024
S = input()
T = input()

ans = "Yes"
 
for i in range(0,len(S)):
  for j in range(0,i):
    if S[j] == S[i]:
      if T[i] != T[j]:
        ans = "No"
        break
      break
    if T[j] == T[i]:
      if S[j] != S[i]:
        ans = "No"
        break
      break
print(ans)

Measured memory_bytes: 3760
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[]) {
	LL n, ga, sa, ba, gb, sb, bb;
	cin >> n >> ga >> sa >> ba >> gb >> sb >> bb;
	vector<LL> dp(n + 1);
	for (LL i = 0; i <= n; ++i) {
		dp[i] = i;
	}
	for (LL i = ga; i <= n; ++i) {
		dp[i] = max(dp[i], dp[i - ga] + gb);
	}
	for (LL i = sa; i <= n; ++i) {
		dp[i] = max(dp[i], dp[i - sa] + sb);
	}
	for (LL i = ba; i <= n; ++i) {
		dp[i] = max(dp[i], dp[i - ba] + bb);
	}
	LL mx = *max_element(dp.begin(), dp.end());
	dp = vector<LL>(mx + 1);
	for (LL i = 0; i <= mx; ++i) {
		dp[i] = i;
	}
	for (LL i = gb; i <= mx; ++i) {
		dp[i] = max(dp[i], dp[i - gb] + ga);
	}
	for (LL i = sb; i <= mx; ++i) {
		dp[i] = max(dp[i], dp[i - sb] + sa);
	}
	for (LL i = bb; i <= mx; ++i) {
		dp[i] = max(dp[i], dp[i - bb] + ba);
	}
	LL ans = *max_element(dp.begin(), dp.end());
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 195584
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int table[110000];
void createTable(string pat){
    table[0] = -1;
    int j = -1;
    for(int i = 0; i < pat.size(); i++){
        while(j >= 0 && pat[i] != pat[j]){
            j = table[j];
        }
        j += 1;
        table[i + 1] = j;
    }
}

int KMPSearch(string target, string pattern){
    createTable(pattern);
    int ret = 0;
    int i = 0, p = 0;
    while(i < target.size() && p < pattern.size()){
        if(target[i] == pattern[p]){
            i += 1;
            p += 1;
        }else if(p == 0){
            i += 1;
        }else{
            p = table[p];
        }
        ret = max(ret, p);
    }
    return ret;
}

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans = 0;
    for(int i = 1; i < N; i++){
        ans = max(ans, KMPSearch(S.substr(0, i), S.substr(i)));
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//Author: Herson Rezende - 2ºSemestre de CC - UFBA - 2020
//Site: hrezend.github.io/resume-web
#include <bits/stdc++.h>
#define desync ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define all(x) (x.begin(), x.end())
#define rall(x) (x.rbegin(), x.rend())
#define mkp(x,y) (make_pair(x,y))
#define out(x) cout << x << endl
using namespace std;

int main(){
	desync;
	int inicio, fim, multiplo, count = 0;
	cin >> inicio >> fim >> multiplo;
	
	for(int i = inicio; i <= fim; i++){
		if(i % multiplo == 0){
			count++;
		}
	}
	out(count);
}


Measured memory_bytes: 3604
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author AnandOza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DCaracalVsMonster solver = new DCaracalVsMonster();
        solver.solve(1, in, out);
        out.close();
    }

    static class DCaracalVsMonster {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long h = in.nextLong();

            long answer = f(h);

            out.println(answer);
        }

        private static long f(long h) {
            if (h == 0)
                return 0;
            return 1 + 2 * f(h / 2);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 21844
n = int(input())
l = [int(x) for x in input().split()]
cnt = 0
f = False
while True:
    if f:
        break
    for i in range(len(l)):
        if l[i] % 2 == 0:
            l[i] = l[i] // 2
        else:
            f = True
            break
    else:
        cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 3e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
int n;
ll a[maxx];
ll suml[maxx], sumr[maxx];
ll s1, s2;
priority_queue <ll, vector<ll>, less<ll> > qua; //降序, 队头大
priority_queue <ll, vector<ll>, greater<ll> > que; //升序, 队头小

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n * 3; i++) {
		scanf("%lld", &a[i]);
		if(i <= n) {
			s1 += a[i];
			que.push(a[i]);
		}
		else if(i >= 2 * n + 1) {
			s2 += a[i];
			qua.push(a[i]);
		}
	}
	suml[n] = s1; //前n项和
	sumr[n * 2 + 1] = s2; //后n项和
	int l = n + 1, r = 2 * n;
	//只能精确删除n项, 无论怎么删, 后n项都不可能进到前n项去
	//故让中间的n项去往两边置换(相当于在两边删除)
	//中间的n项必然是前x个置换到前n项内, 后n-x个置换到后n项内(或者不发生置换)
	//故分别维护前缀和、后缀和, 前缀和与后缀和的差维护一个最大值
	while(l <= r) {
		if(a[l] > que.top()) { //每次置换出最小的队头
			s1 += a[l];
			s1 -= que.top();
			que.pop();
			que.push(a[l]);
		}
		suml[l] = s1; //维护前缀和
		l++;
	}
	l = n + 1, r = 2 * n;
	while(l <= r) {
		if(a[r] < qua.top()) { //每次置换出最大的队头
			s2 += a[r];
			s2 -= qua.top();
			qua.pop();
			qua.push(a[r]);
		}
		sumr[r] = s2; //维护后缀和
		r--;
	}
	ll ans = -INF;
	for(int i = n; i <= n * 2; i++) ans = max(ans, suml[i] - sumr[i + 1]);
	printf("%lld\n", ans);
}

Measured memory_bytes: 7668
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

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

using namespace std;
typedef long long int ll;
typedef pair<int,int> PI;

int A, P;
int main(void){
    cin >> A >> P;
    cout << (A*3+P)/2 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define eb emplace_back
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define all(a) (a.begin(),a.end())

using ll = long long;
using namespace std;
template<typename... Args>
void read(Args&... args)
{((cin >> args), ...);}

template<typename... Args>
void write(Args... args)
{((cout << args << " "), ...);}

template<typename... Args>
void writeln(Args... args)
{((cout << args << " "), ...); cout << "\n";}

template<typename T>
void read(vector<T> &a)
{for (auto &ele : a) cin >> ele;}

template<typename T>
void writeln(vector<T> &a)
{for (auto &ele : a) cout << ele << ' '; cout << "\n";}

const pii dxy[] = {{ -1, 0}, {1, 0}, {0, -1}, {0, 1}};
const pii fxy[] = {{ -1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, { -1, -1}, { -1, 1}, {1, -1}};

int dp[100005];

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin.tie(0); cout.tie(0);
	ios::sync_with_stdio(false);
//	int t;cin >> t;while(t--) solve();
	int n;
	read(n);
	vector<int> a(n);
	read(a);


	for (int i = 1; i < n; ++i) {
		dp[i] += dp[i - 1] + abs(a[i] - a[i - 1]);


	}

	for (int i = 1; i < n; ++i) {
		if (i - 1 >= 0) {
			dp[i] = min(dp[i], dp[i - 1] + abs(a[i] - a[i - 1]));
		}
		if (i - 2 >= 0) {
			dp[i] = min(dp[i], dp[i - 2] + abs(a[i] - a[i - 2]));
		}
	}
	writeln(dp[n - 1]);
	return 0;
}



Measured memory_bytes: 3964
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi; 
typedef vector< vi > vvi; 
/////////////////////////
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define loop(i,a,b) for (int i = a; i < b; i++)
//////////////////////////
#define printvector(n) for(int i=0;i<n.size();i++){cout<<n[i]<<" ";}cout<<'\n'
#define printstack(n) for(int i=0;i<n.size();i++){cout<<n[i]<<" ";}cout<<'\n'
#define PI_val 3.14159265359
#define printpair(n) cout<<n.F<<" "<<n.S
#define printvop(n) loop(i,0,n.size()-1){printpair(n[i])<<endl;}
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
long long int mod=1000000007;
//////////////////////////

int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("E:/codes/testcases/input.in", "r", stdin);
    // for writing output to output.txt
    freopen("E:/codes/testcases/output.in", "w", stdout);
    #endif
    long long int a,b,x,n,c,m,k,sum=0,ans=0,res=0,q;
    cin >> n;
    map<int, int> amap;
    ;
    int arr[n];
            loop(i,0,n)
            {
                cin>>arr[i];
                sum+=arr[i];
                if(amap[arr[i]]>0){
                                amap[arr[i]]++;}
                else{
                    amap[arr[i]]=1; 
                }
            }
  
    cin>>q;

for (int i = 0; i < q; ++i)
    {
    	/* code */
    	cin>>b>>c;
        sum-=amap[b]*b;
        sum+=amap[b]*c;
        
        amap[c]+=amap[b];
        amap[b]=0;
        
        cout<<sum<<endl;

    }    //       printvector(arr);
    //        sort(arr.begin(),arr.end());
    

    return 0;
}


Measured memory_bytes: 8476
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int,int> Q;
typedef pair<int,Q> P;

int main(){
  int n,m,a;

  while(cin >> n >> m >> a , n | m | a){
    vector<P> v;
    int h,p,q;
    for(int i = 0 ; i < m ; i++){
      cin >> h >> p >> q;
      v.push_back(P(h,Q(p,q)));
    }
    sort(v.begin(),v.end(),greater<P>());

    for(int i = 0 ; i < (int)v.size() ; i++){
      if(v[i].second.first == a) a = v[i].second.second;
      else if(v[i].second.second == a) a = v[i].second.first;
    }
    cout << a << endl;
  }

  return 0;
}

Measured memory_bytes: 1224
import sys
input = sys.stdin.readline
from collections import deque

def main():
	n, k = map(int, input().strip().split())
	v = deque(map(int, input().strip().split()))
	ans = 0
	for i in range(k+1):
		for j in range(k - i + 1):
			now = 0
			s = []
			if i + j > n:
				continue
			md = k - i - j
			for t in range(i):
				s.append(v[t])
				now += v[t]
			for t in range(j):
				s.append(v[n-1-t])
				now += v[n-1-t]
			s.sort()
			# for t in range(min(md, i+j)):
			# 	# print("t:{}, len:{}".format(t, len(s)))
			# 	if s[t] >= 0:
			# 		break
			# 	else:
			# 		s[t] = 0
			for t in range(md):
				if t >= len(s):
					break
				if s[t] >= 0:
					break
				now -= s[t]
			ans = max(now, ans)

	print(ans)


if __name__ == '__main__':
	main()


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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl ;
#define Yes cout << "Yes" << endl ;
#define NO cout << "NO" << endl ;
#define No cout << "No" << endl ;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
	
    lli h , a ;
  cin >> h >> a ;
  lli cnt = 0 ;
  for(; h > 0 ; h-=a , cnt ++)
    ;
  cout <<cnt ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int min(int x,int y){
if(x<y)
return x;
else
return y;


}
int max(int x,int y){
if(x>y)
return x;
else
return y;


}
int main(){
int a,b;
while(true){
cin>>a>>b;
if(a==0&&b==0)
break;
cout<<min(a,b)<<' '<<max(a,b)<<'\n';

}



return 0;
}

Measured memory_bytes: 3060
using System;
class hoge
{
    static void Main()
    {
        int i = 0;
        string input;
        bool notZero = true;
        while (notZero)
        {
        i+= 1;
        input = Console.ReadLine();
            if(input != "0")
            {
                Console.WriteLine("Case {0}: {1}", i, input);
            }else
            {
                notZero = false;
            }
        }
    }
}

Measured memory_bytes: 9292
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int ufpar[100020]; //グローバル変数
void ufinit(void){for(int i=0;i<100020;i++){ufpar[i]=i;}}//初期化
int uffind(int X){if(ufpar[X]!=X)return ufpar[X]=uffind(ufpar[X]);return X;}//親の検索
void ufunite(int X,int Y){ufpar[uffind(X)]=uffind(Y);}//結合
bool ufsame(int X,int Y){return uffind(X)==uffind(Y);}//判定


int main(void){
    ufinit();
    int n,m;
    scanf("%d%d",&n,&m);
    int ans=0;
    
    
    
    for (int i=0; i<m; i++){
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        ufunite(x-1,y-1);
    }
    
    for (int i=0; i<n; i++){
        if (ufpar[i]==i){
            ans++;
        }
    }

    printf("%d\n",ans);
    return 0 ;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const string YES = "Yes";
const string NO = "No";

void solve(long long K, long long X){
    if(K * 500 >= X){
        cout<<YES<<endl;
    }else{
        cout<<NO<<endl;
    }
}

int main(){
    long long K;
    scanf("%lld",&K);
    long long X;
    scanf("%lld",&X);
    solve(K, X);
    return 0;
}


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

using namespace std;
typedef long long ll;

const int N=2e5+100;
ll dp[55][55][55*55];///总共有i张牌选了j张的总和为k的个数
ll x[55];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int n,a;
    cin>>n>>a;
    for(int i=1;i<=n;i++){
        cin>>x[i];
    }
    for(int i=0;i<=n;i++){
      for(int j=0;j<=n;j++){
        for(int k=0;k<=n*a;k++){
            if(i==0&&j==0&&k==0) dp[i][j][k]=1;
            else if(i>=1&&k<x[i]) dp[i][j][k]=dp[i-1][j][k];
             else if(i>=1&&j>=1&&k>=x[i]) dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-x[i]];
             else dp[i][j][k]=0;
        }
      }
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        ans+=dp[n][i][i*a];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 64796
#include <bits/stdc++.h>
using namespace std;
vector<long long> ans;
vector<vector<long long>> node;
vector<bool> visited;

void dfs(long long n) {
  visited[n] = true;
  for (auto child : node[n]) {
    if (visited[child]) continue;
    ans[child] += ans[n];
    dfs(child);
  }
}

int main(void) {
  long long N, Q;
  cin >> N >> Q;
  ans.resize(N, 0);
  node.resize(N);
  visited.resize(N, false);
  for (long long i = 0; i < N - 1; i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    node[a].push_back(b);
    node[b].push_back(a);
  }

  for (long long i = 0; i < Q; i++) {
    long long p, x;
    cin >> p >> x;
    p--;
    ans[p] += x;
  }

  dfs(0);

  for (long long i = 0; i < N - 1; i++) {
    cout << ans[i] << " ";
  }
  cout << ans[N - 1] << endl;
  return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 10; i >= 0; i--) {
    if (n >= (1 << i)) {
      cout << (1 << i) << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    double A, B, C, D, E, F; cin >> A >> B >> C >> D >> E >> F;

    pair<int, int> ans;
    double maxv = 0.0;

    for(int i=0; i<=F/(100*A); i++){
        for(int j=0; j<=F/(100*B); j++){
            if(i == 0 && j == 0) continue;

            for(int k=0; k<=F/C; k++){
                for(int l=0; l<=F/D; l++){
                    
                    double solution = 100*A*i + 100*B*j + C*k + D*l;
                    double solute = C*k + D*l;

                    if(solution <= F && solute <= E*(A*i + B*j)){
                        if(solute/solution >= maxv){
                            maxv = solute/solution;
                            ans = {solution, solute};
                        }
                    }
                }
            }
        }
    }

    printf("%d %d\n", ans.first, ans.second);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	int N;
	int[]a;
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		N=sc.nextInt();
		a=new int[N];
		for(int i=0;i<N;i++){
			a[i]=sc.nextInt();
		}
		
		int min=Integer.MAX_VALUE/2;
		for(int i=-100;i<=100;i++){
			int sum=0;
			
			for(int j=0;j<N;j++){
				sum+=(a[j]-i)*(a[j]-i);
			}
			min=Math.min(min, sum);
		}
		
		System.out.println(min);
	}
}

Measured memory_bytes: 21844
class Stack:
    def __init__(self, data=None):
        # Pythonではクラスのデフォルト引数は１度しか初期化されないため、
        # うっかりdata=[]としてしまうと、複数のインスタンスを生成したときに
        # 同じ配列を参照することになってしまう！！！
        # http://amacbee.hatenablog.com/entry/2016/12/07/004510
        if data is None:
            self.data = []
        else:
            self.data = data

    def push(self, x):
        self.data.append(x)

    def pop(self):
        if self.is_empty() is True:
            return None
        else:
            return self.data.pop(-1)

    def is_empty(self):
        if len(self.data) == 0:
            return True
        else:
            return False

    def get_length(self):
        return len(self.data)

    def reverse(self):
        self.data.reverse()


# \\//
# \\///\_/\/\\\\/_/\\///__\\\_\\/_\/_/\

diagram = input()
A = 0  # 総面積
k = 0  # 水たまりの数
L = []  # 各水たまりの面積

s1 = Stack()
s2 = Stack()

new_flood = False

# s1.push(10)
# s1.push(20)
# s1.push(30)
# print(s2.data)

for i, vector in enumerate(diagram):
    # print('----------')
    # print(i, vector)

    if vector == '\\':
        # print('下り')
        # print('test')
        s1.push(i)

        # 個別
        # data = {'first_pos': i, 'area': 0}
        # s2.push(data)
        # grad = 'down'

        new_flood = True

    elif vector == '/':
        # print('上り')
        j = s1.pop()
        if j is not None:
            # print(i, j)
            A += i - j

            # current_flood = s2.pop()
            # if current_flood['first_pos'] =
            # Agenshidan88
            # = i:
            #     current_flood['area'] += i - j

            size = i - j

            if new_flood is True:
                s2.push({'first_pos': j, 'size': size})
                new_flood = False

            # if s2.is_empty() is True:
            #     s2.push({'first_pos': j, 'area': i-j})

            else:
                current_flood = s2.pop()
                current_flood['first_pos'] = j
                current_flood['size'] += size

                while True:
                    prev_flood = s2.pop()
                    if prev_flood is not None:
                        if prev_flood['first_pos'] > j:
                            current_flood['size'] += prev_flood['size']
                        else:
                            s2.push(prev_flood)
                            s2.push(current_flood)
                            break
                    else:
                        s2.push(current_flood)
                        break

    # print(s1.data)
    # print(s2.data)
    # print('----------')

print(A)

output = str(s2.get_length())
for elem in s2.data:
    output += ' ' + str(elem['size'])

print(output)



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

int main()
{
    int n;
    scanf("%d",&n);
    if((floor((int)(n/1.08)*1.08))==n) printf("%d\n",(int)(n/1.08));
    else if((floor(((int)(n/1.08)+1)*1.08))==n) printf("%d\n",(int)(n/1.08)+1);
    else printf(":(\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

bool solve() {
    ll N, d1, d2;
    cin >> N;
    ll c = 0, cm = 0;
    for ( int i = 0; i < N; i++ ) {
        cin >> d1 >> d2;
        if ( d1 == d2 ) {
            c++;
            cm = max(cm, c);
        } else {
            c = 0;
        }
    }
    return cm >= 3;
}

int main() {
    string ans = solve() ? "Yes" : "No";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m;
signed main(){
	scanf("%lld%lld",&n,&m);
	if (n<=9&&m<=9&&n>0&&m>0){
		printf("%lld\n",n*m);
	}
	else puts("-1");
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
int main()
{
	int n;
	vector<int>num;
	vector<int>dp;
	cin >> n;
	dp.resize(n);
	for(int i=0;i<n;i++)
	{
		int temp;
		cin >> temp;
		num.push_back(temp);
	}
	dp[0] = num[0];
	dp[1] = abs(num[0] - num[1]);
	for (int i = 2; i < n; i++)
	{
		int temp1 = abs(num[i] - num[i - 1]) + dp[i - 1];
		if (i - 1 == 0)temp1 -= dp[i - 1];
		int temp2 = abs(num[i] - num[i - 2]) + dp[i - 2];
		if (i - 2 == 0)temp2-= dp[i - 2];
		dp[i] = temp1<temp2?temp1:temp2;
	}
	cout << dp[n - 1];
	return 0;
}

Measured memory_bytes: 1276