akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

VI color;
void dfs(const vector<VP> &G, const int v){
    for (PII p : G[v]){
        if (color[p.first] != -1) continue;
        else if (p.second % 2 == 1) color[p.first] = 1 - color[v];
        else color[p.first] = color[v];

        dfs(G, p.first);
    }
}

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

int N; cin >> N;
vector<VP> G(N+1); // 重み付きグラフ
rep(i, 0, N-1){
    int u, v, w; 
    cin >> u >> v >> w;
    G[u].push_back(make_pair(v, w));
    G[v].push_back(make_pair(u, w));
}

color.assign(N+1, -1); // 未訪問-1
color[1] = 0;
dfs(G, 1);
rep(i, 1, N+1) cout << color[i] << "\n";

}

// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，次にDP
// 制限を見る
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

    int m,d,ans=0;
    cin>>m>>d;
    for(int month=4;month<=m;month++)
    {
        int cnt = 0;
        for(int div=2;div<=9;div++)
        {
            if( month%div == 0 )
            {
                int a = div, b = month/div;
                if( b < 2 || b > 9 ) continue;
                int x = 10*a + b;
                if( x <= d ) cnt++;
            }
        }
        // cout<<month<<" "<<cnt,nl;
        ans += cnt;
    }
    cout<<ans,nl;
    return 0;
}

