akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ll long long

int main() {
  int a,v,b,w,t=0;
  cin>>a>>v>>b>>w>>t;
  string ans="a";
  if(v<w){
    cout<<"NO";
    return 0;
  }
  if(a-b>0){
    if(a-b-abs((v-w)*t)<=0){
      ans="YES";
    }else{
      ans="NO";
    }
  }
  if(a-b<0){
    if(a-b+abs((v-w)*t)>=0){
      ans="YES";
    }else{
      ans="NO";
    }
  }
  cout<<ans;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>                                         
using namespace std;                                             
                                                                 
int ans(int count,int a,int b,int c,int l[],int x[],int n){      
  if(count == n){                                                
    if(min({a,b,c}) > 0){                                        
      return abs(a-x[0]) + abs(b-x[1]) + abs(c-x[2]) -30 ;       
    }                                                            
    else return 100000000;                                       
  }                                                              
  int r0 = 0,r1 = 0,r2 = 0,r3 = 0;                               
  r0 = ans(count+1,a,b,c,l,x,n);                                 
  r1 = ans(count+1,a + l[count],b,c,l,x,n) + 10;                 
  r2 = ans(count+1,a,b + l[count],c,l,x,n) + 10;                 
  r3 = ans(count+1,a,b,c + l[count],l,x,n) + 10;                 
  return min({r0,r1,r2,r3});                                     
}                                                                
                                                                 
int main(void){                                                  
  int n,x[3];                                                    
  cin >> n >> x[0] >> x[1] >> x[2];                              
  int l[n];                                                      
  for(int i = 0;i < n;++i){                                      
    cin >> l[i];                                                 
  }                                                              
  cout << ans(0,0,0,0,l,x,n) << endl;                            
  return 0;                                                      
}                                                                

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(void)
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	int now=0;
	while(1)
	{
		if(!now)
			c-=b;
		else
			a-=d;
		if(a<=0)
		{
			printf("No");
			return 0;
		}
		if(c<=0)
		{
			printf("Yes");
			return 0;
		}
		now^=1;
	}
	return 0;
}

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

int Rank[1000005];
int Tmp[1000005];
int kc,len;

bool compare_sa(int i,int j){
  return
    Rank[i]!=Rank[j]?
    Rank[i]<Rank[j]:
    (i+kc<=len?Rank[i+kc]:-1)<(j+kc<=len?Rank[j+kc]:-1);
}

void construct_sa(char* S,int *sa){
  len=strlen(S);
  for(int i=0;i<=len;i++){
    sa[i]=i;
    Rank[i]=i<len?S[i]:-1;
  }
  for(kc=1;kc<=len;kc*=2){
    sort(sa,sa+len+1,compare_sa);
    Tmp[sa[0]]=0;
    for(int i=1;i<=len;i++){
      Tmp[sa[i]]=Tmp[sa[i-1]]+compare_sa(sa[i-1],sa[i]);
    }
    for(int i=0;i<=len;i++)Rank[i]=Tmp[i];
  }
}


int n,m;
char str[1000005];
char t[1000005];
int sa[1000005];

int main(){
  scanf("%s",str);
  n=strlen(str);
  construct_sa(str,sa);
  scanf("%d",&m);
  while(m--){
    scanf("%s",t);
    int k=strlen(t);
    int l=0,r=n+1,m;
    while(l+1<r){
      m=(l+r)/2;
      if(strncmp(str+sa[m],t,k)<=0)l=m;
      else r=m;
    }
    printf("%d\n",(strncmp(str+sa[l],t,k)==0));
  }
  return 0;
}

Measured memory_bytes: 15912
#include<bits/stdc++.h>
#include<climits>
 
using namespace std;
 
#define debug(x,y) cout<<(#x)<<" " <<(#y)<<" is " << (x) <<" "<< (y) << endl
#define watch(x) cout<<(#x)<<" is " << (x) << endl
#define fast ios_base::sync_with_stdio(false)
#define fie(i,a,b) for(i=a;i<b;i++)
#define MOD 1000000007
#define mod 998244353
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define ll long long
#define lld long long int
#define ALL(x) (x).begin(),(x).end()
 
typedef vector<lld> vi;
typedef vector<vector<lld>> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<pair<lld, lld>> vpi;
typedef long long LL;
 
lld pw(lld x,lld n){
    lld t=1;
    while(n){
        if(n&1) t=(t*x)%MOD;
        n=n>>1;
        x=(x*x)%MOD;
    }
    return t%MOD;
} 
 
int main() {
	fast;
	cin.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
	int n, i, k;
	cin >> n >> k;
	lld ans = k;
	lld dp[k + 5];
	dp[k] = 1;
	for (i = k - 1; i >= 1; i--) {
		lld num = k / i;
		dp[i] = pw(num, n);
		for (lld j = i + i; j <= k; j += i) {
			dp[i] = dp[i] + MOD - dp[j];
			if (dp[i] >= MOD) dp[i] -= MOD;
		}
		ans += (dp[i] * i) % MOD;
		ans%=MOD;
	}
	cout << ans << endl;
 
}

Measured memory_bytes: 4428
import math

a, b, x = map(int, input().split())
v = a * a * b
if(x <= v / 2):
    h = 2 * x / a / b
    ans = math.degrees(math.atan(b / h))
