akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int INF = 1e9;

const int N = 1e5;
vector<int> adj[N];
vector<int> dp(N, -1);

int rec(int v) {
    if (dp[v] != -1) return dp[v];
    int ans = 0;
    for (int u : adj[v])
        ans = max(ans, rec(u) + 1);
    dp[v] = ans;
    return ans;
}

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

    int n, m;
    cin >> n >> m;
    
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        adj[a - 1].push_back(b - 1);
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
        ans = max(ans, rec(i));
    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 11012
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    
    vector<ll> a(n);
    REP(i,n) {
        cin >> a[i];
        a[i] -= i+1;
    }
    sort(ALL(a));
    int b = (n%2==1 ? a[n/2] : (a[n/2]+a[n/2-1])/2);
    ll ans = 0;
    REP(i,n) ans += abs(a[i]-b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    ll n, m; cin >> n >> m;

    vector<ll> cd(1002003,-1);

    ll it = 0;
    ll num = 1;

    while(num * num <= m){

        if(m%num == 0){
            cd[it] = num;
            it++;
            if(num != m/num){
                cd[it] = m/num;
                it++;
            }
        }

        num++;
    }


    ll ans = 1;

    rep(i,it){

        if(cd[i] * n <= m){
            ans = max(ans,cd[i]);
        }

    }

    cout << ans << endl;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1000000000;

int N, C;
vector<vector<int>> D, c, cnt;

ll dist(int c0, int c1, int c2) {
  ll sum = 0;
  for (int i = 1; i <= C; i++) {
    sum += D[i][c0] * cnt[0][i];
  }

  for (int i = 1; i <= C; i++) {
    sum += D[i][c1] * cnt[1][i];
  }

  for (int i = 1; i <= C; i++) {
    sum += D[i][c2] * cnt[2][i];
  }

  return sum;
}

void abc099d() {
  if (N == 1) {
    cout << "0\n";
    return;
  }
  else {
    ll ans = INF;
    for (int p = 1; p <= C; p++) {
      for (int q = 1; q <= C; q++) {
        for (int r = 1; r <= C; r++) {
          if (p == q || q == r || r == p) {
            continue;
          }
          else {
            ans = (ans < dist(p, q, r)) ? ans : dist(p, q, r);
          }
        }
      }
    }
    cout << ans << '\n';
    return;
  }
}

int main() {
  cin >> N >> C;
  D.resize(C + 1);
  c.resize(N + 1);
  cnt.resize(3);
  for (int i = 1; i <= C; i++) {
    D[i].resize(C + 1, 0);
  }
  for (int i = 1; i <= N; i++) {
    c[i].resize(N + 1, 0);
  }

  for (int i = 0; i < 3; i++) {
    cnt[i].resize(C + 1, 0);
  }

  for (int i = 1; i <= C; i++) {
    for (int j = 1; j <= C; j++) {
      cin >> D[i][j];
    }
  }

  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      cin >> c[i][j];
      cnt[(i + j) % 3][c[i][j]]++;
    }
  }
  abc099d();
  return 0;
}

Measured memory_bytes: 1280
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iterator>
#include <random>
#include <cassert>
#include <iomanip>
#define FOR(i, a, b) for(int (i)=(a);(i)<(b);++(i))
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cout<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef vector<int> vi;
typedef vector<lint> vl;
typedef vector<char> vc;
typedef vector<vector<int>> vii;
typedef vector<vector<lint>> vll;
typedef vector<vector<char>> vcc;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}
const double EPS = 1e-10;
const double PI = acos(-1);

class ASumOfTwoIntegers {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        in>>N;
        out<<(N-1)/2<<'\n';
    }
};


