akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define yes cout<<"Yes"<<nl
#define no  cout<<"No"<<nl
#define nl  '\n'
#define tr ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define tst int t;cin>>t;while(t--)
#define     Max             1000000000000000014
#define     Min             -1000000000000000014
#define     PI              3.1415926535897
#define     Fr               first
#define     Se               second
#define     all(v)          v.begin(),v.end()
#define     mem(a,v)        memset(a,v,sizeof(a))
#define     space            ' '
#define COUT(v) for(auto it:v)cout<<it<<space;cout<<nl;
/*error cheaking method starts from here */
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
err(++it, args...);
}
/*error cheaking method ebds here */
 
#define vi    vector<int>
#define    vl    vector<ll>
#define    si    set<int>
#define    sl    set<ll>
#define    msi    multiset<int>
#define    msl    multiset<ll>
#define    pii    pair<int,int>
#define    pil    pair<int,ll>
#define    pli    pair<ll,int>
#define    pll    pair<ll,ll>
#define    mp    make_pair
#define    pb    push_back
int main()
{
    ll d,t,s,m;
    cin>>d>>t>>s;
    m=t*s;
    if(m>=d)
        yes;
    else
        no;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
typedef tuple<ll,int,int> T;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
set<string> c;
const ll mod=1000000007;
const ll mod2=998244353;
const ll inf=100000000000000000;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
vector<int> dy={-1,0,1,0},dx={0,-1,0,1};
map<ll,int> b;
int main(){
int n;
cin>>n;
vector<ll> a(3*n);
ll lsum=0,rsum=0;
for(int i=0;i<3*n;i++){
    cin>>a[i];
    if(i<n)lsum+=a[i];
    else if(2*n<=i) rsum+=a[i];
}
priority_queue<ll> pr;
priority_queue<ll,vector<ll>,greater<ll>> pl;
for(int i=0;i<n;i++)pl.push(a[i]);
for(int i=2*n;i<3*n;i++)pr.push(a[i]);
vector<ll> l(n+1),r(n+1);
l[0]=lsum;r[n]=rsum;
for(int i=n;i<2*n;i++){
    pl.push(a[i]);
    ll tmp=pl.top();
    pl.pop();
    lsum+=(a[i]-tmp);
    l[i-n+1]=lsum;
}
for(int i=2*n-1;i>=n;i--){
    pr.push(a[i]);
    ll tmp=pr.top();
    pr.pop();
    rsum+=(a[i]-tmp);
    r[i-n]=rsum;
}
ll ans=-inf;
for(int i=0;i<=n;i++){
    ans=max(l[i]-r[i],ans);
}
cout<<ans<<endl;
}

Measured memory_bytes: 5876
def main():
  A, B, K = map(int, input().split())
  
  if K <= A:
    print(A - K, B)
  elif K > A and B >= K - A:
    print(0, B - (K - A))
  elif K > A and B < (K - A):
    print(0, 0)
  
  
  
main()

Measured memory_bytes: 9144
mod=10**9+7
k=int(input())
s=input()
n=len(s)
ans=0
r=pow(26,k,mod)
c=1
for i in range(k+1):
    ans+=r*c
    ans%=mod
    r*=25*pow(26,mod-2,mod)
    r%=mod
    c*=(n+i)*pow(i+1,mod-2,mod)
    c%=mod
print(ans)


Measured memory_bytes: 75600
n=int(input())
w=list(map(int,input().split()))
dif_w=sum(w)
for i in range(n):
    temp = dif_w - 2*w[i]
    if(abs(temp)<dif_w):
        dif_w = temp
    else:
        break
print(abs(dif_w))

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
//const int mod = 100000;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n, c;
  cin >> n >> c;
  vector<vector<int>> d(c, vector<int>(c));
  rep(i, c) rep(j, c) cin >> d[i][j];

  vector<vector<int>> table(n, vector<int>(n));
  rep(i, n) rep(j, n) cin >> table[i][j];
  rep(i, n) rep(j, n) --table[i][j];

  vector<vector<int>> memo(c, vector<int>(3, 0));
  rep(i, n) rep(j, n) ++memo[table[i][j]][(i+j+2)%3];

  int ans = INF;

  for(int z = 0; z < c; ++z) for(int o = 0; o < c; ++o) for(int t = 0; t < c; ++t) {
    if(z == o || z == t || o == t) continue;
    int tmp = 0;
    rep(i, c) {
      tmp += d[i][z]*memo[i][0] + d[i][o]*memo[i][1] + d[i][t]*memo[i][2];
    }
    chmin(ans, tmp);
  }
  cout << ans << endl;
}


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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

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

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

