akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  	
  	double a,c=0;
  	cin >> a;
  	for (int i=0; i<a; i++) {
      double b;
      cin >> b;
      c+=1/b;
    }
  	cout << 1/c;
      
}

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

int main(){
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	if (n*a<b){
		printf("%d",n*a);
	}
	else{
		printf("%d",b);
	}
	return 0;
}

Measured memory_bytes: 256
/*
?????????: Elementary Number Theory - Power
URL: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_B&lang=jp
?????°:
18:51:44 ??????????????§?????????????????????????????¨???
18:56:25 ??????????????°??§?????????????????£?????????????????¢????????????????????????????????§?????????
19:01:47 ??????????????£????°??????????
*/
#include <iostream>
using namespace std;

/* n < 1000^3 < 1024^3 = 2^30 */

long long table[32];
// table[k] = pow(m, pow(2,k));
// table[0] = pow(m,1);
// table[1] = pow(m,2);

long long mul(long long a, long long b){
	return (a*b) % 1000000007;
}


signed main()
{
	long long m; long long n;
	cin >> m >> n;

	long long tmp = m;
	for(int i=0;i<32;i++){
		table[i] = tmp;
		tmp = mul(tmp,tmp);
	}

	// 1010 multiplies table[1] and table[3]

	long long ans = 1;
	for(int i=0; i<32; i++){
		if((n >> i) % 2) { // bit????????£??????
			ans = mul(ans, table[i]);
		}
	}
	cout << ans << endl;
}

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