else:
    h = (v - x) / a / a * 2
    ans = math.degrees(math.atan(h / a))

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <utility>
#include <bitset>
#include <queue>

using namespace std;

using ll = long long;

struct shop
{
	ll stock;
	ll price;
};

bool operator<(const shop &a, const shop &b)
{
	return a.price < b.price;
}
bool operator>(const shop &a, const shop &b)
{
	return !(a < b);
}

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

	priority_queue<shop, vector<shop>, greater<shop>> pq;

	for (int i = 1; i <= n; i++)
	{
		shop obj;
		cin >> obj.price >> obj.stock;
		pq.push(obj);
	}

	ll current = 0;
	ll cost = 0;

	while (!pq.empty())
	{
		if (m - current >= pq.top().stock)
		{
			// 全購入
			cost += (pq.top().stock * pq.top().price);
			current += pq.top().stock;
		}
		else
		{
			// 残り分購入
			cost += (pq.top().price * (m - current));
			current += (m - current);
		}

		if (current == m)
			break;

		pq.pop();
	}

	// M本に至るまで安いところから買い漁る

	cout << cost << endl;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

int main(){
  int a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  map<int,int> water;
  for(int i=0;i*100*a<=f;i++){//a増やすやつをi回やる
    for(int j=0;j*100*b<=f-i*a;j++){//b増やすやつをj回やる
      water[i*100*a+j*100*b] ++;
    }
  }
  map<int,int> sugar;
  for(int i=0;i*c<=f;i++){//c増やすやつをi回やる
    for(int j=0;j*d<=f-i*c;j++){//d増やすやつをj回やる
      sugar[i*c+j*d] ++;
    }
  }
  int ans1 = 0;
  int ans2 = 0;
  int dens = 0;
  for(auto w : water){
    for(auto s : sugar){
      int wat = w.first;
      int sug = s.first;
      if(wat + sug == 0) continue;
      if(wat + sug <= f && sug <= e*wat/100){
        double tmp = (double)10000*sug/(wat+sug);
        if(tmp >= dens){
          ans1 = wat + sug;
          ans2 = sug;
          dens = tmp;
          //cout << ans1 << " " << ans2 << " " << e*wat/100 << " " << dens << endl;
        }
      }
    }
  }
  cout << ans1 << " " << ans2 << endl;
}


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

int main() {
	long long K, S;
	long long counter = 0;
	cin >> K >> S;

	for (int X = 0; X <= K; X++) {
		for (int Y = 0; Y <= K; Y++) {
			if (S - X - Y <= K && S - X - Y >= 0) {
				counter++;
			}
		}
	}

	cout << counter << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define fi                      first
#define se                      second
#define pb                      push_back
#define pbb                     pop_back
#define mp                      make_pair
#define pii     	            pair<int,int>
#define all(x)                  x.begin(), x.end()
#define mem(array, value)       memset(array, value, sizeof(array))
#define fastRead 	            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#ifdef Lollipop
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " = " << arg1 << " , ";
    __f(comma + 1, args...);
    }
#else
    #define line
    #define trace(...)
#endif

int main ()
{
    #ifdef Lollipop
        //freopen ("input.txt", "r", stdin);
        //freopen ("output.txt", "w", stdout);
    #endif
    //fastRead;
    int n;
    cin >> n;
    ll sum = 0;
    for (int i = 1; i <= n; i++){
        if (i % 3 != 0 && i % 5 != 0)   sum += i;
    }
    cout << sum << endl;
    return 0;
}




Measured memory_bytes: 3636
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_2_A&lang=jp
//verify用に

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

class Prim {
public:
    typedef pair<ll, int> P;
    int N;
    vector<vector<P>> G;
    vector<bool> used;

    Prim(int N) : N(N) {
        G.resize(N);
        used.resize(N, false);
    }

    void add_edge(int s, int t, ll c){
        G[s].push_back(P(c, t));
        G[t].push_back(P(c, s));
    }

    ll prim() {
        priority_queue<P, vector<P>, greater<P>> que;
        ll res = 0;

        used[0] = true;
        for(int i = 0; i < (int)G[0].size(); i++){
            que.push(G[0][i]);
        }

        while(!que.empty()) {
            P e = que.top();
            que.pop();

            int to = e.second;
            ll cost = e.first;

            if(!used[to]) {
                used[to] = true;
                res += cost;
                for(int i = 0; i < (int)G[to].size(); i++){
                    if(!used[G[to][i].second]) {
                        que.push(G[to][i]);
                    }
                }
            }
        }

        return res;
    }
};

