akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)( 998244353))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return


ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }


/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////



int main(){
    ll n,k;
    cin >> n >> k;
    ll a[n];
    rep(i,0,n){
	cin >> a[i];
	a[i]--;
    }
    
    int p = 0;
    bool f[n] = {};

    while(k > 0){
	if(f[p] == 1){
	    break;
	}
	
	f[p] = 1;
	p = a[p];
	k--;
    }

    if(k <= 0){
	P(p+1);
	ret 0;
    }
    bool f2[n] = {};
    ll cnt = 0;
    while(1){
	f2[p] = 1;
	p = a[p];
	cnt++;
	if(f2[p] == 1){
	    break;
	}
    }
    //  P(k);
    //P(cnt);

    k %= cnt;
    rep(i,0,k){
	p = a[p];
    }
    P(p+1);
    return  0;
}


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

#define INF 1e18
#define int long long

signed main() {
    string s, t; cin >> s >> t;
    vector<string> candidate;

    for(int i = 0; i < s.size() - t.size() + 1; i++) {
        string u = s;
        for(int j = i; j < i + t.size(); j++) {
            u[j] = t[j - i];
        }
        bool flag = true;
        for(int j = 0; j < s.size(); j++) {
            if(s[j] != '?' && s[j] != u[j]) flag = false;
        }
        if(flag) {
            for(int k = 0; k < u.size(); k++) {
                if(u[k] == '?') u[k] = 'a';
            }
            candidate.push_back(u);
        }
    }

    if(candidate.size() == 0) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

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

    cout << candidate[0] << endl;
    return 0;
}


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

#define infi            5e9
#define infl            5e18
#define MX              100005
#define pi              2*acos(0.0)
#define ll              long long int
#define rr              read()
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define ms(a,b)         memset(a, b, sizeof(a))
#define loop(i,n)       for(register int i=0;i<n;i++)
#define pool(i,n)       for(register int i=n-1;i>=0;i--)
#define loop1(i,n)      for(register int i=1;i<=n;i++)
#define pool1(i,n)      for(register int i=n;i>0;i--)

using namespace std;

inline ll read(){char c=getchar();ll num,sign=1;for(;c<'0'||c>'9';c=getchar())if(c=='-')sign=-1;for(num=0;c>='0'&&c<='9';){c-='0';num=num*10+c;c=getchar();}return num*sign;}
inline ll pw(ll b, ll p){ll ans=1;while(p>0){if(p&1)ans*=b;p>>=1;b*=b;}return ans;}
// inline bool isPrime(ll n){if(n==1)return false;if(n==2)return true;if(!(n%2))return false;for(ll i=3;i<=sqrt(n);i+=2)if(!(n%i))return false;return true;}
// inline ll gcd(ll a, ll b){if(a==0)return b;return gcd(b%a,a);}

// //*************************************  Bitmask Opereations  **********************************//
// int Set(int N,int pos){return N=N | (1<<pos);}
// int reset(int N,int pos){return N= N & ~(1<<pos);}
// bool check(int N,int pos){return (bool)(N & (1<<pos));}
// //********************************************************************************************//


int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    //#ifdef rid.dle
    //freopen("in.txt", "r", stdin);//#endif
    
    string str;
    cin >> str;

    int n=str.length();

    int cur=-1,ans=-1;
    loop(i,n){
        if(str[i]=='A' && cur==-1)cur=1;
        else if(cur!=-1)cur++;
        if(str[i]=='Z' && cur!=-1)ans=cur;
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  
  int n = 1;
  for(int i=0; i<N; i++){
    if((2 * n - n)< K)
      n *= 2;
    else
      n += K;
  }
  
  cout << n << endl;
}


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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;
// 入力
int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;


int main() {

    // int N;
    // cin >> N;
    // vector<int> a(N);
    // REP(i, N){
    //     cin >> a[i];
    // }
    ll a, b, c;
    cin >> a >> b >> c;
    ll tmp = (c-a-b) * (c-a-b);
    if(4 * a * b < tmp && (c-a-b) > 0)cout << "Yes";
    else cout << "No";




}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


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