int main() {
    int n, m;
    string s[110], t[110];
    cin >> n;
    for(int i = 0; i < n; ++i) cin >> s[i];
    cin >> m;
    for(int i = 0; i < m; ++i) cin >> t[i];
    
    int ans = 0;
    for(int i = 0; i < n; ++i) {
        int res = 0;
        for(int j = 0; j < max(n, m); ++j) {
            if(s[i] == s[j]) ++res;
            if(s[i] == t[j]) --res;
        }
        if(ans < res) ans = res;
    }
    
    cout << ans << endl;
}


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int i;
    long long sum=0;
    for(i=1;i<=n;i++)
    {
        if(i%3&&i%5)
            sum+=i;
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3632
#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 INF 2e9
#define MOD 1e9+7;
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef vector<string> VS;

int main(){
    int a, b, c;
  cin >> a >> b >> c;
  if ((a == b && a != c) || (a == c && a != b) || (c == b && a != c)){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;
template <class T>
ostream &operator<<(ostream &s, vector<T> vec) {
    for (int i = 0; i < (int)vec.size(); ++i) {
        if (i > 0) {
            s << ' ';
        }
        s << vec[i];
    }
    return s << endl;
}

int main() {
    char c;
    cin >> c;
    cout << (char)(c + 1) << endl;
}


Measured memory_bytes: 256
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll t;
    cin >> t;
    ll n, m, a, b;
    for (ll i = 0; i < t; i++) {
        cin >> n >> m >> a >> b;
        printf("%lld\n", floor_sum(n, m, a, b));
    }
}

Measured memory_bytes: 3760
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

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

int main() {
    int n;
    ll d, a;
    cin >> n >> d >> a;
    vector<pair<ll, ll>> m(n);
    for (int i = 0; i < n; i++) {
        int x, h;
        cin >> x >> h;
        m.at(i) = make_pair(x, h);
    }
    sort(m.begin(), m.end());

    auto binary_search = [&](ll x){
        int ng = n;
        int ok = -1;

        while (abs(ok - ng) > 1) {
            int mid = (ok + ng) / 2;

            if (m.at(mid).first <= x) ok = mid;
            else ng = mid;
        }
        return ok;
    };

    vector<ll> diff(n + 1);
    ll diff_sum = 0;
    ll cnt = 0;
    for (int l = 0; l < n; l++) {
        diff_sum += diff.at(l);
        m.at(l).second += diff_sum;
        if (m.at(l).second <= 0) continue;

        int r = binary_search(m.at(l).first + d * 2);
        ll c = (m.at(l).second + a - 1) / a;
        diff_sum -= c * a;
        diff.at(r + 1) += c * a;
        cnt += c;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 4992
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:

};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    cin >> n >> m;
    if (n == m) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    
    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using Vec = vector<int>;


int main() {

int a,b;
cin>>a>>b;
bool x=true;
for(int i=0;i<=a;i++){
    if(i*2+4*(a-i)==b){
        cout<<"Yes"<<endl;
        x=false;
        break;
    }
}
if(x==true){
    cout<<"No"<<endl;
}


}

Measured memory_bytes: 3632
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = sum(B)

for i in range(N - 1):
  if A[i + 1] == A[i] + 1:
    ans += C[A[i] - 1]
    
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <random>

using namespace std;

const long long MOD = 998244353;

int main(){
    int a , b, c;
    cin >> a >> b >> c;
    map<int, bool> m;
    int cnt = 1;
    bool can = false;
    while(true){
        int amari = (a * cnt)  % b;
        if(amari == c){
            can = true;
            break;
        }
        if(m[amari]){
            break;
        }
        m[amari] = true;
        cnt++;
    }
    if(can){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
from collections import deque
d=deque()
e=deque()
h,w=map(int,input().split())
field=[0 for i in range(h+2)]
field[0]=[True for i in range(w+2)]
distance=0
white=0
for i in range(h):
    s=input()
    a=[False for i in range(w+2)]
    a[0]=True
    for j in range(w):
        if s[j]=="#":
            a[j+1]=True
        else:
            white+=1

    a[w+1]=True
    field[i+1]=a
field[h+1]=[True for i in range(w+2)]
d.append((1,1))
ans=-1
while d:
    while d:
        some=d.popleft()
        index1,index2=some[0],some[1]
        if index1==h and index2==w:
            ans=distance
        if field[index1-1][index2]==False:
                field[index1-1][index2]=True
                e.append((index1-1,index2))
        if field[index1+1][index2]==False:
                field[index1+1][index2]=True
                e.append((index1+1,index2))
        if field[index1][index2+1]==False:
                field[index1][index2+1]=True
                e.append((index1,index2+1))
        if  field[index1][index2-1]==False:
                field[index1][index2-1]=True
                e.append((index1,index2-1))
    distance+=1
    d=e
    e=deque()
if ans>=0:
    print(white-ans-1)
else:
    print(-1)

Measured memory_bytes: 3316
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 10

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

int N, D;
int X[MAX][MAX];

bool isSquare(int n) {
    int temp = sqrt(n);
    return (n == pow(temp, 2));
}

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

    REP(i, N) {
        REP(j, D) {
            cin >> X[i][j];
        }
    }

    int ans = 0;

    REP(i, (N-1)) {
        for(int j = i+1; j < N; j++) {
            int sum = 0;
            REP(t, D) {
                sum += pow((X[i][t] - X[j][t]), 2);
            }

            bool temp = isSquare(sum);

            if (temp) {
                ans += 1;
            }
        }
    }

    cout << ans << endl;

    return 0;
}



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


using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define vec vector

int main(void)
{
	while(1) {
		int n, m;
		cin >> n >> m;
		if (n == 0 && m == 0) break;
		vec<int> c(m), x(n + 1);
		x[0] = 128;
		rep(i, m) cin >> c[i];
		rep(i, n) cin >> x[i + 1];
		// cout << "finish input" << endl;

		vec<vec<int>> dp(n + 1, vec<int>(256, - 1));
		dp[0][128] = 0;
		rep(i, n) {
			// cout << i << endl;
			rep(j, 256) {
				if (dp[i][j] < 0) continue;
				// cout << j << endl;
				rep(k, m) {
					int l = j + c[k];
					if (l < 0) l = 0;
					else if (l > 255) l = 255;
					int keep = dp[i][j] + (l - x[i + 1]) * (l - x[i + 1]);
					// cout << "keep = " << keep << endl;
					
					if (dp[i + 1][l] < 0 || dp[i + 1][l] > keep) dp[i + 1][l] = keep;
					// cout << "dp = " << dp[i + 1][l] << endl;
				}
			}
		}
		// cout << "out" << endl;

		int min = 1000000000;
		rep(i, 256) {
			if (dp[n][i] < 0) continue;
			if (min > dp[n][i]) min = dp[n][i];
		}

		cout << min << endl;
	}
	return 0;
}

Measured memory_bytes: 23660
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
using namespace std;

int field[30][30];
int hor[30][30];
int ver[30][30];
int result;
int w, h;


int main() {
	while(1) {
		cin >> w >> h;
		if(w==0 && h==0) break;

		for(int i=0; i<h; i++)
			for(int j=0; j<w; j++)
				field[i][j] = 0;

		for(int i=0; i<h*2-1; i++) {
			if(i%2==0) {
				for(int j=0; j<w-1; j++) {
					cin >> ver[i/2][j];
				}
			}
			else {
				for(int j=0; j<w; j++) {
					cin >> hor[i/2][j];
				}
			}
		}

		queue<int> q;
		q.push(0);
		q.push(0);
		q.push(1);
		result = 0;

		while(q.size() != 0) {
			int x = q.front();
			q.pop();
			int y = q.front();
			q.pop();
			int cnt = q.front();
			q.pop();

			if(field[y][x] == 1) continue;

			if(x == w-1 && y == h-1) {
				result = cnt;
				break;
			}

			if(y<h-1 && hor[y][x] == 0) {
				q.push(x);
				q.push(y+1);
				q.push(cnt+1);
			}
			if(x<w-1 && ver[y][x] == 0) {
				q.push(x+1);
				q.push(y);
				q.push(cnt+1);
			}
			if(y>0 && hor[y-1][x] == 0) {
				q.push(x);
				q.push(y-1);
				q.push(cnt+1);
			}
			if(x>0 && ver[y][x-1] == 0) {
				q.push(x-1);
				q.push(y);
				q.push(cnt+1);
			}
			field[y][x] = 1;
		}
		cout << result << endl;
	}
	return 0;
}

Measured memory_bytes: 1232
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
int main()
{
    int A,B;

    cin >> A >> B;

    if(A<10 && B<10){
        cout << A*B <<endl;
    }

    else{
        cout << -1 <<endl;
    }

}

Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(){
    int n, k, ans=0;

    cin>>n>>k;

    int x[n];

    for(e : x){
        cin>>e;
    }
    for(int i=0; i<n; i++){
        ans+=2*min(x[i], (k-x[i])*((k-x[i]<0) ? -1 : 1));
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
    string s; cin >> s;
    int diff = 0;
    int ans = 0;
    for (int i = 0, N = s.size(); i < N; i++)
    {
        if(diff>0){
            diff--;
            if(s[i]=='g') ans++; 
        } else {
            diff++;
            if(s[i]!='g') ans--; 
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
import java.io.*;
public class Main {
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
            String line = reader.readLine();
            int x = Integer.parseInt(line);
            System.out.println(+(x*x*x));
        } catch (IOException e){
            System.out.println(e);
        } catch (NumberFormatException e){
            System.out.println("The input number was not correct.");
        }

    }
}


Measured memory_bytes: 24308
#include <bits/stdc++.h>
 
using namespace std;
const int N = 4e5 + 5;
typedef long long ll;
const ll inf=1e15;
#define pb push_back
const int INF=(0x3f3f3f3f);
 
//#define _

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
#ifdef _
  //freopen("text.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  const clock_t begin_time=clock();
#endif  
  
  long long N,K,S;
  cin>>N>>K>>S;
  long long tmp = S;
  long long h = 1e9;
  if (S == 1e9)h--;
  if (S == 1)tmp = S + 1;
  else tmp = S - 1;
  vector<long long> vec;
  for (int i = 0; i < K; i++){
    vec.pb(S);
  }
  while (vec.size() < N){
    vec.pb(h);
  }
  for(auto x:vec)cout<<x<<' ';
  cout<<'\n';
  
#ifdef _
  //cout<<"\n\n\n\n\n\n\n\n\n\n\n";
  //cout<<float(clock()-begin_time)/CLOCKS_PER_SEC;
  cout<<fixed<<setprecision(45)<<double(clock()-begin_time)/CLOCKS_PER_SEC;
#endif
}










Measured memory_bytes: 2292
#include <algorithm>
#include <iostream>
#include <map>
#include <cstdio>
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORq(i, m, n) for(int i = m;i <= n;i++)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define PRINTD(n) printf("%d\n",n)
using namespace std;

int main() {
	int A,B,C,D;
	scanf("%d%d%d%d",&A,&B,&C,&D);
	int l = max(A,C);
	int r = min(B,D);
	
	if (l>r){
		PRINTD(0);
	}else{
		PRINTD(r-l);
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define sz(a) signed(a.size())
using namespace std;

void solve(){
	ll x,y,z;
	cin>>x>>y>>z;
	cout<<z<<" "<<x<<" "<<y;
}

int main() {
    FAST;
    ll t=1;
    //cin>>t;
    while(t--) solve();	
    return 0;
}



Measured memory_bytes: 256
<?php
  fscanf(STDIN, "%d", $a);
  fscanf(STDIN, "%d", $b);
  if($a == 1){
    if($b == 2){
      echo 3;
    }else{
      echo 2;
    }
  }elseif($a == 2){
    if($b == 3){
      echo 1;
    }else{
      echo 3;
    }
  }else{
    if($b == 2){
      echo 1;
    }else{
      echo 2;
    }
  }
?>

Measured memory_bytes: 3700
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define ff fflush(stdout)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int degree[10000+10];
vector<int> each[10000+10];
priority_queue<mp> q;
int used[10000+10];
int res=0;
vector<int> c;
int color[10000+10];
int main(){
	int n;
	cin>>n;
	rep(i,n-1){
		int ai,bi;
		scanf("%d %d",&ai,&bi);
		degree[ai]++;
		degree[bi]++;		
		each[ai].PB(bi),each[bi].PB(ai);
	}
	rb(i,1,n) {
		int ci;
		scanf("%d",&ci);
		c.PB(ci);
	}c.PB(0);
	sort(ALL(c));
	
	rb(i,1,n){
		q.push(II(-degree[i],i));
	}
	rb(i,1,n){
		while(used[q.top().SEC]) q.pop();
		mp now=q.top();
		q.pop();
//		cout<<now.SEC<<" "<<degree[now.SEC]<<" "<<c[i]<<endl;
		used[now.SEC]=1;
		color[now.SEC]=c[i];
		now.FIR*=-1;
		res+=degree[now.SEC]*c[i];
		for(auto it:each[now.SEC]){
			degree[it]--;
			q.push(II(-degree[it],it));
		}
	}
	cout<<res<<endl;
	rb(i,1,n) cout<<color[i]<<" ";cout<<endl;
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <unistd.h>
#include <stdio.h>
using namespace std;
typedef long long lli;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define forr(c, n) for (int i = c; i < n; i++)
#define forli(n) for (lli i = 0; i < n; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())

//FUNCTONS
lli llipower(lli x, lli y)
{
    lli res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x);
        y = y >> 1;
        x = (x * x);
    }
    return res;
}
lli llipowerp(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli gcd(lli a, lli b)
{
    if (!a)
        return b;
    return gcd(b % a, a);
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
template <typename T>
void printvec(vector<T> inp)
{
    for (int i = 0; i < inp.size(); i++)
    {
        cout << inp[i] << " ";
    }
    cout << endl;
}
template <typename T>
T ceildiv(T x, T y) { return 1 + ((x - 1) / y); }
lli modInverse(lli a, lli m)
{
    lli g = gcd(a, m);
    if (g != 1)
        return -1;
    else
        return llipowerp(a, m - 2, m);
}

int main()
{
   lli n;
   cin>>n;
   set<lli> ans;
   lli nc=n;
   if(n==2) cout<<1<<endl;
   else{
       for (lli i = 2; i <= (lli)sqrtl(n); i++)
       {
           if (n % i == 0)
           {
               nc = n;
               while (nc % i == 0)
                   nc /= i;
               //cout<<nc%i<<endl;
               if (nc % i == 1)
                   ans.insert(i);

               nc = n;
               while (nc % (n / i) == 0 && n / i != i)
                   nc /= (n / i);
               if (nc % (n / i) == 1)
                   ans.insert(n / i);
           }
       }
       n--;
       for (lli i = 2; i <= (lli)sqrtl(n); i++)
       {
           if (n % i == 0)
           {
               ans.insert(i);
               ans.insert(n / i);
           }
       }
       cout << ans.size() + 2 << endl;
   }
   
}

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

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

    vector<int> d(n);
    for (int i = 0; i < n; ++i) {
        cin >> d[i];
    }

    set<int> seq;
    for (int i = 0; i < n; ++i) {
        int m = 0;
        for (int j = 0; j < 3 && i + j < n; ++j) {
            m *= 10;
            m += d[i + j];
            seq.insert(m);
        }
    }

    for (int i = 0; i < 1000; ++i) {
        if (seq.find(i) == seq.end()) {
            cout << i << endl;
            break;
        }
    }


    return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,m,q;
  cin>>n>>m>>q;
  string s[n+1];
  for(int i=0;i<n;i++) cin>>s[i];
  int im[3][n+1][m+1];
  memset(im,0,sizeof(im));
  {
    for(int i=0;i<n;i++)
      for(int j=0;j<m;j++)
	im[0][i+1][j+1]=im[0][i+1][j]+(s[i][j]=='1');
    for(int i=0;i<n;i++)
      for(int j=0;j<=m;j++)
	im[0][i+1][j]+=im[0][i][j];
  }
  
  {
    for(int i=0;i<n;i++)
      for(int j=0;j<m;j++)
	im[1][i+1][j+1]=im[1][i+1][j]+(s[i][j]=='1'&&i>0&&s[i-1][j]=='1');
    for(int i=0;i<n;i++)
      for(int j=0;j<=m;j++)
	im[1][i+1][j]+=im[1][i][j];
  }
  //cout<<im[1][n][m]<<endl;
  
  {
    for(int i=0;i<n;i++)
      for(int j=0;j<m;j++)
	im[2][i+1][j+1]=im[2][i+1][j]+(s[i][j]=='1'&&j>0&&s[i][j-1]=='1');
    for(int i=0;i<n;i++)
      for(int j=0;j<=m;j++)
	im[2][i+1][j]+=im[2][i][j];
  }
  //cout<<im[2][n][m]<<endl;
  
  for(int i=0;i<q;i++){
    int sx,sy,gx,gy;
    cin>>sx>>sy>>gx>>gy;
    sx--;sy--;
    //cout<<sx<<" "<<sy<<":"<<gx<<" "<<gy<<endl;
    //cout<<im[0][gx][gy]<<" "<<im[0][gx][sy]<<" "<<im[0][sx][gy]<<" "<<im[0][sx][sy]<<endl;
    int ans=im[0][gx][gy]-im[0][gx][sy]-im[0][sx][gy]+im[0][sx][sy];
    sx++;
    ans-=im[1][gx][gy]-im[1][gx][sy]-im[1][sx][gy]+im[1][sx][sy];
    //cout<<sx<<" "<<sy<<":"<<gx<<" "<<gy<<endl;
    //cout<<im[1][gx][gy]<<" "<<im[1][gx][sy]<<" "<<im[1][sx][gy]<<" "<<im[1][sx][sy]<<endl;
    sx--;
    sy++;
    ans-=im[2][gx][gy]-im[2][gx][sy]-im[2][sx][gy]+im[2][sx][sy];
    sy--;
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 100608
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    StringBuilder sb=new StringBuilder(s);
    int n=sc.nextInt();
    for(int i=0;i<s.length();i++){
      if(n==0){
        break;
      }
      if(sb.charAt(i)=='a'){
        continue;
      }
      if(n>='z'+1-sb.charAt(i)){
        n-=('z'+1-sb.charAt(i));
        sb.setCharAt(i,'a');
      }
    }
    n=(n%26);
    if(n>0){
      char last=sb.charAt(sb.length()-1);
      int neww=((last-'a'+n)%26)+'a';
      sb.setCharAt(
        sb.length()-1,
        (char)neww
      );
    }
    System.out.println(sb);
  }
}


Measured memory_bytes: 27012
#include <stdio.h>
  
typedef struct {
    short surf[6];
    short top;
} dice;
  
int main(void){
  
    dice dice1 = {0,0};
  
    char command;
    short trade;
    register short i;
  
    for(i = 0;i < 6;i++){
        scanf("%d",&dice1.surf[i]);
    }
  
    while(scanf("%c",&command) != EOF){
        switch (command){
            case 'E':
                trade = dice1.surf[0];
                dice1.surf[0] = dice1.surf[3];
                dice1.surf[3] = dice1.surf[5];
                dice1.surf[5] = dice1.surf[2];
                dice1.surf[2] = trade;
                break;
            case 'N':
                trade = dice1.surf[0];
                dice1.surf[0] = dice1.surf[1];
                dice1.surf[1] = dice1.surf[5];
                dice1.surf[5] = dice1.surf[4];
                dice1.surf[4] = trade;
                break;
            case 'S':
                trade = dice1.surf[0];
                dice1.surf[0] = dice1.surf[4];
                dice1.surf[4] = dice1.surf[5];
                dice1.surf[5] = dice1.surf[1];
                dice1.surf[1] = trade;
                break;
            case 'W':
                trade = dice1.surf[0];
                dice1.surf[0] = dice1.surf[2];
                dice1.surf[2] = dice1.surf[5];
                dice1.surf[5] = dice1.surf[3];
                dice1.surf[3] = trade;
                break;
            default:
                break;
        }
    }
    printf("%d\n",dice1.surf[0]);
    return 0;
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if(A>B) {
   cout << 0 << endl;
}
  else if(A==B) { 
    cout << 1 << endl;
}
  else if(A<B){
    if(B/A>=C){
    cout << C << endl;
      }
    else if(B/A<C){    
    cout << B/A << endl;      
     } 
}
}


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

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define MOD 1000000007

#define trace1(x)                    cout <<#x<<": "<<x<< endl;
#define trace2(x, y)                 cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)              cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)           cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;

typedef long long ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    ll a,b;
    cin>>a>>b;
    if(a>=13)
    cout<<b;
    else if(a<=5)
    cout<<"0";
    else
    cout<<b/2;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N + 1];
        A[0] = 0;
        for (int i= 1; i <= N; ++i) {
            A[i] = sc.nextInt();
        }
        sc.close();

        long sum1 = 0;
        long sum2 = 0;
        long ans1 = 0;
        long ans2 = 0;
        for (int i= 1; i <= N; ++i) {
            sum1 += A[i]; 
            if (i % 2 == 0 && sum1 >= 0) {
                ans1 += Math.abs(sum1) +1;
                sum1 = -1;
            } else if (i % 2 != 0 && sum1 <= 0) {
                ans1 += Math.abs(sum1) + 1;
                sum1 = 1;
            }
        }
        for (int i= 1; i <= N; ++i) {
            sum2 += A[i]; 
            if (i % 2 == 0 && sum2 <= 0) {
                ans2 += Math.abs(sum2) +1;
                sum2 = 1;
            } else if (i % 2 != 0 && sum2 >= 0) {
                ans2 += Math.abs(sum2) + 1;
                sum2 = -1;
            }
        }
        System.out.println(Math.min(ans1, ans2));
    }
}


Measured memory_bytes: 50984
#include<bits/stdc++.h>
using namespace std;
long long n,m,a,b,c;
int main()
{
	cin>>a>>b>>c;
	if((a==b && b!=c) || (a==c && b!=c) || (c==b && a!=c))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;	
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < (int) n; i++)
#define forin(i, a, b) for(int i = a; i < (int) b; i++) 
#define rofin(i, a, b) for(int i = a; i > b; i--)
#define v vector
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define debug(i) cout << #i << ": " << i << endl
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

int main() {
    crap;
    ll N;
    int M; 
    cin >> N >> M;
    ll days = 0;
    bool ok = true;
    forn(i, M) {
        ll a;
        cin >> a;
        days += a;
        if(days > N) {
            ok = false;
            break;
        }
    }
    if(ok) cout << N - days << endl;
    else cout << -1 << endl;

}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i = 0; i < N; i++) {
		cin >> A[i];
		A[i] -= i+1;
	}
	sort(begin(A), end(A));
	cat ans = 0;
	for(int i = 0; i < N; i++) ans += abs(A[i]-A[N/2]);
	cout << ans << "\n";
	return 0;}

// look at my code
// my code is amazing


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

using namespace std;

#define pb push_back
#define mp make_pair
#define MOD ((int)(1e9) + 7)
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
const int N = ((int)1e2) + 5;
const int M = ((int)1e2) + 5;

int n,d;
int arr[N][M];

double dist (int i, int j)
{
	double a = 0;
	for (int x = 1; x <= d; x++)
	{
		a += (arr[i][x] - arr[j][x]) * (arr[i][x] - arr[j][x]);
	}
	return sqrt(a);
}

int main ()
{
	fast;
	cin >> n >> d;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= d; j++)
		{
			cin >> arr[i][j];
		}
	}

	int ans = 0;

	for (int i = 1; i <= n - 1; i++)
	{
		for (int j = i + 1; j <= n; j++)
		{
			if (trunc(dist(i,j)) == dist(i,j))
				ans++;
		}
	}

	cout << ans << "\n";

}

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