int main(){
    int N, M;
    cin >> N >> M;
    Prim pr = Prim(N);
    for(int i = 0; i < M; i++){
        int a, b;
        ll c;
        cin >> a >> b >> c;
        pr.add_edge(a, b, c);
    }

    cout << pr.prim() << endl;
    return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, m;
  cin >> n >> m;
  int ans = 0;
  if(n >= 2 && m >= 2) ans += (n-2)*(m-2);
  else if(n >= 2) ans += (n-2)*m;
  else if(m >= 2) ans += n*(m-2);
  else ans = 1;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const long long MOD = 1e9+7;
const long long B = 61;

signed main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    vector<vector<bool>> bit(N, vector<bool>(B));
    for (long long i = 0; i < N; i++) {
        for (long long j = 0; j < B; j++) {
            bit[i][j] = (A[i]&(1LL<<j));
        }
    }
    
    long long ans = 0;
    long long two = 1;
    for (int j = 0; j < B; j++) {
        int one = 0, zero = 0;
        for (int i = 0; i < N; i++) {
            if (bit[i][j]) one++;
            else zero++;
        }
        /*
        if (j == 33) cout << one << " " << zero << endl;
        cout << j << "bit is " << ans << endl;
        */
        long long res = (((two * one)%MOD) * zero) % MOD;
        ans += res;
        ans %= MOD;
        two *= 2LL;
        two %= MOD;
    }
    
    cout << ans%MOD << endl;
    return 0;
}

Measured memory_bytes: 25728
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fo(i,n) for(i=0;i<n;i++)
#define fok(i,k,n) for(i=k;i<n;i++)
#define ci(x) cin>>x;
#define ci2(x,y) cin>>x>>y;
#define co(x) cout<<x<<"\n";
#define co2(x,y) cout<<x<<" "<<y<<"\n";
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;

