akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
const int MAX = 300005;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ll Pow(ll a , ll b){
	if(b == 0) return 1 ;
	ll c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c)% mod )) % mod ;
	return (c * c) % mod ;
}

//check modulo
int main(){
	IOS;
	cout.precision(50) ;
	int n ; cin >> n ;
	cout << Pow(n , 3) << endl; 
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  int n;
  char s[10010];
  cin >> n;
  cin >> s;
  int len = strlen(s);
  for(int i=0; i<len; i++){
    int x=s[i]-'A';
    x=(x+n)%26;
    putchar('A'+x);
  }
  cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
 
const int N = 100005;
 
int n, a[N];
 
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
         scanf("%d", a + i);
    sort(a + 1, a + n + 1);
    printf("%d ", a[n]);
    for (int i = 1; i < n; i++)
        if (a[i] + a[i + 1] >= a[n])
        {
             printf("%d ", a[i]);
             return 0;
        }
}

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

int main() {
    int N ,Q,l,r,sum;
    string S;
    cin >> N >> Q >> S;
    vector<int> vec(N);
    sum = 0;
    rep(i,N-1)
    {
        if (S.at(i) == 'A' && S.at(i+1) == 'C')
            sum += 1;
        vec.at(i) = sum;
    }

    rep(i,Q)
    {
        cin >> l >> r;
        if(l == 1)
        {
            if ( r == 1)
            cout << 0 << endl;
            else
            cout <<vec.at(r-2) << endl;
        }
        else
            cout << vec.at(r-2) - vec.at(l-2) << endl;        
    }
}

Measured memory_bytes: 1408
import sys
import numpy as np
from numba import njit


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

N,Q = map(int,input().split())

C=np.array(input().split(), int)

# Query取得-rightでソート
# dtypeQuery = [("index", int), ("start", int), ("end", int)]
queries=np.empty((Q,2),int)
# #rights=[[] for _ in range(N+1)]

for q in range(Q):
	l,r=map(int,input().split())
	#queries[q] = (q,l,r)
	queries[q][0] = l
	queries[q][1] = r
	#queries=np.sort(queries,order="end")

#queries=np.array(sys.stdin.buffer.read().split(),int).reshape(Q,2)

orderByR=np.argsort(queries[:,1])

# 各色の現在の一番右のindex
mostRightColorIndex = np.zeros(N+1, int)
# bit indexed tree
bitArray=np.zeros(N+1,int)

@njit
def main(N,Q,C,queries,orderByR,mostRightColorIndex,bitArray):

	def add(itemCount, items, i, value):
		while i <= itemCount:
			items[i] += value
			i += (i & (-i))

	def sumFromStart(items, end):
		summary = 0
		i = end
		while i > 0:
			summary += items[i]
			i -= (i & (-i))
		return summary

	def sum(items, start,end):
		summary = sumFromStart(items, end) - sumFromStart(items, start-1)
		return summary

	# 答え配列
	#ans=np.zeros(Q, int)
	ans=[0]*Q
	# 左からBITと現在色の更新をしながら、クエリのrightに到達したときにBITにクエリ発行する
	qindex = 0

	for n in range(N):
		# 外側のループでは、全部の色をループ

		if Q <= qindex:
			break

		if 0 < mostRightColorIndex[C[n]]:
			# ループ中の場所の色のindexが既にある場合(=過去に、同じ色が登録されていた場合)
			# 今回で、同じ色の一番右側の要素はループ中の要素になる
			# 前登録したこの色の一番右のindexを一度BITから抜く(↓で再度登録される)
			add(N,bitArray,mostRightColorIndex[C[n]], -1 )

		# この要素の色の一番右のindexを、BITに登録
		mostRightColorIndex[C[n]] = n+1
		add(N,bitArray,n+1, 1)

		# while qindex < Q and n+1 == queries[qindex][2]:
		while qindex < Q and n+1 == queries[orderByR[qindex]][1]:
			# 今のBITが次のクエリ発行するための状態(n==query.right)だったら、クエリ発行
			tmpIndex = orderByR[qindex]
			start = queries[tmpIndex][0]
			end = queries[tmpIndex][1]
			ans[tmpIndex]=sum(bitArray,start,end)
			# print(tmpIndex,start,end,ans[tmpIndex])
			qindex += 1

	return ans

for a in main(N,Q,C,queries,orderByR,mostRightColorIndex,bitArray):
	print(a)


Measured memory_bytes: 160800
#include<stdio.h>

long long abss(long long x){
	if(x < 0)
		return x*(-1);
	else
		return x;
}
int main(){
	long long  n,k;
	scanf("%lld %lld",&n,&k);
	
	if(n < k){
		if( n < abss(n - k))
			printf("%lld",n);
		else
			printf("%lld",abss(n-k));
	}else{
		if(n%k == 0)
			printf("0");
		else
			printf("%lld",(((n/k)+1)*k)-n);
	}
	
	return 0;
}

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



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

