akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)

const initBufSize, maxBufSize = 10000, 1000000

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

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

func nextInts(n int) []int {
	res := make([]int, n)
	for i := range res {
		res[i] = nextInt()
	}
	return res
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func abs(n int) int {
	return int(math.Abs(float64(n)))
}

func pow(r, n int) int {
	return int(math.Pow(float64(r), float64(n)))
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initBufSize), maxBufSize)
	hpTakahashi := nextInt()
	atTakahashi := nextInt()
	hpAoki := nextInt()
	atAoki := nextInt()

	//相手を倒すまでの攻撃回数
	countTakahashi := hpAoki / atTakahashi
	countAoki := hpTakahashi / atAoki
	if hpAoki%atTakahashi != 0 {
		countTakahashi++
	}
	if hpTakahashi%atAoki != 0 {
		countAoki++
	}

	if countTakahashi <= countAoki {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1756
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
//cout << fixed << setprecision(20) << *** << endl;
#define rep(i,N) for(int i=0;i<(int)N;++i)
typedef long long ll;
using namespace std;
int main()
{
	ll N,M;
	vector<pair<ll,ll>>V;
	cin>>N>>M;
	rep(i,M){
		ll t;
		char u;
		cin>>t>>u;
		V.push_back(make_pair(t,u));
	}
	ostringstream oss;
	oss<<102;
	rep(i,1000){
		ostringstream oss;
		oss<<i;
		bool F=true;
		if(oss.str().size()==N){
			rep(j,V.size()){
				//cout<<oss.str()<<" "<<oss.str()[V[j].first-1]<<" "<<F<<endl;
				if(oss.str()[V[j].first-1]!=V[j].second){
					F=false;
				}
			}
		}
		else F=false;
		if(F==true){
				cout<<i<<endl;
				return 0;
		}
	}
	cout<<"-1"<<endl;
}

Measured memory_bytes: 3164
#include "bits/stdc++.h"
#include<cassert>
#pragma warning(disable:4996)
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MRE assert(0)
const int mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<P, int>PP;
int ans[100006];
signed main() {
	int n, q; cin >> n >> q;
	deque<int>s;
	s.push_back(n);
	rep(i, q) {
		int a; cin >> a;
		while (s.size() && s.back() >= a)s.pop_back();
		if (s.size() == 0 || s.back() < a)s.push_back(a);
	}
	vector<int>V;
	while (s.size()) {
		V.push_back(s.front()); s.pop_front();
	}
	set<int>S;
	S.insert(V[V.size() - 1]);
	map<int, int>M;
	M[V[V.size() - 1]]++;

	while (S.size()) {
		auto k = S.rbegin();
		int K = *k;
		if (K <= V[0])break;
		S.erase(K);
		int a = *(lower_bound(V.begin(), V.end(), K) - 1);
		int b = K / a, q = K%a;
		M[a] += M[K] * b;
		S.insert(a);
		if (q) {
			M[q] += M[K];
			S.insert(q);
		}
	}
	rep(i, V[0]) {
		ans[0] += M[i + 1];
		ans[i + 1] -= M[i + 1];
	}

	rep(i, n)ans[i + 1] += ans[i];
	rep(i, n)cout << ans[i] << endl;
}

Measured memory_bytes: 31992
{-# LANGUAGE BangPatterns        #-}
{-# LANGUAGE FlexibleContexts    #-}
{-# LANGUAGE MultiWayIf          #-}
{-# LANGUAGE RankNTypes          #-}
{-# LANGUAGE ScopedTypeVariables #-}
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State
import           Control.Monad.Trans.State
import           Data.Array.IArray
import           Data.Array.ST
import           Data.Array.Unboxed
import           Data.Bits
import qualified Data.ByteString.Char8        as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import           Data.Proxy
import           Data.Sequence                (Seq ((:<|), (:|>)), ViewL ((:<)),
                                               ViewR ((:>)), viewl, viewr, (<|),
                                               (><), (|>))
import qualified Data.Sequence                as Seq
import qualified Data.Set                     as S
import           Data.STRef
import qualified Data.Vector                  as V
import qualified Data.Vector.Mutable          as VM
import qualified Data.Vector.Unboxing         as VU
import qualified Data.Vector.Unboxing.Mutable as VUM
import           Numeric

main :: IO ()
main = do
  x <- readLn :: IO Int
  print $ if x == 0 then 1 else 0




-- converter
unconsChar :: StateT BS.ByteString Maybe Char
unconsChar = StateT BS.uncons

unconsInt :: StateT BS.ByteString Maybe Int
unconsInt = StateT $ BS.readInt . BS.dropWhile isSpace

unconsInteger :: StateT BS.ByteString Maybe Integer
unconsInteger = StateT $ BS.readInteger . BS.dropWhile isSpace

-- 1D Data
-- for list
readLnAsListWith :: StateT BS.ByteString Maybe a -> IO [a]
readLnAsListWith !st = unfoldr (runStateT st) <$> BS.getLine

-- for array (boxed or unboxed)
readLnAsArrayWith :: IArray a e => StateT BS.ByteString Maybe e -> Int -> IO (a Int e)
readLnAsArrayWith !st !n = listArray (1,n) <$> readLnAsListWith st

-- for boxed vector
readLnAsVecWith :: StateT BS.ByteString Maybe a -> Int -> IO (V.Vector a)
readLnAsVecWith !st !n = V.unfoldrN n (runStateT st) <$> BS.getLine

-- for unboxed vector
readLnAsUVecWith :: VU.Unboxable a => StateT BS.ByteString Maybe a -> Int -> IO (VU.Vector a)
readLnAsUVecWith !st !n = VU.unfoldrN n (runStateT st) <$> BS.getLine

-- example: 1D tuple vector
readLnAsUVecWith2Tuple :: VU.Unboxable a => StateT BS.ByteString Maybe a -> Int -> IO (VU.Vector (a,a))
readLnAsUVecWith2Tuple !st !n = VU.replicateM n $ (\vec -> (vec VU.! 0, vec VU.! 1)) <$> readLnAsUVecWith st 2


-- 2D Data
-- n: number of lines
-- m: number of values per a line

-- for boxed vector
readLnAs2DVecWith :: StateT BS.ByteString Maybe a -> Int -> Int -> IO (V.Vector a)
readLnAs2DVecWith !st !n !m = V.unfoldrN (n * m) (runStateT st) . BS.concat <$> replicateM n BS.getLine

readLnAs2DUVecWith :: VU.Unboxable a => StateT BS.ByteString Maybe a -> Int -> Int -> IO (VU.Vector a)
readLnAs2DUVecWith !st !n !m = VU.unfoldrN (n * m) (runStateT st) . BS.concat <$> replicateM n BS.getLine


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

const ll MAX_N=1e5+1;
vvll a(MAX_N);
vvll b(MAX_N);
vll memo(MAX_N,-1);

ll dfs(ll cur){
  if(a[cur].size()==0)
    return memo[cur]=0;

  if(memo[cur]>=0)
    return memo[cur];

  priority_queue<ll> que;
  for(auto g:a[cur]){
    que.push(dfs(g));
  }

  ll cnt=0;
  ll res=0;
  while(!que.empty()){
    res=max(res,cnt+que.top());
    que.pop();
    cnt++;
  }

  res++;
  memo[cur]=res;
  return res;
}

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

  ll n;
  cin>>n;
  REP(i,n-1){
    ll x;
    cin>>x;
    x--;
    a[x].push_back(i+1);
  }

  ll ans=dfs(0);
  cout<<ans<<endl;
}



Measured memory_bytes: 18176
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = 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 fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
// clang-format on

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

    vector<int> d(k);
    rep(i, k) scanf(" %d", &d[i]);

    while (q--) {
        int n, x, m;
        scanf(" %d %d %d", &n, &x, &m);
        x %= m;

        int ans = n - 1;

        int L = n / k;
        ll add = 0;
        rep(i, k) {
            int ct = L;
            if (i == k - 1) {
                --ct;
                if ((n - 1) % k != k - 1) ++ct;
            } else {
                int r = (n - 1) % k;
                if (r != k - 1 && i < r) ++ct;
            }
            // printf(" %d : %d\n", i, ct);

            ll b = d[i] % m;
            if (b == 0) ans -= ct;
            add += b * ct;
        }
        ans -= (add + x) / m;
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 3784
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

N, K = map(int, input().split())
H = list(map(int, input().split()))
count = 0
for i in range(N):
    if H[i] >= K:
        count += 1

print(count)

Measured memory_bytes: 11972
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
  int n,k; cin>>n>>k;
  int a[n]={};
  int tmp;
  for(int i=0;i<n;i++){
    cin>>tmp;
    a[tmp-1]++;
  }
  sort(a,a+n);
  int sum=0;
  for(int i=0;i<n;i++){
    if(a[i]>0) sum++;
  }
  int ans=0;
  if(k<sum){
    int i=0,cnt=0;
    bool flag=true;
    while(flag){
      if(a[i]>0){
        ans+=a[i]; cnt++;
      }
      i++;
      if(cnt==sum-k) flag=false;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
  vector<ll> A(3);
  ll ans;
  rep(i,3){
    cin >> A[i];
    if(A[i]%2 == 0){
      cout << 0 << endl;
      return 0;
    }
  }
  sort(A.begin(),A.end());
  ans = A[0]*A[1];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
total = 0
ng_number = -1
end_number = -1
for i in range(1, n + 1):
    total += i
    if total == n:
        end_number = i
        break
    elif total > n:
        ng_number = total - n
        end_number = i
        break
for i in range(1, n+1):
    if end_number < i:
        break
    if not ng_number == i:
        print(i)

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

const int INF = 1e9;
using lint = long long;
const lint LINF = 1e18;
#define bit(n) ((lint)1 << n);

const lint MOD = 1e9 + 7;
// const lint MOD = 998244353;

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

    int n, m;
    cin >> n >> m;
    int lef = 0, rig = n;
    for (int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;
        lef = max(lef, l);
        rig = min(rig, r);
    }

    cout << max(0, rig - lef + 1) << endl;

    return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    while (cin>>n, n) {
        map<long long, int> m;
        int c=0, res=0, a;
        for (int i=0; i<n; ++i) {
            cin >> a;
            int &ma = m[a];
            ++ma;
            if (c < ma) {
                c = ma; res = a;
            }
        }
        if (n < c*2) {
            cout << res << endl;
        } else {
            cout << "NO COLOR" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3252
#include <stdio.h>

int fibonacci(int ); 

int main(){
  int i,n;
 
  scanf("%d",&n);
  printf("%d\n",fibonacci(n));
 
  return 0;
}


int fibonacci(int n){
  int i;
  int a=1, b=1, tmp=1;
 
  for(i=2;i<=n;i++){
    tmp = a + b;
    a = b;
    b = tmp;
  }
  return tmp;
}

Measured memory_bytes: 596
import bisect

s = list(input())
t = list(input())

# 辞書を作る
dictionary = {}

tt = t[:]
ss = dict(zip(list(range(len(s * 2))), s * 2))

for i in range(len(ss)):
    c = ss[i]
    if c not in dictionary:
        dictionary[c] = []
    dictionary[c].append(i)

result = 0
current_idx = 0
sLen = len(s)

for c in t:
    if c not in dictionary:
        print(-1)
        exit(0)
    indexes = dictionary[c]
    next = dictionary[c][bisect.bisect_left(indexes, current_idx)] + 1
    result += next - current_idx
    current_idx = next
    if next >= sLen:
        current_idx -= sLen

print(result)




Measured memory_bytes: 33704
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<unordered_set>
#include<unordered_map>
#include<set>
#include<map>
#include<list>

using namespace std;

#define in(s) cin >> s
#define out(s) cout << s << endl
#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
    ll H,W;
    cin>>H>>W;
    ll ans=H*W;
    if(W==1||H==1){
        out(1);
        return 0;
    }
    if(ans%2)out(ans/2+1);
    else out(ans/2);

	return 0;
}


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

int main() {
  string A;
  cin >> A;
  
  
  if (A[0] == A[1] && A[1] == A[2]){
    cout << "Yes" << endl;
  }
  else if (A[1] == A[2] && A[2] == A[3]){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
}

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

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

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

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


int main()
{
  ll n, d;
  cin >> n >> d;
  int ans = 0;
  rep(i, n) {
    ll x, y; cin >> x >> y;
    if(x*x + y*y <= d*d) ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <math.h>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
#include <cstdlib>
using namespace std;

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

	if (a + b < 24)
	{
		cout << a + b << endl;
	}
	else
	{
		cout << a + b - 24 << endl;
	}
}


Measured memory_bytes: 256
N = int(input())
X = [int(i) for i in input().split()]
x = sorted(X)
num1 = x[N//2]
num2 = x[N//2 - 1]
ans = []
for i in X:
    if i <= num2:
        ans.append(num1)
    else:
        ans.append(num2)
for i in ans:
    print(i)

Measured memory_bytes: 26772
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdlib>
using namespace std;

int main() {
	int x1, y1, x2, y2,vx,vy;
	cin >> x1 >> y1 >> x2 >> y2;
	vx = y1 - y2;
	vy = x2 - x1;
	cout << x2 + vx <<" "<< y2 + vy <<" "<< x1 + vx <<" "<< y1 +vy << endl;
	return(0);
}


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

using namespace std;
using p=pair<int,int>;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<int>a(n);
  rep(i,n){
    cin >> a[i];
  }
  int k=1000000;
  int ans=0;
  rep(i,n){
    k=min(k,a[i]);
    if(k==a[i]){
      ans++;
    }
  }
  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int a[3][3];
    rep(i, 0, 3) {
        rep(j, 0, 3) {
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    bool f[3][3] = {};
    rep(i, 0, n) {
        int b;
        cin >> b;
        rep(j, 0, 3) {
            rep(k, 0, 3) {
                if (a[j][k] == b) {
                    f[j][k] = true;
                }
            }
        }
    }
    rep(i, 0, 3) {
        bool ok = true;
        rep(j, 0, 3) {
            if (!f[i][j]) ok = false;
        }
        if (ok) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    rep(i, 0, 3) {
        bool ok = true;
        rep(j, 0, 3) {
            if (!f[j][i]) ok = false;
        }
        if (ok) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    bool ok = true;
    rep(i, 0, 3) {
        if (!f[i][i]) ok = false;
    }
    if (ok) {
        cout << "Yes" << endl;
        return 0;
    }
    ok = true;
    rep(i, 0, 3) {
        if (!f[i][2 - i]) ok = false;
    }
    if (ok) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header
int calc(int t){
	if(t%2 == 0) return t/2;
	else return 3*t+1;
}
int main() {
	int s;
	cin >> s;
	map<int, int> m;
	m[s]++;
	int old=s;
	int ans = 1;
	while(1){
		ans++;
		int k = calc(old);
		//cout << k;
		m[k]++;
		if(m[k]>1){
			cout << ans << endl;
			return 0;
		}
		old = k;
	}
	return 0;
}

Measured memory_bytes: 256
#if 1

#include <bits/stdc++.h>
using namespace std;
int n,e,w,s = 1000000000,a[1000005];
char c[1000005];
int main()
{
    cin >> n;
	for(int i = 0;i < n;i++)
    {
        cin >> c[i];
        a[i] = w;
        w += (c[i] == 87);
    }
	for(int i = n-1;i >= 0;i--)
    {
        s = min(s,a[i]+e);
        e += (c[i] == 69);
    }
	cout<< s;
}

#endif // 1++

Measured memory_bytes: 3712
#include<stdio.h>
int main(void)
{
	int a, b, c, d;
	scanf("%d %d %d",&a, &b, &c);
	if(a<b && b<c && a<c){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 2588
while True:
  m, f, r = map(int, input().split())
  if m==-1 and f==-1 and r==-1:
    break
  elif m==-1 or f==-1:
    print('F')
  elif (m+f) >= 80:
    print('A')
  elif 65 <= (m+f) < 80:
    print('B')
  elif 50 <= (m+f) < 65:
    print('C')
  elif 30 <= (m+f) < 50:
    if r < 50:
      print('D')
    else:
      print('C')
  else:
    print('F')






Measured memory_bytes: 5592
// clang-format off
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort(all(x), greater<>())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl;
const ll LINF = (1LL << 62) - 1;
const int INF = (1 << 30) - 1;
template<class T>bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if (b<a){a=b;return 1;}return 0;}
const string YES = "Yes";
const string NO = "No";
// clang-format on

void solve(std::string S) {
  ANS(((S[2] == S[3] && S[4] == S[5]) ? YES : NO));
}

// clang-format off
int main() {
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 256
n,w = map(int,input().split())
#list1[i][重さw,価値v]
list1 = [list(map(int,input().split())) for i in range(n)]

#1次元配列で、更新していく形で解くこととする。(本来i,j方向に2次元配列で解く)
dp = [0]*(w+1) #wは0,1,2,...,wとなる
"""
#こっちのループは、重さを外側で、商品を内側で回しているので、
#商品の重複を許すことになる。よって、商品を外側で回さなければならない。
for i in range(w+1): #iには現在の重さが入る
    for j in range(n): #jには各商品が入る
        if i - list1[j][0] >= 0:
            dp[i] = max(dp[i-list1[j][0]]+list1[j][1],dp[i])
"""

for i in range(n):
    for j in range(w,-1,-1): #後ろから見ることで重複を避けている。※
        if j - list1[i][0] >= 0:
            dp[j] = max(dp[j-list1[i][0]]+list1[i][1],dp[j])
"""
※例えば、i=0のループで、
jを前から回すと、wの条件を満たすたびにlist1[i][1]が足されていくので、
一つの商品に対して何度も重複を許すことになる。但し、後ろから回せば
dp[j-list1[i][0]]は必ずその要素を足し合わせていない値であることがわかる。
これを前から回したいときは、適宜一周前のループを参照する必要があるため、
二次元配列を作成する必要がある。
"""
print(dp[-1])

Measured memory_bytes: 42444
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

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; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    string a, b, c;
    while(cin >> n >> a >> b >> c){
        int ans = 0;
        REP(i, n) {
            if (a[i] != b[i]) {
                if (a[i] == c[i] || b[i] == c[i]) ans ++;
                else ans += 2;
            } else {
                if (a[i] != c[i]) ans ++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    Scanner sc = new Scanner(in);
    int N = sc.nextInt();
    Integer C[] = new Integer[N-1];
    Integer S[] = new Integer[N-1];
    Integer F[] = new Integer[N-1];
    for(int i=0; i<N-1; i++){
      C[i] = sc.nextInt();
      S[i] = sc.nextInt();
      F[i] = sc.nextInt();
    }
    for(int i=0; i<N-1; i++){
      int ans = S[i] + C[i];
      for(int j=i+1; j<N-1; j++){
        if(ans <= S[j]) ans = S[j];
        else{
          while(ans % F[j] != 0) ans++;
        }
        ans += C[j];
      }
      out.println(ans);
    }
    out.println(0);
  }

  public static int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
  }
}

Measured memory_bytes: 26452
#include <stdio.h>

// 5%利子を加算
int plus_five_percent(int);
// 下三桁を取得
int get_three(int);
// 切り上げをするかどうか
int is_rounding_up(int);
// 切り上げ処理
int rounding_up(int);

int main(){
	int i, n, debt=100000;
	// 5% 加算 → 下3桁を確認 →
	// 下三桁が、1以上の場合は、切り上げ
	// 切り上げ = 3桁未満を引いてから1000円プラス
	scanf("%d", &n);

	for(i=0; i<n;i++){
		// 5%加算
		debt = plus_five_percent(debt);
		// 切り上げ処理
		debt = rounding_up(debt);
	}

	printf("%d\n", debt);

	return 0;
}

int plus_five_percent(int num){
	return num + num * 0.05;
}

int get_three(int num){
	return num % 1000;
}

int is_rounding_up(int num){
	return get_three(num) > 0;
}

int rounding_up(int num){
	// 下三桁を引いてから、1000足す
	if(is_rounding_up(num)){
		return num - get_three(num) + 1000;
	// 下三桁が0だったらそのまま
	} else {
		return num;
	}
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	if (a >= 13) { cout << b << '\n'; }
	else if(a>=6&&a<=12) { cout << b/2 << '\n'; }
	else { cout << 0 << '\n'; }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a,b,n,i,j,x,y;
	
	while(scanf("%d%d",&a,&b),a,b){
		int dp[20][20]={0};
		int koji[20][20]={0};
		
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d%d",&x,&y);
			koji[x][y]=1;
		}
		
		dp[0][1]=1;
		
		for(i=1;i<=a;i++){
			for(j=1;j<=b;j++){
				dp[i][j]=dp[i-1][j]+dp[i][j-1];
				if(koji[i][j]==1)dp[i][j]=0;
			}
		}
		printf("%d\n",dp[a][b]);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

vector<int> a, dp;

int main()
{
    int n, m;
    cin>>n>>m;
    a.resize(m);
    dp.resize(n+1, -1);
    REP(i,m) {
        cin>>a[i];
        dp[a[i]] = 0;
    }
    dp[0] = 1;
    dp[1] = dp[1] == 0 ? 0 : 1;
    REP(i,n-1) {
        if (dp[i+2] == 0)
            continue;
        dp[i+2] = dp[i];
        dp[i+2] += dp[i+1];
        dp[i+2] %= MOD;
    }
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 1024
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll a, b;
  cin >> a >> b;
  string as;
  string bs;
  rep(i, b){
    as += ('0'+a);
  }
  rep(i, a){
    bs += ('0'+b);
  }
  print(min(as, bs));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a; i < n; i++)
#define per(i,a,n) for (int i=n-1; i >= a; i--)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define pb push_back
#define mp make_pair
#define MOD 1000000007
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
using namespace std;
int main(){
    int n; cin >> n;
    int streak = 0;
    int f,s;
    rep(i, 0, n){
        cin >> f >> s;
        if (f== s) streak++;
        else streak = 0;
        if (streak == 3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <math.h>
int main(void){
  int N, K, point, amount;
  double prob=0.0;
  scanf("%d %d", &N, &K);
  for(int i=1; i<=N; i++){
    point = i;
    for(amount=0;point<K;amount++)
      point *= 2;
    prob += pow(0.5, amount)/N;
  }
  printf("%.16lf\n", prob);
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    lint K;
    cin >> N >> K;
    VEC(int) A(N);
    READVEC(A);

    VEC(int) Chain;
    map<int, int> pos;

    int offset = -1, cycle = -1;
    for(int p = 0, i = 0;;i++, p = A[p] - 1) {
        if (pos.find(p) != pos.end()) {
            offset = pos[p];
            cycle = i - pos[p];
            break;
        }

        pos[p] = i;
        Chain.push_back(p);
    }

    if (K < offset) {
        cout << 1 + Chain[(int)K] << endl;
    } else {
        K -= offset;
        K %= cycle;
        int p = Chain[offset + K];
        cout << 1 + p << endl;
    }

    return 0;
};

Measured memory_bytes: 13968
#include <stdio.h>

int n,a,b ;

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

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pii  = pair<int,int>;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define rep2(i,x,n) for(ll i=x; i<(n); i++)
#define MOD 1000000007
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
const double PI = 3.141593;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}    //最大公約数
ll lcm(ll a,ll b) {return a * b / gcd(a, b);}   //最小公倍数
ll combination(ll n, ll r) {
  if ( r * 2 > n ) r = n - r;
  ll dividend = 1;
  ll divisor  = 1;
  for ( ll i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int main(){
  string s;
  cin >> s;
  int len = s.length();
  int n = s.length() / 2;
  int ans = 0;
  rep(i, n)
  {
    if(s[i]!=s[len-1-i])
      ans++;
  }
  cout << ans << endl;
}

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

int main() {
    string s,t; cin >> s >> t;
    if(s[0] == t[2] && s[1] == t[1] && s[2] == t[0]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  
  int X = 0;
  if (a == b) X++;
  if (b == c) X++;
  if (c == a) X++;
  
  if (X == 1){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}

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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n,k;
	cin>>n>>k;
	ll res=k;
	for(int i=0;i<n-1;++i)
		res*=(k-1);
	cout<<res<<'\n';
}




Measured memory_bytes: 3656
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    e = LI()
    d = defaultdict(int)
    for i in e:
        d[i] += 1
    for i in d.values():
        if i != 2:
            print("no")
            break
    else:
        print("yes")
    return

#B
def B():
    n = I()
    a = LI()
    a.sort()
    ans = -float("inf")
    for c in range(n):
        for d in range(c):
            m = a[c]-a[d]
            for i in range(n)[::-1]:
                if i != c and i != d:
                    e = i
                    break
            for i in range(e)[::-1]:
                if i != c and i != d:
                    b = i
                    break
            ans = max(ans, (a[e]+a[b])/m)
    print(ans)
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    B()



Measured memory_bytes: 8316
#include <cstdio>
#include <algorithm>
using std::sort;
typedef struct {
	int num;
	int data;
} St;

int n;
St a[200005];

bool cmp(St &x, St &y)
{
	if (x.data > y.data)
		return 1;
	return 0;
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i].data);
		a[i].num = i;
	}
	sort(a, a + n, cmp);
	for (int i = 0; i < n; i++) {
		if (i == a[0].num) {
			printf("%d\n", a[1].data);
		} else {
			printf("%d\n", a[0].data);
		}
	}
	return 0;
}

Measured memory_bytes: 3072
#include<iostream>
using namespace std;
int main(){
    int m, f, r, p;
    
    while(1){
        cin >> m >> f >> r;
        
        p = m + f;
        
        if((m == -1) && (f == -1) && (r == -1)) break;
        
        if((m == -1) || (f == -1)){
            cout << "F" << endl;
        }
        
        else if(p >= 80){
            cout << "A" << endl;
        }
        
        else if((p < 80) && (p >= 65)){
            cout << "B" << endl;
        }
        
        else if((p < 65) && (p >= 50)){
            cout << "C" << endl;
        }
        
        else if((p < 50) && (p >= 30)){
            if(r >= 50){
                cout << "C" << endl;
            }else{
                cout << "D" << endl;
            }
        }
        
        else if(p < 30){
            cout << "F" << endl;
        }
    }
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    string s,t;
    cin >> s >> t;
    string tes;
    bool flag;
    int num = s.size()-t.size();
    for(int i=0;i<=num;i++){
        flag = true;
        tes = s.substr(num-i,t.size());
        for(int j=0;j<t.size();j++){
            if(tes[j]!=t[j]&&tes[j]!='?')flag = false;
        }
        if(flag){
            for(int k=0;k<s.size();){
                if(k==num-i){
                    cout << t;
                    k += t.size();
                }
                else{
                    if(s[k]=='?') cout << 'a';
                    else cout << s[k];
                    k++;
                }
            }
        cout << endl;
        return 0;
        }
    }
    COUT("UNRESTORABLE");
    return 0;
}

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

using namespace std;

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

    int n;
    string s;
    cin >> n >> s;

    vector<set<int>> b(26, set<int>());
    for (int i = 0; i < n; i++) {
        b[s[i] - 'a'].insert(i);
    }

    int q;
    cin >> q;

    for (int i = 0; i < q; i++) {
        int qi;
        cin >> qi;

        if (qi == 1) {
            int iq;
            char cq;
            cin >> iq >> cq;
            iq--;

            for (int j = 0; j < 26; j++) {
                b[j].erase(iq);
            }
            b[cq - 'a'].insert(iq);
        } else {
            int lq, rq;
            cin >> lq >> rq;
            lq--;
            rq--;

            int res = 0;
            for (int j = 0; j < 26; j++) {
                set<int>::iterator l = b[j].lower_bound(lq);
                set<int>::iterator r = b[j].upper_bound(rq);
                if (l != r) {
                    res++;
                }
            }

            cout << res << endl;
        }
    }
}


Measured memory_bytes: 26268
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<queue>
int main()
{
	int n,d;
	while(~scanf("%d%d",&n,&d))
	{
		int b=2*d+1;
		int total=0;
		total=n/(2*d+1);
		if(n%b>0)
		{
			total++;
		}
		printf("%d\n",total);
	}
}

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

int keta(long long n){
    int result = 0;
    
    while(n){
        n /= 10;
        result++;
    }
    return result;
}

int main(){
    long long n;
    cin >> n;
    
    int ans = 12;
    for (long long  i = 1; i <= pow(n, 0.5); i++){
        if (n % i == 0){
            long long b = n / i;
            
            //cout << i << b << endl;
            int delta_keta = max(keta(i), keta(b));
            
            ans = min(ans, delta_keta);
        }
    }
    cout << ans << endl;
}

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

int main()
{
    int n, k, *table, count{};
    scanf("%d%d", &n, &k);
    table = new int[n];
    std::fill(table, table + n, 0);
    for (int i = 0; i < n; i++)
    {
        int a;
        scanf("%d", &a);
        table[a - 1]++;
    }
    std::sort(table, table + n, [](const int& a, const int& b){ return a > b; });
    for (int i = k; i < n && table[i] != 0; i++)
        count += table[i];
    printf("%d\n", count);

    delete[] table;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
  int i,m;
  char h=0,s[4],w[7]={72,76,68,86,73,93,70};
  scanf("%s",&s);
  for(i=0;i<3;i++){
    h^=s[i];
  }
  for(i=0;i<7;i++){
    if(h==w[i]) break;
  }
  printf("%d",7-i);
  return(0);
}


Measured memory_bytes: 128
import math
n,d = map(int, input().split())
x = [0] * n
for i in range(n):
    x[i] = list(map(int, input().split()))
count = 0
for i in range(n-1):
    for j in range(i+1,n):
        temp = 0
        for k in range(d):
            temp = temp + (x[i][k]-x[j][k])**2
        temp = math.sqrt(temp)
        if temp.is_integer() == True:
            count += 1
print(count)

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;
using namespace std;

signed main() {
  ll n, ans = 0;
  cin>>n;
  vector<ll> p(n);
  rep(i,0,n)
    cin>>p[i];
  for (int i=1; i<n-1; i++) {
    vector<ll> v(3);
    v[0] = p[i-1];
    v[1] = p[i  ];
    v[2] = p[i+1];
    sort(begin(v), end(v));
    if (v[1] == p[i])
      ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <memory>
#include <algorithm>
#include <cstring>

using namespace std;


int main() {
    int n, k;
    cin >> n >> k;
    if (k == 1) {
        cout << 0;
        return 0;
    }
    cout << n - k;

    return 0;
}


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

int main() 
{
    int N;
    cin >> N;
    pair<int, int> A[N];
    for(int i = 0; i < N; ++i) {
        int tmp;
        cin >> tmp;
        A[i].first = tmp;
        A[i].second = i;
    }
    sort(A, A + N);
    sort(A, A + N,
        [](const pair<int, int> &x, const pair<int, int> &y) {
            return x.first < y.first;
        }
    );
    /*
    for(int i = 0; i < N; ++i) {
        cout << A[i].first << " " << A[i].second << endl;
    }
    */
    
    int ans[N];
    for(int i = 0; i < N; ++i) {
        if(i < N-1) {
            ans[A[i].second] = A[N-1].first;
        }
        else {
            ans[A[i].second] = A[N-2].first;
        }
    }
    for(int i = 0; i < N; ++i) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 5120