const int size = 86;
long long table[size]={0};


long long lucas(long long x)
{
  if ( x == 0 ) return 2;
  else if ( x == 1 ) return 1;

  long long l1, l2;
  if ( table[x-1] != 0 ) l1 = table[x-1];
  else {
    l1 = lucas(x-1);
    table[x-1] = l1;
  }
  if ( table[x-2] != 0 ) l2 = table[x-2];
  else {
    l2 = lucas(x-2);
    table[x-2] = l2;
  }

  return l1 + l2;
}


int main()
{
  long long n;
  cin >> n;
  cout << lucas(n) << endl;
  return 0;
}


Measured memory_bytes: 256
n,m,v,p = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
p-=1

a.sort(reverse=True)

ans=0
s = sum(a)

def safe(index):
    if a[p]>a[index]+m:
        return False
    i=0
    while a[i]>=a[index]+m:
        i+=1
    if i>index:
        return True
    intg = 0
    i = max(i,p)
    while i<index:
        intg += a[index] + m - a[i]
        i+=1
    intg += (len(a)-1-index)*m
    #print(intg,m*(v-1))
    return intg >= m*(v-1) - p*m

left = 0
right = len(a)-1
ans = int((right - left)/2)
if safe(right):
    ans = right
else:
    j = safe(ans)
    while not(j and not safe(ans+1)):
        if j:
            left = ans
        else:
            right = ans
        ans = left + int((right - left)/2)
        j = safe(ans)