Measured memory_bytes: 256
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def cnt_digit(n):
    return 0 if n ==0 else (n&1) + cnt_digit(n//2)

def solve():
    n = f()[0]
    g = {}
    start = ['M', 'A', 'R', 'C', 'H']
    for i in start:
        g[i] = 0

    for i in range(n):
        s = input()
        if s[0] in start:
            g[s[0]] += 1


    ans  = 0
    for i in range(2**5):
        if cnt_digit(i) == 3:
            cur_ans = 1
            for j in range(5):
                if i&(1<<j):
                    cur_ans *= g[start[j]]
            ans += cur_ans
    
    print(ans)






solve()


Measured memory_bytes: 3064
from itertools import accumulate
n,k=map(int,input().split())
a=list(map(int, input().split()))
b = [0] + a
b = list(accumulate(b))

ans = []
for i in range(n-k+1):
    ans.append(b[i+k]-b[i])
index = ans.index(max(ans))
a=a[index:index+k]
total=0
for i in a:
  total+=(1+i)/2
print(total)

Measured memory_bytes: 27076
#include<bits/stdc++.h>
inline int Calcu(int a,int b){
    while(a&&b){
        if(a>b){
            a = a%b;
        }else{
            b = b%a;
        }
    }
    return a+b;
}

class SegTree{
    public:
        int n;
        int g;
        std::vector<int> data;

        SegTree(std::vector<int> a, int _g){
            g = _g;
            for (n = 1; n < (int) a.size(); n *= 2);
            data.resize(n * 2, g);
            for (int i = 0; i < (int) a.size(); i++) data[i + n] = a[i];
            for (int i = n - 1; i >= 1; i--)
                data[i] = Calcu(data[i * 2], data[i * 2 + 1]);
        }
        int rec(int l, int r, int node, int node_l, int node_r) {
            if (node_r <= l || node_l >= r) return g;
            if (node_l >= l && node_r <= r) return data[node];
            int mid = (node_l + node_r) / 2;
            return Calcu(
                rec(l, r, node * 2, node_l, mid),
                rec(l, r, node * 2 + 1, mid, node_r));
        }

        int get(int l,int r){
            return rec(l,r,1,0,n);
        }

        void assign(int index, int val){
            data[index += n] = val;
            for(;index /= 2;)
                data[index] = Calcu(data[index * 2],data[index * 2 + 1]);
        }
};



int main()
{
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for(int i = 0; i < n; i++)std::cin >> a[i];
    SegTree tree(a,0);
    int max = 0;
    for(int i = 0; i < n; i++){
        tree.assign(i,0);
        max = std::max(tree.get(0,n),max);
        tree.assign(i,a[i]);
    }
    std::cout << max << std::endl;
}


Measured memory_bytes: 2048
N = int(input())
P = [list(map(int, input().split())) for i in range(N)]
C = [[0]*101 for i in range(101)]
P.sort(key=lambda x:x[2], reverse=True)
for X in range(101):
  for Y in range(101):
    tmp1 = -1
    flg = 0
    for i in range(N):
      x,y,h = P[i]
      if h != 0 and tmp1 == -1:
        tmp1 = abs(X-x)+abs(Y-y)+h
      elif tmp1 != -1:
        tmp2 = abs(X-x)+abs(Y-y)+h
        if h != 0: 
          if tmp1 != tmp2:
            flg = 1
            break
        if h == 0:
          if tmp1 > tmp2:
            flg = 1
            break
    if flg == 0:
      print(X, Y, tmp1)        
      exit()

Measured memory_bytes: 3064
import java.io.PrintWriter
import java.util.StringTokenizer

fun main() {

    fun PrintWriter.solve() {
        var (n,m,k) = List(3){nextInt()}
        var A = LongArray(n+1){0}
        var B = LongArray(m+1){0}

        for (i in 1..n){
            A[i] = A[i-1] + nextInt()
        }

        for (i in 1..m){
            B[i] = B[i-1] + nextInt()
        }

        var ans = 0

        for (i in 0..n){


            var (l,r) = listOf(0,m)
            while (l <= r){
                var mid = (l+r)/2
                var nval = A[i] + B[mid]

                if (nval <= k){
                    ans = maxOf(ans,i+mid)
                    l = mid+1
                }
                else{
                    r = mid-1
                }

            }



        }

        println(ans)





    }

    writer.solve()
    writer.flush()


}


private val reader = System.`in`.bufferedReader()
private val writer = PrintWriter(System.out, false)

private var tokenizer: StringTokenizer = StringTokenizer("")

private fun next(): String {
    while (tokenizer.hasMoreTokens().not()) tokenizer = StringTokenizer(reader.readLine())
    return tokenizer.nextToken()
}

private fun nextInt() = next().toInt()
private fun nextLong() = next().toLong()
private fun nextDouble() = next().toDouble()
private fun nextLine() = reader.readLine()



Measured memory_bytes: 71116
#include<stdio.h>
#include<iostream>

using namespace std;

int main(void){
  
 int a,b,sum;
  
  cin>>a>>b;
  
  if(a>=13){
    sum = b;
  }else if(a>=6){
    sum = b/2;
  }else{
    sum = 0;
  }
  
  cout<<sum<<endl;
  
  
  return 0;
  
  
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<pair<string, int> > p(n);
    vector<pair<string, int> > q(n);
    vector<int> order(n);
    int tmp;

    for (int i = 0; i < n; ++i) {
        cin >> p[i].first >> p[i].second;
    }
    q = p;
    sort(p.begin(), p.end());

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if(p[i].first == p[j].first && p[i].second > p[j].second){
                tmp = p[j].second;
                p[j].second = p[i].second;
                p[i].second = tmp;
            }
        }
        
    }

    for (int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            if(p[i] == q[j]) {
                cout << j + 1 << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }

const ll MOD = ll(1e9) + 7;

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll modinv(ll i, ll mod){
    return modpow(i, mod-2, mod);
}

int main()
{
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    ll M = min(K, N - 1);
    vector<ll> add(M+1);
    add[0] = 1;
    for(ll i=1; i <= M; i++) {
        ll invi1 = modinv(i, MOD);
        add[i] = add[i-1] * (N-i+1) % MOD;
        add[i] = add[i] * invi1 % MOD;
        add[i] = add[i] * (N-i) % MOD;
        add[i] = add[i] * invi1 % MOD;
    }
    for(ll i=0; i <= M; i++) {
        ans = (ans + add[i]) % MOD;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1792
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    s = input()
    k = ni()

    substring = set()
    for i in range(97, 97 + 26):
        word = chr(i)

        for j in range(len(s)):
            if s[j] == word:
                tmp = s[j:j + k]

                while len(tmp) > 0:
                    substring.add(tmp)
                    tmp = tmp[:-1]

        if len(substring) >= k:
            break

    ans = list(substring)
    ans.sort()

    print(ans[k - 1])


if __name__ == '__main__':
    main()


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

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


Measured memory_bytes: 256
# https://atcoder.jp/contests/dp/tasks/dp_h

h, w = [int(i) for i in raw_input().split()]
board = [['.' for _ in range(w)] for _ in range(h)]
walls = []

for i in xrange(h):
    inp = raw_input()
    for j in range(w):
        board[i][j] = inp[j]

f = [[0 for _ in range(w)] for _ in range(h)]

f[0][0] = 1

for i in range(1, h):
    if board[i][0] == '#':
        f[i][0] = 0
    else:
        f[i][0] = f[i-1][0]

for i in range(1, w):
    if board[0][i] == '#':
        f[0][i] = 0
    else:
        f[0][i] = f[0][i-1]

for i in range(1, h):
    for j in range(1, w):
        if board[i][j] == '#':
            f[i][j] = 0
        else:
            f[i][j] = f[i-1][j] + f[i][j-1]

print f[-1][-1] % (int(1e9)+7)


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


int main() {


    int n,m;
    cin >> n >> m;

    int ans;
    ans =0;
    if(n>=2){
        ans += n*(n-1)/2;
    }
    if (m>=2){
        ans += m*(m-1)/2;
    }
    cout << ans << endl;

    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main()
{
    int n, r;
    cin >> n >> r;
    if(n < 10) cout << 100 * (10 - n) + r << endl;
    else cout << r << endl;
}


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

void deleteBlankRow(vector<vector<char>>& grid);
void deleteBlankColumn(vector<vector<char>>& grid);
  
int main() {
    int numOfRows = 0;
    int numOfColumns = 0;
    cin >> numOfRows >> numOfColumns;
    
    vector<vector<char>> grid(numOfRows, vector<char>(numOfColumns));
    for (int i = 0; i < numOfRows; ++i) {
        for (int j = 0; j< numOfColumns; ++j) {
            cin >> grid.at(i).at(j);
        }
    }
    
    deleteBlankRow(grid);
    deleteBlankColumn(grid);

    for (int i = 0; i < grid.size(); ++i) {
        for(int j = 0; j < grid.at(i).size(); ++j) {
            cout << grid.at(i).at(j);
        }
        cout << endl;
    }
}

void deleteBlankRow(vector<vector<char>>& grid) {
    stack<int> blankRowNum;
    for (int i = 0; i < grid.size(); ++i) {
        bool isBlankRow = true;
        for(int j = 0; j < grid.at(i).size(); ++j) {
            if(grid.at(i).at(j) == '#') {
                isBlankRow = false;
                break;
            }
        }
        if (isBlankRow) blankRowNum.push(i);
    }
    
    while (!blankRowNum.empty()) {
        grid.erase(grid.begin() + blankRowNum.top());
        blankRowNum.pop();
    }
}

void deleteBlankColumn(vector<vector<char>>& grid) {
    stack<int> blankColumnNum;
    for (int i = 0; i < grid.at(0).size(); ++i) {
        bool isBlankColumn = true;
        for(int j = 0; j < grid.size(); ++j) {
            if (grid.at(j).at(i) == '#') {
                isBlankColumn = false;
                break;
            }
        }
        if (isBlankColumn) blankColumnNum.push(i);
    }
    
    while(!blankColumnNum.empty()) {
        for (int i = 0; i < grid.size(); ++i) {
            grid.at(i).erase(grid.at(i).begin() + blankColumnNum.top());
        }
        blankColumnNum.pop();
    }
}

Measured memory_bytes: 3540
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using ll = long long;
const ll alp = 26;

int main(){
    ll n;
    std::cin >> n;
    ll tmp = n;
    ll base = alp;
    std::vector<int> coe;
    while(tmp > 0){
        if(tmp % alp == 0){
            coe.push_back(alp);
            tmp -= alp;
        }else{
            coe.push_back(tmp % alp);
        }
        base *= alp;
        tmp /= alp;
    }

    int size = coe.size();
    std::string S;
    for(int i = 0; i < size; i++){
        S += 'a' + (coe[size - 1 - i] - 1);
    }
    std::cout << S << std::endl;
    return 0;
}


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

int main()
{
	int n;
	string tmp;
	while (cin >> n, n) {
		vector<string> v;
		v.reserve(n);
		for (int i = 0; i < n; i++) {
			cin >> tmp;
			v.push_back(tmp);
		}
		int del = 0;
		int flag = 0;
		while (flag != 5) {
			flag = 0;
			int length = 0;
			for (int i = del;i < v.size();i++) {
				length += v[i].size();
				if (length == 5 || length == 12 || length == 17 || length == 24 || length == 31)
					flag++;
			}
			del++;
		}
		cout << del << endl;
	}
	return 0;
}

Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define vl vector<ll>
#define forn(i,a,b) for(ll i=1;i<=b;++i)
#define forr(i,a,b) for(ll i=0;i<b;++i)
#define vll vector<pair<ll,ll> >
#define r0 return 0
#define be begin()
#define en end()
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define el endl; cf
#define mp make_pair
#define cf cout.flush()
int main()
{
   ios;
   ll n ;
   cin >> n ;
   vl v;
   v.pb(0);
   forn(i ,1 , n ) {
      ll x ;
      cin >> x;
      v.pb(x);
   }
   v.pb(0);
   ll cnt = 0  ;
   while(true){
     ll res = 0 ;
     for(ll i =1 ; i <= n;++i){
        if(v[i]==0) ++res;
     }
     if(res == n) break;
     ll fn0= -1;
     for(ll i = 1; i<=n ;++i){
        if(v[i]!=0){
            fn0 = i ;
            break;
        }
     }
     ll fl0 = -1 ,  fr0 = -1;
     for(ll i=fn0-1;i>=0;--i){
        if(v[i]==0){
            fl0 =  i;
            break;
        }
     }
     for(ll i = fn0+1;i<=n+1;++i){
        if(v[i]==0){
            fr0 = i ;
            break;
        }
     }
     for(ll i = fl0+1;i<=fr0-1;++i){
        v[i] = v[i]-1;
     }
     ++cnt ;


   }
   cout << cnt << el ;
   r0 ;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  llong N;
  vector<llong> A;

  cin >> N;
  A.resize(N);
  map<llong, llong> m, ans;
  for (auto &in: A) {
    cin >> in;
    ++m[in];
  }

  llong ret = 0;
  for (auto it: m) {
    ans[it.first] = it.second * (it.second-1)/2;
    ret += ans[it.first];
  }

  for (auto a: A) {
    cout << ret - ans[a] + (m[a]-1)*(m[a]-2)/2 << endl;
  }

  return 0;
}

Measured memory_bytes: 20224
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    string s;
    int ab=0,ba=0,a=0,b=0,ss;
    for (int i=0;i<N;i++) {
        cin >> s;
        ss = s.size();
        for (int j=0;j<ss-1;j++) {
            if (s[j]=='A' && s[j+1]=='B') ab++;
        }
        if (s[0]=='B' && s[ss-1]=='A') ba++;
        if (s[0]=='B') b++;
        if (s[ss-1]=='A') a++;
    }
    int ans = ab + min(a,b) - (ba>1 && a==ba && b==ba ? 1 : 0);
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int R;
    double C,pi;
    pi=3.1416;//59265;
    //cin>>R;
    scanf("%d",&R);
    C=2*pi*R;
    //cout<<C;
    printf("%.10lf",C);
    return 0;
}


Measured memory_bytes: 3812
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int n, x, y;
  cin >> n >> x >> y;
  vector<int> ans(n);
  rep(i, n) rep(j, i) {
    ++ans[min((i - j),
              (abs(j + 1 - x) + abs(i + 1 - y) + 1))];
  }
  rep(i, n) {
    if(i == 0) continue;
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n,s,i,min=1000,max=3,sum=0,ave;
  while(1){
    scanf("%d",&n);
    if(n==0){
      break;
    }
    for(i=0;i<n;i++){
      scanf("%d",&s);
      if(s<min){
    min=s;
      } 
      if(s>max){
    max=s;
      }
      sum=sum+s;
    }
    sum=sum-max-min;
    ave=sum/(n-2);
    printf("%d\n",ave);
    sum=0;
    min=1000;
    max=3;
  }
  return 0;
}

Measured memory_bytes: 2712
#include <stdio.h>
int main(){
  int a[3],max=0,i;
  scanf("%d %d %d",&a[0],&a[1],&a[2]);
  for(i=0;i<3;i++){
    if(max<a[i]){
      max=a[i];
    }
  }
  if(max*2==a[0]+a[1]+a[2]){
    printf("Yes\n");
  }else{
    printf("No\n");
 
  }
   return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int nagasa = scan.nextInt();
		String moziS = scan.next();
		String moziT = scan.next();
		String[] newmozi = new String[nagasa*2];
		String re = "";


		for(int i=0;i<nagasa;i++) {

			newmozi[i] = moziS.substring(i,i+1) + moziT.substring(i,i+1);
			re += newmozi[i];
		}

		System.out.println(re);
		scan.close();

	}

}


Measured memory_bytes: 21716
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//

    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define int long long
    #define fo(i,a,b) for(i=a;i<b;i++)
    #define rfo(i,b,a) for(i=b;i>=a;i--)
    #define deb(x) cout<<#x<<" "<<x<<endl;
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int MOD =  1000000007 ;
    const int MAX = 2e6 + 7;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    double dp[MAX];
    double sum,x;
    void solve()
    {
        cin>>n;
        dp[0]=1;
        fo(i,0,n)
        {
            cin>>x;
            rfo(j,i+1,0)
            {
                dp[j]=dp[j-1]*x+dp[j]*(1-x);
            }
        }
        
        fo(i,(n+2)/2,n+1)
        {
            sum+=dp[i];
        }
        deci(10)
        cout<<sum<<endl;
    	
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //

    int32_t main() 
      {
      	
      	// int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
      	ios_base::sync_with_stdio(0);
      	cin.tie(NULL);
      	
      	// cin>>t;while(t--)
      	solve();
      	
    	return 0;
      }

Measured memory_bytes: 384
#include<stdio.h>

int main(void) {
    int a, b, c;
    int i;
    int j = 0;
    
    scanf("%d %d %d", &a, &b, &c);
    
    for(i = a; i <= b; i++) {
        if(c % i == 0) {
            j++;
        }
    }
    
    printf("%d\n", j);
    
    return 0;
}


Measured memory_bytes: 2100
//OM
#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <sstream>
#include <algorithm>
using  namespace  std;

#define  x first
#define  y second
#define  pb push_back
#define  mp make_pair
#define  PI (acos(-1.0))
#define  mem(a,b) memset(a,b,sizeof(a))
#define  Sort(x) sort(x.begin(),x.end())
#define  FOR(i, b, e) for(int i = b; i <= (int)(e); i++)
#define  FORR(i, b, e) for(int i = b; i >=(int)(e); i--)
#define  FORI(i, s) for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
#define  pr(x) cout<<x<<"\n"
#define  prs(x) cout<<x<<" "
#define  pr2(x,y) cout<<x<<" "<<y<<"\n"
#define  pr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define  ppr(a) cout<<a.x<<" "<<a.y<<"\n"

typedef  long long ll;
typedef  pair <int, int> pii;
typedef  pair <double , double> pdd;
typedef  vector <int> vi;
typedef  vector <pii> vpii;

//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};
//int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction

#define  EPS 1e-9
#define  MAX 100007
char s[MAX];
vi a[50];
int main()
{
    int T,n;
    scanf("%s",s);
    int len=strlen(s);
    FOR(i,0,len-1)
    {
        a[s[i]-'a'].pb(i);
    }
//    FOR(i,0,len-1){
//
//        FOR(c,0,25)
//        {
//            int s=-1;
//            FOR(k,0,a[c].size()-1)
//            {
//                if(a[c][k]<k)continue;
//                else{
//                    if(s==-1)s=a[c][k];
//                }
//            }
//        }
//    }
       FOR(c,0,25)
       {
            int s=-1;
            FOR(i,0,a[c].size()-2)
            {
               int  j=i+1;
                    int cha=j-i+1;
                    int str=a[c][j]-a[c][i]+1;
                    if(cha>str/2&&cha>=2)
                    {
                        printf("%d %d",a[c][i]+1,a[c][j]+1);
                        return 0;
                    }
            }
        }
        printf("-1 -1");
    return 0;
}



Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=1000010,P=998244353;
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
inline void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
}
ll a,b,n,l,r;
int main(){
	//freopen("1.in","r",stdin);
	//freopen("1.out","w",stdout);
	n=read();a=read();b=read();
	if(a>b)return puts("0"),0;
	if(n==1)return puts(a==b?"1":"0"),0;
	l=1ll*(n-1)*a+b;r=1ll*(n-1)*b+a;
	printf("%lld\n",r-l+1);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <unistd.h>
#define ll long long
#define ull unsigned long long
#define inf 1000000007
#define inf16 0x3f3f3f3f
#define INF 1000000000000000007LL
#define VI vector<int>
#define VPII vector<pair<int, int> >
#define VLL vector<ll>
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define flush fflush(stdout)
using namespace std;

#define N 500007

ll n, a, b, c, d;

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	cin >> n >> a >> b >> c >> d;

	b -= a;
	--n;

	for(int i = 0; i <= n; ++i)
	{
		if(-i*d+(n-i)*c <= b && b <= -i*c+(n-i)*d)
		{
			cout << "YES";
			return 0;
		}
	}

	cout << "NO";
}


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

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

    int ans = 0;
    int cnt = 0;
    for(int i=1;i<n;i++){
        cnt = 0;
        sl = s.substr(0,i);
        sr = s.substr(i);
        //cout << sl << endl;
        //cout << sr << endl;

        for(char c = 'a';c <= 'z';c++){
            bool left = false,right = false;
            for(int j=0;j<sl.size();j++){
                if(sl[j] == c) {left = true;}
            }
            for(int j=0;j<sr.size();j++){
                if(sr[j] == c) right = true;
            }
            if(left&&right){cnt++;}
        }
        ans = max(ans,cnt);
    }
    cout << ans << endl;
}

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

int main( void )
{
    int n,a;
    cin >> n >> a;
    
    if ( n % 500 <= a )
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Collection;


public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int[][]A=new int[2][N];
        for(int i=0;i<2;i++){
            for(int j=0;j<N;j++){
                A[i][j]=sc.nextInt();
            }
        }
        int[]C=new int[N];
        C[0]=A[0][0];
        for(int i=1;i<N;i++){
            C[i]=C[i-1]+A[0][i];
        }
        int[]D=new int[N];
        D[0]=A[1][0];
        for(int i=1;i<N;i++){
            D[i]=D[i-1]+A[1][i];
        }
        int max=0;
        int sum=0;
        for(int i=0;i<N;i++){
            if(i==0){
                sum=C[i]+D[N-1];
                max=sum;
            }else{
                sum=C[i]+D[N-1]-D[i-1];
                if(sum>max){
                    max=sum;
                }
            }
        }
        System.out.println(max);

}
        
        
    }


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