int main() {
   int N, K;
   cin >> N >> K;
   set<int> st;

   for(int i=0; i<K; i++) {
      int d;
      cin >> d;
      for(int j=0; j<d; j++) {
         int a;
         cin >> a;
         st.insert(a);
      }
   }

   int count = 0;

   for(int i=1; i<=N; i++) {
      bool b = false;
      for(auto x : st) {
         if(i == x) {
            b = false;
            break;
         }
         else {
            b = true;
         }
      }
      if(b == true) count++;
   }
   cout << count << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

const int N = 100;
int n, a[N], b[N], c[N], ans;

int main() {
	ios_base::sync_with_stdio(false);

	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) cin >> b[i];
	for(int i = 1; i < n; i++) cin >> c[i];

	ans += b[a[1]];
		for(int i = 2; i <= n; i++) {
			if(a[i - 1] + 1 == a[i])
				ans += c[a[i - 1]];
			ans += b[a[i]];
		}
	cout << ans << '\n';

}	


	

Measured memory_bytes: 256
// https://ynucpc.github.io/blog/2018/04/15/cp_vscode/
// http://www.atmarkit.co.jp/ait/articles/1509/08/news019.html

#include <bits/stdc++.h>
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;




int main(){
    int N;
    cin >> N;
    int P[N];
    rep(i, N)cin >> P[i];
    sort(P, P+N);
    ll ans = accumulate(P, P+N, 0);
    ans -= P[N-1]/2;
    cout << ans << endl;

}




Measured memory_bytes: 256
#if __has_include("noamoa_atcoder_lib.h")
#include "noamoa_atcoder_lib.h"
#else
#include <bits/stdc++.h>
#define endl '\n'
#define all(x) (x).begin(),(x).end()
namespace atcoder {
	using namespace std;
	using ll = long long;
	using intv = vector<int>;
	using charv = vector<char>;
	using boolv = vector<bool>;
	using floatv = vector<float>;
	using doublev = vector<double>;
	using stringv = vector<string>;

	constexpr ll MOD  = 1000000007;
    constexpr ll MOD9 = 1000000009;

	template<typename T>
	void sort(vector<T>& v){
		sort(all(v));
	}
	template<typename T>
	void sortInv(vector<T>& v){
		sort(all(v), greater<T>());
	}

	template<typename T>
	T sum(const vector<T>& v){
		T ret = 0;
		for(const auto& e : v) ret += e;
		return ret;
	}

	template<typename T>
	inline vector<T>& operator+=(vector<T>& v, const T& e){
		v.push_back(e);
		return v;
	}

	template<typename T>
	void in(vector<T>& v){
		for(auto& e : v) cin >> e;
	}

	template<typename T>
	istream& operator>>(istream &stream, vector<T>& v){
		for(auto& e : v) stream >> e;
		return stream;
	}

	template<typename T>
	void out(const vector<T>& v){
		for(const auto& e : v) cout << e << ' ';
		cout << endl;
	}

	template<typename T>
	void outln(const vector<T>& v){
		for(const auto& e : v) cout << e << endl;
	}