int main() {
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	int n;
	ci(n);
	int i;
	int ans=0;
	fo(i,n){
		int temp;
		ci(temp);
		ans+=(temp-1);
	}
	co(ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
set<long long int> s;
void dfs(long long int n,long long int m,long long int stepNum) 
{ 
 if(stepNum<=m && stepNum>=n) 
 s.insert(stepNum);
 if(stepNum==0 || stepNum>m) 
 return ; 
 int lastDigit = stepNum % 10; 
 long long int stepNumA = stepNum*10 + (lastDigit-1); 
 long long int stepNumB = stepNum*10 + (lastDigit+1);
 long long int stepNumC = stepNum*10 + (lastDigit);
 dfs(n, m, stepNumC);
 if (lastDigit == 0) 
 dfs(n, m, stepNumB); 
 else if(lastDigit == 9) 
 dfs(n, m, stepNumA); 
 else
 { 
  dfs(n, m, stepNumA);
  dfs(n, m, stepNumB); 
 } 
} 
void find(long long int n,long long int m) 
{ 
 for(int i=0;i<=9;i++) 
 dfs(n, m, i); 
}
int main() 
{ 
 int k;
 long long int n,m;
 n=1;
 m=3234566667;
 find(n,m);
 vector<long long int> v;
 for(auto it=s.begin();it!=s.end();it++)
 v.push_back(*it);
 cin >> k;
 cout << v[k-1];
 return 0; 
}

Measured memory_bytes: 6136
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int a[3],ans=0;
int main(){
	cin>>a[0]>>a[1]>>a[2];
	while(a[0]!=a[1]||a[0]!=a[2]||a[1]!=a[2]){
		sort(a,a+3);
		if(a[2]-a[0]>=2){
			a[0]+=2;
			ans++;
		}
		else{
			a[0]+=1;
			a[1]+=1;
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main() {
  int n;
  cin >> n;
  int minusCount = 0;
  ll minAbs = 10000000000;
  ll sum = 0;
  rep(i, n){
	ll num;
    cin >> num;
    if(num < 0) minusCount++;
    if(abs(num) < minAbs) minAbs = abs(num);
    sum += abs(num);
  }
  if(minusCount % 2 == 0){
    cout << sum << endl;
  }else{
    cout << sum - minAbs - minAbs << endl;
  }
  return 0;
}

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

int main(){
    int A,X;
    cin >> X >> A;
    if(X >= A) cout << 10 << endl;
    else cout << 0 << endl;
}


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

int main(){
	int x;
	cin >> x;
	int s1, s2, s3;
	s1 = x/100;
	s2 = (x%100)/10;
	s3 = (x%100)%10;
	cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
const int SIZE = 1<<18;
using ll = long long;
using pll = pair<ll, ll>;
int h[200001];
struct LiChao{
	struct Node{
		int l=0,r=0;
		pll line = pll(0, (ll)1e18);
	} node[2*SIZE];
	int cnt;
	inline ll f(pll line, int x){
		return line.first*x + line.second;
	}
	void update(int nn, int ns, int ne, pll newLine){
		auto &cur = node[nn];
		pll l1 = cur.line, l2 = newLine;
		if(f(l1, ns) > f(l2, ns)) swap(l1, l2);
		if(f(l1, ne) <= f(l2, ne)){
			cur.line = l1;
			return;
		}
		int m = ns+ne>>1;
		if(f(l1, m) <= f(l2, m)){
			cur.line = l1;
			if(!cur.r) cur.r = ++cnt, node[cnt].line = l1;
			update(cur.r, m+1, ne, l2);
		}
		else{
			cur.line = l2;
			if(!cur.l) cur.l = ++cnt, node[cnt].line = l2;
			update(cur.l, ns, m, l1);
		}
	}
	ll query(int nn, int ns, int ne, int x){
		auto &cur = node[nn];
		if(ns==ne) return f(cur.line, x);
		int m = ns+ne>>1;
		if(m<x) return min(f(cur.line, x), cur.r?query(cur.r, m+1, ne, x):(ll)1e18);
		return min(f(cur.line, x), cur.l?query(cur.l, ns, m ,x):(ll)1e18);
	}
} L;
int N;
ll dp[200001], C;
int main(){
	scanf("%d%lld",&N,&C);
	for(int i=1; i<=N; ++i) scanf("%d",h+i);
	L.update(0, 0, 1e6, pll(-2ll*h[1], 1ll*h[1]*h[1]));
	for(int i=2; i<=N; ++i){
		dp[i] = 1ll*h[i]*h[i]+C+L.query(0, 0, 1e6, h[i]);
		L.update(0, 0, 1e6, pll(-2ll*h[i], 1ll*h[i]*h[i]+dp[i]));
	}
	printf("%lld",dp[N]);
	return 0;
}


Measured memory_bytes: 14848
//x[i] + 1 =rx[i] -D
#include <bits/stdc++.h>

using namespace std;

int main()
{
	int x, r, d;
	cin >> r >> d >> x;
	int ans1 = r * x - d ;
	int ans2 = r * ans1 - d;
	int ans3 = r * ans2 - d;
	int ans4 = r * ans3 - d;
	int ans5 = r * ans4 - d;
	int ans6 = r * ans5 - d;
	int ans7 = r * ans6 - d;
	int ans8 = r * ans7 - d;
	int ans9 = r * ans8 - d;
	int ans10 = r * ans9 - d;
	cout << ans1 << endl;
	cout << ans2 << endl;
	cout << ans3 << endl;
	cout << ans4 << endl;
	cout << ans5 << endl;
	cout << ans6 << endl;
	cout << ans7 << endl;
	cout << ans8 << endl;
	cout << ans9 << endl;
	cout << ans10 << endl;
	return 0;
}

Measured memory_bytes: 256
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

int main() {
	int n=read(); double d=read(),x=read(),ans=0;
	while (n) {
		ans+=d+1.0*(2*n-1)/2*x;
		d=d+(2*d+5*x)/2/n;
		x=x+2.0*x/n;
		--n;
	}
	printf("%.10lf\n",ans);
	return 0;
}

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

main() {
  int tmp;
  vi A, B;
  while ((tmp = cin.get()) != '\n') A.push_back(tmp);
  while ((tmp = cin.get()) != '\n') B.push_back(tmp);

  if (A.size() < B.size()) {
    cout << "LESS" << endl;
  } else if (A.size() > B.size()) {
    cout << "GREATER" << endl;
  } else {
    rep(i, A.size()) {
      if (A[i] > B[i]) {
        cout << "GREATER" << endl;
        break;
      } else if (A[i] < B[i]) {
        cout << "LESS" << endl;
        break;
      }

      if (i == A.size() - 1) cout << "EQUAL" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define BUF_SIZE 50

int get_int2(uint64_t *a1, uint64_t *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%llu %llu", a1, a2);
#else
#error
#endif
  return 0;
}

int main(void) {
    uint64_t start, end;
    get_int2(&start, &end);
    int cnt = 0;
    while(start <= end) {
        start *= 2;
        cnt++;
    }
    printf("%d\n", cnt);
    return 0;
}

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


int main(void){
        ll X;
        cin >> X;
        ll now = 100;
        ll ans = 0;

        while (now < X) {
                now += now/100;
                ans++;
        }
        cout << ans << endl;
        return 0;
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << (a - c) * (b - d) << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

#define int long long

using namespace std;

signed main()
{
    int N, M;
    //pair(number, the number of the number)
    vector<pair<int, int>> np;

    cin >> N >> M;
    for (int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        np.push_back(pair<int, int>(a, 1));
    }
    for (int i = 0; i < M; i++)
    {
        int b, c;
        cin >> b >> c;
        np.push_back(pair<int, int>(c, b));
    }

    sort(np.begin(), np.end(), greater<pair<int, int>>());

    int ans = 0;
    int nans = 0;
    for (int i = 0; i < np.size(); i++)
    {
        int n = np[i].first;
        int nn = np[i].second;
        if (nans + nn < N)
        {
            ans += nn * n;
            nans += nn;
        }
        else
        {
            ans += (N - nans) * n;
            break;
        }
    }

    cout << ans << endl;
}

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

int main(int argc, char const *argv[]) {
	int a,b,x;
	cin >> a >> b >> x;
	if (((a + b) < x)| (a > x)){
		cout << "NO" << endl;
	}else{
		cout << "YES" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

struct UnionFind {
    vector<ll> par;
    vector<ll> siz;
    
    UnionFind(ll N): par(N), siz(N,1) {
        for (ll i=0;i<N;i++) par[i] = i;
    }

    ll root(ll x) {
        if (par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return;
        // if (siz[rx] < siz[ry]) swap(rx,ry);
        par[rx] = ry;
        siz[ry] += siz[rx];
    }

    bool same(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

int main(void) {
    int N, M;
    cin >> N >> M;
    vector<int> A(100010), B(100010);
    for (int i=0;i<M;i++) cin >> A[i] >> B[i];

    UnionFind U(N);
    vector<ll> ans(100010);
    ans[M] = N*(N-1LL)/2LL;
    for (int i=M-1;i>=0;i--) {
        if (U.same(A[i]-1,B[i]-1)) {
            ans[i] = ans[i+1];
        } else {
            ans[i] = ans[i+1] - U.size(A[i]-1)*U.size(B[i]-1);
        }
        U.unite(A[i]-1,B[i]-1);
    }
    for (int i=1;i<=M;i++) {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 4480
#include "bits/stdc++.h"
using namespace std;
signed main()
{
	bool o[100];
	int n, k, ans = 0;
	scanf("%d%d", &n, &k);
	for(int i = 0; i < n; o[i++] = false);
	for(int i = 0, d; i < k; ++i)
	{
		scanf("%d", &d);
		for(int j = 0, a; j < d; ++j)
		{
			scanf("%d", &a);
			o[a - 1] |= true;
		}
	}
	for(int i = 0; i < n; ++i)
	{
		ans += !o[i];
	}
	printf("%d\n", ans);
}

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

int main(){
  string a;
  cin >> a;
  
  int count = 0;
  rep(i,3){
    if(a[i] == '1') count++;
  }
  
  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 3588
def gcd(a,b):
    while b!=0:
         a,b=b,a%b
    return a
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(i)
    if temp!=1:
        arr.append(temp)
    if arr==[]:
        arr.append(n)
    return arr
if __name__ == "__main__":
    A,B = map(int,input().split())
    d = gcd(A,B)
    if d == 1:
        print(1)
    else:
        D = factorization(d)
        print(len(D)+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#ifdef DEBUG
  #include "debug.hpp"
#else
  #define DUMP(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
using value_type = typename iterator_traits<FwdIter>::value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */


int main(const int /*argc*/, char ** /*argv*/) {
  ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

  int64_t a, b;
  cin >> a >> b;
  if (b == 1) {
    cout << 0;
    return 0;
  }

  int64_t ub = 1, lb = 0;
  while (ub * a - ub + 1 < b) {
    lb = ub;
    ub <<= 1;
  }

  while (lb + 1 < ub) {
    const int64_t x = (lb + ub) >> 1;
    if (x * a - x + 1 < b) {
      lb = x;
    } else {
      ub = x;
    }
  }

  cout << ub;

  return EXIT_SUCCESS;
}


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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumlate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

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

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

  n %= 500;

  if(n <= a) cout << "Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 256
from fractions import gcd
from math import factorial, ceil, sqrt, atan2, log, pi, e, asin,acos, cos, sin
from itertools import *
from fractions import Fraction
import string
import copy
import random
import bisect
from decimal import *
def id_generator(size=20, chars=string.digits):
    return ''.join(random.choice(chars) for _ in range(size))
 
def mp():
    return map(int,str(raw_input()).split())

n=input()
s=str(n)
ans=''
if s[0]!='9':
	print max(9*(len(s)-1)+(int(s[0])-1),sum(map(int,list(s))))
else:
	if s[1]=='0':
		print 9*(len(s)-1)+8
	else:
		i=0
		while i<len(s) and s[i]=='9':
			i+=1
		if i==len(s):
			print 9*len(s)
		else:
			if s[i]=='0':
				ans= 9*(len(s)-1)+8
			else:
				ans=9*(len(s)-1)+8
			print ans


Measured memory_bytes: 6540
#include <cstdio>
#include <cmath>
#include <queue>
#include <map>
#include <string>
#include <utility>

using namespace std;

#define N (3)
#define N2 (N*N)

struct Puzzle {
    int f[N2];
    int space;
    string path;

    bool operator < ( const Puzzle &p ) const {
	for ( int i = 0; i < N2; i++ ) {
	    if ( f[i] == p.f[i] ) continue;
	    return ( f[i] < p.f[i] );
	}
	return false;		// ????????????????????´???????????\????????????
        //return true;
    }
};

// x, y?????????????????£??????
static const int dx[4] = {-1, 0, 1, 0};
static const int dy[4] = {0, -1, 0, 1};
static const char dir[4] = {'u', 'l', 'd', 'r'};

bool isTarget( Puzzle p ) {
    for ( int i = 0; i < N2; i++ ) {
	if ( p.f[i] != ( i + 1 ) ) return false;
    }
    return true;
}

string bfs( Puzzle s ) {
    queue<Puzzle> Q;
    map<Puzzle, bool> V;
    Puzzle u, v;
    s.path = "";
    Q.push( s );
    V[s] = true;
    
    while ( !Q.empty() ) {
	u = Q.front(); Q.pop();
	if ( isTarget( u ) ) return u.path;
	int sx = u.space / N;
	int sy = u.space % N;
	
	for ( int r = 0; r < 4; r++ ) {
	    int tx = sx + dx[r];
	    int ty = sy + dy[r];

	    if ( tx < 0 || ty < 0 || tx >= N || ty >= N ) continue;
	    v = u;
	    swap( v.f[u.space], v.f[tx * N + ty] );
	    v.space = tx * N + ty;
	    if ( !V[v] ) {
		V[v] = true;
		v.path += dir[r];
		Q.push( v );
	    }
	}
    }

    return "unsolvable";
}

int main()
{
    Puzzle in;
    
    for ( int i = 0; i < N2; i++ ) {
	scanf("%d", &in.f[i]);
	if ( in.f[i] == 0 ) {
	    in.f[i] = N2;
	    in.space = i;
	}
    }
    string ans = bfs( in );

    printf("%d\n", (int)ans.size());

    return 0;
}

Measured memory_bytes: 28536
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main(void) {
	int num;
	scanf("%d", &num);
	int i, tmp;
	int cnt = 0;
	for (i = 0; i < num; i++) {
		cnt++;
		//3??§?????????????????°???134??????3???????????§????????°?????????
		tmp = cnt;
		char threeJudge[1000];
		char *judge;
		sprintf(threeJudge, "%d", cnt);
		if ((judge=strstr(threeJudge,"3"))!=NULL) {
			printf(" %d", cnt);
		}else if (tmp % 3 == 0 || tmp % 10 == 3) {
			printf(" %d", cnt);
		}else {
			tmp =floor(tmp/10);
			if (tmp % 10 == 3) {
				printf(" %d", cnt);
			}
			
		}

		
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 616
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
ll a, b, n;
 
 
 
 
 
ll pow_mod(ll b,ll e){
  ll ac = 1;
  ll x = e;
  ll apow=b;
  while(x){
    if(x%2 == 1){
      ac = (ac*apow)%mod;
    }
    x>>=1;
    apow = (apow*apow)%mod;
  }
  return ac;
}
 
ll C(ll n, ll k) {
    ll res = 1;
    for (int i = n - k + 1; i <= n; ++i)
        res = (res * i) % mod;
    for (int i = 2; i <= k; ++i)
        res = (res * pow_mod(i, mod - 2)) % mod;

	return res;
}
 
int main(){
  cin >> n >> a >> b;
  
  // cout << pow_mod(2, n) - 1 << endl;
  // cout << C(n, a) << endl;
  // cout << C(n, b) << endl;
  
 
  cout << ((pow_mod(2, n) - 1ll - C(n, a) - C(n, b)) % mod + mod) % mod << '\n'; 
}

Measured memory_bytes: 256
import sys
s=''.join(reversed(list(input())))
t=''
text = ['maerd', 'esare', 'resare', 'remaerd']
while len(t) < len(s):
  for tx in text:
    if t + tx == s[:len(t+tx)]:
      t += tx
      break
  else:
    print('NO')
    sys.exit()
print('YES')

Measured memory_bytes: 10088
int main(void)
{
    int i, j, k, z, point[10] ,sum[2] ,flag;
   
    for(k = 0; k < 2; k++){
    
        for(i = 0; i < 10; i++){
            scanf("%d", &point[i]);
        }
    
        for(i = 0; i < 3; i++){
            flag = 0;
            for(j = i + 1; j < 10; j++){
                if(point[i] < point[j]){
                    z = point[i];
                    point[i] = point[j];
                    point[j] = z;
                    flag++;
                }
            }
            if(flag == 0)
                break;
        }
        
        sum[k] = point[0] + point[1] + point[2];
        
    }
    
    printf("%d %d\n", sum[0],sum[1]);
    return (0);
}

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

using namespace std;

int main()
{
    string s1;
    string s2;
    cin>>s1;
    cin>>s2;
    int l2=s2.length();
    s2.erase(l2-1);
    if(s1==s2)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3624
n, m = map(int, input().split())
wa = [0]*n
ac = [0]*n
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC' and ac[p] == 0:
        ac[p] = 1
    elif s =='WA' and ac[p] == 0:
        wa[p] += 1
for j in range(n):
    if ac[j] == 0:
        wa[j] = 0
print(sum(ac), sum(wa))
    

Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b,c,d;
  string s;
  cin>>s;
  a=s[0]-48;
  b=s[1]-48;
  c=s[2]-48;
  d=s[3]-48;
  if(a+b+c+d==7) cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"="<<7<<endl;
  else if(a+b+c-d==7) cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"="<<7<<endl;
  else if(a+b-c+d==7) cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"="<<7<<endl;
  else if(a-b+c+d==7) cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"="<<7<<endl;
  else if(a+b-c-d==7) cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"="<<7<<endl;
  else if(a-b-c+d==7) cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"="<<7<<endl;
  else if(a-b+c-d==7) cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"="<<7<<endl;
  else if(a-b-c-d==7) cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"="<<7<<endl;
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    int i, j;
    cin >> i >> j;
    string u;
    cin >> u;
    if(s == u) i--;
    else j--;
    cout << i << " " <<j <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	char a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int cnt[4]={0,0,0,0};\
	for(int i=0;i<n;i++){
		if(a[i]=='G'){
			cnt[0]++;
		}
		if(a[i]=='W'){
			cnt[1]++;
		}
		if(a[i]=='Y'){
			cnt[2]++;
		}
		if(a[i]=='P'){
			cnt[3]++;
		}
	}
	int ans=0;
	for(int i=0;i<4;i++){
		if(cnt[i]!=0){
			ans++;
		}
	}
	if(ans==1){
		cout<<"One";
	}
	if(ans==2){
		cout<<"Two";
	}
	if(ans==3){
		cout<<"Three";
	}
	if(ans==4){
		cout<<"Four";
	}
} 

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

int main(){
  char in[120];
  pair<pair<string,int>,int> p[110];
  int a;
  cin >> a;
  rep(i,a){
    int t;
    string s;
    cin >> s >> t;
    p[i]=make_pair(make_pair(s,-t),i);
  }
  sort(p,p+a);
  rep(i,a)
    cout << p[i].second+1 << endl;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	vl b(n-1);
	FOR(i,0,n-1) cin >> b[i];

	ll res = 0;
	FOR(i,0,n) {
		ll x = oo;
		if (i < n-1) x = min(x,b[i]);
		if (i > 0) x = min(x,b[i-1]);
		res += x;
	}
	cout << res << endl;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}

	return i
}
func main() {
	sc.Split(bufio.ScanWords)
	k := nextInt()
	a := nextInt()
	b := nextInt()

	if k == 1 {
		fmt.Println("OK")
		return
	}
	if a%k == 0 {
		fmt.Println("OK")
		return
	}
	if b%k == 0 {
		fmt.Println("OK")
		return
	}

	for i := k; i < 1000; i += k {
		if (a < i) && (i < b) {
			fmt.Println("OK")
			return
		}

	}

	fmt.Println("NG")

}


Measured memory_bytes: 1760
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

Int X;
Int used[2000000];
void dfs(Int sum){
  if(used[sum]) return;
  used[sum] = 1;
  if(sum >= X) return;

  for(Int i=0;i<=5;i++)dfs(sum + 100 + i);
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);


  cin>>X;
  dfs(0);
  cout<<used[X]<<endl;
  return 0;
}


Measured memory_bytes: 1024
import java.io.*
import java.util.*

fun solve(N: Long, K: Long, h: LongArray){
    h.count{ it >= K }.let{ println(it) }
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toLong()
    val K = sc.next().toLong()
    val h = LongArray(N.toInt())
    for (i in 0 until N.toInt()) {
        h[i] = sc.next().toLong()
    }
    solve(N, K, h)
}



Measured memory_bytes: 39544
def make_divisors(n):
    ans = 10 ** 12 + 10
    i = 1
    while i*i <= n:
        if n % i == 0:
            t = 0
            if i != n // i:
                t = i + (n//i) - 2
            else:
                t = i * 2 - 2
            #print(i, n//i, t)
            if ans > t:
                ans = t
        i += 1
    return ans

n = int(input())
print(make_divisors(n))

Measured memory_bytes: 63356
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#include <limits>
#include <iomanip>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<ll> dp(N+1);
    for(int i=0;i<N;i++){
        cin >> A[i];
        dp[A[i]]++;
    }
    ll total=0;
    for(int i=1;i<=N;i++){
        if(dp[i]>1){
            total+= (dp[i]*(dp[i]-1))/2;
        }
    }
    for(int i=0;i<N;i++){
        int num = A[i];
        ll ans=total;
        if(dp[num]>1){
            ans = ans - (dp[num]*(dp[num]-1))/2;
            if(dp[num]>2){
                ans +=((dp[num]-1)*(dp[num]-2))/2;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 5576
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll H;
    cin>>H;
    ll ans=0;
    for (int i=0; ;++i)
    {
        ans += pow(2,i);
        H/=2;
        if (H==0) break;
    }
    cout << ans << "\n";
    // else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
    while b != a:
        if a < b:
            b = b % a
            if b == 0:
                return a
        elif b < a:
            a = a % b
            if a == 0:
                return b
    return a

def m(a):
    a.sort()
    l = len(a)
    b = []
    for i in range(l // 2):
        b.append(gcd(a[i], a[l - i - 1]))
    if l % 2 == 1:
        b.append(a[l // 2])
    return list(set(b))

    
n = int(input())
a = [int(x) for x in input().split(" ")]

while len(a) > 1:
    a = m(a)

print(a[0])


Measured memory_bytes: 14484
#include <bits/stdc++.h>
#define N ('z'-'a')
using namespace std;
int n,ans,mp[N+1];
string str[501];

void mk_mp(int pos,int i,int j){
  while(i<=j&&pos>=str[i].size())i++;
  if(i>=j)return;
  int ni=i,ch=str[i][pos]-'a';

  while(i<j){
    int a=str[++i][pos]-'a',f=ch==a;
    if((f&&!ni<0)||(f&&str[i-1].size()>str[i].size()&&!str[i][pos+1]))ans=0;

    if(!f){
      mk_mp(pos+1,ni,i-1);
      mk_mp(pos,i,j);
      mp[ch]|=(1<<a|mp[a]);
      return ;
    }
  }
  if(ni>=0) mk_mp(pos+1,ni,j);
}

int main(){
  while(cin>>n,n){
    for(int i=0;i<n;i++)cin>>str[i];
    ans=1;
    mk_mp(0,0,n-1);
    for(int i=0;i<=N;mp[i]=0,i++) ans*=!(mp[i]&1<<i);
    cout <<(ans? "yes":"no")<<endl;
  }
  return 0;
}

Measured memory_bytes: 1248
//Night's template
//orzakyrt
#include <bits/stdc++.h>
#define R register
#define LL long long
#ifdef __DEBUG__
	#define Debug (fprintf(stderr,"orzyrt\n"),fflush(stderr))
	#define debug(__a...) (fprintf(stderr,__a),fflush(stderr))
	#define setfile(__a) ('orzyrt')
	#define Compile(__a) system("g++ "__a".cpp -lm -o "__a)
#else
	#define Debug ('orzyrt')
	#define debug(__a...) ('orzyrt')
	#define setfile(__a) freopen(__a".in","r",stdin);freopen(__a".out","w",stdout)
	#define Compile(__a) ('orzyrt')
#endif
template<class TT>inline TT Max(R TT a,R TT b){return a<b?b:a;}
template<class TT>inline TT Min(R TT a,R TT b){return a<b?a:b;}
template<class TT>inline TT Abs(R TT a){return a<0?-a:a;}
template<class TT>inline TT cmin(R TT &a,R TT b){(b<a)&&(a=b);}
template<class TT>inline TT cmax(R TT &a,R TT b){(a<b)&&(a=b);}
using namespace std;
template<class TT>inline void read(R TT &x){
	x=0;R bool f=false;R char c=getchar();
	for(;c<48||c>57;c=getchar())f|=(c=='-');
	for(;c>47&&c<58;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	(f)&&(x=-x);
}
//end template

namespace Night{
	int n;
	int a[111];
	double avg=0,ansdis=1ll<<60;
	int ans;
	int main(){
		read(n);
		for(R int i=1;i<=n;++i){
			read(a[i]);
			avg+=a[i];
		}
		avg/=n;
		for(R int i=1;i<=n;++i){
			if(ansdis>Abs(a[i]-avg)){
				ansdis=Abs(a[i]-avg);
				ans=i;
			}
		}
		cout<<ans-1;
		return 0;
	}
}
int main(){
	return Night::main();
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, K;
int A[1000];

std::vector<int> divisors(int n){
    std::vector<int> res;

    for(int i=1;i*i<=n;++i){
        if(n % i == 0){
            res.emplace_back(i);

            if(n / i != i){
                res.emplace_back(n / i);
            }
        }
    }

    return res;
}

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

  std::cin >> N >> K;

  for(int i=0;i<N;++i){
      std::cin >> A[i];
  }

  int sum = std::accumulate(A, A + N, 0);
  auto ds = divisors(sum);

  int res = 0;
  
  for(int d : ds){
      std::sort(A, A + N, [&](int l, int r){return l % d > r % d;});

      int rem_sum = std::accumulate(A, A + N, 0, [&](int acc, int x){return acc + x % d;});
      int q = rem_sum / d;
      int cost = std::accumulate(A, A + q, 0, [&](int acc, int x){return acc + (d - x % d);});
      
      if(cost <= K){
          res = std::max(res, d);
      }
  }

  std::cout << res << std::endl;
}


Measured memory_bytes: 256
import sys
import bisect

inf = float('inf')

def solve():
    n = int(input())
    A = [int(input()) for i in range(n)]
    dp = [inf] * n
    max_ = 1

    for a in A:
        j = bisect.bisect_left(dp, a, lo=0, hi=max_)
        max_ = max(max_, j + 1)
        dp[j] = a

    # print(dp)
    ans = max_
    print(ans)


def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

if __name__ == '__main__':
    solve()

Measured memory_bytes: 12424
import java.util.*;

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

		Scanner scan = new Scanner(System.in);
		int num1 = scan.nextInt();
		int num2 = scan.nextInt();
		int num3 = scan.nextInt();
		int con = 0;
		int div = 0;
			
		do{
			if(num3 % (num1 + con) == 0) {
				div++;
			}
			else{}
			con++;
		}while(num1 + con <= num2);

		System.out.println(div);
	}
}

Measured memory_bytes: 26412
s = input()
l = len(s)
# def cal():
total = 0
for i in range(2 ** (l - 1)):
    str_bin = '{0:0=9b}'.format(i)
    str_bin = str_bin[10 - l:]
    list_cut = [0] + [k + 1 for k, cur_num in enumerate(str_bin) if cur_num == "1"] + [l]
    cur_total = []
    for j in range(len(list_cut) - 1):
        cur_total.append(int(s[list_cut[j]:list_cut[j + 1]]))
    total += sum(cur_total)

print(total)

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

int main() {
  int N, now=1, next, count=1;
  cin >> N;
  vector<int> a(N+1);
  for (int i = 1; i < N+1; i++) {
    cin >> a.at(i);
  }
  for (int i = 0; i < N; i++) {
    if (a.at(now) == -1) {
      cout << "-1" << endl;
      break;
    }
    if (a.at(now) == 2) {
      cout << count << endl;
      break;
    }
    next = a.at(now);
    a.at(now) = -1;
    now = next;
    count++;
  }
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  ll X;
  cin>>X;

  ll now=100;
  int ans=0;
  while(now<X){
    now+=now/100;
    ans++;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3648
from collections import defaultdict
from math import gcd
import time
import sys
from collections import Counter
import itertools
import math
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
start = time.time()
# N = list(map(int, input()))[::-1]
N = int(input())
# A, B = map(int, input().split())
y = 0
s = 100
while 1:
    s *= 1.01
    s = math.floor(s)
    y += 1
    if s >= N:
        print(y)
        exit()


Measured memory_bytes: 66568