int main() {
    int N, M;
    cin >> N;
    vector<string> s(N);
    for(int i = 0; i < N; i++) {
        cin >> s.at(i);
    }
    cin >> M;
    vector<string> t(M);
    for(int i = 0; i < M; i++) {
        cin >> t.at(i);
    }

    int max_cnt = 0;
    vector<string> checked;
L1:
    for(int i = 0; i < N; i++) {
        string str = s.at(i);
        bool need_check = true;
        for(int j = 0; j < checked.size(); j++) {
            if(checked.at(j) == str) {
                need_check = false;
                break;
            }
        }
        if(!need_check) {
            continue;
        }
        int cnt = 0;
        for(int j = i; j < N; j++) {
            if(s.at(j) == str) {
                cnt++;
            }
        }
        for(int j = 0; j < t.size(); j++) {
            if(t.at(j) == str) {
                cnt--;
            }
        }
        max_cnt = max(max_cnt, cnt);
    }
    if(max_cnt < 0) {
        cout << "0" << endl;
    } else {
        cout << max_cnt << endl;
    }
}

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

using namespace std;

int binarysearch(vector<int> S, int key){
    int left=0;
    int right=S.size();
    int mid;
    while( left<right ){
        mid = (left+right) / 2;
        if( key == S[mid]){
            return 1;
        }else if( key > S[mid]){
            left = mid+1;
        }else if( key < S[mid]){
            right = mid;
        }
    }
    return 0;
}

int main()
{
    int n;
    cin >> n;
    vector<int> S(n,0);
    for( auto&& x: S){
        cin >> x;
    }

    int q;
    cin >> q;
    vector<int> T(q,0);
    for( auto&& x: T){
        cin >> x;
    }

    int C = 0;
    for(int i=0; i<q; ++i){
        if( binarysearch(S,T[i])){
            ++C;
        }
    }

    cout << C << endl;

}


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

using namespace std;