	void init(){
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}
using namespace atcoder;
#endif

int main(){
	init();
	string s;
	cin>>s;
	cout <<((s[0]=='7'|s[1]=='7'||s[2]=='7')?"Yes":"No");
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n; cin>>n;
	set<int> s;
	for(int i = 0 ; i < n ; i++)
	{
		int k; cin>>k;
		s.insert(k);
	}
		if(s.size()==n)
			cout<<"YES\n";
		else
			cout<<"NO\n";
	return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;

const int maxn = 1002;
const int maxs = 10002;

int n;
long long f[maxs<<1];

struct block
{
	int w, s, v;
};

bool mycmp(const block &a, const block &b) {
	return a.w + a.s < b.w + b.s;
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n;
	vector<block> data(n);

	for (int i = 0; i < n; ++i)
		cin >> data[i].w >> data[i].s >> data[i].v;

	sort(data.begin(), data.end(), mycmp);

	// for (int i = 0; i < n; ++i)
	// 	printf("%d %d %d\n", data[i].w, data[i].s, data[i].v);

	for (int i = 0; i < n; ++i)
		for (int j = min(data[i].s, 20000 - data[i].w); j >= 0; --j)
			f[j+data[i].w] = max(f[j+data[i].w], f[j] + data[i].v);

	long long ans = 0;
	for (int j = 1; j <= 20000; ++j)
		ans = max(ans, f[j]);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
pair<int,int> pos[3005];
#define ll long long
ll dp[3005];
const ll MOD=1e9+7;
ll inv[200005],po[200005];
ll C(int a,int b){
	if(b&&b!=a)return po[a]*inv[a-b]%MOD*inv[b]%MOD;
	else if(b==0||b==a) return 1;
	else return 0;
}
int main(){
	int h,w,n;
	cin>>h>>w>>n;
	for(int i=0;i<n;i++){
		scanf("%d %d",&pos[i].first,&pos[i].second);
		pos[i].first--;pos[i].second--;
	}
//	pos[n]=make_pair(0,0);
	pos[n]=make_pair(h-1,w-1);
	n+=1;
	sort(pos,pos+n);
	inv[1]=1;
	for(int i=2;i<200002;i++) inv[i]=(MOD-(inv[MOD%i]*(MOD/i)%MOD));
	for(int i=2;i<200002;i++) inv[i]=inv[i]*inv[i-1]%MOD;
	po[1]=1;
	for(int i=2;i<200002;i++) po[i]=po[i-1]*i%MOD;
//	dp[0]=1;
//	for(int i=0;i<n;i++) cout<<pos[i].first<<" "<<pos[i].second<<endl;
	for(int i=0;i<n;i++){
		dp[i]=C(pos[i].first+pos[i].second,pos[i].first);
	//	cout<<i<<" "<<dp[i]<<" "<<pos[i].first<<" "<<pos[i].second<<endl;
		for(int j=0;j<i;j++){
			if(i==j||pos[i].first<pos[j].first||pos[i].second<pos[j].second) continue;
			dp[i]-=dp[j]*C(pos[i].first-pos[j].first+pos[i].second-pos[j].second,pos[i].first-pos[j].first)%MOD;
//			cout<<"lala"<<dp[i]<<endl;
			if(dp[i]<0) dp[i]+=MOD;
		}
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 3456
//https://atcoder.jp/contests/abc162/tasks/abc162_e
//
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}

template<uint32_t M = 1000000007>
struct modint{
    using u64 = std::uint_fast64_t;
    u64 val;
    modint(): val(0){}
    template<typename T>
    modint(T t){t %= (T)M; if(t < 0) t += (T)M; val = t;}

    modint pow(ll k) const {
        modint res(1), x(val);
        while(k){
            if(k&1) res *= x;
            x *= x;
            k >>= 1;
        }
        return res;
    }
    static modint nCr(ll n, ll r){
        modint a(1),b(1);
        for(ll i=0;i<r;++i){
            a *= (n-i);
            b *= (i+1);
        }
        return a/b;
    }
    template<typename T>
    modint& operator=(T t){t %= (T)M; if(t < 0) t += (T)M; val = t; return *this;}
    modint inv() const {return pow(M-2);}
    modint& operator+=(modint a){val += a.val; if(val >= M) val -= M; return *this;}
    modint& operator-=(modint a){if(val < a.val) val += M-a.val; else val -= a.val; return *this;}
    modint& operator*=(modint a){val = (u64)val*a.val%M; return *this;}
    modint& operator/=(modint a){return (*this) *= a.inv();}
    modint operator+(modint a) const {return modint(val) +=a;}
    modint operator-(modint a) const {return modint(val) -=a;}
    modint operator*(modint a) const {return modint(val) *=a;}
    modint operator/(modint a) const {return modint(val) /=a;}
    modint operator-(){return modint(M-val);}
    bool operator==(const modint a) const {return val == a.val;}
    bool operator!=(const modint a) const {return val != a.val;}
    bool operator<(const modint a) const {return val < a.val;}
    constexpr u64 &value() noexcept { return val; }
    constexpr const u64 &value() const noexcept { return val; }
    friend ostream& operator<<(ostream& os, const modint& dt){
        os<<dt.val;
        return os;
    }
};
constexpr ll MOD=1e9+7;
using mint = modint<MOD>;

int main() {
#if LOCAL&01
  std::ifstream in("./test/sample-1.in");
  //std::ifstream in("./input.txt");
  std::cin.rdbuf(in.rdbuf());
#else
  cin.tie(0);
  ios::sync_with_stdio(false);
#endif
  ll N,K; cin>>N>>K;
  vector<mint> nums = vector<mint>(K+1);
  mint ans=0;
  for(ll i=K;i>=1;--i){
    ll n=K/i;
    mint mul = n;
    mul = mul.pow(N);
    ll j=2;
    do{
      ll jxi=j*i;
      if(jxi>K){
        break;
      }else{
        mul -= nums.at(jxi);
      }
      ++j;      
    }while(true);
    nums.at(i) = mul; //何個か
    ans += mul * mint(i);
  }
  cout<<ans<<endl;
  return 0;
}

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

vector<ll> leg(100, 0), acc(100, 0);
ll one[6] = {0, 0, 1, 2, 3, 3};

ll dfs(ll x, ll i){
    if(i == 1) return one[x];
    if(x == 1) return 0;
    if(x == 2 + leg[i-1]) return acc[i-1] + 1;
    if(x == 3 + 2 * leg[i-1]) return  2*acc[i-1] + 1;
    if(x < 2 + leg[i-1]) return dfs(x-1, i-1);
    if(x > 2 + leg[i-1]) return dfs(x-leg[i-1]-2, i-1) + acc[i-1] + 1;
}

int main(){
    ll N, X;
    cin >> N >> X;
    acc[1] = 3;
    leg[1] = 5;
    rep(i, 2, N+1){
        leg[i] = 3 + 2 * leg[i-1];
        acc[i] = 1 + 2 * acc[i-1];
    }
    cout << dfs(X, N) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<numeric>
#include<vector>
#include<cstdio>
#include<climits>
#include<cfloat>
#include<cstring>
#define foreach(t,p,tit) for(t::iterator tit=p.begin();tit!=p.end();++tit)
#define rforeach(t,p) for(t::reverse_iterator it=p.rbegin();it!=p.rend();++it)
#define all(p) p.begin(),p.end()
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int costs[1010][1010];
int times[1010][1010];
int d[1010];
#define INF 10000
struct E
{
    int a,b,c;
    E(){};
    E(int a,int b,int c):a(a),b(b),c(c){};
};
#define MONEY 0
#define EKI 1

int main()
{
    int n,m;
    while(cin>>n>>m)
    {
        if(n==0&&m==0)break;
        memset(costs,INF,sizeof(costs));
        memset(times,INF,sizeof(times));
        vector<E> cs;
        vector<E> ts;
        int a,b,c,t;
        rep(i,n)
        {
            cin>>a>>b>>c>>t;
            costs[a][b] = c; costs[b][a] = c;
            times[a][b] = t; times[b][a] = t;
            cs.push_back(E(a,b,c));
            cs.push_back(E(b,a,c));
            ts.push_back(E(a,b,t));
            ts.push_back(E(b,a,t));
        }
        rep(i,m)
        {
            costs[i][i] = 0;
            times[i][i] = 0;
        }
        int k,p,q,r;
        cin>>k;
        rep(i,k)
        {
            memset(d,INF,sizeof(d));
            cin >> p >> q >> r;
            d[p] = 0;
            if(r==MONEY)
            {
                //rep(j,n*2){if(cs[j].a == p) d[cs[j].b] = cs[j].c;}
                while(true)
                {
                    bool update = false;
                    rep(j,n*2)
                    {
                        //cout <<"edge"<< j<<cs[j].a<<"to"<<cs[j].b << endl;

                        if( (d[ cs[j].a] != INF) && d[cs[j].b] > d[cs[j].a] + cs[j].c)
                        {
                            d[cs[j].b] = d[ cs[j].a] + cs[j].c;
                            update = true;
                            //cout << "updated" <<d[cs[j].b] <<endl;
                        }
                    }
                    if(!update)break;
                }
                cout << d[q]<<endl;
            }
            else
            {
                //rep(j,n*2){if(ts[j].a == p) d[ts[j].b] = ts[j].c;}
                while(true)
                {
                    bool update = false;
                    rep(j,n*2)
                    {
                        if(d[ ts[j].a] != INF && d[ts[j].b] > d[ts[j].a] + ts[j].c)
                        {
                            d[ts[j].b] = d[ ts[j].a] + ts[j].c;
                            update = true;
                        }
                    }
                    if(!update)break;
                }
                cout << d[q]<<endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 0
[n, x] = list(map(int, input().strip().split(" ")))
a = list(map(int, input().strip().split(" ")))
sa = [0] * (n + 1)
sa[0] = 0

def calc(num):
    res = 0
    k = 0
    now = n - 1
    while (now >= 0):
        right = now
        left = max(0, now - num + 1)
        if (k == 0):
            res += 5 * (sa[right + 1] - sa[left])
        else:
            res += (2 * k + 3) * (sa[right + 1] - sa[left])
        k += 1
        now -= num
    return res + x * (num + n)

for i in range(n):
    sa[i+1] = sa[i]+a[i]

ans = 1000000000000000000000000000000000
for i in range(n):
    ans = min(ans, calc(i+1))

print(ans)

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

int main() {
    long long deposit = 100;
    long long x;
    cin >> x;
    int ans = 0;
    while (deposit < x) {
        ans++;
        deposit += deposit / 100;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
n = int(input())
h = list(map(int, input().split()))

dp = [0]*n
dp[1] = abs(h[1]-h[0])
for i in range(2, n):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])

Measured memory_bytes: 13980
#include<bits/stdc++.h>
using namespace std;
// int S[200000];
struct opt{
	int x,a,b,c,dbg;
	opt(int x=0,int a=0,int b=0,int c=0,int dbg=1):x(x),a(a),b(b),c(c),dbg(dbg){}
	void output(){
		if(x==0){
			if(dbg)cout << '+' << " " << a << " " << b << " " << c << endl;
			// if(dbg)cout << S[a] << " " << S[b] << endl;
			// S[c] = S[a] + S[b];
			// if(dbg)cout << S[c] << endl;
		}else{
			if(dbg)cout << "< " << a << " " << b << " " << c << endl;
			// if(dbg)cout << S[a] << " " << S[b] << endl;
			// S[c] = S[a] < S[b];
			// if(dbg)cout << S[c] << endl;
		}
	}
};
vector<opt> op;
void output(){
	cout << op.size() << endl;
	for(int i=0;i<(int)op.size();i++)op[i].output();
}
 
inline void rpt(int x,int y){
	for(int j=0;j<y;j++)op.push_back(opt(0,x,x,x));
}
 
int pw[64];
int g[128];
 
int main()
{
	// cin >> S[0] >> S[1];
	pw[0]=200000-1;
	op.push_back(opt(1,pw[0],1,pw[0]));
	op.push_back(opt(0,pw[0],0,0));
	op.push_back(opt(0,pw[0],1,1));
	for(int i=1;i<64;i++){
		pw[i] = pw[i-1] - 1;
		op.push_back(opt(0,pw[i-1],pw[i-1],pw[i]));
	}
	int pos0=pw[63]-1;
	g[0]=9;for(int i=1;i<128;i++)g[i]=g[i-1]+1;
	int po2=3,po3=4;
	int po4=5,po5=6;
	// op.push_back(opt(1,pos1,po2,po2));
	for(int i=63;~i;i--){
		op.push_back(opt(0,po2,pw[i],po3));
		
		op.push_back(opt(1,pos0,pos0,po4));//clear 0
		for(int j=63;~j;j--){
			op.push_back(opt(0,po4,pw[j],po5));
			op.push_back(opt(1,po3,0,7));op.push_back(opt(1,7,pw[0],7));
			op.push_back(opt(1,po5,1,8));op.push_back(opt(1,8,pw[0],8));
			op.push_back(opt(1,7,pw[0],7));
			op.push_back(opt(1,8,7,8));
			// for(int k=0;k<i+j;k++){
			// 	op.push_back(opt(0,8,8,8));
			// }
			op.push_back(opt(0,8,g[i+j],g[i+j]));
 
			op.push_back(opt(1,po5,1,po5));
			for(int k=0;k<j;k++){
				op.push_back(opt(0,po5,po5,po5));
			}
			op.push_back(opt(0,po5,po4,po4));
		}
		op.push_back(opt(1,po3,0,po3));
		for(int j=0;j<i;j++){
			op.push_back(opt(0,po3,po3,po3));
		}
		op.push_back(opt(0,po3,po2,po2));
	}
	for(int i=0;i<128;i++){
		for(int j=0;j<i;j++){
			op.push_back(opt(0,g[i],g[i],g[i]));
		}
		op.push_back(opt(0,g[i],2,2));
	}
	output();
	// cout << S[2] << endl;
}

Measured memory_bytes: 8276
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

std::map<ll, ll> prime_factor( ll x )
{
  std::map<ll, ll> ret;

  for( ll i = 2; i*i <= x; ++i )
  {
    while( x%i == 0 )
    {
      ++ret[i];
      x /= i;
    }
  }

  if( x != 1 )
    ++ret[x];

  return ret;
}

ll N;

ll upp( ll x )
{
  ll p = 1;

  while( p*(p+1)/2 < x )
    ++p;

  if( p*(p+1)/2 > x )
    --p;

  return p;
}

ll ans;

int main()
{
  std::cin >> N;

  auto ps = prime_factor(N);

  itr( it, ps )
    ans += upp( it->second );

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define rep0(i, n) for(int i=0; i<(int)(n);i++)
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n],mi = INT_MAX,mc = 0;
    long long sum = 0, ans;
    rep0(i,n)
    {
        cin >> a[i];
        mi = min(mi, abs(a[i]));
        if(a[i]<0)mc ++;
        sum += abs(a[i]);
    }
    cout << sum-(mc%2?mi*2:0) << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
const int mod=1e9+7;

int main() {
  int n;
  cin>>n;
  vector<int>ans(100005);
  for(int x=1;x<=100;x++){
    for(int y=1;y<=100;y++){
      for(int z=1;z<=100;z++){
        int s=x*x+y*y+z*z+x*y+y*z+z*x;
        ans[s]++;
      }
    }
  }
  for(int i=1;i<=n;i++){
    cout<<ans[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3684
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

int n, pos;
vector<int> pre, in, post;

void rec(int l, int r)
{
    if(l>=r) return;
    int root = pre[pos++];
    int m = distance(in.begin(), find(in.begin(), in.end(), root));
    rec(l, m);
    rec(m+1, r);
    post.push_back(root);
}
void solve()
{
    pos = 0;
    rec(0, n);
    for(int i=0; i<n; i++)
    {
        if(i) cout << " ";
        cout << post[i];
    }
    cout << endl;
}
int main()
{
    cin >> n;
    int s1, s2;
    for(int i=0; i<n; i++)
    {
        cin >> s1;
        pre.push_back(s1);
    }
    for(int i=0; i<n; i++)
    {
        cin >> s2;
        in.push_back(s2);
    }
    solve();
    return 0;
}



Measured memory_bytes: 3160
#include "bits/stdc++.h"
using namespace std;

int main(){
	string s;
	int m;
	map<string,int> mp;
	while(cin>>s){
		mp[s]++;
		int asd=s.size();
		m=max(m,asd);
	}
	
	int x=0;
	
	for(auto &el:mp){
		if(x<el.second){
			x=el.second;
		}
	}
	
	for(auto &el:mp){
		if(x==el.second){
			cout<<el.first<<" ";
			break;
		}
	}
	
	for(auto &el:mp){
		if(m==el.first.size()){
			cout<<el.first<<endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3204
#include <iostream>

using namespace std;

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

   if(a > b){ t=a; a=b; b=t;}
   if(b > c){ t=b; b=c; c=t;}
   if(a > b){ t=a; a=b; b=t;}

   cout << a << " " << b << " " << c << endl;

   return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

using Graph = vector<vector<int>>;
Graph G;

vector<int> a, b;
int deg = 0;

using P = pair<int, int>;
map<P, int> m;

void dfs(int v, int p, int c){
    int nec = 1;
    for(auto nv: G[v]){
        if(nv == p) continue;
        if(nec == c) nec++;
        m[P{v, nv}] = nec;
        dfs(nv, v, nec);
        nec++;
    }
}



int main(){
    int n;
    cin >> n;
    G.assign(n+1, vector<int>());
    a.resize(n-1);
    b.resize(n-1);
    rep(i, n-1){
        int x, y;
        cin >> x >> y;
        a[i] = x;
        b[i] = y;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    rep(i, n+1) chmax(deg, (int)G[i].size());

    dfs(1, -1, 0);

    cout << deg << endl;
    rep(i, n-1){
        cout << m[P{a[i], b[i]}] << endl;
    }

}

Measured memory_bytes: 14980
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int main(){
  bool ans=true;
  int a, b, i;
  string s;
  rd(a);
  rd(b);
  cin >> s;
  for(i=0;i<a;i++){
    if (!isdigit(s[i])){
      ans = false;
    }
  }
  if (s[a] != '-'){
    ans = false;
  }
  for(i=0;i<b;i++){
    if (!isdigit(s[a+1+i])){
      ans = false;
    }
  }
  wt_L(ans?"Yes":"No");
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20170910-1

// --- original code ---
// {
//   int a, b;
//   rd(a,b);
//   string s;
//   cin >> s;
//   bool ans = true;
//   rep(i,a) {
//     if (!isdigit(s[i])) ans = false;
//   }
//   if (s[a] != '-') ans = false;
//   rep(i,b) {
//     if (!isdigit(s[a+1+i])) ans = false;
//   }
//   wt(ans?"Yes":"No");
// }

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

#define int long long 

template<class T> inline void read(T& ans){
    int f = 1; char c = getchar(); ans=0;
    while(c < '0' || c > '9')
        if(c == '-') f = -1, c = getchar();
    while('0' <= c && c <= '9')
        ans = (ans << 1) + (ans << 3) + (c ^ 48), c = getchar();
    ans = ans * f;
}

struct point{
	int x, y, t;
};

point mp(int x, int y, int t){//make_point
	point ret;
	ret.x = x, ret.y = y, ret.t = t;
	return ret;
}

bool ok(point a, point b){
	int dis = abs(a.x - b.x) + abs(a.y - b.y), tim = abs(a.t - b.t);
	if(tim >= dis && (tim - dis) % 2 == 0)return true;
	return false;
}
vector<point> v;
int n;
signed main(){
	read(n);

	v.push_back(mp(0,0,0));
	for (int i = 1; i <= n; i += 1){
		int x, y, t;
		read(t), read(x), read(y);
		v.push_back(mp(x,y,t));
	}
	
	puts("");
	bool ans = 1;
	for(int i = 1; i < v.size(); i++){
		ans = ans && ok(v[i], v[i-1]);
//		printf("%d\n", ok(v[i], v[i-1]));
	}
	puts(ans ? "Yes" : "No");
	return 0;
}












Measured memory_bytes: 4852
#require 'pp'
#require 'set'

n, k = gets.chomp!.split(" ").map(&:to_i)
h_n = []
n.times do |i|
    h_n[i] = gets.to_i
end
h_n.sort!

#pp h_n

min = 10 ** 20

head = 0
tail = k - 1

(n - k + 1).times do |i|
    diff = h_n[tail + i] - h_n[head + i]
    #pp diff
    if diff < min
        min = diff
    end
end

puts min


Measured memory_bytes: 3908
#include <cstdio>
#include <string>
#include <queue>
#include <iostream>
using namespace std;

int main() {
    string S;
    priority_queue<int> PQ;
    while(1) {
        cin >> S;
        if (S.at(0) == 'i') {
            int key; cin >> key;
            PQ.push(key);
        } else if (S.at(1) == 'x') {
            cout << PQ.top() << endl;
            PQ.pop();
        } else if (S.at(0) == 'e') {
            break;
        }
    }
}


Measured memory_bytes: 6872
// 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() {
    string t;
    cin >> t;

    int n = t.size();
    rep(i, n) {
        if (t[i] == '?') t[i] = 'D';
    }
    cout << t << "\n";
    return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

struct UnionFind {
	vector<int> par;
	vector<int> rank;
	
	UnionFind() {}
	UnionFind(int n) {
		init(n);
	}
	
	int operator[] (int x) {
		return find(x);
	}

	void init(int n) {
		par.resize(n);
		rank.resize(n);
		REP(i, n) {
			par[i] = i;
			rank[i] = 0;
		}
	}

	int find(int x) {
		if (par[x] == x) return x;
		return par[x] = find(par[x]);
	}

	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;

		if (rank[x] < rank[y]) {
			par[x] = y;
		} else {
			par[y] = x;
			if (rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

int N;
int x[112345], y[112345];

int main() {
	cin >> N;
	REP(i, N) scanf("%d %d", x + i, y + i);
	
	set<pii> ss;
	REP(i, N) ss.insert(pii(x[i], y[i]));
	
	vector<pii> v;
	for (set<pii>::iterator it = ss.begin(); it != ss.end(); ++it)
		v.push_back(*it);
	
	vector<pii> x, y;
	REP(i, v.size()) {
		x.push_back(pii(v[i].fi, i));
		y.push_back(pii(v[i].se, i));
	}
	sort(ALL(x));
	sort(ALL(y));
	
	priority_queue<P, vector<P>, greater<P> > pq;
	REP(i, x.size() - 1) pq.push(P(abs(x[i + 1].fi - x[i].fi), pii(x[i + 1].se, x[i].se)));
	REP(i, y.size() - 1) pq.push(P(abs(y[i + 1].fi - y[i].fi), pii(y[i + 1].se, y[i].se)));
	
	ll ans = 0;
	
	UnionFind uf(N);
	while (!pq.empty()) {
		int p = pq.top().se.fi;
		int q = pq.top().se.se;
		pq.pop();
		
		if (uf.same(p, q)) continue;
		ans += min(abs(v[p].fi - v[q].fi), abs(v[p].se - v[q].se));
		uf.unite(p, q);
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 17044
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vector<vi>
#define vll vector<ll>
#define vvll vector<vll>
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define sf(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define sff(a,b) scanf("%d%d",&a,&b);
#define sfffl(a,b) scanf("%lld%lld",&a,&b);
#define nwln() printf("\n");
#define prd(a) printf("%d",a);
#define prld(a) printf("%lld",a);
#define space printf(" ");
#define ft cout<<"for test"<<endl;
#define read(v) for(auto &it:v)cin>>it;
#define PI 2*acos(0.0)
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main()
{
    FIO;
    int n,k,i,j;
    cin>>n>>k;
    int d;
    vi v(n+1);
    while(k--)
    {
        cin>>d;
        while(d--)
        {
            cin>>j;
            v[j]=1;
        }
    }
    int gd=0;
    for(i=1; i<=n; i++)
        if(!v[i])gd++;
    cout<<gd<<endl;
}


Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int ary[4];
	for(int i = 0; i < 4; i++){
		cin >> ary[i];
	}
	sort(ary , ary + 4 , greater<int>());
	if(ary[0] == ary[1] && ary[2] == ary[3]){
		cout << "yes" << endl;
	}else{
		cout << "no" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
 #define ll long long
 #define int long long
 #define MOD  1000000007
 #define MAX 500005
 #include<iomanip>
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define x first
 #define y second
using namespace std;
 int power(int x, unsigned int y, int p)
 {
     int res = 1;      // Initialize result
   
     x = x % p;  // Update x if it is more than or
                 // equal to p
   
     while (y > 0)
     {
         // If y is odd, multiply x with result
         if (y & 1)
             res = (res*x) % p;
   
         // y must be even now
         y = y>>1; // y = y/2
         x = (x*x) % p;
     }
     return res;
 }
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
ll arr[1000004];
void spf(ll num)
{
    fore(i,0,num+1)arr[i]=i;
    for(ll i=2;i<=num;i+=2)
    {
        arr[i]=2;
    }
    for(ll i=3;i<=num;i+=2)
    {
        if(arr[i]==i)
        for(ll j=i;j<=num;j+=i)
        {
           if(arr[j]==j) arr[j]=i;
        }
    }
}
void PrintSPF(ll num)
{
    while(num!=1)
    {
        cout<<arr[num]<<" ";
        num/=arr[num];
    }
}
int modInverse(int a, int m)
{
    int g = gcd(a, m);
    
        
    
    {
        return power(a, m-2, m);
    }
}
 int32_t main()
{
    Need_for_speed(activated);
//    satisfy
//    {}
   
    char a;
    cin>>a;
    cout<<char(a+1);
    return 0;
    }


Measured memory_bytes: 256
module Main where

import qualified Data.Vector as V
import           Data.List
import           Control.Applicative
import           Control.Monad

main :: IO ()
main = do
  [h, w] <- map read . words <$> getLine
  ss <- replicateM h $ getLine
  putStrLn . init $ f ss [(i, j) | j <- [0 .. h - 1], i <- [0 .. w - 1]] h w

f _ [] _ _ = ""
f ss (i:is) h w
  | (ss !! snd i) !! fst i == '#' = "#"
    ++ (if fst i == w - 1
        then "\n"
        else "")
    ++ f ss is h w
  | otherwise = show
    (length
     $ filter (== True)
     $ map
       (\i -> (ss !! snd i) !! fst i == '#')
       [(fst i + x, snd i + y)
       | x <- [-1, 0, 1]
       , y <- [-1, 0, 1]
       , fst i + x >= 0 && fst i + x < w
       , snd i + y >= 0 && snd i + y < h])
    ++ (if fst i == w - 1
        then "\n"
        else "")
    ++ f ss is h w


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

using namespace std;

#define pb push_back
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

const double eps = 1e-10;
const int MOD = 1000000007;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, s.size()) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int digit(int n) {
  int cnt = 0;
  while(n > 0) {
    n /= 10;
    cnt++;
  }
  return cnt;
}

int pow(int a, int b) {
  int ans = 1;
  REP(i, b) {
    ans *= a;
  }
  return ans;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int q; cin >> q;
  REP(i, q) {
    int r; cin >> r;
    map<int, bool> sel;
    int next = r;
    int cnt = 0;
    while(1) {
      if(sel[next]) {
        cout << -1 << endl;
        break;
      }
      if(next / 10 == 0) {
        cout << cnt << endl;
        break;
      }
      sel[next] = true;
      int ma = 0;
      FOR(i, 1, digit(next)) {
        ma = max(ma, (next / pow(10, i)) * (next % pow(10, i)));
      }
      next = ma;
      cnt++;
    }
  }  
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define ps puts("")
#define fi first
#define nd second
#define mset(x) memset((x), 0, sizeof (x))
#define mk make_pair
#define sqr(x) ((x)*(x))
#define pii pair<int,int>
#define lch (o<<1)
#define rch (o<<1|1)
using namespace std;
typedef long long ll;
ll read() {ll x = 0;char f = 1, ch = getchar();while(ch < '0' || ch > '9') {if(ch == '-')f = -1;
ch = getchar();}while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0';ch = getchar();}return x * f;}
void write(ll x) {if(x < 0) x = -x, putchar('-');if(x > 9) write(x / 10);putchar(x % 10 + '0');}
inline void writeln(ll x) {write(x);puts("");}
const int N = 600000;
ll a[600][600], n, m;
ll x[N], y[N], tot, ans, t;
ll tox[N], toy[N];
bool vis[600][600];
int main() {
	n = read(), m = read();
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
			a[i][j] = read() & 1, ans += a[i][j];
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j < m; ++j)
			if(a[i][j] & 1) {
				x[++tot] = i;
				y[tot] = j;
				tox[tot] = i;
				toy[tot] = j + 1;
				a[i][j] ^= 1;
				a[i][j + 1] ^= 1;
			} 
	}
	for(int i = 1; i < n; ++i)
		if(a[i][m] & 1) {
			x[++tot] = i;
			y[tot] = m;
			tox[tot] = i + 1;
			toy[tot] = m;
			a[i][m] ^= 1;
			a[i +1][m] ^= 1;
		}
	writeln(tot);
	for(int i = 1; i <= tot; ++i)
		printf("%d %d %d %d\n", x[i], y[i], tox[i], toy[i]);
	return 0;
}

Measured memory_bytes: 14336
#include <iostream>
#include <vector>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < (n); ++(i))
using namespace std;
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
int main() {
    int n; cin >> n;
    if (n == 2) {
        cout << -1 << endl;
    } else {
        vector<vector<int> > f = vectors(n, n-1, int());
        repeat (i,n) repeat (j,n-1) f[i][j] = (i+j+1)%n;
        // swap
        if (n%2 == 0) {
            int k = n/2;
            repeat_from (j,k,n) {
                swap(f[j][k-1], f[j][k]);
            }
        }
        // output
        repeat (i,n) {
            repeat (j,n-1) {
                if (j) cout << ' ';
                cout << f[i][j]+1;
            }
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }



main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t, d, s;
    cin >> d >> t >> s;
    double T = (ld) d / s;
    if (T <= t) {
        cout << "Yes\n";
    }
    else cout << "No\n";
}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

void solve(void){
    int maze[3][3];
    rep(3, i) rep(3, j) scanf("%d\n", &maze[i][j]);
    int d1 = maze[0][0] - maze[0][1], d2 = maze[0][1] - maze[0][2];
    rep(2, j) {
        if (maze[1+j][0] - maze[1+j][1] != d1 || maze[1+j][1] - maze[1+j][2] != d2) {
            cout << "No" << endl;
            return;
        }
    }
    d1 = maze[0][0] - maze[1][0], d2 = maze[1][0] - maze[2][0];
    rep(2, i) {
        if (maze[0][i+1] - maze[1][i+1] != d1 || maze[1][i+1] - maze[2][i+1] != d2) {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashSet<Integer> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            set.add(sc.nextInt());
        }
        System.out.println(set.size());
    }
}


Measured memory_bytes: 73200
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()-1

ans=[]
while n>=0:
  ans.append(chr(ord('a')+n%26))
  n//=26
  n-=1
print(''.join(ans[::-1]))

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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0;i<n;i++) cin >> v[i];
    sort(v.begin(),v.end(),greater<int>());
    priority_queue<array<int,3>> q;
    q.push({v[0],v[0],v[0]});
    ll res=0;
    for(int i=1;i<n;i++)
    {
        int c=v[i];
        auto [x,a,b]=q.top();
        q.pop();
        res+=x;
        q.push({min(a,c),a,c});
        q.push({min(b,c),b,c});
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 7164
from collections import deque
H,W = map(int,input().split())
S = [input().strip() for _ in range(H)]
cnt = 0
for i in range(H):
    for j in range(W):
        if S[i][j]==".":
            cnt += 1
dist = [[-1 for _ in range(W)] for _ in range(H)]
que = deque([(0,0,0)])
dist[0][0] = 0
while que:
    i,j,d = que.popleft()
    if j+1<W and dist[i][j+1]<0 and S[i][j+1]==".":
        que.append((i,j+1,d+1))
        dist[i][j+1]=d+1
    if i-1>=0 and dist[i-1][j]<0 and S[i-1][j]==".":
        que.append((i-1,j,d+1))
        dist[i-1][j]=d+1
    if j-1>=0 and dist[i][j-1]<0 and S[i][j-1]==".":
        que.append((i,j-1,d+1))
        dist[i][j-1]=d+1
    if i+1<H and dist[i+1][j]<0 and S[i+1][j]==".":
        que.append((i+1,j,d+1))
        dist[i+1][j]=d+1
x = dist[H-1][W-1]
if x<0:
    print(-1)
else:
    print(cnt-1-x)

Measured memory_bytes: 40304
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> A(N+1);
    for(int i=1; i<=N; i++) cin >> A[i];
    map<int,int> mp;
    ll ans = 0;
    for(int i=1; i<=N; i++){
        ans += mp[i-A[i]];
        mp[A[i]+i]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 21068