long long dp0[200001][16];
long long dp1[200001][16];

long long calc_dp(long long dp[200001][16], int x, int p, vector<long long> &A){

    if(p < 16){
        if(dp[x][p] != -1)
            return dp[x][p];
        long long a = A[x] * (1LL << (2*p));
        long long b = A[x+1];
        long long pow = 0;
        while(a > b){
            while(a % 4 == 0 && b % 4 == 0){
                a /= 4;
                b /= 4;
            }
            b *= 4;
            pow++;
        }
        long long tmp = calc_dp(dp, x+1, pow, A);
        if(pow < 16)
            dp[x+1][pow] = tmp;
        return pow + tmp;
    }else{
        long long m = A.size()-x-1;
        dp[x][15] = calc_dp(dp, x, 15, A);
        return dp[x][15] + (p-15)*m;
    }
}

int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i=0; i<N; i++)
        cin >> A[i];

    for(int i=0; i<N-1; i++){
        for(int j=0; j<16; j++){
            dp0[i][j] = -1;
            dp1[i][j] = -1;
        }
    }

    for(int i=N-2; i>=0; i--)
        for(int j=0; j<16; j++)
            dp0[i][j] = calc_dp(dp0, i, j, A);

    reverse(A.begin(), A.end());
    for(int i=N-2; i>=0; i--)
        for(int j=0; j<16; j++)
            dp1[i][j] = calc_dp(dp1, i, j, A);

    long long ans = 1LL<<60;
    for(int i=0; i<=N; i++){
        long long tmp1 = 2*dp0[i][0];
        long long tmp2 = 2*dp1[N-i][0] + i;
        ans = min(ans, tmp1+tmp2);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 51840
# frozen_string_literal: true

n = gets.to_i
a, b = Array.new(n) { gets.split.map(&:to_i) }.transpose
cnt = 0

a.zip(b).reverse_each do |e|
  tmp = (e[0] + cnt) % e[1]
  cnt += tmp == 0 ? 0 : e[1] - tmp
end

puts cnt

Measured memory_bytes: 13308
#!/usr/bin/env python3

n = int(input())
s = input()
k = int(input())

S = []
for i in s:
    S.append(i)

ta = S[k-1]
    
for i in range(n):
    if S[i] == ta:
        print(S[i],end = "")

    else:
        print("*",end = "")
        


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

long long BIT[200010];
long long tab[200010];
long long val[200010];

void upd(long long x,long long val)
{
	for ( ; x <= 200000 ; x += (x & -x))
		BIT[x] = max(BIT[x],val);
}

long long query(long long x)
{
	long long res = 0;
	for ( ; x ; x -= (x & -x))
		res = max(res,BIT[x]);
	return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	long long n;
	cin >> n;
	for (long long i = 1 ; i <= n ; i++)
	{
		cin >> tab[i];
	}
	for (long long i = 1 ; i <= n ; i++)
		cin >> val[i];
	long long ans = 0;
	for (long long i = 1 ; i <= n ; i++)
	{
		long long tmp = query(tab[i] - 1);
		tmp += val[i];
		// cout << tmp << endl;
		ans = max(ans,tmp);
		upd(tab[i],tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);


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

  ll n, m;
  cin >> n >> m;
  vector<pair<ll, ll>> req;
  rep(i, m) {
    ll a, b; cin >> a >> b; a--; b--;
    req.emplace_back(b, a);
  }

  sort(ALL(req));
  ll ans = 0;
  ll idx = 0;   // idx で示す島の手前の橋が切断されている
  for (auto& p : req) {
    if (p.second >= idx) {
      idx = p.first;
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2420
//include
//------------------------------------------
#include <bits/stdc++.h> // only for GCC

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

//container util
//------------------------------------------
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

//repetition
//------------------------------------------
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

//constant
//--------------------------------------------
const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

// output vector
// ------------------------------------------
namespace std {
    template<typename T>ostream&operator<<(ostream&os, vector<T>const&v){
        iter(it,v) os<<*it<<(it+1==v.end()?"":",");
        return os;
    }
    template<typename T, typename U>ostream&operator<<(ostream&os,const pair<T,U>&p){
        return os << "[" << p.dirst << "," << p.second << "]";
    }
}

//clear memory
// ------------------------------------------
#define clr(a,i) memset((a), (i) ,sizeof(a))

int main(){
   string s;
   int ans=0;
   while(cin >> s){
      ans=(s[0]-'0')+(s[1]-'0')*9+(s[2]-'0')*6+(s[3]-'0')*4+(s[4]-'0')*6
      +(s[9]-'0')+(s[8]-'0')*9+(s[7]-'0')*6+(s[6]-'0')*4+(s[5]-'0')*6;
      ans%=10;
      cout << ans << endl;
   }
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int max_len = (int)s.length();
    //need to run from len 1 to max_len
    //  need to run from index 0 to max_len-1 for all len
    int overall_max=0;
    int start,end;
    for(int i=0;i<max_len;i++){
        for(int len=1;len<=max_len;len++){
            int maxi=0;
            start=i;end=i+len-1;
            if (end>=max_len)break;
            for(int j=start;j<=end;j++){
                if(s[j]=='A' || s[j]=='C' || s[j]=='G' || s[j]=='T')maxi+=1;
                else break;
            }
            overall_max = max(maxi,overall_max);
        }
    }
    cout<<overall_max;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int d, n;
    
    scanf("%d %d", &d, &n);
    
    if(d==0&&n==100) printf("101");
    else if(d==0) printf("%d", n);
    if(d==1&&n==100) printf("10100");
    else if(d==1) printf("%d", 100*n);
    if(d==2&&n==100) printf("1010000");
    else if(d==2) printf("%d", 10000*n);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define rev(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;






int main() {

    
    int n;
    cin >> n;
    int a, b, c, d;
    d = n % 10;
    n /= 10;
    c = n % 10;
    n /= 10;
    b = n % 10;
    n /= 10;
    a = n % 10;

    cout << a;
    if (a + b + c + d == 7) cout << "+" << b << "+" << c << "+";
    else if (a + b + c - d == 7) cout << "+" << b << "+" << c << "-";
    else if (a + b - c + d == 7) cout << "+" << b << "-" << c << "+";
    else if (a + b - c - d == 7) cout << "+" << b << "-" << c << "-";
    else if (a - b + c + d == 7) cout << "-" << b << "+" << c << "+";
    else if (a - b + c - d == 7) cout << "-" << b << "+" << c << "-";
    else if (a - b - c + d == 7) cout << "-" << b << "-" << c << "+";
    else if (a - b - c - d == 7) cout << "-" << b << "-" << c << "-";
    cout << d << "=7" << endl;



    return 0;
}




//              g++ -std=c++1z






Measured memory_bytes: 256
from functools import reduce
N = int(input())
amounts = sorted(sum(([6 ** (i + 1), 9 ** i] for i in range(6)), []))
account = 1 << N
times = 0
while (times := times + 1) and not (account := reduce(lambda a, b: a | b, [account >> amount for amount in amounts])) & 1:
    pass
print(times)

Measured memory_bytes: 9628
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  print(a*b/2);
 
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


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

    int a;
    cin >> a;
    map<int,int> b;
    b[a]++;  
    int cnt = 1;
    while(true){
        cnt++;
        if(a%2==0) a/=2;
        else a = 3*a + 1;
        //cout << a << endl;
        b[a]++;
        if(b[a]>1) break;
    }
    cout << cnt << endl;
    return 0;

}


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

int main(void){
    int h,n;
    cin >> h >> n;
    int k;
    int sum = 0;
    rep(i,n){
        cin >> k;
        sum += k;
    }
    if(sum >= h){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <iomanip>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    long long int sum,n,m=0,r=0,a=0,c=0,h=0;
    cin>>n;
    vector<string>k(n);
    for(long long int i=0;i<n;i++){
        cin>>k[i];
        if(k[i][0]=='M')m++;
        if(k[i][0]=='R')r++;
        if(k[i][0]=='A')a++;
        if(k[i][0]=='C')c++;
        if(k[i][0]=='H')h++;
    }
    sum=m*r*c + m*r*a + m*r*h + m*a*c + m*a*h + m*c*h + r*a*c + r*a*h + r*c*h + a*c*h;
    cout<<sum;
}

Measured memory_bytes: 5760
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int N;
    cin >> N;
    if(N>=1000) cout << "ABD" << endl;
    else cout << "ABC" << endl;
}

Measured memory_bytes: 256
// B.

#include <sstream>
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
	int n;
	cin >> n;
	vector<int> pos(n + 1);
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		pos[a] = i;
	}
	pos[0] = 1<<30;
	int cnt = 0, mx = 0;
	for (int i = 1; i <= n; ++i) {
		if (pos[i - 1] > pos[i]) {
			cnt = 0;
		}
		++cnt;
		mx = max(mx, cnt);
	}
	int ans = n - mx;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<map<int,int>> m(2);
  for(int i=0;i<n;i++){
    int v;
    cin>>v;
    m.at(i%2)[v]++;
  }
  int xf=0,xs=0,yf=0,ys=0;
  for(auto x:m.at(0)){
    if(x.second>m.at(0)[xf]){
      xs=xf;
      xf=x.first;
    }else if(x.second>m.at(0)[xs])
      xs=x.first;
  }
  for(auto y:m.at(1)){
    if(y.second>m.at(1)[yf]){
      ys=yf;
      yf=y.first;
    }else if(y.second>m.at(1)[ys])
      ys=y.first;
  }
  cout<<(xf!=yf?n-m.at(0)[xf]-m.at(1)[yf]:min(n-m.at(0)[xs]-m.at(1)[yf],n-m.at(0)[xf]-m.at(1)[ys]));
}

Measured memory_bytes: 8152
n = int(input())
cnt_dict = {}
for _ in range(n):
    s = input()
    cnt_dict.setdefault(s,0)
    cnt_dict[s] += 1

cnt_t = sorted(cnt_dict.items(), key=lambda x:(-1)*x[1])

ans_s = []
max_cnt = cnt_t[0][1]
for t in cnt_t:
    if t[1] != max_cnt:
        break
    ans_s.append(t[0])

ans_s.sort()
for s in ans_s:
    print(s)

Measured memory_bytes: 162616
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        long a = sc.nextInt();
        long b = sc.nextInt();
        long c = sc.nextInt();
        long d = sc.nextInt();
        long max = Long.MIN_VALUE;

        List<Long> ab = new ArrayList<>();
        ab.add(a);
        if (a * b < 0) {
            ab.add(0L);
        }
        ab.add(b);
        List<Long> cd = new ArrayList<>();
        cd.add(c);
        if (c * d < 0) {
            cd.add(0L);
        }
        cd.add(d);

        for (long x: ab) {
            for (long y: cd) {
                max = Math.max(x * y, max);
            }
        }

        System.out.print(max);
    }
}


Measured memory_bytes: 27100
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define ss second
#define ff first
#define INF 300000000000001
#define ll_max 1000000000000000000
#define mod 998244353
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define db(args...) {string _ss = #args; replace(_ss.begin(), _ss.end(), ',' , ' '); stringstream ___s(_ss) ; debug(___s, args);}
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;
const ll N = 200001;
const ll M = 21;
struct point {
    ll x, y, sol;
    bool operator == (point b)
    {
        if(this -> x == b.x && this -> y == b.y) return 1;
        return 0;
    }
    bool operator != (point b)
    {
        return !(*this == b);
    }
};

void debug(stringstream &s){}
template <typename T, typename... Args>
void debug(stringstream &s, T a, Args... args)
{
    string word;
    s >> word;
    cout << word << " = " << a << endl;
    debug(s, args...);
}

ll fast_exp(ll x,ll n)
{
    if(n == 0) return 1;
    ll ans;
    if(n % 2 == 0)
    {
         ans = fast_exp(x, n / 2);
         ans = ans * ans;
    }
    else ans = fast_exp(x, n - 1) * x;
    return ans;
}
ll a[N], b[N], c[N], o[N], z[N];
vector<int> tree[N];
ll solve(ll x, ll p)
{
    ll ans = 0;
    for(auto i:tree[x])
    {
        if(i != p)
        {
            a[i] = min(a[i], a[x]);
            ans += solve(i, x);
            o[x] += o[i];
            z[x] += z[i];
        }
    }
    if(b[x] != c[x])
    {
        if(b[x]) o[x]++;
        else z[x]++;
    }
    if(o[x] && z[x])
    {
        ans += 2 * a[x] * min(o[x], z[x]);
        ll y = min(o[x], z[x]);
        o[x] -= y;
        z[x] -= y;
    }
    return ans;
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll n, m = 0, x = 0, y = 0, ans = 1, k;
        long double tmp;
        cin >> n >> tmp;
        m = int(tmp);
        x = (tmp - m + 0.001) * 100L;
        ans = n * m + (n * x) / 100;
        cout << ans << "\n";
     }
     return 0;
}


Measured memory_bytes: 8380
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MA=1e5+5;

int main(){
	int n; 
	cin>>n;
	bool flag=false;
	for(int i=1;i<=9;i++){
		if(n%i==0){
			int t=n/i;
			if(t>=1&&t<=9){
				flag=true;
				break;
			}
		}
	}
	if(flag)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256