int main(void) {
    string s;
    cin >> s;
    int n = s.size();

    vector<int> cnt(2,0);
    for (int i=0; i<n; i++) {
        cnt[s[i]%2]+=2;
    }

    cout << min(cnt[0],cnt[1]) << endl;
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using Pi_i = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
using VLL = vector<ll>;
using VS = vector<string>;
using VC = vector<char>;
using VB = vector<bool>;

const int MOD = 1000000007;
const int INF = 1000000000;

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



void printVector(VI &a){
    int n = SZ(a);
    REP(i, n){
        if(i) cout << " ";
        cout << a[i];
    }
    cout << "\n";
}

void insertionSort(VI &a){
    int n = SZ(a);
    FOR(i, 1, n){
        int instnum = a[i], j;
        for(j = i - 1; j >= 0 && a[j] > instnum; --j)
            a[j+1] = a[j];
        a[j+1] = instnum;
        printVector(a);
    }
}

int main(){
    int n; cin >> n;
    VI a(n);
    REP(i, n) cin >> a[i];
    printVector(a);
    insertionSort(a);
    return 0;
}



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

void show(int nums[], int n) {
    for (int k = 0; k < n; ++k) {
        if( k == n - 1) {
            cout << nums[k];
        } else {
            cout << nums[k] << " ";
        }
    }
    cout << endl;
}

void insert_sort(int nums[], int n) {
    for (int i = 1; i < n; ++i) {
        int v = nums[i];
        int j = i - 1;
        while (j >= 0 && nums[j] > v) {
            nums[j + 1] = nums[j];
            j--;
        }
        nums[j + 1] = v;
        show(nums, n);
    }
}

int main()
{
    int n;
    cin >> n;
    int nums[n];
    for (int i = 0; i < n; ++i) {
        cin >> nums[i];
    }
    show(nums, n);
    insert_sort(nums, n);
    return 0;
}

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

using namespace std;

typedef long long ll;

const int MAX = 3e5+1;
const ll MOD = 998244353;

ll fac[MAX];

void init() {
    fac[0] = 1;
    for (int i=1; i<MAX; ++i) {
        fac[i] = fac[i-1]*i%MOD;
    }
}

ll rep_pow(int n, int p) { // n^p
    if (p==0) {
        return 1;
    }
    if (p%2==0) {
        ll t=rep_pow(n, p/2);
        return t*t%MOD;
    } else {
        return n*rep_pow(n, p-1)%MOD;
    }
}

ll com(int n, int k) {
    if (n<k || n<0 || k<0) {
        return 0;
    }
    return fac[n]*rep_pow(fac[k], MOD-2)%MOD*rep_pow(fac[n-k], MOD-2)%MOD;
}

int main() {
    init();
    ll n, a, b, k; cin >> n >> a >> b >> k;
    ll ans=0;
    for (ll i=0; a*i<=k; ++i) {
        if ((k-a*i)%b!=0) {
            continue;
        }
        ll l=(k-a*i)/b;
        ans+=com(n, i)*com(n, l);
        ans%=MOD;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 2560
#include<cstdio>
#define MAX 20

int A[MAX];

bool solve(int i, int m, int n) {
  if (m == 0) return true;
  else if (n <= i) return false;

  return solve(i + 1, m, n) || solve(i + 1, m - A[i], n);
}

int main() {
  int n;
  scanf("%d", &n);

  for (int i = 0; i < n; i++) scanf("%d", &A[i]);

  int q, m;
  scanf("%d", &q);

  for (int i = 0; i < q; i++) {
    scanf("%d", &m);
    if (solve(0, m, n)) printf("yes");
    else printf("no");
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2760
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
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;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
  int n;
  cin>>n;
  V<ll> a(n),b(n);
  for(int i=0;i<n;i++)cin>>a[i]>>b[i];
    sort(all(a));sort(all(b));
  if(n%2==1) cout<<abs(b[n/2]-a[n/2])+1<<"\n";
  else cout<<abs(b[n/2]+b[n/2-1]-(a[n/2]+a[n/2-1]))+1<<"\n";
}


Measured memory_bytes: 6352
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    from collections import Counter
    N = int(input())
    A = list(map(int, input().split()))
    D = Counter(A)
    S = sum(A)
    Q = int(input())
    B = [0] * Q
    C = [0] * Q
    for i in range(Q):
        b, c = map(int, input().split())
        x = D[b]
        y = D[c]
        temp = -x * b + x * c
        print(S+temp)
        S += temp
        D[b] = 0
        D[c] += x  

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

Measured memory_bytes: 90316
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE LambdaCase            #-}
{-# LANGUAGE MagicHash             #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiWayIf            #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}
{-# LANGUAGE ViewPatterns          #-}

import           Control.Applicative
import           Control.Exception
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString             as B
import qualified Data.ByteString.Builder     as B
import qualified Data.ByteString.Char8       as C
import qualified Data.ByteString.Internal    as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import qualified Data.Foldable               as F
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import qualified Data.List                   as L
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           GHC.Exts
import qualified System.IO                   as IO
import           Unsafe.Coerce

main :: IO ()
main = do
    !n <- readLn :: IO Int
    print $ length [x|x<-[1..n],odd.length$show x]


-------------------------------------------------------------------------------
type Parser a = C.ByteString -> Maybe (a, C.ByteString)

parseInt :: Parser Int
parseInt = C.readInt . C.dropWhile isSpace

parseInt2 :: Parser (Int, Int)
parseInt2 = runStateT $
    (,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt3 :: Parser (Int, Int, Int)
parseInt3 = runStateT $
    (,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt4 :: Parser (Int, Int, Int, Int)
parseInt4 = runStateT $
    (,,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

Measured memory_bytes: 892
#include <stdio.h>
      
int main(void){
 
    int i;
    char bt[4];
    int cnt[4] = {};
 
    while( scanf("%d,%s",&i, bt) != EOF ) {
        if( bt[1] == 'B' ) {
            cnt[3] ++;
        } else if( bt[0] == 'A' ) {
            cnt[0] ++;
        } else if( bt[0] == 'B' ) {
            cnt[1] ++;
        } else {
            cnt[2] ++;
        }
         
    }
    printf("%d\n%d\n%d\n%d\n", cnt[0], cnt[1], cnt[3], cnt[2] );
    return 0;
}

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

int main(){
    int count = 0;
    string s;
    cin >> s;
    int n = s.size();
    for(int i=0;i<n/2;i++){
        if(s.at(i) != s.at(n-i-1)) count++;
    } 
    cout << count << endl;
    return 0;  
}

Measured memory_bytes: 256
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Function
import Data.List
import Data.Maybe
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt = fst . fromJust . BS.readInt

readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine

getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine

calc :: [[Int]] -> Int -> String
calc [] _ = "Yes"
calc (ab : abs) n
  | n' <= b = calc abs n'
  | otherwise = "No"
  where
    [a, b] = ab
    n' = n + a

main = do
  n <- getInt
  abs <- getIntNList n
  let abs' = sortBy (compare `on` last) abs
  putStrLn $ calc abs' 0


Measured memory_bytes: 99856
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int times = 1;
    int ans = 0;
    while(true) {
        int k = 9;
        RREP(j, 9, 1) {
            if (N - j * times >= 0) {
                ans += j;
                N -= j * times;
                break;
            }
            k = j;
        }
        if (k != 9) break;
        times *= 10;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def test1(s):
    stack = deque()
    out = ''
    tmp = ''

    for i in range(len(s)):
        if s[i] == ')' and len(stack) == 1 and stack[-1] == '(':
            out += '(' + tmp + ')'
            tmp = ''
            stack.pop()
        elif s[i] == ')' and len(stack) > 0 and stack[-1] == '(':
            tmp = '(' + tmp + ')'
            stack.pop()
        elif s[i] == ')' and len(stack) == 0:
            tmp = '(' + tmp + ')'
        else:
            stack.append('(')
            out += tmp
            tmp = ''

    for i in range(len(tmp)//2):
        out = '(' + out + ')'

    tmp = ''
    while len(stack) > 0:
        tmp = '(' + tmp + ')'
        stack.pop()

    out += tmp

    return out


def test2(s):
    stack = deque()
    out = ''
    tmp = ''

    for i in range(len(s)):
        if s[i] == ')' and len(stack) > 0 and stack[-1] == '(':
            tmp = '(' + tmp + ')'
            stack.pop()
        elif s[i] == ')' and len(stack) == 0:
            tmp = '(' + tmp + ')'
        else:
            stack.append('(')
            out += tmp
            tmp = ''
        # print('out', out)
        # print(tmp)

    out += tmp

    tmp = ''
    while len(stack) > 0:
        tmp = '(' + tmp + ')'
        stack.pop()

    out += tmp

    return out


def main():
    N = I()
    s = S()
    c = 0
    stack = deque()

    for i in range(len(s)):
        if s[i] == '(':
            stack.append('(')
            c += 1
        elif len(stack) > 0:
            stack.pop()
            c -= 1
        else:
            c += 1

    # print(c, stack)
    print('(' * (c - len(stack)) + s + ')' * len(stack))

    # print('out1', out1)
    # print('out2', out2)

    # print(sorted([out1, out2])[0])


if __name__ == '__main__':
    main()


Measured memory_bytes: 38640
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string wheather[3] = { "Sunny","Cloudy","Rainy" };
	string s;
	cin >> s;
	for (int i = 0; i < 3; i++)
	{
		if (s == wheather[i])
		{
			if (i == 2)
				cout << wheather[0] << endl;
			else
				cout << wheather[i + 1] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define N 100000
using namespace std;
int n;
int a1[N+5],a2[N+5];
long long s1,s2;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a1[i]);
	for(int i=1;i<=n;i++)
		scanf("%d",&a2[i]);
	for(int i=1;i<=n;i++)
	{
		if(a1[i]<a2[i])
		{
			int x=a2[i]-a1[i];
			if(x%2)
				x++,s2++;
			s1+=x/2;
		}
		else
			s2+=a1[i]-a2[i];
	}
	if(s2<=s1)
		printf("Yes\n");
	else
		printf("No\n");
}

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

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

    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        int tmp = C;
        for (int j = 0; j < M; j++)
        {
            cin >> A;
            tmp += B[j] * A;
        }
        if (tmp > 0)
        {
            ans++;
        }
    }
    cout << ans << endl;
}


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

using std::cin;
using std::cout;
using std::endl;

int main(void) {
	int w,h;
	cin >> w;
	cin >> h;

	while (w!=0||h!=0) {
		int count = 0;
		std::stack<int> st_x,st_y;
		int xn,yn;
		int c;
		bool all = false;
		std::vector< std::vector<bool> > island(h+2, std::vector<bool>(w+2));
		for (int i = 0; i < h+2; i++) {
			for (int j = 0; j < w+2; j++) {
				if (i==0||i==h+1||j==0||j==w+1) {
					island[i][j] = false;
				} else {
					cin >> c;
					if (c==1) {
						island[i][j] = true;
					} else {
						island[i][j] = false;
					}
				}
			}
		}

		while (!all) {
			all = true;
			for (int i = 1; i < h+1; i++) {
				for (int j = 1; j < w+1; j++) {
					if (island[i][j]) {
						xn = i;
						yn = j;
						all = false;
					}
				}
			}
			if (!all) {
				st_x.push(xn);
				st_y.push(yn);
				if (island[xn][yn]) {
					island[xn][yn] = false;
					count++;

					while (!st_x.empty()) {
						xn = st_x.top();
						yn = st_y.top();
						st_x.pop();
						st_y.pop();
						if (island[xn+1][yn]) {
							st_x.push(xn+1);
							st_y.push(yn);
							island[xn+1][yn] = false;
						}
						if (island[xn-1][yn]) {
							st_x.push(xn-1);
							st_y.push(yn);
							island[xn-1][yn] = false;
						}
						if (island[xn+1][yn+1]) {
							st_x.push(xn+1);
							st_y.push(yn+1);
							island[xn+1][yn+1] = false;
						}
						if (island[xn+1][yn-1]) {
							st_x.push(xn+1);
							st_y.push(yn-1);
							island[xn+1][yn-1] = false;
						}
						if (island[xn-1][yn+1]) {
							st_x.push(xn-1);
							st_y.push(yn+1);
							island[xn-1][yn+1] = false;
						}
						if (island[xn-1][yn-1]) {
							st_x.push(xn-1);
							st_y.push(yn-1);
							island[xn-1][yn-1] = false;
						}
						if (island[xn][yn+1]) {
							st_x.push(xn);
							st_y.push(yn+1);
							island[xn][yn+1] = false;
						}
						if (island[xn][yn-1]) {
							st_x.push(xn);
							st_y.push(yn-1);
							island[xn][yn-1] = false;
						}
					}
				}
			}
		}
		cout << count << endl;

		cin >> w;
		cin >> h;
	}	
		return 0;
}

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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << endl;}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
inline void yesno(bool ok, string yes = "Yes", string no = "No") {cout << (ok?yes:no) << endl;}


signed main() {
    //my-code
    ll n; cin >> n;
    string s = "";
    while(n!=0) {
        n--;
        char d = n % 26;
        n /= 26;
        s = (char)('a' + d) + s;
    }
    print(s);

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 3652
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

int a,b,c,d[100005] = {},n,m;
string s,t;

int main(){

    cin >> n >> a;

    P(n%a);
    return  0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
H = [int(i) for i in input().split()]
good = [1] * N

for m in range(M):
    A, B = map(int, input().split())
    if H[A - 1] <= H[B - 1]:
        good[A - 1] = 0
    if H[B - 1] <= H[A - 1]:
        good[B - 1] = 0

print(sum(good))


Measured memory_bytes: 20108
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
#define asn ans
bool dbg = false;


void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    for (auto& c : s) {
        if (c == '7') {
            Yes();
            return 0;
        }
    }
    No();


    solve();
    return 0;
}


Measured memory_bytes: 3656
def examC():
    N, K = LI()
    A = LI()
    d = defaultdict(int)
    for i in A:
        d[i] +=1
    cur = 0
    que = []
    heapq.heapify(que)
    for i in d.values():
        heappush(que,i)
    for i in range(len(d)-K):
        cur += heappop(que)
    print(cur)

import sys,copy,bisect,itertools,heapq
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()


Measured memory_bytes: 34364
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n; cin >> n;
  int w[n],u[n],l[n];
  cin>>w[0];
  u[0]=w[0];
  for(int i=1;i<n;i++){
    cin>>w[i];
    u[i]=u[i-1]+w[i];
  }
  l[n-1]=w[n-1];
  for(int i=n-2;i>=0;i--){
  	l[i]=l[i+1]+w[i];
  }
  int ans=abs(u[0]-l[1]);
  for(int i=1;i<n-1;i++)ans=min(ans,abs(u[i]-l[i+1]));
  cout << ans;
  return 0;
}

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

class Program
{
    static void Main(string[] args) {
        int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int h = s[0];
        int w = s[1];
        List<string> a = new List<string>();
        for (int i = 0; i < h; i ++) {
            string str = Console.ReadLine();
            if (str.Contains("#")) a.Add(str);
        }
        int l = a.Count();
        for (int i = 0; i < a[0].Length; i ++) {
            for (int j = 0; j < l; j ++) {
                if (a[j][i]=='#') break;
                if (j == l-1) {
                    for (int k = 0; k < l; k ++) {
                        a[k] = a[k].Remove(i,1);
                    }
                    i --;
                }
            }
        }
        foreach(string i in a) Console.WriteLine(i);
    }
}

Measured memory_bytes: 11348
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    int sN = (int) Math.sqrt(N);
    long ans = Long.MAX_VALUE;
    for (int di = 1; di <= sN; di++) {
      long dj = N / di;
      if (di * dj == N) {
        ans = Math.min(ans, di - 1 + dj - 1);
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


    class Program
    {
        static void Main(string[] args)
        {
            int K = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            
            if(S.Length <= K){
                Console.WriteLine(S);
            }
            else{
                string line = S.Substring(0,K);
            Console.WriteLine(line + "...");
            }
        }
    }

Measured memory_bytes: 17624
import itertools
N, K = map(int, input().split())
snack = [list(map(int, input().split())) for i in range(2*K)]
answer = [int(i) for i in range(1, N+1)]

for i in snack[1::2]:
  for j in i:
    try:
      answer.remove(j)
    except:
      continue
print(len(answer))

Measured memory_bytes: 9204
import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        List<Integer> list = new ArrayList<>();
        Map<Integer, Integer> map = new HashMap<>();
        for(int i = 1;i <= n;i++){
            int num = sc.nextInt();
            map.put(num, i);
            list.add(num);
        }

        Collections.sort(list);
        StringBuilder sb = new StringBuilder();
        for(int i = 0;i < n;i++){
            sb.append(map.get(list.get(i)));
            sb.append(" ");
        }

        sb.deleteCharAt(sb.length() -1);
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 73280
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define MOD 1000000007

int main() {
    int X, Y, Z, K; cin >> X >> Y >> Z >> K;
    vll A(1000, 0), B(1000, 0), C(1000, 0);
    rep(i, X) cin >> A[i];
    rep(j, Y) cin >> B[j];
    rep(k, Z) cin >> C[k];
    vll D(1e6 + 1, 0);
    rep(i, X) {
        rep(j, Y) {
            D[i * Y + j] = A[i] + B[j];
        }
    }
    sort(all(D), greater<ll>());
    vll E(9e6 + 1, 0);
    int a = min(X * Y, K), b = min(Z, K);
    rep(i, a) {
        rep(j, b) {
            E[i * b + j] = D[i] + C[j];
        }
    }
    sort(all(E), greater<ll>());
    rep(i, K) cout << E[i] << endl;

}



Measured memory_bytes: 78592
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k=int(input())
for i in range(32):
	if i+1==k:
		print(a[i])
		exit()

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

static const int MAX = 2005;
static const int INF = 1001001001;

vector<int> G[MAX];

// 幅優先探索を使って解けないか？
// bfsはO(N)だから全ての頂点を始点にしてbfsしても十分間に合う
int main(){
    int n, x, y; cin >> n >> x >> y;
    x--; y--;
    G[y].push_back(x), G[x].push_back(y);
    for(int i = 0; i < n - 1; ++i) G[i].push_back(i + 1), G[i + 1].push_back(i);
    
    queue<int> q;
    vector<int> ans(n,0);
    rep(sv,n){
        vector<int> d(n,INF);
        d[sv] = 0;
        q.push(sv);
        while( !q.empty() ) {
            int u = q.front(); q.pop();
            for(int v : G[u]){
                if (d[v] != INF) continue;
                d[v] = d[u] + 1;
                q.push(v);
            }
        }
        rep(i,n) ans[d[i]]++;
    }
    for(int i = 1; i < n; i++) cout << ans[i] / 2 << endl;
    return 0;
}

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

int main() {
    int s;
    cin >> s;
    vector<int> ans;
    ans.push_back(s);
    rep(i,1e6) {
        if (s % 2 == 0) s /= 2;
        else s = 3*s+1;
        rep(j,ans.size()) {
            if (s == ans[j]) {
                cout << i+2 << endl;
                return 0;
            }
        }
        ans.push_back(s);
    }
}

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

using namespace std;

int main() {
	long int n;
	cin >> n;
	long int i;
	vector<long int>b(n);
	long int s;

	for (i = 0; i < n - 1; i++) {
		cin >> s;
		b[s - 1]++;
	}

	for (i = 0; i < n; i++) {
		cout << b[i] << endl;
	}

	return 0;
}

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

int main() {
    int n;
    cin >> n;
    map<ll, int, greater<ll>> m;
    rep(i, n) {
        ll a;
        cin >> a;
        m[a]++;
    }

    ll ans = 0;
    int cnt = 0;
    for (auto c : m) {
        if (c.second >= 4) {
            cnt == 0 ? ans = c.first* c.first : ans *= c.first;
            break;
        } else if (c.second >= 2) {
            if (cnt == 0)
                ans = c.first, cnt++;
            else if (cnt == 1) {
                ans *= c.first;
                break;
            }
        }
    }

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


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
int main(){
string A,B,C;
  cin>>A>>B>>C;
  int N=A.size();
  int M=B.size();
  if(A.at(N-1)!=B.at(0))
    cout<<"NO"<<endl;
  else{
  if(B.at(M-1)!=C.at(0))
    cout<<"NO"<<endl;
    else
      cout<<"YES"<<endl;
  }
   return 0;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b,k; cin>>a>>b>>k;
	set<int> st;
	for (int i=0; i<k; i++) {
		int x=a+i;
		if(x<=b)
			st.insert(x);
	}
	for (int i=0; i<k; i++) {
		int x=b-i;
		if(x>=a)
			st.insert(x);
	}
	for (auto it : st)
		cout << it << endl;
	return 0;
}


Measured memory_bytes: 256
(defun make-acceptor (string)
  (let ((num 0)
        (pos 0))
    (labels ((acc (c)
               (if (null c)
                   num
                   (cond ((and (= pos (1- (length string))) (char= c (char string pos)))
                          (incf num)
                          (setf pos 0))
                         ((char= c (char string pos))
                          (incf pos))
                         ((/= pos 0)
                          (setf pos 0)
                          (if pos(acc c)))))))
      #'acc)))

(let ((n (read))
      (x (make-acceptor "ABC")))
  (loop :for i :from 1 :to n
        :for c := (read-char)
        :do (funcall x c))
  (format t "~A~%"  (funcall x nil)))


Measured memory_bytes: 24440
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

struct edge{int to,cap,rev;};

int MAX_V=120;
int tmp1,tmp2;

vector<vector<edge>> g(MAX_V);//グラフの隣接リスト表現
vin level(MAX_V);//distance form s
vin iter(MAX_V);//どこまで調べたか

void add_edge(int from,int to,int cap){
    tmp1=g[to].size();tmp2=g[from].size();
    g[from].push_back((edge){to,cap,tmp1});//g[to]のg[to].size()番目にfromが入っている
    g[to].push_back((edge){from,0,tmp2});//g[from]のg[from].size()-1番目にtoが入っている
}

void bfs(int s){
    fill(all(level),-1);
    queue<int> q;
    q.push(s);
    level[s]=0;
    while(q.size()){
        int v=q.front();q.pop();
        for(auto& e:g[v]){
            if(e.cap>0&&level[e.to]<0){
                level[e.to]=level[v]+1;
                q.push(e.to);
            }
        }
    }
}

//増加パスをdfsで探す
//v:今見てる頂点 t:終点 f:流量
int dfs(int v,int t,int f){
    if(v==t)return f;
    for(int& i=iter[v];i<(int)g[v].size();i++){
        edge& e=g[v][i];
        if(e.cap>0&&level[v]<level[e.to]){
            int d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                g[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}

//sからtへの最大流を求める
int max_flow(int s,int t){
    int flow=0;
    int f;
    for(;;){
        bfs(s);
        if(level[t]<0)return flow;
        fill(all(iter),0);
        while((f=dfs(s,t,inf))>0)flow+=f;
    }
}

int main(){
    int V,E;cin>>V>>E;
    int u,v,c;
    rep(i,E){
        cin>>u>>v>>c;
        add_edge(u,v,c);
    }
    cout<<max_flow(0,V-1)<<endl;
}


Measured memory_bytes: 3208
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

N = INT()

ans = 0

for i in range(1, N+1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    else:
        ans += i

print(ans)


Measured memory_bytes: 64452