print(ans+1)
"""
for i in range(len(a)):
    print(a[i],safe(i))
"""

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int r, g, b, n;
int main() {
	std::cin >> r >> g >> b >> n;

	ll ans = 0;
	for (int i = 0, end = n / r; i <= end; ++i) {
		for (int j = 0, end2 = n / g; j <= end2; ++j) {
			auto s = n - (r * i + g * j);
			if (s >= 0 && s % b == 0)
				++ans;
		}
	}

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


Measured memory_bytes: 256
def primes(n):
  ps = {}
  while n%2==0:
    n//=2
    if 2 not in ps:
      ps[2] = 1
    else:
      ps[2] += 1
  
  for i in range(3,int(n**.5)+1,2):
    while n%i==0:
      n//=i
      if i not in ps:
        ps[i] = 1
      else:
        ps[i] += 1
  
  if n!=1:
    ps[n] = 1
  
  return ps
  
N,P = map(int,input().split())
if N==1:
  print(P)
  exit()
ps = primes(P)
ans = 1
for p, num in ps.items():
  if num>=N:
    ans *= p**(num//N)
print(ans)
    


Measured memory_bytes: 38512
using System;
using System.Collections.Generic;
using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            int minusCount = S.Count(x=>x=='-');
            int plusCount = S.Count(x=>x=='+');
            Console.WriteLine(plusCount-minusCount);
        }   
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 11220
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
                Out.Flush();
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var s = ReadLine();
            for (int i = 0; i < s.Length; i++)
            {
                for (int j = 0; i + j < s.Length; j++)
                {
                    var newS = s.Substring(0, i) + s.Substring(i + j);
                    if (newS == "keyence")
                    {
                        WriteLine("YES");
                        return;
                    }
                }
            }
            WriteLine("NO");
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 18616
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int N, K;

int main(void){
	cin >> N >> K;
	int res = 0;

	while(N > 0){
		N /= K;
		res++;
	}

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    string s; cin >> s;

    ll ans = 0;
    string prev = "";
    string curr = "";
    REP(i, s.size()) {
        curr.push_back(s[i]);
        if (curr != prev) {
            prev = curr;
            curr = "";
            ans++;
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 640
//// Journey of Harry Singh from Diploma in Cse to Red Coder of India.///////////////////////////////////////////////////
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
} 
int main(){


ll n,m;
cin>>n>>m;
ll a[n+1];
for(int i=1;i<=n;i++)
cin>>a[i];
ll count=0;
for(int i=2;i<=n;i++)
{
	ll p=a[i-1];
	ll c=a[i];
	if(c+p>m)
	{
		ll del=c+p-m;
		count+=del;
		if(del>=a[i]){
		del-=a[i],a[i]=0;}
		else if(del<a[i]){
		a[i]=a[i]-del,del=0;}
		
		
		if(del>0)
		{
			if(del>=a[i-1]){
		del-=a[i-1],a[i-1]=0;}
		else if(del<a[i-1]){
		a[i-1]=a[i-1]-del,del=0;}
		}
	}
}

cout<<count<<"\n";



}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
double x, y;
priority_queue<double> pq;
int n;
int main() {
    DAU
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> x;
        pq.emplace(-x);
    }
    while (pq.size() > 1) {
        x = -pq.top();
        pq.pop();
        y = -pq.top();
        pq.pop();
        pq.emplace(-(x + y) / 2.0);
    }
    x = -pq.top();
    pq.pop();
    cout << fixed << setprecision(10) << x;
    PLEC
}


Measured memory_bytes: 3772
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      int A = sc.nextInt();
      int B = sc.nextInt();
      int C = sc.nextInt();
      int K = sc.nextInt();
      
      // 操作
      int ope = 0;
      String result = "";
      while(A >= B){
        B *= 2;
        ope++;
      }
      while(B >= C){
        C *= 2;
        ope++;
      }
      if(ope <= K){
        result = "Yes";
      }else{
        result = "No";
      }
      
      // 出力
      System.out.println(result);
    }

}