int main() {
	ASumOfTwoIntegers solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef set<ll> sll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll a, b, _gcd, i, j;
	vll cop;
	sll div;
	cin >> a >> b;
	_gcd = gcd(a, b);
	for (i = 1; i * i <= _gcd; i++) {
		if (_gcd % i == 0) {
			div.insert(i);
			div.insert(_gcd / i);
		}
	}
	for (auto it = div.begin(); it != div.end(); it++) {
		i = (*it);
		for (j = 1; j < cop.size(); j++) {
			if (i % cop[j] == 0) {
				i = 0;
				break;
			}
		}
		if (i > 0)
			cop.push_back(i);
	}
	cout << cop.size() << "\n";
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>

using namespace std;

int main()
{
	// スペース区切りの整数の入力
	string in;
	cin >> in;
	int cnt = 0;
	for (int i = 1; i <= stoi( in ); ++i) {
		int keta = to_string( i ).length() % 2;
		if (keta != 0 ){
			++cnt;
		}
	}
	// 出力
	cout << cnt;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pl(s) cout << (s) << "\n";
#define pls(...) {bool space = false; for(auto i : __VA_ARGS__) (cout << (space?" ":"") << i), space = true; cout << "\n";}
#define plexit(s) {cout << (s) << "\n"; exit(0);}
#define yes(s) cout << ((s)?"Yes":"No") << "\n";
#ifdef __LOCAL
#include <dump.hpp>
#define dump(...) DUMPOUT << "  " << string(#__VA_ARGS__) << ": " << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl << "    ", dump_func(__VA_ARGS__)
#else
#define dump(...)
#endif
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct IOInit { IOInit() { cin.tie(nullptr); ios::sync_with_stdio(false); dump("READY"); /*cout << unitbuf;*/} } IO_INIT;
using ll = long long; using ull = unsigned long long; using ld = long double;
template<typename T = int> using V = vector<T>; template<typename T = int> using P = pair<T, T>;
using Vi = V<int>; using Vl = V<ll>; using Vd = V<ld>; using VVi = V<Vi>; using VVl = V<Vl>; using Pi = P<int>; using Pl = P<ll>; using Pd = P<ld>;
constexpr ll MOD = 1000000007; constexpr int INF = (1 << 30) - 1; constexpr ll INFL = 1LL << 60; constexpr ld EPS = 1e-12; constexpr ld PI = 3.141592653589793238462643383279;



signed main(void) {
  string s; cin >> s;
  Vi sa = suffix_array(s);
  ll ans = 1LL * s.size() * (s.size() + 1) / 2;
  for(auto x : lcp_array(s, sa)) ans -= x;
  pl(ans)
  return 0;
}


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

// 最大公約数を計算( gcd.cpp 参照)
ll gcd(ll a, ll b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}

// 最小公倍数を計算
ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

int main() {
  ll n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;
  ll g = gcd(n, m);
  ll l = lcm(n, m);
  bool ok = true;
  for (int i = 0; i < g; i++) {
    int nn = i * n / g;
    int mm = i * m / g;
    if (s.at(nn) == t.at(mm)) {
      continue;
    } else {
      ok = false;
      break;
    }
  }
  if (ok) {
    cout << l << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 3752
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <cmath>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(size_t i = (j); i < (n); ++i)
#define rrep(i, j, n) for(size_t i = (n) - 1; (j) <= i; --i)
constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll n, k; cin >> n >> k;

	ll ans = 0;
	rep(i, k, n + 2) {
		ll mn = (ll)(i - 1) * i / 2;
		ll mx = (ll)(2 * n - i + 1) * i / 2;
		ans = (ans + mx - mn + 1) % MOD;
	}
	cout << ans;
	return 0;

}


Measured memory_bytes: 3612
n,k = map(int, input().split())
mod = 10**9 + 7

al = [0]*(k+1)
for x in range(1,k+1):
    al[x] = pow(k//x,n,mod)

for x in range(k,0,-1):
    for b in range(2, k//x+1):
        al[x] -= al[x*b]

res = 0
for i in range(k+1):
    res += i*al[i]
    res %= mod
print(res)

Measured memory_bytes: 11432
#累積和による解法

N,Q = map(int, input().split())
S = input()
cnt_list = [0]

for i in range(1,N):
    if S[i]=="C" and S[i-1]=="A":
        cnt_list.append(cnt_list[-1]+1)
    else:
        cnt_list.append(cnt_list[-1])
for j in range(Q):
    l,r = map(int, input().split())
    ans = cnt_list[r-1]-cnt_list[l-1]
    print(ans)


Measured memory_bytes: 6100
#include <stdio.h>
#include <string.h>

int main() {
    char str1[11], str2[11];
    int c = 1;
    scanf("%s %s", str1, str2);

    for (int i = 0; i < (strlen(str1)); ++i)
        if (str1[i] != str2[i])
            c = 0;
    
    if (c == 1)
        printf("%s\n", "Yes");
    else
        printf("%s\n", "No");

    return 0;
}

Measured memory_bytes: 1664
N=int(input())
A=list(map(int,input().split()))
B,C=[],[]
for i in range(N):
  if A[i]>=0:
    B.append(A[i])
  else:
    C.append(-A[i])
if len(C)%2==0:
  ans=sum(B)+sum(C)
else:
  ans=sum(B)+sum(C)
  B.sort()
  C.sort()
  if len(B)==0:
    b=10**12
  else:
    b=B[0]
  a=min(b,C[0])
  ans-=2*a
print(ans)



Measured memory_bytes: 14412
# include <bits/stdc++.h>
using namespace std;
#define int long long
int memo[22][(1 << 22) - 1];
int compat[22][22] = {};
int mod = 1e9 + 7;
int top(int i, int wstatus, int n)
{
	//base case
	if (i == n)
	{
		if (wstatus == 0) // no women is available, all used therefore success
			return 1;
		return 0;//unsuccessful pairing
	}
	if (memo[i][wstatus] != -1)
		return memo[i][wstatus];
	int ans = 0;
	for (int j = 0; j < n; j++)
	{
		if (compat[i][j] && (wstatus & (1 << j))) //woman compatible as well as available
		{
			ans += top(i + 1, (wstatus ^ (1 << j)), n);// xoring making this woman unavailable for next man
			ans = ans % mod;
		}
	}
	return memo[i][wstatus] = ans;
}
int32_t main ()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	memset(memo, -1, sizeof(memo));
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
			cin >> compat[i][j];
	}
	int wstatus = (1 << n) - 1;
	cout << (top(0, wstatus, n));
}
// 3
// 0 1 1
// 1 0 1
// 1 1 1

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

int main(){
  int A[10010];
  for(int i=0;i<10010;i++){
    A[i]=0;
  }

  for(int i=1;i<=100;i++){
    for(int j=1;j<=100;j++){
      int kmax=min(100,40100/(i+j));
      for(int k=1;k<=kmax;k++){
        
        int temp=i*i+j*j+k*k+i*j+j*k+i*k;
        if(temp<10010){
        A[temp]++;
        }
      }
    }
  }

  
  int N;
  cin>>N;
  for(int i=1;i<=N;i++){
    cout<<A[i]<<endl;
  }
 //cout<<A[N]<<endl;
  return 0;
}

  

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define inf 100000000000000000
#define mod 1000000007
#define MAX 100005
#define pb push_back
#define vit vector<int>::iterator
typedef pair<lint,lint> pii;
lint M[3005][3005],DP[3005][3005][4];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    lint R,C,K,a,b,c;
    cin>>R>>C>>K;
    for(lint i=1;i<=K;i++){
        cin>>a>>b>>c;
        M[a][b]=c;
    }
    for(lint i=R;i>=1;i--){
        for(lint j=C;j>=1;j--){
            for(lint k=0;k<=3;k++){
                DP[i][j][k]=max(DP[i][j+1][k],DP[i+1][j][3]);
            }
            if(M[i][j]){
                DP[i][j][1]=max(DP[i][j][1],max(M[i][j]+DP[i][j+1][0],M[i][j]+DP[i+1][j][3]));
                DP[i][j][2]=max(DP[i][j][2],max(M[i][j]+DP[i][j+1][1],M[i][j]+DP[i+1][j][3]));
                DP[i][j][3]=max(DP[i][j][3],max(M[i][j]+DP[i][j+1][2],M[i][j]+DP[i+1][j][3]));
            }
        }
    }/*
    for(lint i=1;i<=R;i++){
        for(lint j=1;j<=C;j++){
            cout<<DP[i][j][3]<<' ';
        }
        cout<<endl;
    }*/
    cout<<DP[1][1][3];
    return 0;
}
/*
2 5 5
1 1 3
2 4 20
1 2 1
1 3 4
1 4 2
*/


Measured memory_bytes: 355708
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test int t; cin>>t; while(t--)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define f0(i,n) for( ll i = 0; i < ( n ); i ++)
#define f1(i,n) for(i = 1; i <= ( n ); i ++)
#define f(i,m,n) for(auto i = ( m ); i <= ( n ); i ++)
#define nl cout<<"\n"
#define  mod 1000000007
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define rall(v) v.rbegin(), v.rend()
#define SZ(x) ((ll)x.size())
#define mem(a, b) memset(a, b, sizeof(a));
#define make_graph(k) int x,y; f0(i,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define dekh cout<<"dekh"

#define o_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setpll tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update>
typedef vector<ll> vl;




/*ll Pow(ll a, ll b, ll m){
    if(b==0)return 1;
    if(b%2==0){
        ll x = a*a;
        x%=m;
        return Pow(x,b/2,m);
    }
    return (a*Pow(a,b-1,m))%m;
}
*/
vector<ll>adj[200005];
 ll vis[200005]={0};

//ll p;ll arr[200005];

void dfs(ll x)
{
    cout<<x;nl;
    vis[x]=1;

    for(auto child : adj[x])
    {   if(!vis[child])
         {
             dfs(child);
         }
    }

}




ll n;
ll arr[100005];
ll dp[100005];
ll solve(ll i)
{
    if(i>=n-1)return 0;
    if(dp[i]!=-1)return dp[i];

    ll ans = (solve(i+1)+abs(arr[i+1]-arr[i]));
    if(i+2<n)
        ans= min(ans,   solve(i+2)+ abs(arr[i+2]-arr[i]));
        return dp[i]=ans;
   // return ans;

}

int main()
{
    fast
 mem(dp,-1);
   // ll n;
    cin>>n;
    f0(i,n)cin>>arr[i];
    cout<<solve(0);


}





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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)

typedef long long Int;

bool monthOK(int n) {
    if (n >= 1 && n <= 12) return true;
    else return false;
}

int main() {
    string S;
    cin >> S;

    int n, m;
    n = (S[0] - '0') * 10 + (S[1] - '0');
    m = (S[2] - '0') * 10 + (S[3] - '0');

    if (monthOK(n)) {
        if (monthOK(m)) cout << "AMBIGUOUS" << endl;
        else cout << "MMYY" << endl;
    }
    else {
        if (monthOK(m)) cout << "YYMM" << endl;
        else cout << "NA" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vel vector<long long>
#define vech vector<char>
#define ves vector<string>
#define veb vector<bool>
#define vvel vector<vel>
#define vvech vector<vech>
#define int long long
#define pin pair<int,int>
#define ppin pair<int,pin>
#define mkp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define maxel(vec, j) *max_element(vec.begin(), vec.begin()+j)

using namespace std;
void mmin(int &a, int b) { a = min(a, b); }
void mmax(int &a, int b) { a = max(a, b); }
int vsum(vel v){ return accumulate(v.begin(), v.end(), 0); }
int msum(vvel v){
    int ans = 0;
    rep(i, v.size()){
        ans += vsum(v[i]);
    }
    return ans;
}
signed main() {
    int pr = 1000;
    pr *= pr * pr; pr += 7;
    int N;
    cin >> N;
    vel W(N);
    rep(i, N){
        cin >> W[i];
    }
    vel C(N);
    int sum = 0;
    rep(i, N){
        sum += W[i];
        C[i] = sum;
    }
    int Wsum = vsum(W);
    int minimum = Wsum;
    rep(i, N){
        int temp = abs((Wsum - C[i]) - C[i]);
        if(temp<minimum){
            minimum = temp;
        }
    }
    cout<<minimum;
    return 0;
}
/*
4
1 3 1 1
 */


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
using namespace std;
typedef pair< int, int > Pi;
const int INF = 1 << 30;
struct edge: vector< Pi > {
  void add_edge(int to, int cost){
    push_back(Pi(to,cost));
  }
} info[100000];
int hoge[100000];

void bfs(const int& st, const int& V){
  fill_n( hoge, V, INF);
  queue< int > que;
  que.push(st);
  hoge[st] = 0;
  while(!que.empty()){
    int p = que.front();
    que.pop();
    for(int i = 0 ; i < info[p].size() ; i++){
      int cost = info[p][i].second;
      int to = info[p][i].first;
      if( cost + hoge[p] < hoge[to]){
        que.push(to);
        hoge[to] = cost + hoge[p];
      }
    }
  }
}

int main(){
  int N;
  scanf("%d", &N);
  for(int i = 0; i < N; i++){
    int u, k;
    scanf("%d %d", &u, &k);
    while(k--){
      int v, c;
      scanf("%d %d", &v, &c);
      info[u].add_edge( v, c);
    }
  }
  bfs(0, N);
  for(int i = 0 ; i < N ; i++ ){
    printf("%d %d\n", i, hoge[i]);
  }
}

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

int main()
{
    long long int n;
    cin>>n;
    if(n%1000==0)
    {
        cout<<0<<endl;
    }
    else
    {
        int m=n%1000;
        int k=1000-m;
        cout<<k<<endl;

    }
    return 0;

}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
#define ull unsigned long long
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ull x,y;
    cin >> x >> y;
    if(x==y || x%y==0){
        cout << -1 << endl;
        return 0;
    }
    for(ull i=x;i<10000000000000000000;i*=x){
        if(i%x!=i%y){
            cout << i << endl;
            return 0;
        }
        else continue;
    }

    return 0;
}


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

using namespace std;

const long long int INF=1e9;

int main() {
    long long int mx;
    cin >> mx;
    long long int t6=1, t9=1;
    vector<long long int> vec;
    vec.push_back(0);
    vec.push_back(1);
    while(t6<=mx) {
        t6 *= 6;
        if(t6<=mx) {
            vec.push_back(t6);
        }
    }
    while(t9<=mx) {
        t9 *= 9;
        if(t9<=mx) {
            vec.push_back(t9);
        }
    }

    vector<vector<long long int> > memo(vec.size(), vector<long long int>(mx+1, INF));
    memo[0][0]=0;
    for(int vi=1; vi<vec.size(); vi++) {
        for(int n=0; n<=mx; n++) {
            memo[vi][n] = min(memo[vi-1][n], memo[vi][n]);
            if(n-vec[vi]>=0) {
                memo[vi][n] = min(memo[vi][n-vec[vi]]+1, memo[vi][n]);
            }
            // cout << memo[vi][n] << " ";
        }
        // cout << endl;
    }
    cout << memo[vec.size()-1][mx] << endl;


    return 0;
    
}

Measured memory_bytes: 11264
#include "iostream"
#include "string"
#include "algorithm"
#include "map"
#include "vector"
#include "math.h"
#include "cstring"
using namespace std;
typedef long long ll;
int main()
{
    string s1,p;
    cin>>s1;
    int n = s1.length();
    if(s1[n-1] != 's')
    {
    p = s1 + "s";
    }
    else
    {
    p = s1 + "es";
    }
    cout<<p<<"\n";
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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


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

int N,K,Q,A[2020];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int k;
    cin>>k;
    int n=s.size();

    for(int i=0;i<n-1;i++){
        int t = (26 - (s[i] - 'a')) % 26;
        if(t<=k){
            k-=t;
            s[i]='a';
        }
        else continue;
    }
    k %= 26;
    for(int j=0;j<k;j++){
        s[n-1]++;
        if(s[n-1]>'z') s[n-1]='a';
    }

    cout<<s<<endl;

}


Measured memory_bytes: 592
#include <stdio.h>
#include <math.h>

void solve(double x1, double x2, double x3, double y1, double y2, double y3) {
	double cx1 = (x1+x2)/2.0, cx2 = (x2+x3)/2.0;
	double cy1 = (y1+y2)/2.0, cy2 = (y2+y3)/2.0;
	double tx1 = y1-y2, tx2 = y2-y3;
	double ty1 = x2-x1, ty2 = x3-x2;
	double a=ty1, b=-tx1, c=cx1*ty1-cy1*tx1;
	double d=ty2, e=-tx2, f=cx2*ty2-cy2*tx2;
	double det = a*e-b*d;
	double x = (e*c-b*f)/det;
	double y = (-d*c+a*f)/det;
	double r = sqrt((x1-x)*(x1-x) + (y1-y)*(y1-y));
	printf("%.3f %.3f %.3f\n", x, y, r);
}

int main(void) {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		double x1,x2,x3,y1,y2,y3;
		scanf("%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3);
		solve(x1, x2, x3, y1, y2, y3);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>
 
using namespace std;
 
int pw (int n, int p) {
  if (n == 0) return 0;
  if (p == 0) return 1;
  if (p == 1) return n;
  return n * pw(n, p-1);
}
 
int computeM (int e) {
   
  int ret = e;
   
  // zukky&#227;&#129;&#8226;&#227;&#8218;“&#227;&#129;&#174;&#227;&#8218;&#179;&#227;&#402;&#161;&#227;&#402;&#179;&#227;&#402;&#710;&#227;&#129;&#171;&#227;&#8218;&#710;&#227;&#8218;&#8249;&#227;&#402;’&#227;&#402;&#179;&#227;&#402;&#710;&#227;&#8218;’&#232;?&#8249;&#227;&#129;&#376;&#227;&#8364;&#8218;
  // z&#227;&#129;&#338;&#230;&#339;&#8364;&#227;&#8218;&#8218;&#232;‡&#170;&#231;”±&#229;&#186;?&#227;&#129;&#174;&#229;°&#143;&#227;&#129;&#8226;&#227;&#129;&#8222;&#230;&#8226;°&#227;&#129;&#170;&#227;&#129;&#174;&#227;&#129;§&#227;&#8364;&#129;z&#227;&#129;&#8249;&#227;&#8218;‰&#230;±&#186;&#229;&#174;&#353;&#227;&#129;—&#227;&#129;?&#227;&#129;&#8222;&#227;&#129;&#143;&#227;&#8364;&#8218;
 
  for(int y = 0; y <= sqrt(e); y++) {
    for(int z = 0; z <= sqrt(e); z++) {
      int temp = pw(y, 2) + pw(z, 3);
      int x = e - temp;
      if (x < 0) x = 0;
      if (x + temp == e) ret = min(x + y + z, ret);
    }
  }
   
 
  return ret;
}
 
int main (void) {
  int e, m;
 
  while (1) {
    cin >> e; if (e == 0) break;
    m = computeM(e);
    cout << m << endl;
  }
  return 0;
}

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

void insertionSort(vector<int> &a, int N) {
    for (int i = 0; i < N; i++) {
        int v = a.at(i);
        int j = i - 1;

        while (j >= 0 && a.at(j) > v) {
            a.at(j+1) = a.at(j);
            j--;
        }

        a.at(j+1) = v;

        for(int i = 0; i < N; i++) {
            if (i == N-1) {
                cout << a.at(i) << '\n';
                break;
            }
            cout << a.at(i) << " ";
        }
    }
}

void bubbleSort(vector<int> &a, int N) {
    bool flag = 1;
    int i = 0;
    int count = 0;
    while (flag) {
       flag = 0;
       for (int j = N - 1; j > i; j--) {
           if (a.at(j) < a.at(j-1)) {
               swap(a.at(j), a.at(j-1));
               flag = 1;
               count++;
           }
       }
       i++;
    }

    for (int i = 0; i < N; i++) {
        if (i == N - 1) {
            cout << a.at(i) << endl;
            break;
        }
        cout << a.at(i) << " ";
    }
    cout << count << endl;
}

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

    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
    }

    bubbleSort(a, N);
    return 0;

}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    long long n=s.size();
    long long int arr[n];
    long long int t=1;
    for(long long int i=n-1;i>=0;i--)
    {
        arr[i]=(t*(s[i]-'0'))%2019;
        arr[i]%=2019;
        t=(t*10)%2019;
    }
    long long int dp[n];
    dp[n-1]=arr[n-1];
    for(long long int i=n-2;i>=0;i--)
    {
        dp[i]=(dp[i+1]+arr[i])%2019;
        dp[i]%=2019;
    }
    long long ans[2019],count=0;
    for(long long int i=0;i<2019;i++)
    ans[i]=0;
    for(long long int i=0;i<n;i++)
    {
        ans[dp[i]]++;
    }
    for(long long int i=0;i<2019;i++)
    count=count+(ans[i]*(ans[i]-1))/2;
    count+=ans[0];
    cout<<count;

}

Measured memory_bytes: 6888
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int string(char *front,char *buck,int num,int N);

int main(void){
  int N,i,j,k,l[2],count,max;
  char str[105],s[105],*p,front[105],buck[105];
  
  fgets(str,sizeof(str),stdin);
  N=atoi(str);
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  strcpy(s,p);
  
  for(i=0,max=0;i<N;i++){
    strcpy(front,s);
    p=&s[i+1];
    front[i+1]='\0';
    strcpy(buck,p);
    
    string(front,buck,i,N);
    
    l[0]=strlen(front);
    l[1]=strlen(buck);
    
      for(j=0,count=0;j<l[0];j++){
        for(k=0;k<l[1];k++){
          if(front[j]==buck[k]){
            count++;
          }
        }
      }
    
    if(max<count){
      max=count;
    }
  }
  
  printf("%d\n",max);
  
  return 0;
}

int string(char *front,char *buck,int num,int N){
  int i,j;
  char buff;
  
  for(i=0;i<=num;i++){
    for(j=num;j>i;j--){
      if(front[j-1]>front[j]){
        buff=front[j-1],front[j-1]=front[j],front[j]=buff;
      }
    }
  }
  i=0;
  while(front[i]!='\0'){
    if(front[i]==front[i+1]){
      for(j=i;front[j]!='\0';j++){
        front[j]=front[j+1];
      }
    }else{
      i++;
    }
  }
  
  for(i=0;i<N-num-1;i++){
    for(j=N-num-2;j>i;j--){
      if(buck[j-1]>buck[j]){
        buff=buck[j-1],buck[j-1]=buck[j],buck[j]=buff;
      }
    }
  }
  
  i=0;
  while(buck[i]!='\0'){
    if(buck[i]==buck[i+1]){
      for(j=i;buck[j]!='\0';j++){
        buck[j]=buck[j+1];
      }
    }else{
      i++;
    }
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  int r, d, x;
  cin >> r >> d >> x;

  for (int i = 0; i < 10; i++){
    x = r*x - d;
    cout << x << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,mini=0,maxi=102; cin>>n;
    vector<int> x(n);
    rep(i,n){
        cin>>x[i];
        mini=min(mini,x[i]);
        maxi=max(maxi,x[i]);
    }
    int ans=INFINITY;
    for(int i=mini;i<=maxi;i++){
        int c=0;
        rep(j,n) c+=(x[j]-i)*(x[j]-i);
        ans=min(ans,c);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include <queue>
#include<map>
#include<set>
#include <cstring>
using namespace std;
#define ll long long int


int main()
{
    int n , m , k ;
    cin>>n>>m>>k ;
    vector<ll>  r(n , 0) , c(m , 0) ;

    set<pair<ll ,ll>> st ;
    for(ll i = 0 ; i < k ; i++)
    {
        ll a , b ;
        cin>>a>>b ;
        a-- ;
        b-- ;
        st.insert({a , b}) ;
        r[a]++ ;
        c[b]++ ;

    }
    ll maxr = -1 , maxc = -1 ;
    for(ll i = 0  ; i < n ; i++)
    {
        if(r[i] > maxr)
        {
            maxr = r[i] ;

        }
    }

    vector<ll> vr , vc ;
      for(ll i = 0  ; i < n ; i++)
    {
        if(r[i] == maxr)
        {
            vr.push_back(i) ;

        }
    }
     for(ll i = 0  ; i < m ; i++)
    {

        if(c[i] > maxc)
        {

            maxc = c[i] ;

        }
    }
     for(ll i = 0  ; i < m ; i++)
    {

        if(c[i] == maxc)
        {

            vc.push_back(i) ;

        }
    }

    ll ans = 0 ;
    ll n1 = vr.size() , m1 = vc.size() ;
    for(ll i = 0 ; i < n1 ; i++)
    {
        for(ll j = 0 ; j < m1 ; j++)
        {

                if(st.find({vr[i] , vc[j]}) == st.end()){
                  ans = max(ans , r[vr[i]] + c[vc[j]]) ;
                  break ;
                }
                else
                  ans = max(ans , r[vr[i]] + c[vc[j]] - 1) ;


        }
    }

    cout<<ans ;
}


Measured memory_bytes: 35020
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <algorithm>

#define rep(i,n) for(int i=0; i < n; i++)
using namespace std;
#define PI 3.14159265358979

int main()
{
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;

    if (s == u) a--;
    else if (t == u) b--;

    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


class Info:
    def __init__(self,arg_word,arg_count):
        self.word= arg_word
        self.count = arg_count

    def __lt__(self,another):
        if self.count != another.count:
            return self.count > another.count
        else:
            return self.word < another.word


while True:

    num_row = int(input())
    if num_row == 0:
        break

    DICT = {} #単語→ID
    rev_DICT = {} #ID→単語
    COUNT = {} #IDをキーとして、出現数を計上
    num_words = 0

    for _ in range(num_row):
        words = input().split()
        for i in range(len(words)):
            if words[i] in DICT:
                COUNT[DICT[words[i]]] += 1
            else:
                DICT[words[i]] = num_words
                rev_DICT[num_words] = words[i]
                num_words += 1
                COUNT[DICT[words[i]]] = 1

    head_word = str(input())
    table = []
    for i in range(num_words):
        word = rev_DICT[i]
        if word[0] != head_word:
            continue
        table.append(Info(word,COUNT[DICT[word]]))

    if len(table) == 0:
        print("NA")
        continue

    table.sort()
    print("%s"%(table[0].word),end = "")
    for i in range(1,min(5,len(table))):
        print(" %s"%(table[i].word),end="")
    print()



Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
deque < int > a;
int ans=0;
int main()
{
	int a2=0;
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a2;
		a.push_back(a2);
	}
	reverse(a.begin(),a.end());
	a.push_back(-1);
	for(int i=0;i<n;i++)
	{
		int ans2=0;
		for(int c=i;a[c]<=a[c+1];c++)
		{
			ans2++;
			i=c; 
		} 
		ans=max(ans,ans2);
	}
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
	int h, a;
	cin >> h >> a;
	
	if (h % a == 0)
	{
		cout << (h / a) << endl;
	}
	else
	{
		cout << (h / a) + 1 << endl;
	}
	
	return 0;
}


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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, W;
    cin >> N >> W;
    vector<ll> w(N), v(N);
    ll sum = 0;
    REP(i, 0, N) {
        cin >> w[i] >> v[i];
        sum += v[i];
    }

    const ll inf = 1LL << 60;
    auto dp = make_v(N + 1, sum + 1, inf);
    dp[0][0] = 0;
    REP(i, 0, N) {
        REP(j, 0, sum + 1) {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            if (dp[i][j] + w[i] <= W) {
                dp[i + 1][j + v[i]] = min(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
            }
        }
    }

    ll ans = inf;
    REP(i, 0, sum + 1) {
        if (dp[N][i] <= W) {
            ans = i;
        }
    }

    cout << ans << endl;

    return 0;
}


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

typedef long long ll;

int N, T;
int t[(int)2e5];

int main() {
    cin >> N >> T;

    rep(i, N) cin >> t[i];

    // cout << T << endl;;

    ll ans = T;
    for (int i = N - 2; i >= 0; i--) {
        int dist = min(T, t[i + 1] - t[i]);

        // printf("t[i] %d, t[i + 1] %d dist: %d\n", t[i], t[i + 1], dist);
        ans += dist;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    lint n, a, b;
    scanf("%lld%lld%lld", &n, &a, &b);
    lint ans = n/(a+b) * a;
    ans += min(a, n%(a+b));
    printf("%lld\n", ans);
}

Measured memory_bytes: 256
from queue import Queue


def solve():

    K = int(input())

    q = Queue()
    for i in range(9):
        q.put(i+1)
    num = 0
    for i in range(K):
        num = q.get()
        if num % 10 != 0:
            q.put(num*10+num % 10-1)
        q.put(num*10+num % 10)
        if num % 10 != 9:
            q.put(num*10+num % 10+1)
    print(num)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 57500
#include <iostream>

using namespace std;

int main()
{
 int r, d,x ;
 cin>>r>>d>>x;
 int res = r*x-d;
 cout<<res<<endl ;
 for(int i=0 ; i<9 ; i++){
     res = res*r-d;
     cout<<res<<endl;
 }

    return 0;
}

Measured memory_bytes: 256
import sys

input=sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()


def II(): return int(input())


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


def MF(): return map(float,input().split())


def LI(): return list(map(int,input().split()))


def LF(): return list(map(float,input().split()))


def TI(): return tuple(map(int,input().split()))


# rstrip().decode('utf-8')

def main():
	n,m,k=MI()
	mod=998244353
	
	f=[1]
	for i in range(1,n+10):
		f.append((f[-1]*i)%mod)
	finv=[]
	for i in f:
		finv.append(pow(i,mod-2,mod))
	
	mp=[1]
	for i in range(1,n+10):
		mp.append((mp[-1]*(m-1))%mod)
		
	
	ans=0
	for kk in range(k+1):
		cnt=f[n-1]*finv[kk]*finv[n-1-kk]
		cnt%mod
		cnt*=m*mp[n-kk-1]
		ans+=cnt
		ans%mod
	print(ans%mod)













if __name__=="__main__":
	main()


Measured memory_bytes: 32524
S = input()
T = input()

s = len(S)
t = len(T)

ans = t
for j in range(s - t + 1):
    val = 0
    for i in range(t):
        if S[j:j + t][i] != T[i]:
            val += 1
    ans = min(ans, val)
print(ans)


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

int main(){
  long long cnt=0,n,ans=0;
  cin>>n;
  vector<int>a(n);
  vector<int>b(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    if(a[i]<0){
      a[i]=(-1)*a[i];
      ans+=a[i];
      cnt++;
    }
    else{
      ans+=a[i];
     }
  } 
  for(int i=0;i<n;i++){
    if(a[i]<0){
      b[i]=a[i]*(-1);
  }
    else{
      b[i]=a[i];
    }
  }
  sort(b.begin(),b.end());
  if(cnt%2==0){
    cout<<ans<<endl;
    return 0;
  }
  else{
    cout<<ans-b[0]*2<<endl;
    return 0;
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;

int main()
{
	ll n, m;
	cin >> n >> m;
	vector<ll> x(n), y(m);
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> y[i];
	}
	ll row = 0, res = 0;
	for (ll i = 1; i < n; i++) {
		row = (row + (x[i] - x[i - 1]) % mod * i % mod * (n - i) % mod) % mod;
	}
	for (ll i = 1; i < m; i++) {
		res = (res + row * (y[i] - y[i - 1]) % mod * i % mod * (m - i) % mod) % mod;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1792
fn main() {
    let mut times: Vec<isize> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).ok();
        buf.trim()
            .split_whitespace()
            .map(|e| e.trim().parse().ok().unwrap())
            .collect()
    };

    if times[0] >= times[3] || times[1] <= times[2] {
        println!("{}", 0);
        return;
    }

    times.sort();
    println!("{}", times[2] - times[1]);
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	int num=0;
	for(int i=1;i<=n;i++)
	{
		int t=0;
		int x=i;
		while(x)
		{
			x=x/10;
			t++;
		}
		if(t%2==1) num++;
	}
	printf("%d\n",num);
   return 0;
}

Measured memory_bytes: 128
def main():
    L = int(input())
    N = 2
    while 2**N <= L:
        N += 1
    L -= 2**(N-1)
    E = []
    for i in range(N-1):
        E.append((N-i-1, N-i, 0))
        E.append((N-i-1, N-i, 2**i))
    i = 0
    nxt = 2**(N-1)
    for i in range(2, N+1):
        tmp = 2**(N-i)
        if tmp <= L:
            E.append((1, i, nxt))
            L -= tmp
            nxt += tmp
    print(N, len(E))
    for u, v, w in E:
        print(u, v, w)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.IO;
using System.Text;
using System.Diagnostics;

class Program
{
    static void Main()
    {
        long n = long.Parse(Console.ReadLine());
        long[] a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        SortedDictionary<long, long> dict = new SortedDictionary<long, long>();
        long ans = 0;

        for (long i = 0; i < n; i++)
        {
            if (dict.ContainsKey(a[i]))
            {
                dict[a[i]]++;
            }
            else
            {
                dict[a[i]] = 1;
            }
        }

        foreach (var item in dict)
        {
            if(item.Value > item.Key)
            {
                ans += item.Value - item.Key;
            }
            else if(item.Value < item.Key)
            {
                ans += item.Value;
            }
        }
        Console.WriteLine(ans);
    }
}

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

long long modinv(long long a, long long m) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

int64_t MOD = 1000000007;

int main(){
  int64_t N;
  cin >> N;
  vector<int64_t> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  map<int64_t,int64_t> lcm;
  vector<map<int64_t,int64_t>> cnt(N);
  for(int i=0; i<N; i++){
    map<int64_t,int64_t> mp;
    int64_t n = vec.at(i);
    int64_t a = 2;
    while(n >= a*a){
     if(n %a == 0){
        if(mp.count(a)){
          mp[a]++;
        }
        else{
          mp[a] = 1;
        }
        n /= a;
     }
     else{
       a++;
      }
    }
    if(mp.count(n)){
      mp[n]++;
    }
    else{
      mp[n] = 1;
    }
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
      int64_t x = itr->first;
      int64_t y = itr->second;
      if(lcm.count(x)){
        if(y > lcm[x]){
          lcm[x] = y;
        }
      }
      else{
        lcm[x] = y;
      }
    }
    cnt.at(i) = mp;
  }
  int64_t X = 1;
  for(auto itr = lcm.begin(); itr != lcm.end(); itr++){
    int64_t a = itr->first;
    int64_t b = itr->second;
    for(int i=0; i<b; i++){
      X *= a;
      X %= MOD;
    }
  }
  int64_t ans = 0;
  for(int i=0; i<N; i++){
    ans += X *modinv(vec.at(i),MOD) %MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3968
import sys
import math


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()
L = inintl()

ans = 0

for i in range(n):
    for j in range(n):
        for k in range(n):
            if i < j < k and (L[i]+L[j] > L[k] and L[j]+L[k] > L[i] and L[k]+L[i] > L[j]) and (L[i] != L[j] and L[i] != L[k] and L[j] != L[k]):
                ans += 1

print(ans)


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

int main(){
	int a, b;
  	cin >> a >> b;
  	int ans = a * b;
  	cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x;cin>>x;
  ll res=x/(11)*2;
  if(x%11>0)res++;
  if(x%11>6)res+=1;
  cout<<res<<endl;

  return 0;

}


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

int main() {
    string n;
    cin >> n;
    int counter = 0;

    for (int i = 0; i < n.size(); i++) {
        counter += n.at(i) - '0';
    }

    cout << (counter%9? "No" : "Yes") << endl;

    return 0;
}


Measured memory_bytes: 3744
#include <cstdio>
int main(){
    int in;
    int h,m,s;
    scanf("%d",&in);

    h = in / 3600;
    in %= 3600;

    m = in / 60;
    in %= 60;

    s = in;

    printf("%d:%d:%d\n",h,m,s);
}




Measured memory_bytes: 2700
class _Node {
  constructor(key, parent = null, left = null, right = null) {
    this.key = key;
    this.parent = parent;
    this.left = left;
    this.right = right;
  }

  getChildrenNumber() {return (this.left && 1 || 0 ) + (this.right && 1 || 0 );}

  isLeftChild() {
    if (this.parent === null) return null;
    return this.parent.left === this;
  }

  getLeftOrRight() {return this.isLeftChild() ? 'left' : 'right';}

  getSuccessor() {
    let n;
    if (this.right !== null) {
      n = this.right;
      while (n.left !== null) n = n.left;
    } else {
      n = this.parent;
      while (!n.isLeftChild && n.parent != null) n = n.parent;
    }
    return n;
  }
}

class BinaryTree {
  constructor() {
    this.root = null;
  }

  static get Node() { return _Node; }

  insert(key) {
    if (this.root === null) {
      this.root = new BinaryTree.Node(key);
      return;
    }
    let x = this.root, y;
    let newNode = new BinaryTree.Node(key);
    while (x !== null) {
      y = x;
      x = x[key < x.key ? 'left' : 'right'];
    }
    newNode.parent = y;
    y[key < y.key ? 'left' : 'right'] = newNode;
  }

  find(key, n = this.root) {
    if (n === null || n.key === key) return n;
    return this.find(key, n[key < n.key ? 'left' : 'right']);
  }

  delete(key) {
    const n = this.find(key);
    const leftOrRight = n.getLeftOrRight();
    switch (n.getChildrenNumber()) {
    case 0:
      n.parent[leftOrRight] = null;
      break;
    case 1:
      n.parent[leftOrRight] = n.left || n.right;
      n.parent[leftOrRight].parent = n.parent;
      break;
    default:
      const skey = n.getSuccessor().key;
      this.delete(skey);
      n.key = skey;
    }
  }

  printByIneorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      innerFunc(n.left);
      str += ` ${n.key}`;
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  printByPreorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      str += ` ${n.key}`;
      innerFunc(n.left);
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  print() {
    this.printByIneorder();
    this.printByPreorder();
  }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());

  const tree = new BinaryTree();
  lines.forEach(function(cmd) {
    switch (cmd.charAt(0)) {
    case 'i': tree.insert(Number(cmd.split(' ')[1])); break;
    case 'f': console.log(tree.find(Number(cmd.split(' ')[1])) ? 'yes' : 'no'); break;
    case 'd': tree.delete(Number(cmd.split(' ')[1])); break;
    default: tree.print();
    }
  });
})();



Measured memory_bytes: 203444
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0

for A in range(a+1):
    for B in range(b+1):
        for C in range(c+1):
            if A*500 + B*100 + C*50 == x:
                cnt += 1

print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 1e6 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  map<vector<int>, int> mp;
  int n;
  cin >> n;
  vector<int> vec(n);
  iota(vec.begin(), vec.end(), 1);
  int idx = 1;
  do {
    mp[vec] = idx;
    ++idx;
  } while(next_permutation(vec.begin(), vec.end()));
  vector<int> V1, V2;
  int a, a2;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    V1.push_back(a);
  }
  for (int i = 0; i < n; ++i) {
    cin >> a;
    V2.push_back(a);
  }
  cout << abs(mp[V1] - mp[V2]);
  return 0;
}


Measured memory_bytes: 5248