akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

//dp
int n, m;
vector<P> vp2;
ll dp[510][1100];

int main() {
	cin >> n >> m;
	if (m == 0) {
		cout << n + 1 << endl;
		return 0;
	}
	rep(i, m) {
		ll c, d;
		cin >> c >> d;
		vp2.push_back({ c,d });
	}
	sort(ALL(vp2));
	rep(i, 510)rep(j, 1010)dp[i][j] = INF;
	dp[0][0] = 0;
	int now = 0;
	rep(i, vp2.size()) {
		ll ci = vp2[i].first;
		ll di = vp2[i].second;
		FOR(j, di, n + 2) {//新しく経由する点
			FOR(k, now, n + 2) {//今までに経由した点
				if (k < j)dp[i + 1][j] = min(dp[i + 1][j], dp[i][k] + (j - now) + (j - ci));
				else dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + (ci - now));
			}
		}
		now = ci;
	}
	ll ans = INF;
	rep(i, n + 2) {
		ans = min(dp[vp2.size()][i] + n + 1 - now, ans);
	}
	cout << ans << endl;
}

//int n, m;
//vector<P> vp;
//int sum[100100];
//
//int main() {
//	cin >> n >> m;
//	vp.resize(m);
//	rep(i, m) {
//		int a, b;
//		cin >> a >> b;
//		sum[a]++;
//		sum[b]--;
//	}
//	rep(i, n + 2)sum[i + 1] += sum[i];
//	ll ans = 0;
//	rep(i, n + 1) {
//		if (sum[i] > 0)ans += 3;
//		else ans++;
//	}
//	cout << ans << endl;
//}


Measured memory_bytes: 7516
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
 #define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        3e18
 #define sm         -2e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
    freopen("gout.txt", "w", stdout);
   
    #endif
}



int dp[3001][6001];
pii a[3001];

void solve()
{
  
  int n,t,an=-1;
  cin >> n >> t;

  forf(i,1,n+1) cin >> a[i].fi >> a[i].se;
  

  sort(a+1,a+n+1);
  
  for(int i=1;i<=n;i++)
  {
     for(int j=0;j<=6000;j++) dp[i][j] =dp[i-1][j];

     for(int j=0;j<t;j++)  dp[i][j+a[i].fi] = max(dp[i][j+a[i].fi] , dp[i-1][j]+ a[i].se); 
  }
  
  for(int i=1;i<=6000;i++) an = max(an , dp[n][i]);
  cout<<an;

}


int32_t main()
{
  pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
   // cout << "Time taken by function: "
   //       << duration.count() << " microseconds" << endl; 

 }
      
      

Measured memory_bytes: 144220
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
    long long n, m, k;
    cin >> n >> m >> k;
    for (long long i = 0; i <= n; i++) {
        for (long long j = 0; j <= m; j++) {
            if (i * m + j * n - i * j * 2 == k) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    vector<vector<int>> a(n, vector<int>(m));
    rep(i, n) {
        rep(j, m) {
            scanf("%d", &a[i][j]);
        }
    }
    vector<int> b(m);
    rep(i, m) {
        scanf("%d", &b[i]);
    }

    vector<int> c(n);
    rep(i, n) {
        int sum = 0;
        rep(j, m) {
            sum += a[i][j] * b[j];
        }
        c[i] = sum;
        printf("%d\n", c[i]);
    }
}


Measured memory_bytes: 3304
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 998244353
using namespace std;
int main() {
    string s;
    cin >> s;
    for(int i = 0; i < s.size() - 8; i++) {
        cout << s[i];
    }
    cout << endl;
}

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

#define LLINF (1LL<<60)
typedef long long ll;

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

//C++14 (GCC 5.4.1)
int main() {
    int N;
    cin >>N;

    ll An[N+1];
    An[0]=2;
    An[1]=1;
    rep(i,N-1){
        An[i+2]=An[i]+An[i+1];
    }
    cout<< An[N] <<endl;

    return (0);
}

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

using namespace std;

int main(){
  
  long long n;
  cin>>n;
  long long a[n];
  for(long long i=0;i<n;i++)
    cin>>a[i];
  
  long long dp[n];
  dp[0]=0;dp[1]=abs(a[1]-a[0]);
  for(long long i=2;i<n;i++)
    dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
  
  cout<<dp[n-1]<<endl;
  
 return 0; 
}

Measured memory_bytes: 1792
//TO CHANGE THE WORLD
#include <bits/stdc++.h>

using namespace std;

#define L first
#define R seoncd
#define mp make_pair
#define pb push_back
typedef long long ll;

const int maxn=1e5+10;

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int l, r;
    cin>>l>>r;
    if(l<=0 && r>=0) return cout<<"Zero"<<endl, 0;
    if((min(r,0)-l+1)%2==0) cout<<"Positive"<<endl;
    else cout<<"Negative"<<endl;
}