// 100まで素数
int prime[25] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};

// 素因数分解
int sobun[100][25];
int sobunN[25];

int main(){
    ios::sync_with_stdio(false);
    REP(i, 100) {
        ll num = i+1;
        REP(j, 25) {
            while(num % prime[j] == 0) {
                sobun[i][j]++;
                num /= prime[j];
            }
        }
    }
    
    int N;
    cin >> N;
    REP(i, N) {
        REP(j, 25) {
            sobunN[j] += sobun[i][j];
        }
    }
    
    // 約数の数
    ll ans = 0;
    REP(i, 25) {
        // 5 * 5 * 3
        if (sobunN[i] >= 2) {
            // 約数4以上を数える
            int cnt = 0;
            REP(j, 25) {
                if (j != i && sobunN[j] >= 4) {
                    cnt++;
                }
            }
            if (cnt >= 2) {
                ans += cnt * (cnt-1) / 2;
            }
        }
        // 25 * 3
        if (sobunN[i] >= 24) {
            int cnt = 0;
            REP(j, 25) {
                if (j != i && sobunN[j] >= 2) {
                    cnt++;
                }
            }
            ans += cnt;
        }
        // 15 * 5
        if (sobunN[i] >= 14) {
            int cnt = 0;
            REP(j, 25) {
                if (j != i && sobunN[j] >= 4) {
                    cnt++;
                }
            }
            ans += cnt;
        }
        // 75 * 1
        if (sobunN[i] >= 74) {
            ans += 1;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

pair <double,double> cal(int len,int h,int m)
{
    pair <double,double> ans;
    double x=m;
    x/=60;
    x+=h;
  
    x=2*3.141592653589793*(x/12);
    double y=3.14159265358979323846;
    double theta=x*180;
    if(theta<=90)
        ans={len*sin(x),len*cos(x)};
    else if(theta<=180)
    {
        ans={len*cos(x-y/2),-len*sin(x-y/2)};
    }
    else if(theta<=270)
        ans={-len*sin(x-y),-len*cos(x-y)};
    else
        ans={-len*cos(x-y-y/2),len*sin(x-y-y/2)};
    return ans;
}

pair <double,double> cal2(int len,int h,int m)
{
    pair <double,double> ans;
    double x=m;
  
    x=2*3.141592653589793*(x/60);
    double y=3.14159265358979323846;
    double theta=x*180;
    if(theta<=90)
        ans={len*sin(x),len*cos(x)};
    else if(theta<=180)
    {
        ans={len*cos(x-y/2),-len*sin(x-y/2)};
    }
    else if(theta<=270)
        ans={-len*sin(x-y),-len*cos(x-y)};
    else
        ans={-len*cos(x-y-y/2),len*sin(x-y-y/2)};
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a=nxt(),b=nxt(),h=nxt(),m=nxt();
    pair <double,double> x1=cal(a,h,m),x2=cal2(b,h,m);
    cout<<setprecision(15)<<sqrt(pow(x1.first-x2.first,2)+pow(x1.second-x2.second,2))<<endl;
   
    
    
    return 0;   
}




 
 


Measured memory_bytes: 4184
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  xs <- getc toInt
  mapM_ print $ solve xs

solve :: [Int] -> [Int]
solve = map numOfArea

numOfArea :: Int -> Int
numOfArea 1 = 2
numOfArea n = n + numOfArea (n - 1)

toInt :: String -> Int
toInt s = read s

getc :: (String -> a) -> IO [a]
getc f = map f . lines <$> getContents

Measured memory_bytes: 4864
#include <iostream>
using namespace std;
int main()
{
    int a,b,c,d;
    while(cin>>a>>b>>c>>d){
        if((a+b)==(c+d)){
            cout<<"Balanced"<<endl;
        }
        else if((a+b)>(c+d)){
            cout<<"Left"<<endl;
        }
        else cout<<"Right"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
/*
 ID: swagchicken1
 PROG:
 LANG: C++11
 */

#include <iostream>
#include <tuple>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <vector>
#include <fstream>
#include <iomanip>
#include <ctime>
#include <cctype>
#include <climits>
#include <chrono>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vector <int> > vvi;
typedef pair<int, int> pii;
typedef pair < pair < int, int >, int > piii;
typedef pair < pair <int, int > , pair <int, int> > piiii;

#define FOR(i,a,b) for(int i = a; i < b; i ++)
#define RFOR(i,a,b) for(int i = a-1; i >= b; i --)

//#define endl '\n';

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1000000007;

long double PI = 4*atan(1);
long double eps = 1e-12;


ll dp[2010][2010] = {};
int main() {
    //auto start = chrono::high_resolution_clock::now();
    ios_base::sync_with_stdio(0);cin.tie(0);
    //ofstream cout("output.txt");
    //ifstream cin("input.txt");
    string str; cin >> str;
    
    int n = (int) str.length();
    
    int mod2019[200010] = {};
    int pow10 = 1;
    int modcnt[2020] = {};
    modcnt[0] ++;
    FOR(i,1,n+1) {
        mod2019[i] = (mod2019[i-1] + pow10*(str[n -i]-'0'))%2019;
    
        modcnt[mod2019[i]] ++;
        pow10 *= 10;
        pow10 %= 2019;
    }
    ll ans = 0;
    FOR(i,0,2020) {
        
        ans +=(modcnt[i] * (modcnt[i] -1))/2;
    }
    cout <<ans << endl;
    //auto stop = chrono::high_resolution_clock::now();
    //auto duration = chrono::duration_cast<chrono::microseconds>(stop - start);
    //cout << duration.count() << endl;
    //cin.close();
    //cout.close();
}


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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) 
#define repi(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}
//最終奥義
//#define int long long
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }

signed main(void){
  int n;cin >> n;
  int ans = 0;
  repi(i,1,n+1){
    string t = to_string(i);
    if(t.length()%2)ans++;
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut x = read::<i64>();
    let mut a = vec![0; 4];
    for i in 0..4 {
        a[3-i] = x % 10;
        x /= 10;
    }

    let mut c = vec!['+'; 3];
    for o in 0..2_i32.pow(3) {
        let mut tmp = a[0];
        for i in 0..3 {
            if 1 << i & o != 0 {
                tmp += a[i+1];
                c[i] = '+';
            } else {
                tmp -= a[i+1];
                c[i] = '-';
            }
        }
        if tmp == 7 {
            break;
        }
    }
    print!("{}", a[0]);
    for i in 0..3 {
        print!("{}{}", c[i], a[i+1])
    }
    println!("=7")
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
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;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n,m;
    cin>>n>>m;
    vector<vector<int>> g(n);
    REP(i,m) {
        int a,b;
        cin>>a>>b;
        a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    
    int cnt[2];
    cnt[0]=cnt[1]=0;
    vector<int> col(n,-1);
    function<bool(int,int,int)> dfs=[&](int v,int p,int c) {
        bool ret=1;
        col[v]=c;
        cnt[c]++;
        FORE(x,g[v]) {
            if(x==p) continue;
            if(col[x]!=-1) {
                if(col[x]==c) {
                    return false;
                } else {
                    continue;
                }
            }
            bool r=dfs(x,v,!c);
            if(!r) {
                ret=0;
            }
        }
        return ret;
    };
    
    bool r=dfs(0,-1,0);
    if(r) {
        cout<<(cnt[0]*cnt[1]-m)<<endl;
    } else {
        cout<<(n*(n-1)/2-m)<<endl;
    }
    return 0;
}


Measured memory_bytes: 9088
import time
import math
N=int(input())
if N==1:
    print(1)
    exit()


d=[1]*(N+1)

ans=1
for i in range(2,N+1):
    j=0
    while i+j<=N:
        d[i+j]+=1
        j+=i
    ans+=d[i]*i


print(ans)


Measured memory_bytes: 151564
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define MAX_N (200)
#define MAX_M (MAX_N * (MAX_N - 1) / 2)
#define MAX_R (8)
#define INF (1000000000)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  int N, M, R, rs[MAX_R], as[MAX_M], bs[MAX_M], cs[MAX_M];
  scanf("%d %d %d", &N, &M, &R);
  for (int k = 0; k < R; k++) {
    scanf("%d", &rs[k]);
    rs[k]--;
  }
  for (int k = 0; k < M; k++) {
    scanf("%d %d %d", &as[k], &bs[k], &cs[k]);
    as[k]--;
    bs[k]--;
  }

  // warshall floyd
  int distances[MAX_N][MAX_N];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      distances[i][j] = (i == j ? 0 : INF);
    }
  }
  for (int k = 0; k < M; k++) {
    const int a = as[k], b = bs[k], c = cs[k];
    distances[a][b] = c;
    distances[b][a] = c;
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        distances[i][j] =
            min(distances[i][j], distances[i][k] + distances[k][j]);
      }
    }
  }

  // solve
  int ans = INF;
  int perm[MAX_R];
  for (int k = 0; k < R; k++) {
    perm[k] = k;
  }
  do {
    int d = 0;
    for (int k = 1; k < R; k++) {
      d += distances[rs[perm[k]]][rs[perm[k - 1]]];
    }
    ans = min(ans, d);
  } while (next_permutation(perm, perm + R));
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int64_t fukuri(int64_t price, int64_t target, int64_t count) {
    if (price >= target) {
        return count;
    }

    price = int(price * 1.01);
    count += 1;
    return fukuri(price, target, count);
}
int main() {
    long long X;
    cin >> X;
    long long count = 0;
    long long price = 100;
    while (price < X) {
        price = price * 1.01;
        count += 1;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <cstdio>
#include <cstring>

int main(){
    char s[101],t[101];
    scanf("%s\n%s",s,t);
    char a;
    for(int i = 0; s[i] != 0; i++){
        for(int j = i + 1; s[j] != 0; j++){
			if(s[i] > s[j]){
				a = s[i];
				s[i] = s[j];
				s[j] = a;
			}
		}
	}
    for(int i = 0; t[i] != 0; i++){
        for(int j = 0; t[j] != 0; j++){
            if(t[i] > t[j]){
                a = t[i];
                t[i] = t[j];
                t[j] = a;
            }
        }
    }
    if(strcmp(s, t) < 0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
using namespace std;
typedef long long ll;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
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; }
const int INF = 1e9;

const int MAX_N = 100000;
bool used[MAX_N];
int pen[MAX_N];

int main() {
    int N,M;
    cin >> N >> M;
    rep(i,M) {
        int p;
        string s;
        cin >> p >> s;
        --p;
        if(s == "AC") {
            used[p] = true;
        } else if(!used[p]){
            ++pen[p];
        }
    }
    int cntac = 0;
    int cntwa = 0;
    rep(i,N) {
        if(used[i]) {
            ++cntac;
            cntwa += pen[i];
        }
    }
    cout << cntac << " " << cntwa << endl;
    return 0;
}


Measured memory_bytes: 768
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int,input().split()))
    A.insert(0,0)

    B = [[] for i in range(N+1)]
    B[0] = 0

    for i in range(N, 0, -1):
        if 2*i > N:
            B[i] = A[i]
        else:
            B[i] = (A[i]+sum(B[i*2::i]))%2

    print(sum(B))
    for i in range(1, N+1,1):
        if B[i] == 1:
            print(i, end =" ")


if __name__ == "__main__":
    main()


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

int main() {

    string S;
    cin >> S;

    int max_length = 0;
    int count = 0;
    auto length = (int)S.length();
    for(int i = 0; i < length; i++) {
        switch(S[i]) {
        case 'A':
        case 'T':
        case 'G':
        case 'C':
            count++;
            max_length = max(count, max_length);
        break;
            default:
            count = 0;
        }
    }

    cout << max_length << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
n=int(input())
edge=[[]for i in range(n+1)]
for i in range(n-1):
    a,b,c=map(int,input().split())
    if c%2==0:
        edge[a].append((b,1))
        edge[b].append((a,1))
    else:
        edge[a].append((b,-1))
        edge[b].append((a,-1))
        

ans=[None]*(n+1)


def set_color(x,col):
    ans[x]=col
    for i,j in edge[x]:
        if ans[i] is None:
            set_color(i,j*col)
    
    
set_color(1,1)
            
for i in ans[1:]:
    print((i+1)//2)
    

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

using namespace std;

int main() {

	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;

	string ss = s;
	string tt = t;

	while (ss != tt) {
		ss.erase(ss.begin());
		tt.erase(tt.end()-1);
	}

	cout << s.size()+t.size()-tt.size() << endl;

	return 0;
}

Measured memory_bytes: 3600
ans = 0

def dfs(v, visited, d):
    visited[v] = 1
    if all(visited):
        global ans
        ans += 1
        return
    for node in d[v]:
        if visited[node]:
            continue
        else:
            dfs(node, visited[:], d)

n, m = map(int, input().split())
d = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a = a - 1
    b = b - 1
    d[a].append(b)
    d[b].append(a)
v = 0
visited = [0] * n
dfs(v, visited, d)
print(ans)

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

int main(){
    int N, X;
    cin >> N >> X;
    vector<int> M(N);
    int min_m = 1000;
    for (int i = 0; i < N; i++){
        int m;
        cin >> m;
        M.at(i) = m;
        min_m = min(min_m, m);
    }
    sort(M.begin(), M.end());
    int sum_m = 0;
    for (int i = 0; i < N; i++){
        sum_m += M.at(i);
    }
    cout << N + (X - sum_m) / min_m << endl;
}

Measured memory_bytes: 256
/* HARE KRSNA HARE KRSNA KRSNA KRSNA HARE HARE
    HARE RAMA HARE RAMA RAMA RAMA HARE HARE  */

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

#define nl "\n"
#define ff first
#define ss second
#define pp pop_back
#define pf pop_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define b_s binary_search
#define all(x) x.begin(),x.end()
#define test ll t; cin>>t; while(t--)
#define loop(i,s,n) for(ll i=s;i<n;i++)
#define rloop(i,s,n) for(ll i=s;i>=n;i--)
#define fill(a,value) memset(a,value,sizeof(a))

#define debug2(a)  for(auto x : a)  cout<<x<<" ";  cout<<nl;
#define debug4(a)  for(auto x : a)  cout<<x.ff<<" "<<x.ss<<nl;
#define debug1(a,n) loop(i,0,n)  cout<<a[i]<<" ";  cout<<nl;
#define debug3(a,n,m)  loop(i,0,n){ loop(j,0,m)	cout<<a[i][j]<<" ";	cout<<nl; }

typedef long long ll;
typedef long double ld;

typedef stack<ll> sll;
typedef queue<ll> qll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef pair<ll, pll> ppll;
typedef vector<vector<ll>> vvll;
typedef priority_queue<ll> pqll;

const ll mod = 998244353; //1000000007;
const ld pi =  acos((ld) - 1);	//3.1415926535;

ll num_generator() 		{   return rand() % 1000;	}
void array_generator(ll a[], ll n)
{  loop(i, 0, n)	a[i] = rand() % 100;  }

void brute_force(ll n)
{
	ll cnt;
	loop(i, 1, n + 1)
	{
		cnt = 0;
		loop(x, 1, n + 1)
		{
			loop(y, 1, n + 1)
			{
				loop(z, 1, n + 1)
				{
					if (x * x + y * y + z * z + x * y + y * z + z * x == i)
					{
						cout << x << " " << y << " " << z << " = " << i << nl;
						cnt++;
					}
				}
			}
		}
		cout << cnt << nl;
	}
}

ll bs(ll l, ll h, ll x, ll y, ll n)
{
	while (l <= h)
	{
		ll z = (l + h) / 2;
		ll d = x * x + y * y + z * z + x * y + y * z + z * x;
		if (d == n)	return z;
		else if (d > n)	h = z - 1;
		else l = z + 1;
	}
	return -1;
}

void solve()
{
	ll n;	cin >> n;
	// brute_force(n);
	loop(i, 1, n + 1)
	{
		ll cnt = 0;
		loop(x, 1, 100)
		{
			loop(y, 1, 100)
			{
				// if (i == 6 && x == 1 && y == 1)	cout << bs(1, 100, x, y, i) << nl;
				if (bs(1, 100, x, y, i) >= 1)	cnt++;
			}
		}
		cout << cnt << nl;
	}
}

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// test
	solve();

	return 0;
}

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

using namespace std;

#define pb push_back
const int maxi = 1e6+10;
int a[maxi];
string s;
int n;
vector<int> v[maxi];
int dp[2][maxi];

int main(){
    cin>>s;

    n = s.size();

    int ans = 1;
    int last = 1;

    for (int i=1;i<n;i++)
        if (s[i]!=s[i-1])
        {
            last = 1;
            ans++;
        } else{
           if (last == 2)
        {
            last = 1;
            ans++;
        } else
        {
            if (i<n-1)
            {
                last = 2;
                ans++;
                i++;
            }
        }
    }

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


Measured memory_bytes: 27264
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

int direction[1001][1001];
int dp[1001][1001];

int main(){
  int H,W,n;
  while(~scanf("%d %d %d",&H,&W,&n)){
    if(H == 0 && W == 0) break;

    memset(direction,0,sizeof(direction));
    memset(dp,0,sizeof(dp));

    for(int y=0;y<H;y++){
      for(int x=0;x<W;x++){
	scanf("%d",&direction[y][x]);
      }
    }
    
    dp[0][0] = n-1; //offset
    for(int y=0;y<H;y++){
      for(int x=0;x<W;x++){
	//dir
	//0 v
	//1 ->
	if(y+1 < H) dp[y+1][x] += ((dp[y][x] + (direction[y][x] == 0 ? 1:0)) / 2);
	if(x+1 < W) dp[y][x+1] += ((dp[y][x] + (direction[y][x] == 1 ? 1:0)) / 2);
      }
    }
    
    int x = 0;
    int y = 0;
    while(y < H && x < W){
      if((dp[y][x] + direction[y][x]) % 2 == 0) y++;
      else if((dp[y][x] + direction[y][x]) % 2 == 1) x++;
    }
    printf("%d %d\n",y+1,x+1);
  }
}

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

mini = None
for a in range(1, N):
    b = N - a

    a_sum = sum(int(c) for c in str(a))
    b_sum = sum(int(c) for c in str(b))

    if mini is None or (a_sum + b_sum) < mini:
        mini = a_sum + b_sum

print(mini)


Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	int a1[]=new int[3];
	int b1[]=new int[3];
	for(int i=0;i!=3;i++) {
		a1[i]=scan.nextInt();
		b1[i]=scan.nextInt();
	}
	for(int i=0;i!=4;i++) {
		if(i==3) {
			System.out.println("NO");
			return;
		}
		for(int m=0;m!=2;m++) {
			int basyo=i+1;
			int a=0;
			int b=0;
			int c=0;
			int d=0;
			int mati;
			if(m==0) {
			mati=0;}
			else {
				mati=1;
			}
		for(int j=0;j!=3;j++) {
			if(mati==0) {
				switch(a1[basyo-1]) {
				case 1:a++;break;
				case 2:b++;break;
				case 3:c++;break;
				case 4:d++;break;
				}
			}
			else {
				switch(b1[basyo-1]) {
				case 1:a++;break;
				case 2:b++;break;
				case 3:c++;break;
				case 4:d++;break;
				}	
			}
			if(mati==0) {
				for(int k=0;k!=3;k++) {
					if(b1[basyo-1]==b1[k]) {
						basyo=k+1;
						mati=1;
					}
					if(b1[basyo-1]==a1[k]) {
						basyo=k+1;
						mati=0;
					}
				}	
			}
			else {
				for(int k=0;k!=3;k++) {
					if(a1[basyo-1]==a1[k]) {
						basyo=k+1;
						mati=0;
					}
					if(a1[basyo-1]==b1[k]) {
						basyo=k+1;
						mati=1;
					}
				}
			}
		}

		if(mati==0) {
			switch(a1[basyo-1]) {
			case 1:a++;break;
			case 2:b++;break;
			case 3:c++;break;
			case 4:d++;break;
			}
		}
		else {
			switch(b1[basyo-1]) {
			case 1:a++;break;
			case 2:b++;break;
			case 3:c++;break;
			case 4:d++;break;
			}	
		}
		if(a==1&&b==1&&c==1&&d==1) {
			System.out.println("YES");
		return;
		}
		}
	}
}
}

Measured memory_bytes: 25172
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0 ;i<n ;i++)
	cin>>a[i];
    sort(a,a+n);
    ll c=a[n/2]-a[n/2-1];
  cout<<c;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
 
using namespace std;
 
 
int main(){
 
    int N;
    char buf[3];
    stack<int> S;
    bool FLG = true;
 
    scanf("%d",&N);
 
    for(int i = 0; i < N; i++){
        scanf("%s",buf);
 
        if(buf[0] == 'A'){
            S.push(1);
        }else{
            if(!S.empty()){
                S.pop();
            }else{
                FLG = false;
                break;
            }
        }
    }
 
    if(!S.empty())FLG = false;
 
    if(FLG){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
 
    return 0;
}


Measured memory_bytes: 2700
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>

using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
template<typename T>void max_self(T &a,T b){a=max(a,b);}
template<typename T>void min_self(T &a,T b){a=min(a,b);}
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=3e5+10,oo=0x3f3f3f3f,MOD=998244353;
const long double PI = acos(-1),eps=1.0e-14;
int cnt(int x){
    int ret=0;
    for(int i=1;i*i<=x;i++){
        if(x%i==0){
            ret+=2;
            if(i==x/i)
                ret--;
        }
    }
    return ret;
}
void solve(){
    string s;
    cin>>s;
    int k,idx=-1;
    cin>>k;
    loop(sz(s),i,0){
        if(s[i]!='1'){
            idx=i;
            break;
        }
    }
    if(idx==-1)
        cout<<s.back();
    else if(k<=idx){
        cout<<'1';
    }
    else
        cout<<s[idx];

}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


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


int main() {
  int N ; 
  cin >> N ; 
  vector<int> A(N) ; 
  for(int i = 0 ; i < N ; i++){
    cin >> A.at(i) ; 
  }
  sort(A.begin(),A.end()) ; 
  reverse(A.begin(),A.end()) ; 

  int64_t cnt = 0 ; 
  int t = N-1 ; 
  rep(i , N){
    int lim = 2 ; 
    if(i==0) lim =1 ; 
    rep(j , lim){
      if(t > 0 ){
      	cnt += A.at(i) ; 
      	t-- ; 
      }
    }
  }

  
  cout << cnt << endl ; 
}

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

int main(void){
    int n,x,ans=1;
    scanf("%d%d",&n,&x);
    int l[n];
    for (int i=0; i<n; i++){
        scanf("%d",&l[i]);
    }
    int d=0;
    for (int i=0; i<n; i++){
        d=d+l[i];
        if (d<=x){
            ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pii pair<int,int>
#define pb push_back
#define INF INT_MAX
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)
#define iso ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
int n;
vector<vector<int>>v;
int dp[3][100005];
int solve(int p,int cur)
{
    if(cur==n)return 0;
     if(dp[p][cur]>0)return dp[p][cur];
    int ans=0;
    for(int i=0;i<3;i++)
    {
         if(i!=p)
         ans=max(v[cur][i]+solve(i,cur+1),ans);
    }
    dp[p][cur]=ans;
    return dp[p][cur];
}
int main()
{
    iso;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int a,b,c;cin>>a>>b>>c;
            v.push_back({a,b,c});

    }
    dp[0][0]=v[0][0];
    dp[1][0]=v[0][1];
    dp[2][0]=v[0][2];
    cout<<max(dp[0][0]+solve(0,1),max(dp[1][0]+solve(1,1),dp[2][0]+solve(2,1)));
}


Measured memory_bytes: 15408
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

Pll p[5001];
ll d[5001][5001];
int main() {
	int n;
	scanf("%d",&n);
	fup(i,0,n,1)fup(j,1,n,1)d[i][j]=INF;
	fup(i,1,n,1)scanf("%lld%lld",&p[i].X,&p[i].Y);
	sort(p+1,p+n+1,[&](Pll p1,Pll p2){return p1.X+p1.Y<p2.X+p2.Y;});
	fup(i,1,n,1)
	{
		fup(j,1,i,1)
		{
			d[i][j]=min(d[i][j],d[i-1][j]);
			if(d[i-1][j-1]<=p[i].X)d[i][j]=min(d[i][j],d[i-1][j-1]+p[i].Y);
		}
	}
	int ans=0;
	fup(j,1,n,1)
	{
		if(d[n][j]!=INF)ans=max(ans,j);
	}
	printf("%d",ans);
}

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

using namespace std;

int a[211111];
int main()
{
	int n, h;
	cin >> n >> h;
	for (int i = 0; i < n; i++) {
		scanf("%d%d", a + i * 2, a + i * 2 + 1);
		a[i * 2] *= 2;
		a[i * 2 + 1] = a[i * 2 + 1] * 2 + 1;
	}
	sort(a, a + n * 2, greater<int>());
	auto l = 0ll;
	int m = 0;
	for (; m < n * 2; m++) {
		if (a[m] % 2) {
			l += a[m] / 2;
			if (l >= h) break;
			continue;
		}
		m += (h - l - 1) / (a[m] / 2);
		break;
	}
	cout << m + 1 << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;

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

  int ans = 0;
  for (int i = 1; i < n - 1; i++) {
    if (s[i-1] == 'A' && s[i] == 'B' && s[i+1] == 'C') {
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const ll INF=1<<30;

int main(){
	ll n;cin>>n;
	vector<ll> x(n);
	vector<ll> y(n);
	for(ll i = 0; i < n; i++) {
		cin>>x[i]>>y[i];
	}
	ll res = 0;
	for(ll i = 0; i < n; i++) {
		for(ll j = 0; j < n; j++) {
			ll ans = 0;
			if (i != j){
				ll dx = x[i] - x[j];
				ll dy = y[i] - y[j];
				for(ll k = 0; k < n; k++) {
					for(ll l = 0; l < n; l++) {
						if (k != l && x[k] - x[l] == dx && y[k] - y[l] == dy){
								ans ++;
						}
					}
				}
				res = max(res,ans);
			}
			

		}
	}
	cout << n - res << endl;
	return 0;
}

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

typedef long long ll;
int main(){
  int N;
  cin >> N;
  vector<int> v(N);
  cin >> v.at(0);
  cin >> v.at(1);
  int ans = 0;
  for(int i = 2; i < N; i++){
    int tmp;
    cin >> v.at(i);
    if( ( v.at(i-1) > v.at(i-2) && v.at(i-1) <= v.at(i) ) || ( v.at(i-1) >  v.at(i) && v.at(i-1) <= v.at(i-2) )){
      ans++;
    }
  }
  cout << ans << endl;
}


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


int main(){

 int n,x,free=0;
  cin>>n;
 set<int>s;

 for(int i=0;i<n;i++)
 {
   cin>>x;

   if(x >=3200) free++;
   else if(x<3200){
    for(int j=0;j<8;j++){
        if(400*j <= x && x<400*(j+1) )
         s.insert(j); }
   }

 }


  if(s.size() == 0 && free >= 1)
   cout<<"1"<<" ";
  else cout<<s.size()<<" ";

   cout<<s.size()+free<<endl;


return 0;
}











Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int i, n;
    int a[100] = {0};

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    for (i = n-1; i >= 0; i--) {
        printf("%d", a[i]);
        if (i != 0) {
            printf(" ");
        }
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<int, int> pii;
const int MAXN = 55;
int nums[MAXN];
int pos, neg, n;
vector<pii> ret;
void solve() {
    if (nums[pos] <= 0 || nums[pos] < -nums[neg]) {
        ret.push_back({neg, n});
        for (int i = n-1; i >= 1; i--) {
            ret.push_back({neg, i});
            ret.push_back({i+1, i});
        }
    }
    else {
        ret.push_back({pos, 1});
        for (int i = 2; i <= n; i++) {
            ret.push_back({pos, i});
            ret.push_back({i-1, i});
        }
    }
}

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &nums[i]);
        if (nums[i] >= nums[pos]) pos = i;
        if (nums[i] <= nums[neg]) neg = i;
    }
    solve();
    cout << ret.size() << endl;
    for (auto item : ret) {
        cout << item.first << ' ' << item.second << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n, k; cin>>n>>k;
	ll ret=0;
	if(k==0){
		cout<<n*n<<'\n';
		return 0;
	}
	for(ll b=k+1;b<=n;b++){
		ret+= (n/b) * (b-k);
		ret+= max(0LL, n%b + 1 - k);
	}
	cout<<ret<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll int //long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

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

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    ll a, b;
    cin >> a >> b;
    ll ans = 0 ;
    for(ll k = a; k <= b; k++){
        ll f = 0;
        string s = to_string(k);
        if(s[0] == s[4] && s[1] == s[3]) ans++;
    }
    cout << ans;
}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#define mod 1000000007
typedef long long ll;

int main(void) {
  ll i, j, k, n, ans = 1, now = 0;
  scanf("%lld", &n);
  ll a[n], b[n];
  for(i = 0; i < n; ++i) scanf("%lld", &a[i]);
  for(i = 0; i < n; ++i) scanf("%lld", &b[i]);
  std::sort(a, a + n), std::sort(b, b + n);
  for(i = 0; i < n; ++i) {
    if(a[i] < b[i]) {
      while(a[now] < b[i] && now < n) ++now;
      ans *= now - i;
    } else {
      while(b[now] < a[i] && now < n) ++now;
      ans *= now - i;
    }
    ans %= mod;
  }
  printf("%lld", ans);
  return 0;
}

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

using namespace std;

#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

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

    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int malta = max(A, B);
    malta = max(malta, C);
    int res = A + B + C - malta;
    int latte = malta;
    rep(i, K) {
        latte *= 2;
    }
    cout << res + latte << endl;
    return 0;
}

Measured memory_bytes: 256