Measured memory_bytes: 35676
#include <stdio.h>

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

	while (1)
	{
		scanf("%d %d", &a, &b);

		if (a == 0 && b == 0)
			return 0;
		else if (a > b)
		{
			c = a;
			a = b;
			b = c;
		}
		printf("%d %d\n", a, b);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;

const int N = 200005, M = 40;

template <class T>
void read (T &x) {
	int sgn = 1;
	char ch;
	x = 0;
	for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-'; ch = getchar()) ;
	if (ch == '-') ch = getchar(), sgn = -1;
	for (; '0' <= ch && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
	x *= sgn;
}
template <class T>
void write (T x) {
	if (x < 0) putchar('-'), write(-x);
	else if (x < 10) putchar(x + '0');
	else write(x / 10), putchar(x % 10 + '0');
}

int n, m;

int calc (int x, int y) {
	int res = x & y, ans = 0;
	for (; res; res >>= 1) ans ^= (res & 1);
	return ans;
}

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

	for (int i = 1; i < (1 << n); i++) {
		for (int j = 1; j < (1 << m); j++) {
			int bit = 0;
			bit ^= calc(i, j);
			bit ^= calc(i, j - 1);
			bit ^= calc(i - 1, j);
			bit ^= calc(i - 1, j - 1);
			putchar(bit + '0');
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 1280
K, A, B = map(int, input().split())
if B <= A + 1:
    print(K + 1)
else:
    if A - 1 > K:
        print(K + 1)
    else:
        L = K - A + 1
        count = L // 2
        r = L % 2
        print(count * (B - A) + A + r)

Measured memory_bytes: 3060
a,b,c,d = map(int, input().split())
def gcd(x, y):
    if x == 0:
        return y
    else:
        return gcd(y%x, x)
def lcm(x,y):
    return x * y // gcd(x,y)
l = lcm(c,d)
ans_b = b - b//c - b//d + b//l
ans_a = (a-1) - (a-1)//c - (a-1)//d + (a-1)//l
print(ans_b - ans_a)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,i,s=0;
  cin >> n;
  vector<long> a(n+3,0),x(n+3,0);
  for (i=0;i<n;i++) cin >> a.at(i);
  for (i=0;i<n-1;i++) s+=a.at(i)*(2*(i%2)-1);
  x.at(0)=(a.at(n-1)-s)/2;
  for (i=1;i<n;i++) x.at(i)=a.at(i-1)-x.at(i-1);
  for (i=0;i<n;i++){
    cout << x.at(i)*2;
    if (i==n-1) cout << endl;
    else cout << ' ';
  }
  return 0;
}

Measured memory_bytes: 2944
import sys
mod = 1000000007

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, y//2)**2 * x % mod

def div(a, b):
    return mul(a, pow(b, mod-2,mod))

ivl = [0]
def inverse_max(a): #下2つを使用する際の下準備

    now = 1
    for i in range(a):
        i += 1
        now *= i
        now %= mod
        ivl.append(now)

def nCr(n,r):
    return div(ivl[n] , mul(ivl[n-r] , ivl[r]))


N,M = map(int,input().split())
inverse_max(N + 40)

if N == 1:
    print (1)
    sys.exit()

l = [2]
now = 3

while now ** 2 <= M:
    flag = True
    for i in l:
        if now % i == 0:
            flag = False
            break
    if flag:
        l.append(now)
    now += 2

dic = {}
for i in l:

    while M % i == 0:
        if i not in dic:
            dic[i] = 1
        else:
            dic[i] += 1

        M //= i

if M != 1:
    dic[M] = 1

ans = 1
#print (dic)

for i in dic:
    ans *= nCr(dic[i] + N - 1,dic[i])
    #print (ans)
    ans %= (10 ** 9 + 7)
print (ans % (10**9+7))

Measured memory_bytes: 45040
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<complex>

#define INF (long long)1000000000
#define MOD 1000000007
#define EPS 1e-8

#define REP(i, m) for(long long i = 0; i < m; ++i)
#define FOR(i, n, m) for(long long i = n; i < m; ++i)
#define ALL(v) v.begin(), v.end()
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	vector<int> im(101);
	im[a]+=1;
	im[b]-=1;
	im[c]+=1;
	im[d]-=1;
	REP(i,100) {
		im[i+1]+=im[i];
	}
	ll res = 0;
	REP(i,101) {
		if(im[i]==2) ++res;
	}
	cout<<res<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf (long long)-1e16
using namespace std;

struct edge {
  long long to, c;
  bool flg;
};

struct data {
  vector<long long> use, nuse;
};

long long n, w;
vector<long long> p;
vector<long long> cnt;
vector<vector<edge>> edges;

long long solve();
long long calc(long long now);
data dfs(long long now, vector<long long> &v);

int main() {
  cin >> n >> w;
  p.resize(n);
  edges.resize(n);
  for(int i = 0; i < n; ++i) cin >> p[i];
  for(int i = 0; i < n - 1; ++i) {
    int u, v, c;
    cin >> u >> v >> c;
    --u, --v;
    edges[u].push_back({v, c, 0});
    edges[v].push_back({u, c, 0});
  }
  cout << solve() << endl;
  return 0;
}

long long solve() {
  // calc children
  cnt.assign(n, -1);
  cnt[0] = 0;
  calc(0);
  vector<long long> v(w + 1, 0);
  auto f = [&](edge l, edge r) {
    return cnt[l.to] > cnt[r.to];
  };
  for(int i = 0; i < n; ++i)
    sort(edges[i].begin(), edges[i].end(), f);
  data resd = dfs(0, v);
  long long res = 0;
  for(int i = 0; i <= w; ++i)
    res = max({res, resd.use[i], resd.nuse[i]});
  return res;
}

long long calc(long long now) {
  for(int i = 0; i < edges[now].size(); ++i)
    if(cnt[edges[now][i].to] >= 0)
      edges[now][i].flg = 1;
    else {
      cnt[edges[now][i].to] = 0;
      cnt[now] += calc(edges[now][i].to);
    }
  return (cnt[now] += 1);
}

data dfs(long long now, vector<long long> &v) {
  data res;
  vector<long long> dummy(w + 1, 0);
  res.nuse = res.use = v;
  bool isfirst = 0;
  for(auto e : edges[now])
    if(!e.flg) {
      if(!isfirst) {
        isfirst = 1;
        data tmp = dfs(e.to, res.use);
        for(int i = 0; i <= w; ++i)
          res.nuse[i] =
              max({res.nuse[i], tmp.use[i], tmp.nuse[i]});
        for(int i = w; i >= e.c; --i)
          res.use[i] = max(tmp.use[i - e.c], res.use[i]);
        continue;
      }
      data tmp = dfs(e.to, res.use);
      for(int i = w; i >= e.c; --i)
        res.use[i] = max(tmp.use[i - e.c], res.use[i]);
      data ntmp = dfs(e.to, dummy);
      for(int i = 0; i <= w; ++i)
        res.nuse[i] =
            max({res.nuse[i], ntmp.use[i], ntmp.nuse[i]});
    }
  for(int i = 0; i <= w; ++i) res.use[i] += p[now];

  return res;
}



Measured memory_bytes: 179960