Measured memory_bytes: 256
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	int q;
	cin >> s >> q;
	deque<char> dq;
	REP(i,s.size()) dq.push_back(s[i]);
	bool back_f = true;
	while(q){
		int t;
		cin >> t;
		if(t==1) back_f = !back_f;
		else{
			int f;
			char c;
			cin >> f >> c;
			if(f==1){
				if(back_f) dq.push_front(c);
				else dq.push_back(c);
			}else{
				if(back_f) dq.push_back(c);
				else dq.push_front(c);
			}
		}
		q--;
	} 
	if(back_f) REP(i,dq.size()) cout << dq[i];
	else REPR(i,dq.size()-1) cout << dq[i];
	return 0;
}



Measured memory_bytes: 976
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		long K = in.nextLong();
		long[] A = new long[N];
		for (int i = 0; i < N; i++) {
			A[i] = in.nextLong();
		}

		long X = 0;
		for (int i = 39; i >= 0; i--) {
			int count = 0;
			for (long l : A) {
				count += (1 & (l >> i));
			}
			if (count <= N / 2) {
				long temp = X | 1L << i;
				if (temp <= K) {
					X = temp;
				}
			}
		}

		long sum = 0;
		for (long l : A) {
			sum += (X ^ l);
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 62744
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,B,C,K;
  cin >> A>>B>>C>>K;
  int sum=0;
  if(K<=A){
    sum=K;
  }else if(A<K&&K<=A+B){
    sum=A;
  }else{
    sum=A-1*(K-A-B);
  }
  cout << sum << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

lint F(lint x)
{
    if (x <= 0)
        return 0LL;

    // 2^40 > 10^12
    const int MAXBIT = 40;
    VEC(int) xbits(MAXBIT);
    FOR(i, 0, MAXBIT)
        xbits[i] = (int)((x >> i) & 1LL);

    lint ret = 0, pref = 0;
    FORD(i, MAXBIT - 1, -1) {
        // put one here.
        // (pref + 1) * (suff + 1)
        lint suff = 0;
        FORD(j, i - 1, -1)
            suff = suff * 2 + xbits[j];

        int lsb = i;
        lint total = pref << lsb;
        if (xbits[i] == 1)
            total += suff + 1;

        if (total % 2 == 1)
            ret += 1LL << i;

        pref = 2 * pref + xbits[i];
    }

    return ret;
}

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    lint A, B;
    cin >> A >> B;
    cout << (F(B) ^ F(A - 1)) << endl;
    return 0;
};


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long

using namespace std;

typedef pair<int, int> td;

int main(){
    #ifdef ZERBRA
        freopen("code.inp", "r", stdin);
        //freopen("code.out", "w", stdout);
    #endif // ONLINE_JUDGE
    int n, k;
    scanf("%d%d", &n, &k);
    ll a[100000], op[100000];
    for (int i = 0; i < n; ++i){
        scanf("%I64d", &a[i]);
        op[i] = 1e9 + 5;
    }
    op[0] = 0;
    for (int i = 0; i < n; ++i)
        for (int j = i+1; j <= i+k && j < n; ++j)
            op[j] = min(op[j], op[i] + abs(a[i]-a[j]));
    printf("%lld", op[n-1]);
    return 0;
}


Measured memory_bytes: 1792
input = STDIN.readlines.map{|line|line.strip.split()}
line = input.shift
n = line[0].to_i

counts = Hash.new(0)
Range.new(2, n).each do |out_r|
    temp = out_r
    while temp > 1
        Range.new(2, temp).each do |in_r|
            if temp % in_r == 0 then
                counts[in_r] += 1
                temp /= in_r
                break
            end
        end
    end
end
ans = 0
ans += counts.select{|k,c|c>=74}.size
ans += counts.select{|k,c|c>=24}.size * (counts.select{|k,c|c>=2}.size - 1)
ans += counts.select{|k,c|c>=14}.size * (counts.select{|k,c|c>=4}.size - 1)
if counts.select{|k,c|c>=4}.size >= 2 then
    ans += counts.select{|k,c|c>=4}.size * (counts.select{|k,c|c>=4}.size - 1) / 2 * (counts.select{|k,c|c>=2}.size - 2)
end
puts(ans)

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

ll gcd(ll a, ll b) {
	if(!b)	return a;
	return gcd(b, a % b);
}

int main(void) {
	ll a, b;	cin >> a >> b;
	ll g = gcd(a, b);
	int cnt = 1;
	for(ll i = 2; i * i <= g; ++i) if(g % i == 0) {
		while(g % i == 0)	g /= i;
		++cnt;
	}
	if(g != 1)	++cnt;
	cout << cnt;
	return 0;
}

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

int main()
{
	string S, T;
	cin >> S >> T;
	vector<int> P(26, -1);
	vector<int> Q(26, -1);
	bool ans = true;
	for (int i = 0; i < S.size(); i++)
	{
		int a = S[i] - 'a';
		int b = T[i] - 'a';

		if (P[a] < 0) P[a] = b;
		if (Q[b] < 0) Q[b] = a;
		if (P[a] >= 0 && P[a] != b)	ans = false;
		if (Q[b] >= 0 && Q[b] != a) ans = false;
    }
	if (ans)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 776
#include <iostream>
using std:: cout;
using std:: cin;
using std::endl;



int main() {

long num1, num2;
cin >> num1 >> num2;

if(num1 % 2 != num2 % 2) {
cout << "IMPOSSIBLE" << endl; //bc both of them need to be divided by 2
}

else {
cout << (num1 + num2) / 2 << endl; //bc k = (num1 + num2) / 2 if u add A and B
}
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int m,k;
int main()
{
	cin>>m>>k;
	if(m==1)
	{
		if(k==0)
		  cout<<"0 0 1 1"<<endl;
		else 
		  cout<<-1<<endl;
	}
	else 
	  if(k>=1<<m)
	  {
	    cout<<-1;
	    return 0;
	  }
	else
	{
		for(int i=0;i<1<<m;i++)
		  if(i!=k)
		    cout<<i<<" ";
		cout<<k<<" ";
		for(int i=1<<m;i--;)
		  if(i!=k)
		    cout<<i<<" ";
		cout<<k<<endl;
	}
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll n,T,ans=0;
  cin >>n >>T;
  ll t[n];
  for(ll i=0;i<n;i++)cin>>t[i];
  for(ll i=0;i<n;i++){
    if(i==n-1)ans+=T;
    else if(t[i]+T>t[i+1])ans+=(t[i+1]-t[i]);
    else ans+=T;
  }
  cout << ans <<endl;
}

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

int main() {
  int N,A,B;
  cin >> N >> A >> B;
  //N*AとBを比較するだけ
  if (N*A <= B) {
    cout << N*A << endl;
  } else {
    cout << B << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::vector<int> a(1 << n);
    for (int i = 0; i < (1 << n); i++) std::cin >> a[i];
    std::sort(a.rbegin(), a.rend());
    std::multiset<int, std::greater<int>> par, res, buf;
    par.insert(a[0]);
    for (int i = 1; i < (1 << n); i++) res.insert(a[i]);
    for (int i = 0; i < n; i++) {
        for (auto p : par) {
            auto iter = res.upper_bound(p);
            if (iter == res.end()) {
                std::cout << "No" << std::endl;
                return 0;
            }
            buf.insert(*iter);
            res.erase(iter);
        }
        for (auto p : buf) {
            par.insert(p);
        }
        buf.clear();
    }
    std::cout << "Yes" << std::endl;
    return 0;
}


Measured memory_bytes: 19712
#include<cstdio>

int a[1005];

int main()
{
    int n, m;
    while(scanf("%d %d", &n, &m)){
        if(n == 0){
            return 0;
        }
        for(int i = 1; i <= n; i++){
            scanf("%d", &a[i]);
        }
        int ans = -1;
        for(int i = 1; i < n; i++){
            for(int j = i + 1; j <= n; j++){
                if((a[i] + a[j]) <= m && (a[i] + a[j]) > ans){
                    ans = (a[i] + a[j]);
                }
            }
        }
        if(ans < 0){
            printf("NONE\n");
        }
        else{
            printf("%d\n", ans);
        }
    }
}



Measured memory_bytes: 2756
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;
using plli=pair<ll,int>;
using vplli=vector<pair<ll,int>>;
using pllll=pair<ll,ll>;
using vpllll=vector<pair<ll,ll>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int D;
    cin>>D;
    ll G;
    cin>>G;
    vi p(D);
    vi c(D);
    rep(i,0,D){
        cin>>p[i]>>c[i];
    }
    ll ans=INF;
    for(int i=0;i<1<<D;i++){
        ll res=0;
        ll pcnt=0;
        vb is_slv(D,false);
        rep(j,0,D){
            if(1&i>>j){
                is_slv[j]=true;
                res+=c[j]+p[j]*(j+1)*100;
                pcnt+=p[j];
            }
        }
        if(res>=G){
            chmin(ans,pcnt);
            continue;
        }
        irep(j,0,D){
            if(is_slv[j]==false){
                rep(k,0,p[j]+1){
                    if(res+k*(j+1)*100>=G){
                        chmin(ans,pcnt+k);
                        break;
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 3600
/**
 * Title:
 * Url:
 */
#include<bits/stdc++.h>

using namespace std;

#define ll long long

int a[3][3];
bool b[3][3];

int main() {
    for(int i=0; i<3; i++) {
        for(int j=0; j<3; j++) {
            cin >> a[i][j];
            b[i][j] = false;
        }
    }
    int n; cin >> n;
    for(int k=0; k<n; k++) {
        int bi; cin >> bi;
        for(int i=0; i<3; i++) {
            for(int j=0; j<3; j++) {
                if(a[i][j]==bi) {
                    b[i][j] = true;
                }
            }
        }
    }
    for(int i=0; i<3; i++) {
        bool flag = true;
        for(int j=0; j<3; j++) {
            if(b[i][j]==false) {
                flag = false;
                break;
            }
        }
        if(flag) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    for(int j=0; j<3; j++) {
        bool flag = true;
        for(int i=0; i<3; i++) {
            if(b[i][j]==false) {
                flag = false;
                break;
            }
        }
        if(flag) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    if(b[0][0]&&b[1][1]&&b[2][2]) {
        cout << "Yes" << endl;
        return 0;
    }

    if(b[0][2]&&b[1][1]&&b[2][0]) {
        cout << "Yes" << endl;
        return 0;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int r,g,b;
    cin >> r >> g >> b;
    int a=10*g+b;
    if(a%4==0)cout << "YES" << endl;
    else cout << "NO" << endl;    
}

Measured memory_bytes: 256
# Your code here!

#データの読み込み

fline=readlines
fline=fline[0].split("/")

#実際の処理

a=fline[0].to_i
b=fline[1].to_i
c=fline[2].to_i


#出力

if fline[1].to_i<=4 then
    printf "Heisei"
else 
    printf "TBD"
end    





Measured memory_bytes: 1788
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// x ** n % mods を求める
pub fn mod_pow(x: i64, n: i64, mods: i64) -> i64 {
    if n == 0 {
        return 1;
    }
    let mut res = mod_pow(x * x % mods, n / 2, mods);
    if n % 2 == 1 {
        res = res * x % mods;
    }
    return res;
}

// (1/n) % mods を求める
pub fn mod_inv(n: i64, mods: i64) -> i64 {
    return mod_pow(n, mods-2, mods);
}

// nCk % mods を求める
pub fn mod_comb(n: i64, k: i64, mods: i64) -> i64 {
    let sum1 = (n-k+1..n+1).fold(1, |ac, x| ac * x % mods);
    let sum2 = (1..k+1).fold(1, |ac, x| ac * x % mods);
    return sum1 * mod_inv(sum2, mods) % mods;
}


fn main() {
    input!{
        n: i32,
        m: i32,
        a: [i32; m],
    }
    let mut result = n;
    for item in a.iter() {
        result = result - item;
    }
    if result < 0 {
        println!("-1");
    }
    else {
        println!("{}", result);
    }
}


Measured memory_bytes: 2144
using System;

namespace vscode
{
    class Program
    {
        static void Main(string[] args)
        {
            const int AT_COIN = 500;
            //xInput K X
            string[] input = Console.ReadLine().Split(' ');
            int k = int.Parse(input[0]);
            int x = int.Parse(input[1]);

            if ( AT_COIN * k >= x) {
                Console.WriteLine("Yes");
            } else {
                Console.WriteLine("No");
                
            }
        }
    }
}


Measured memory_bytes: 27524
n, x = gets.chomp.split(" ").map(&:to_i)

a = gets.chomp.split(" ").map(&:to_i)

eated = 0

(n-1).times{ |i|
  if a[i] + a[i+1] > x then
    b = a[i+1]
  	c = a[i] + a[i+1] - x
    a[i+1] = a[i+1] - [b, c].min
    eated = eated + [b, c].min
  end
  if a[i] + a[i+1] > x then
    c = a[i] + a[i+1] - x
    a[i] = a[i] - c
    eated = eated + c
  end
}

print("#{eated}\n")

Measured memory_bytes: 12300
#include<iostream>
using namespace std;
long N;
long mod = 1e9 + 7;
long sum = 1;
long a[1001];
int main() {
	cin >> N;
	for (int i = 2; i <= N; ++i) {
		int k = i;
		for (int j = 2; k > 1;) {
			if (k%j == 0) {
				a[j]++;
				k /= j;
			}
			else {
				j++;
			}
		}
	}
	for (int i = 2; i <= N; ++i) {
		sum *= (a[i] + 1);
		sum %= mod;
	}
	cout << sum << endl;
	return 0;
}

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

int main() {
  int N; cin >> N;
  for (int n = 1; n <= N; n++) {
    int result = 0;
    for (int x = 1; x * x <= n; x++) {
      for (int y = x; y * y <= n; y++) {
        for (int z = y; z * z <= n; z++) {
          int tmp = x*x+y*y+z*z+x*y+y*z+z*x;
          if (n == tmp) {
            if (x == y && y < z) {
              result += 3;
            } else if (x < y && y == z) {
              result += 3;
            } else if (x < y && y < z) {
              result += 6;
            } else {
              result += 1;
            }
          }
        }
      }
    }
    cout << result << endl;
  }
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};

using ll = long long;
using namespace std;
using P = pair<int,int>;
ll mod=1e9+7;

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; } //最大公倍数

int main(){
  int H,W,A[10000],N;
  cin>>H>>W;
  cin>>N;
  int ans[100][100] = {0};
  for (int i(0);i<N;i++){
    cin>>A[i];
  }
  int tmp(0);
  for (int i(0);i<H;i++){
    for (int j(0);j<W;j++){
      if (A[tmp] == 0){
        tmp += 1;
      }
      ans[i][j] = tmp+1;
      A[tmp]--;
    }
  }
  for (int i(0);i<H;i++){
    if (i%2==1){
      for (int j(0);j<W;j++){
        cout << ans[i][W-j-1] << " ";
      }
    }else{
      for (int j(0);j<W;j++){
        cout << ans[i][j] << " ";
      }
    }
    cout << endl;
  }
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int n; cin >> n;
  vi32 a(n); cin >> a;
  vi32 b(n);
  rrep(i, n) {
    int acc = 0;
    for (int j = i; j < n; j += i + 1) {
      acc += b[j];
      acc %= 2;
    }
    if (acc != a[i]) {
      b[i] = 1;
    }
  }
  int ans = 0;
  rep(i, n) ans += b[i] == 1 ? 1 : 0;
  cout << ans << endl;
  vi32 answers;
  rep(i, n) if (b[i]) answers.push_back(i + 1);
  cout << answers << endl;
}


Measured memory_bytes: 3192
module mod_or_plus_max
  implicit none
  integer :: n, a(-1:262143), u
  integer :: f(0:262143), s(0:262143)
contains
  recursive subroutine bit_group(x)
    implicit none
    integer, intent(in) :: x
    integer :: i, y
    if ((f(x).ge.0).and.(s(x).ge.0)) return
    if (and(x,x-1).eq.0) then
      f(x) = 0
      s(x) = x
      if (a(0).lt.a(x)) then
        f(x) = x
        s(x) = 0
      end if
      return
    end if
    do i = 0, n
      if (btest(x,i)) call bit_group(ibclr(x,i))
    end do
    f(x) = x
    do i = 0, n
      if (.not.btest(x,i)) cycle
      y = ibclr(x,i)
      if (a(f(x)).lt.a(f(y))) then
        f(x) = f(y)
      end if
    end do
    if (f(x).ne.x) s(x) = x
    do i = 0, n
      if (.not.btest(x,i)) cycle
      y = ibclr(x,i)
      if ((a(s(x)).lt.a(f(y))).and.(f(y).ne.f(x))) then
        s(x) = f(y)
      end if
      if ((a(s(x)).lt.a(s(y))).and.(s(y).ne.f(x))) then
        s(x) = s(y)
      end if
    end do
    return
  end subroutine bit_group
end module mod_or_plus_max
program or_plus_max
  use mod_or_plus_max
  implicit none
  integer :: k, m, t
  a = -1
  f = -1
  s = -1
  read(*,*) n
  u = 2**n-1
  read(*,*) a(0:u)
  call bit_group(u)
  t = 0
  do k = 1, u
    m = a(f(k))+a(s(k))
    if (m.lt.t) m = t
    write(*,'(i0)') m
    t = m
  end do
  stop
end program or_plus_max

Measured memory_bytes: 6656
#include<bits/stdc++.h>
 
using namespace std;
 
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
#define int ll
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename A,typename B> istream& operator>>(istream&,pair<A,B>&);
template<typename A> istream& operator>>(istream&,vector<A>&);
void add(int&,int);
int mul(int,int);
int powz(int,int);

template<typename A> ostream& operator<<(ostream&,vector<A>&);
 
const int N=1000002;

void solve(){
	long double ans=0;
	int n;
	cin>>n;
	vi a(n);
	cin>>a;
	for(int i=0;i<n;i++){
		ans+=(long double)1/a[i];
	}
	cout<<(long double)1/ans;
}

 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
	    output<<i<<' ';
	return output;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int n;
vector<int> p[10];
vector<char> input;

bool check(int num) {
	string str = to_string(num);
	for (auto&& i : p[str[0] - '0']) {
		if (i + str.size() > n) {
			break;
		}
		bool check = true;
		for (int j = 0; j < str.size(); j++) {
			if (input[i + j] != str[j]) {
				check = false;
				break;
			}
		}
		if (check) {
			return false;
		}
	}
	return true;
}

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

	cin >> n;
	input.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> input[i];
		p[input[i] - '0'].push_back(i);
	}
	for (int i = 0; i < 10000000; i++) {
		if (check(i)) {
			cout << i << "\n";
			return 0;
		}
	}
}


Measured memory_bytes: 3300
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#define ll long long
#define out(a) printf("%lld ",a)
using namespace std;
int n;
ll l,r,lbound,rbound,mid=0,qaq;
ll now;
int a[100050];
bool flag,f;
int read()
{
	int s=0,t=1; char c;
	while (c<'0'||c>'9') {if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9') {s=s*10+c-'0'; c=getchar();}
	return s*t;
}
int main()
{
	n=read(); l=2;
	for (int i=1;i<=n;i++)
	  a[i]=read();
	  r=1e14;
	  lbound=l; rbound=r;
	while (l<=r) {
	  f=false;
	  mid=(l+r)>>1; now=mid;
	  for (int i=1;i<=n;i++) {
	    now=(now/a[i])*a[i];
	    if (now<2&&i!=n) {
	      f=true; break;
	    }
	    if (now<a[i]) {
	      f=true; break;
	    }
	  }
	  if (now<2) f=true;
	    if (now==2) flag=true;
	    //printf("%d\n",now);
	  if (not f) r=mid-1;
	  else l=mid+1;
    }
    while (lbound<=rbound) {
    	f=false;
      mid=(lbound+rbound)>>1; now=mid;
      for (int i=1;i<=n;i++) {
        now=(now/a[i])*a[i];
        if (now<2&&i!=n) {
	      f=true; break;
	    }
	    if (now<a[i]) {
	      f=true; break;
	    }
	  }
	  if (now<=2) f=true;
        if (now==2) flag=true;
      //printf("%d\n",now);
      if (not f) rbound=mid-1;
      else lbound=mid+1;
  }
    if (flag) out(l),out(rbound);
    else puts("-1");
    return 0;
}

Measured memory_bytes: 640
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7



n = I()
graph = [[] for _ in range(n)]
for k in range(n - 1):
    a, b = LI()
    graph[a - 1] += [b - 1]
    graph[b - 1] += [a - 1]


def bfs(v):
    que = deque([v])
    dist = [INF] * n
    dist[v] = 0
    while que:
        cur = que.popleft()
        for nxt in graph[cur]:
            if dist[cur] + 1 < dist[nxt]:
                dist[nxt] = dist[cur] + 1
                que += [nxt]
    return dist



def double_sweep():
    dist = bfs(0)
    ret = -1
    for i in range(n):
        if dist[i] > ret:
            ret = dist[i]
            u = i
    return max(bfs(u))



if (double_sweep() + 1) % 3 == 2:
    print('Second')
else:
    print('First')

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

class uf{
  int n;
  vector<int> rank, parent;
public:
  uf();
  uf(int _n){
    init(_n);
  }
  void init(int _n){
    n = _n;
    rank.resize(n);
    parent.resize(n);
    for (int i = 0; i < n; i++) {
      rank[i] = 0;
      parent[i] = i;
    }
  }
  int find(int x){
    if(x == parent[x])return x;
    else return parent[x] = find(parent[x]);
  }
  
  void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y)return;
    if(rank[x] < rank[y]){
      parent[x] = y;
    }else{
      parent[y] = x;
      if(rank[x] == rank[y])rank[x]++;
    }
  }
  bool same(int x, int y){
    return find(x) == find(y);
  }
  void printParent(){
    for (int i = 0; i < n; i++) {
      std::cout << parent[i] << " ";
    }
    std::cout << std::endl;
  }
};
int dx[] = {1, 0, -1, 0},
  dy[] = {0, 1, 0, -1};

int main(int argc, char *argv[]){
  int w, h, n, ans = 0;
  std::cin >> w >> h;
  vector<string> grid(h);
  for (int i = 0; i < h; i++) {
    std::cin >> grid[i];
    for (int j = 0; j < w; j++) {
      if(grid[i][j] == 't')ans = i*w + j;
    }
  }
  uf u(w*h);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if(grid[i][j] != '.')continue;
      for (int k = 0; k < 4; k++) {
        int nx = j + dx[k], ny = i + dy[k];
        if(!(0 <= nx && nx < w &&
             0 <= ny && ny < h))continue;
        if(grid[ny][nx] == '#')continue;
        u.unite(i*w + j, ny*w + nx);
      }
    }
  }
  std::cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    std::cin >> x >> y;
    if(u.find(0) == u.find(ans)){
      std::cout << i << std::endl;
      return 0;
    }
    grid[y][x] = '.';
    for (int j = 0; j < 4; j++) {
      int nx = x + dx[j], ny = y + dy[j];
      if(!(0 <= nx && nx < w &&
           0 <= ny && ny < h))continue;
      if(grid[ny][nx] == '#')continue;
      u.unite(y*w + x, ny*w + nx);
    }

  }
  if(u.find(0) == u.find(ans)){
    std::cout << n << std::endl;
  }else{
    std::cout <<  -1 << std::endl;
  }
  return 0;
}

Measured memory_bytes: 9844
#include<cstdio>
#include<cstring>
#define INF 1500000
int m,n;
int d[101];

bool check(int x){
	int nx=0,nm=1;
	for(int i=0;i<n;i++){
		if(d[i]>x)return false;
		if(d[i]+nx>x)nm++,nx=d[i];
		else nx+=d[i];
		if(nm>m)return false;
	}
	return true;
}

int main(void){
	while(1){
		scanf("%d%d",&m,&n);
		if(m==0)break;
		for(int i=0;i<n;i++)scanf("%d",&d[i]);
		int l=0,r=1500001;
		for(int i=0;i<30;i++){
			int mid=(l+r)/2;
			if(check(mid))r=mid;
			else l=mid;
		}
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 1028
import java.util.*
import java.util.Random;

fun main(args:Array<String>){
    solve()
}

fun solve(){
    val d = readint()
    val c = readints()
    val s = Array(d){IntArray(26)}
    for(i in 0 until d){
        s[i] = readints().toIntArray()
    }
    val ans = IntArray(d)

    fun score() : Long{
        val t = IntArray(26)
        var sum = 0L
        for(i in 0 until d){
            sum += s[i][ans[i]]
            t[ans[i]] = i
            for(j in 0 until 26){
                sum -= c[j] * (i - t[j])
            }
        }
        return sum
    }

    for(i in 0 until d){
        var ma = 0
        var mai = 0
        for(j in 0 until 26){
            if(ma < s[i][j]){
                ma = s[i][j]
                mai = j
            }
        }
        ans[i] = mai
    }

    var ma = score()
    val rand = Random()

    repeat(3000){
        val k = rand.nextInt(d)
        var curma = ma
        var curmai = ans[k]
        for(i in 0 until 26){
            ans[k] = i
            val m = score()
            if(m > curma){
                curma = m
                curmai = i
            }
        }
        ans[k] = curmai
        ma = curma
    }

    for(i in 0 until d){
        println(ans[i] + 1)
    }
}



fun read() = readLine()!!
fun reads() = readLine()!!.split(" ")
fun readint() = readLine()!!.toInt()
fun readints() = readLine()!!.split(" ").map{it.toInt()}
fun readlong() = readLine()!!.toLong()
fun readlongs() = readLine()!!.split(" ").map{it.toLong()}


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

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

  sort(S.begin(), S.end());
  sort(T.begin(), T.end(), greater<char>());

  string ans= (S < T) ? "Yes"
                      : "No";

  cout << ans << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 1000000007
typedef long long ll;

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

    int n,m,X,Y;
    cin >> n >> m >> X >> Y;
    int x[n],y[m];
    for(int i=0;i<n;i++)
        cin >> x[i];
    for(int i=0;i<m;i++)
        cin >> y[i];
    sort(x,x+n);
    sort(y,y+m);
    bool ans = false;
    for(int z=X+1;z<=Y;z++){
        if(z>x[n-1] && z<=y[0]){
            ans = true;
            break;
        }
    }
    if(ans)
        cout << "No War";
    else
        cout << "War";
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    double A[N];
    double sum = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        A[i] = 1 / A[i];
        sum += A[i];
    }
    printf("%.10f\n", 1 / sum);
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var (
		n int
		s string
	)
	fmt.Scan(&n, &s)

	var x, ans int
	for _, c := range s {
		if c == 'I' {
			x++
		} else {
			x--
		}
		if ans < x {
			ans = x
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n; cin >> n;
  for (int i = 0; i * 4 <= n; i++) {
    if ((n - i * 4) % 7 == 0) {
      cout << "Yes" << '\n';
      return;
    }
  }
  cout << "No" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3628
/* C - Step */

#include <bits/stdc++.h>
using namespace std;

int main(){
  int N;
  long long ans = 0;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
    if(i > 0){
      if(A.at(i - 1) > A.at(i)){
        ans += A.at(i - 1) - A.at(i);
        A.at(i) = A.at(i - 1);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4044
N = int(input())

# 奇数をいくらかけても10の倍数にはならない
if N % 2 != 0:
  print(0)
else:  
  counter = [0] * 25
  for i in range(25):
    counter[i] = N // (2 * 5 ** (i + 1))
  for i in range(24, -1, -1):
    counter[i] = counter[i] - sum(counter[i + 1:])
    
  total = 0
  for i in range(25):
    total += ((i + 1) * counter[i])
                                  
  print(total)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(i,a,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,0,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);   
}
# define PI    3.14159265358979323846  
void solve()
{
  ll n,m;
  cin>>n>>m;
  int p;
  ll c=0;
  rep(i,m)
  {
    cin>>p;
    c+=p;
  }
  cout<<max(-1ll,n-c);
}
int main()
{
  fastio;
  //fopen();
  int t;
//  cin>>t;
  rep(i,1)
  { 
   // cout<<"Case #"<<i+1<<": ";
    solve();
    cout<<endl;
  }
  
}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
#include<functional>
using namespace std;

int INF = 1e9 + 7;

typedef long long ll;
typedef pair<int, int> P;

int main() {
	int n;
	ll k;
	cin >> n >> k;
	vector<P> x(n);
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		x[i] = make_pair(a[i], b[i]);
	}

	sort(x.begin(), x.end());

	for (int i = 0; i < n; i++) {
		k -= x[i].second;

		if (k <= 0) {
			cout << x[i].first << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    int res=0;
    cin>>n;
    int d[n];
    for(int i=0;i<n;i++)cin>>d[i];
    int num[110]={0};
    for(int i=0;i<n;i++){
        num[d[i]]++;
    }
    for(int i=1;i<=100;i++){
        if(num[i])res++;
    }
    cout<<res<<'\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <random>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using Pt = pair<int, int>;

int main()
{
	int L, R, d;
	cin >> L >> R >> d;
	int ct = 0;
	for (int i = L; i <= R; ++i)
	{
		if (i % d == 0)
			++ct;
	}
	cout << ct << endl;

	return 0;
}

Measured memory_bytes: 3632
fib = [0, 1, 1]
for i in range(35):
    fib.append(fib[-1]+fib[-2])
x, y = map(int, input().split())
xn, xm, yn, ym = 0, 0, 0, 0
i = 2
color = 1
if (xn <= x <= xm) and (yn <= y <= ym):
    print(1)
    exit()
while True:
    if i % 4 == 2:
        xn += fib[i-1]
        xm += fib[i]
        yn += 0
        ym += fib[i-2]
    elif i % 4 == 3:
        xn -= fib[i-2]
        xm += 0
        yn += fib[i-1]
        ym += fib[i]
    elif i % 4 == 0:
        xn -= fib[i]
        xm -= fib[i-1]
        yn -= fib[i-2]
        ym += 0
    else:
        xn += 0
        xm += fib[i-2]
        yn -= fib[i]
        ym -= fib[i-1]
    color %= 3
    color += 1
    # print(xn, xm, yn, ym, i-2, color)
    if (xn <= x <= xm) and (yn <= y <= ym):
        print(color)
        break
    i += 1



Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
template <typename Mnd> struct segment_tree {
    int sz;
    vector<Mnd> data;
    function<Mnd(Mnd, Mnd)> f;
    Mnd e;
    //サイズだけ指定して初期化
    segment_tree(int _sz, function<Mnd(Mnd, Mnd)> _f, Mnd _e) : f(_f), e(_e) {
        sz = 1;
        while(sz < _sz)
            sz <<= 1;
        data.assign(sz * 2, e);
    }
    //参照渡しなので代入とかもできる
    Mnd &operator[](const int &k) { return data[k + sz]; }
    //木を構築 O(n)
    void build() {
        for(int i = sz - 1; i > 0; i--)
            data[i] = f(data[2 * i], data[2 * i + 1]);
    }
    //更新しつつ木を再構築 O(log n)
    void update(int k, Mnd x) {
        data[k += sz] = x;
        while(k >>= 1)
            data[k] = f(data[2 * k], data[2 * k + 1]);
    }
    //[a,b)でのクエリに答える　O(log n)
    Mnd query(int a, int b) const {
        Mnd l = e, r = e;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if(a & 1)
                l = f(l, data[a++]);
            if(b & 1)
                r = f(r, data[--b]);
        }
        return f(l, r);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    string s;
    cin >> n >> s >> q;
    vector<segment_tree<int>> seg(
        26, segment_tree<int>(n, [](int a, int b) { return a + b; }, 0));
    for(int i = 0; i < n; i++) {
        seg[s[i] - 'a'].update(i, 1);
    }
    while(q--) {
        int ord;
        cin >> ord;
        if(ord == 1) {
            int ind;
            char c;
            cin >> ind >> c;
            ind--;
            seg[s[ind] - 'a'].update(ind, 0);
            s[ind] = c;
            seg[s[ind] - 'a'].update(ind, 1);
        }
        if(ord == 2) {
            int l, r;
            cin >> l >> r;
            l--;
            int ans = 0;
            for(int i = 0; i < 26; i++) {
                ans += min(1, seg[i].query(l, r));
            }
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 111516
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define ull unsigned long long
#define mk make_pair
#define pb push_back
#define eps 1e-12
#define MAXN 200009
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,l;
	cin>>n>>l;
	int a[n+1];
	int s=0;
	int pre[n+1];
	pre[0]=0;
	int suf[n+2];
	suf[n+1]=0;
	for(int i=1;i<=n;i++)
	{
		a[i]=l+i-1;
		pre[i]=pre[i-1]+a[i];
		s+=a[i];
	}
	for(int i=n;i>=1;i--)
	{
		suf[i]=suf[i+1]+a[i];
	}
	int minn=1e9;
	int ans;
	for(int i=1;i<=n;i++)
	{
		if(minn>abs(s-(pre[i-1]+suf[i+1])))
		{
			minn=abs(s-(pre[i-1]+suf[i+1]));
			ans=pre[i-1]+suf[i+1];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
def collatz_problem(s):
    a = []

    a.append(s)
    counter = 1
    while True:
        counter += 1
        if s % 2 == 0:
            s /= 2
            a.append(s)
        else:
            s = s * 3 + 1
            a.append(s)
        for i in range(len(a)-1):
            if a[i] == s:
                return counter


def main():

    s = int(input())
    answer = collatz_problem(s)
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 63268