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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n, k;
  cin >> n >> k;
  if (k > 500) k = 500;
  vector<int> a(n);

  arep(i, a) cin >> i;

  rep(i, 0, k) {
    vector<int> next(n + 1, 0);
    rep(j, 0, n) {
      // cout << j - a[j] << ' ';
      if (a[j] == 0) {
        next[j]++;
        next[j + 1]--;
        // cout << j << ' ';
        // cout << j + 1 << ' ';
      } else {
        if (j - a[j] < 0) {
          next[0]++;
          // cout << 0 << ' ';
        } else {
          next[j - a[j]]++;
          // cout << j - a[j] << ' ';
        }
        // cout << j + 1 + a[j] << ' ';
        if (j + 1 + a[j] < n) next[j + 1 + a[j]]--;
      }
      // cout << '\n';
    }
    rep(j, 0, n) {
      a[j] = next[j];
      next[j + 1] += next[j];
      // cout << next[j] << ' ';
      // cout << a[j] << ' ';
    }
    // cout << '\n';
  }

  rep(i, 0, n) cout << a[i] << ' ';
  cout << '\n';
  return 0;
}

Measured memory_bytes: 6336
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
struct P
{
    int value = -1;
    int prev = -1; //sのほうのindex
};

int main()
{
    string s, t;
    cin >> s >> t;
    int N = s.size(), M = t.size();
    vvint dp_v(N, vint(M));
    vector<vector<pair<int, int>>> dp_prev(N, vector<pair<int, int>>(M));
    bool b1 = false, b2 = false;
    rep(i, N)
    {
        if (b1 or s[i] == t[0])
        {
            b1 = true;
            dp_v[i][0] = 1;
            dp_prev[i][0] = {-1, -1};
        }
    }
    rep(j, M)
    {
        if (b2 or s[0] == t[j])
        {
            b2 = true;
            dp_v[0][j] = 1;
            dp_prev[0][j] = {-1, -1};
        }
    }
    rep(i, N - 1)
    {
        rep(j, M - 1)
        {
            if (s[i + 1] == t[j + 1])
            {
                if (dp_v[i][j] + 1 > dp_v[i][j + 1] and dp_v[i][j] + 1 > dp_v[i + 1][j])
                {
                    dp_v[i + 1][j + 1] = dp_v[i][j] + 1;
                }
                else if (dp_v[i][j + 1] > dp_v[i + 1][j])
                {
                    dp_v[i + 1][j + 1] = dp_v[i][j + 1];
                }
                else
                {
                    dp_v[i + 1][j + 1] = dp_v[i + 1][j];
                }
            }
            else
            {
                if (dp_v[i][j + 1] > dp_v[i + 1][j])
                {
                    dp_v[i + 1][j + 1] = dp_v[i][j + 1];
                }
                else
                {
                    dp_v[i + 1][j + 1] = dp_v[i + 1][j];
                }
            }
        }
    }
    if (dp_v[N - 1][M - 1] == 0)
    {
        return 0;
    }

    int i = N - 1, j = M - 1;
    int len = dp_v[N - 1][M - 1], L = len;
    vchar ans(len);
    while (len > 0)
    {
        if (s[i] == t[j])
        {
            ans[len - 1] = s[i];
            i--;
            j--;
            len--;
        }
        else if (i > 0 and dp_v[i][j] == dp_v[i - 1][j])
        {
            i--;
        }
        else 
        {
            j--;
        }
    }
    //   reverse(all(ans));
    rep(i, L)
    {
        cout << ans[i];
    }
    return 0;
}

Measured memory_bytes: 105984
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
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<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n,m;
    cin>>n>>m;
    int k=m*2+1;
    cout<<(n+k-1)/k<<endl;
    return 0;
}

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

int main() {
    int res = 0, H, W;
    int dp[1001][1001];
    char grid[1001][1001];
    cin>>H>>W;
    for(int i=1;i<=H;i++) {
        for(int j=1;j<=W;j++) cin>>grid[i][j];
    }
    dp[H][W] = 0;
    bool check = true;
    for(int i=W-1; i>0; i--) {
        if(grid[H][i] == '.' && check) dp[H][i] = 1;
        else {
            check = false;
            dp[H][i] = 0;
        }
    }

    check = true;
    for(int i=H-1; i>0; i--) {
        if(grid[i][W] == '.' && check) dp[i][W] = 1;
        else {
            check = false;
            dp[i][W] = 0;
        }
    }
    
    for(int i=H-1; i>=0; i--) {
        for(int j=W-1; j>=0; j--) {
            if(grid[i][j] == '.') dp[i][j] = (dp[i][j+1] + dp[i+1][j])%mod;
            else dp[i][j] = 0;
        }
    }

    cout<<dp[1][1]<<endl;
    return 0;
}


Measured memory_bytes: 8452
N = int(input())
A = list(map(int,input().split()))
A.sort()
cnt = 0
dp = [True]*(A[-1]+1)

for i in range(N-1):
  if dp[A[i]] == True:
    for j in range(A[i], A[-1]+1,A[i]):
      dp[j] = False
    if A[i] != A[i+1]:
      cnt+=1
if dp[A[-1]] == True:
  cnt+=1
print(cnt)

Measured memory_bytes: 32300
#include <iostream>
#include <cstdio>

#define MAXN 100000

using namespace std;

typedef long long ll;

struct {
  ll x,v;
} typedef sushi;

sushi A[MAXN+2];
ll B[MAXN+1], C[MAXN+1];

ll maxcal ( ll N, ll c )
{
  ll maxcost = 0;
  ll sum = 0;

  for ( int i = 0; i <= N; ++i ) {
    sum += A[i].v;
    ll tmp = sum-A[i].x+C[N-i];
    if ( tmp > maxcost ) maxcost = tmp;
  }

  sum = 0;
  for ( int i = 0; i <= N; ++i ) {
    sum += A[N-i+1].v;
    ll tmp = sum-(c-A[N-i+1].x)+B[N-i];
    if ( tmp > maxcost ) maxcost = tmp;
  }
  return maxcost;
}

int main()
{
  ll N,c;
  ll sum;

  cin >> N >> c;

  for ( int i = 1; i <= N; ++i ) scanf("%ld%ld", &A[i].x, &A[i].v);
  A[N+1] = { c,0};

  sum = 0;
  for ( int i = 1; i <= N; ++i ) {
    sum += A[i].v;
    B[i] = max(sum-A[i].x*2,B[i-1]);
  }

  sum = 0;
  for ( int i = 1; i <= N; ++i ) {
    sum += A[N-i+1].v;
    C[i] = max(sum-(c-A[N-i+1].x)*2,C[i-1]);
  }


  cout << maxcal(N,c) << endl;
}


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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> dct;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define pi 3.14159265

bool compare(pair<pii,vector<int>> a, pair<pii,vector<int>> b){
    if(a.first.first*b.first.second==a.first.second*b.first.first)
        return a.first.second>b.first.second;
    return a.first.first*b.first.second<a.first.second*b.first.first;
}

const int mod = 1e9 + 9;
const ll inf = ll(1e18);

ll modexp(ll x,ll n){
    if(n==0)return 1;
    if(n%2==0)return modexp((x*x)%mod,n/2);
    return (x*modexp((x*x)%mod,n/2))%mod;
}
vl dp(1e7+1);
int main(){
    fastio;
    int n;
    cin>>n;
    vi a(n);
    f(i,0,n)cin>>a[i];
    int k=-1;int x=1;
    f(i,0,n){
        if(a[i]==x){
            k=x;++x;
        }
    }
    if(k==-1)cout<<k<<endl;
    else cout<<n-k<<endl;
}

Measured memory_bytes: 79232
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N = I()
A = LI()
for i in range(N):
    A[i] -= i+1
A.sort()


def f(x):
    return sum(abs(A[i]-x) for i in range(N))


print(f((A[(N-1)//2]+A[N//2])//2))
# 中間値


Measured memory_bytes: 94456
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void) {
    int A, B;   // 座標
    int V, W;   // 速度
    int T;      // 制限時間
    long long dAB;    // 距離
    long long sVW;    // 移動速度

    scanf("%d %d", &A, &V);
    scanf("%d %d", &B, &W);
    scanf("%d", &T);

    dAB = A - B;
    if(dAB < 0) dAB *= -1;

    sVW = V - W;
    if(sVW <= 0) {
        printf("NO\n");
        return 0;
    }

    if( dAB <= (sVW * T) ) {
        printf("YES\n");
        return 0;
    }
    else {
        printf("NO\n");
        return 0;
    }
}


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

int main() {
  int d, g;
  cin >> d >> g;
  vector<int> p(d), c(d);
  for (int i = 0; i < d; i++) {
    cin >> p[i] >> c[i];
  }

  int r = 1e9;
  for (int b = 0; b < 1 << d; b++) {
    int m = 0, s = 0;
    for (int i = 0; i < d; i++) {
      if ((b & 1 << i) != 0) {
        m += p[i];
        s += 100 * (i + 1) * p[i] + c[i];
      }
    }
    for (int i = d - 1; i >= 0 && s < g; i--) {
      if ((b & 1 << i) == 0) {
        int x;
        if (s + 100 * (i + 1) * (p[i] - 1) < g) {
          x = p[i] - 1;
        } else {
          x = (g - s - 1) / (100 * (i + 1)) + 1;
        }
        m += x;
        s += 100 * (i + 1) * x;
      }
    }
    if (s >= g) {
      r = min(r, m);
    }
  }

  cout << r << endl;
}


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

using namespace std;

int main() {
	int N,Y;
	cin >> N >> Y;
  for(int i=0;i<=N;i++){
		for(int j=0;j<=N-i;j++){
			if(10000*i+5000*j+1000*(N-i-j)==Y){
				int k = N-i-j;
				cout<<i<<' '<<j<<' '<<k<<endl;
				return 0;
			}
		}
	}
	cout<<"-1 -1 -1"<<endl;
	return 0;
}


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

using namespace std;

#define int long long
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define fr(i,j,k) for(i = j; i < (k); i++)
#define all(x) x.begin(), x.end()
#define el '\n'
#define remax(a,b) a = max(a, b)
#define remin(a,b) a = min(a, b)
#define sz(x) int32_t(x.size())

typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
// --------------------------------------------------------------------

const pii dxy[] = { {-1, 0}, {1, 0}, {0, 1}, {0, -1} };
const int mod = 1e9 + 7;
const int inf = 2e18;
const ld eps = 1e-9;
const int NN = 2e5 + 2;

vvi g(NN);


void solve() {
	int i = 0, j = 0, k = 0, n = 0, m = 0;
	set<string> s;
	cin >> n;
	string ss;
	fr(i, 0, n) {
		cin >> ss;
		s.emplace(ss);
	}
	cout << sz(s) << el;
}

int32_t main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int T = 1;
	// cin >> T;
	for(int tc = 1; tc <= T; tc++) {
		solve();
	}

	return 0;
}

Measured memory_bytes: 23440
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    int n, m, R;
    cin >> n >> m >> R;
    
    vector<vector<ll>> d(n+1, vector<ll>(n+1, 10000000));
    vector<int> r(R);
    rep(i, R) cin >> r.at(i);

    vector<vector<int>> g(n+1);
    vector<ll> dist(n+1, -1);
    vector<vector<ll>> d2(n+1, vector<ll>(n+1, 100000000));

    rep(i, m){
        int x, y; cin >> x >> y;
        ll c; cin >> c;
        d2.at(x).at(y) = min(d2.at(x).at(y), c);
        d2.at(y).at(x) = min(d2.at(y).at(x), c);
        g.at(x).push_back(y);
        g.at(y).push_back(x);
    }

    sort(r.begin(), r.end());
 /*
    queue<int> q;

    for(int i=1; i<=n; i++){
        dist.at(i) = 0;
        q.push(i);

        while(!q.empty()){
            int u = q.front();
            q.pop();

            for(auto v:g.at(u)){
                if(dist.at(v)!=-1) continue;
                dist.at(v) = dist.at(u) + d.at(u).at(v); 
                d2.at(u).at(v) = dist.at(v);
                q.push(v);
            }
        }

        for(int j=1; j<=n; j++){
            dist.at(j) = -1;
        } 
    }
*/
    for(int i=1; i<=n; i++){
        d2.at(i).at(i) = 0;
    }

    for(int k=1; k<=n; k++){
        for(int i=1; i<=n; i++){
            for(int j=1; j<=n; j++){
                d2.at(i).at(j) = min(d2.at(i).at(j), d2.at(i).at(k) + d2.at(k).at(j));
            }
        }
    }

    ll ans = 1000000000; 
    do{
        ll tmp = 0;
        for(int i=0; i<R-1; i++){
            tmp += d2.at(r.at(i)).at(r.at(i+1)); 
            dump(r.at(i));
        }
        ans = min(ans, tmp);
    }while(next_permutation(r.begin(), r.end()));

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1152
// In the name of God //
 
#include <bits/stdc++.h>
#define ll long long
#define all(x) (x).begin(), (x).end()
#define pii pair <int, int>
using namespace std;
const int N = 1e6 + 5;
const int MAXN = 1e7 + 50;
const int mod = 1e9 + 7;

 
// Calculating SPF (Smallest Prime Factor) for every 
// number till MAXN. 
// Time Complexity : O(nloglogn) 
vector<int> spf(MAXN);
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (int j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 


void solve() {
    int n;
    cin >> n;
    sieve();
    vector<int> dp(MAXN);
    long long ans = 1;
    dp[1] = 1;
    for (int i = 2; i <= n; i++) {
        int x = i;
        int p = spf[x];
        long long s = 0;
        s += dp[x/p];
        x = x/p;
        int q = 0;
        while(x % p == 0) {
            q++;
            x/= p;
        }
        q++;
        s += dp[i/p]/q;
        dp[i] = s;
        ans += i*s;
        // cout << s << " ";
    }
    cout << ans;
}


int main()  {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int tt = 1;
    // cin >> tt;
    for (int tc = 1; tc <= tt; ++tc) {
        solve();
    } 
}                                   

Measured memory_bytes: 81324
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll n,a[100];
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    sort(a,a+n);
    ll result = 0;
    for (int i = 0; i < n/2; i++) {
        result += a[n-1 - (i*2)] - a[n-1 - (i*2+1)] ;
    }
    if(n%2==1){
        result += a[0];
    }
    std::cout << result << std::endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
//using atcorder.DataStructure;
namespace atcorder
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            atcorder.Test.Run();
        }
    }


    public class Test
    {
        public static void Run()
        {
            Input input=new Input(' ');
            input.ReadLine();
            int H = input.Next<int>();
            int W = input.Next<int>();
            input.ReadLine();
            int h = input.Next<int>();
            int w = input.Next<int>();
            Console.WriteLine((H * W) - (H * w) - (h * W) + (h * w));
        }
    }







    public class Input
    {
        int arg;
        int length;
        string s;
        string[] ss;
        char sep;
        public Input(char _sep = '\0')
        {
            sep = _sep;
        }
        public void ReadLine()
        {
            s = Console.ReadLine();
            if (sep != '\0') ss = s.Split(sep);
            else
            {
                ss = new string[1];
                ss[0] = s;
            }
            arg = 0;
            length = ss.Length;
        }
        public T Next<T>()
        {
            if (arg == length) throw new IndexOutOfRangeException();
            return (T)Convert.ChangeType(ss[arg++], typeof(T));
        }
        public void SetSeparater(char _sep)
        {
            sep = _sep;
        }
    }
}


Measured memory_bytes: 11348
#include<stdio.h>

int value[50];


int fib(int n){
  int i;
  value[0]=1;
  value[1]=1;

  for(i=2;i<=n;i++){
    value[i] = value[i-2] + value[i-1];
  }
  return value[n];
}


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

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

#define ull unsigned long long

using namespace std;

main(void)
{
    

    ull n; 
    cin >> n;
    ull *A = new ull[n];
    ull *B = new ull[n+1];

    for (ull i = 0; i <= n; ++i)
        cin >> B[i];
    for (ull i = 0; i < n; ++i)
        cin >> A[i];
   
    ull P = 0;
    for (ull i = 0; i < n; ++i)
    {
        if(A[i] <= B[i])
        {
            P += A[i];
            B[i] -= A[i];
            A[i] = 0;
        }
        else if(A[i] > B[i])
        {
            P += B[i];
            A[i] -= B[i];
            B[i] = 0;
            if (A[i] >= B[i+1])
            {
                P += B[i+1]; 
                B[i+1] = 0; 
            }
            else if (A[i] < B[i+1])
            {
                P += A[i]; 
                B[i+1] -= A[i]; 
                A[i] = 0;
            }
        }
    }
    //for (ull i = 0; i < n; ++i)
    //    cout << A[i] << " ";
    //cout << "\n";
    //for (ull i = 0; i <= n; ++i)
    //    cout << B[i] << " ";
    cout << P;

    return 0;
}

Measured memory_bytes: 5108
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define ll long long
#define f first
#define p_b push_back
#define s second
using namespace std;

int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string st,ed;
    cin >> st >> ed;
    int n,m;
    n = st.size();
    m = ed.size();
    vector < vector < int > > dp(n+1, vector < int > (m+1,0));
    for( int i = 1; i <= n; i++)
    {
        for( int j = 1; j <= m; j++)
        {
            if(st[i-1]==ed[j-1])
            {
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else
            {
                dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
            }
        }
    }
    string ans = "";
    int i = n, j = m;
    while(i>=1 && j >=1)
    {
        if(st[i-1]==ed[j-1])
        {
            ans+=st[i-1];
            i--;
            j--;
        }
        else
        {
            if(dp[i-1][j]>=dp[i][j-1])
            {
                i--;
            }
            else
            {
                j--;
            }
        }
    }
    reverse(all(ans));
    cout << ans;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  int a[N];
  for (int i=0; i<N; i++) {
    cin >> a[i];
  }
  sort(a,a+N,greater<int>());
  int sum=0;
  int ans=N;
  for (int i=0; i<N; i++) {
    if (sum+a[i]<K) {
      sum+=a[i];
    } else {
      ans=N-i-1;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e6 + 10;
string vs[3];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int o = 0;
	for (int i = 0; i < 3; i++)
	{
		cin >> vs[i];
		sort(vs[i].begin(), vs[i].end());
	}
	while (!vs[o].empty())
	{
		int t = vs[o].back() - 'a';
		vs[o].pop_back();
		o = t;
	}
	cout << char(o + 'A') << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <queue>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <deque>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fst first
#define snd second
const ll mod = 1000000007;
const ll INF = (1LL << 59);
const int iINF = (1 << 31) - 1;
const double dINF = 1000000000000000000.0;
const int MAX_N = 1 << 17;
typedef pair<double, double> pdd;

//#define _DEB 0

char mp[1010][1010];
ll n, m, a, b;

void print() {
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cout << mp[i][j];
		}
		cout << endl;
	}
}

int main() {
#ifdef _DEB
	for (int dsum = 2; dsum < 100; dsum++) {
		for (n = 1; n < dsum; n++) {
			m = dsum - n;
			for (int da = 0; da < n*m / 2 + 1; da++) {
				for (int db = 0; db < n*m / 2 + 1; db++) {
					a = da; b = db;
					cout << "dsum= "<<dsum << " ";
					cout << "n,m,a,b= " << n << ',' << m << ',' << a << ',' << b << endl;
					int tt;
					cin >> tt;
#else
	cin >> n >> m >> a >> b;
#endif
	bool flg = true;
	int l = 0, u = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			mp[i][j] = '.';
		}
	}
	if (n % 2 == 1) {
		int x = 0;
		while (a > 0 && m - x >= 2) {
			mp[n - 1][x++] = '<';
			mp[n - 1][x++] = '>';
			a--;
		}
	}
	if (m % 2 == 1) {
		int x = 0;
		while (b > 0 && n - x >= 2) {
			mp[x++][m - 1] = '^';
			mp[x++][m - 1] = 'v';
			b--;
		}
	}
	while ((a > 1 || b > 1) && (n>1&&m>1)) {
		if (a > 1) {
			mp[u][l] = '<';
			mp[u + 1][l] = '<';
			mp[u][l + 1] = '>';
			mp[u + 1][l + 1] = '>';
			u += 2;
			a -= 2;
		}
		else {
			mp[u][l] = '^';
			mp[u][l + 1] = '^';
			mp[u + 1][l] = 'v';
			mp[u + 1][l + 1] = 'v';
			u += 2;
			b -= 2;
		}
		if (n - u < 2) {
			u = 0;
			l += 2;
			if (m - l < 2)break;
		}
	}
	if (a >= 2 || b >= 2) flg = false;
	else if ((a > 0 || b > 0) && m - l < 2) flg = false;
	else if (a == 1 && b == 1) {
		if (m % 2 == 1 && n % 2 == 1) {
			mp[n - 3][m - 3] = '^';
			mp[n - 2][m - 3] = 'v';
			mp[n - 3][m - 2] = '<';
			mp[n - 3][m - 1] = '>';
			mp[n - 2][m - 1] = '^';
			mp[n - 1][m - 1] = 'v';
		}
		else {
			mp[u][l] = '<';
			mp[u][l + 1] = '>';
			u++;
			if (n - u < 3) {
				u = 0;
				l += 2;
			}
			if (m - l >= 2 && n >= 2) {
				mp[u][l] = '^';
				mp[u + 1][l] = 'v';
			}
			else flg = false;
		}
	}
	else if (a == 1) {
		if (m == 1) flg = false;
		else {
			mp[u][l] = '<';
			mp[u][l + 1] = '>';
		}
	}
	else if (b == 1) {
		if (n == 1) flg = false;
		else {
			mp[u][l] = '^';
			mp[u + 1][l] = 'v';
		}
	}
	if (!flg) {
		cout << "NO" << endl;
#ifdef _DEB
		print();
#endif
	}
	else {
		cout << "YES" << endl;
		print();
	}
#ifdef _DEB
				}
			}
		}
	}
#endif
	return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,x=0,ans=0;
	string s;
	cin>>n>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='I'){
			x++;
		}
		else{
			x--;
		}
		if(ans<x){
			ans=x;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
using namespace std;

bool judge(int x)
{
	char msg[9];
	int i=0,j=0;

	while(x>0)
	{
		msg[j++]=x%10;
		x=x/10;
	}
	j--;

	while(i<j)
	{

		if(msg[i]!=msg[j])
			return false;
		i++;
		j--;
	}
	return true;


}


const int MAXN=100003;
int main(void)
{
	int i,res[MAXN]={0},sum=0,x,y;
	for(i=9999;i<=MAXN;i++)
	{
		
		if(judge(i))
			sum++;

		res[i]=sum;
	}

	scanf("%d%d",&x,&y);
	printf("%d\n",res[y]-res[x-1]);
	return 0;
}

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

long long read()
{
	long long x=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
	   if(ch=='-')  w=-1;
	   ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
	   x=x*10+ch-'0';
	   ch=getchar();
	}
	return x*w;
}

int main()
{
	T=read();
	double now=100.0;
	long long num=100,ans=0;
	while(num<T)
	{
		now=now*1.01;
		num=now;
		now=num;
		ans++;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
using namespace std;
template<typename T> void read(T &num){
	char c=getchar();T f=1;num=0;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){num=(num<<3)+(num<<1)+(c^48);c=getchar();}
	num*=f;
}
template<typename T> void qwq(T x){
	if(x>9)qwq(x/10);
	putchar(x%10+'0');
}
template<typename T> void write(T x){
	if(x<0){x=-x;putchar('-');}
	qwq(x);putchar('\n');
}

int main(){
	int n,a,b;read(n);read(a);read(b);
	if((a-b)%2==0){puts("Alice");}
	else{puts("Borys");}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is >> a.first >> a.second; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os << a.first << " " << a.second; }
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; }
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; }
 
#define ForEach(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++)
#define ALL(v) (v).begin(), (v).end()
#define UNQ(s) { sort(ALL(s)); (s).erase( unique( ALL(s)), (s).end());}

typedef long long int64;
typedef pair< int , int > Pi;
typedef pair< int , Pi > Pii;
const int INF = 1 << 30;

int main()
{
  int R, W[2], H[2], X, Y, L[500][500];
  int min_cost[500][500], limit[2][500 * 500 + 1];

  static const signed dy[] = { 0, 1, 0, -1}, dx[] = { 1, 0, -1, 0};

  while(scanf("%d", &R), R){
    map< int, int > level[2];
    for(int i = 0; i < 2; i++){
      scanf("%d %d %d %d", &W[i], &H[i], &X, &Y);
      --X, --Y;
      for(int j = 0; j < H[i]; j++){
        for(int k = 0; k < W[i]; k++){
          scanf("%d", &L[j][k]);
        }
      }
      priority_queue< Pii, vector< Pii >, greater< Pii > > que;
      fill_n( *min_cost, 500 * 500, INF);
      que.push( Pii( L[Y][X], make_pair( X, Y)));
      min_cost[X][Y] = L[Y][X];
      level[i][min_cost[X][Y]]++;
      while(!que.empty()){
        Pii p = que.top(); que.pop();
        if(p.first > min_cost[p.second.first][p.second.second]) continue;
        for(int j = 0; j < 4; j++){
          int nx = p.second.first + dx[j], ny = p.second.second + dy[j];
          if(nx < 0 || nx >= W[i] || ny < 0 || ny >= H[i]) continue;
          if(max( L[ny][nx], p.first) >= min_cost[nx][ny]) continue;
          min_cost[nx][ny] = max( L[ny][nx], p.first);
          que.push( Pii( max( L[ny][nx], p.first), make_pair( nx, ny)));
          level[i][min_cost[nx][ny]]++;
        }
      }

      int sz = 0;
      fill_n( limit[i], H[i] * W[i], 0);
      ForEach(it, level[i]){
        sz += it -> second;
        limit[i][sz] = it -> first;
      }
      for(int j = H[i] * W[i] - 1; j > 0; j--){
        if(limit[i][j] == 0) limit[i][j] = limit[i][j + 1];
      }
    }

    int ret = INF;
    for(int i = 0; i < H[0] * W[0]; i++){
      int nokori = R - i;
      if(nokori < 0 || nokori > W[1] * H[1]) continue;
      ret = min( ret, limit[0][i] + limit[1][nokori]);
    }
    printf("%d\n", ret);
  }
}

Measured memory_bytes: 15612
/*
 * written by Yaqi Zhang
 * University of Wisconsin-Madison
 * 2020
 */

#include<algorithm>
#include<cstring>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stdio.h>
#include<vector>

#define INF 0x3f3f3f3f

using namespace std;


int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    double R;
    cin >> R;
    printf("%.4lf\n", 3.1415926 * 2 * R);
    return 0;

}



Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  int k;
  cin>>k;
  
  vector<int> v={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1,
  15, 2, 2, 5, 4, 1, 4, 1, 51};
  
  cout<<v[k-1]<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>

using namespace std;

std::vector<vector<int>> graph;
std::vector<bool> used;

int Get(int v) {
    used[v] = true;
    std::vector<int> all;
    for (const auto& to : graph[v]) {
        if (!used[to]) {
            used[to] = true;
            all.push_back(Get(to));
        }
    }

    if (all.empty()) {
        return 0;
    }
    sort(all.begin(), all.end());
    int ans = 0;
    for (int i = 0; i < (int)all.size(); i++) {
        ans = max(ans, all[i] + (int)all.size() - i);
    }
    return ans;
}

int main(void) {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    used.resize(n);
    used.assign(n, false);
    graph.resize(n);

    for (int i = 2; i <= n; i++) {
        int x;
        cin >> x;
        graph[x - 1].push_back(i - 1);
    }
    cout << Get(0) << endl;
}


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

int main() {
    string n; cin >> n;
    for(int i = 0; i < n.size(); i++){
        if(n[i] == '1'){
            n[i] = '9';
            continue;
        }
        if(n[i] == '9'){
            n[i] = '1';
            continue;
        }
    }
    cout << n << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long ll;


int main()
{
    ll n,a,b;
    scanf("%lld %lld %lld",&n,&a,&b);
    ll c,d,ans;
    c=n/(a+b);
    d=n-c*(a+b);

    if(d>=a)
    {
        d=a;
    }
    
    ans=a*c+d;    

printf("%lld\n",ans);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cctype>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int seki[3][3] = {{0,0,0},{0,1,1},{0,1,2}};
int wa[3][3] = {{0,1,2},{1,1,2},{2,2,2}};
int hoge[3] = {2,1,0};

int p,q,r;
int eval(string s) {
  //  cout << s << endl;
  if (s[0]=='-') {
    int i;
    for (i=0;s[i]=='-';i++);
    if (i%2) return hoge[eval(s.substr(i))];
    else return eval(s.substr(i));
  }
  if (s[0]!='(') {
    int foo;
    if (isdigit(s[0])) foo = s[0]-'0';
    if (s[0]=='P') foo = p;
    if (s[0]=='Q') foo = q;
    if (s[0]=='R') foo = r;
    return foo;
  }
  int nest = 0;
  REP(i,s.length()) {
    if (s[i] == '(') nest++;
    if (s[i] == ')') nest--;
    if (nest!=1) continue;
    if (s[i] == '+') return wa[eval(s.substr(1,i-1))][eval(s.substr(i+1,s.length()-i-2))];
    if (s[i] == '*') return seki[eval(s.substr(1,i-1))][eval(s.substr(i+1,s.length()-i-2))];
  }
}


int main() {
  string s;
  while(cin>>s,s!=".") {
    int ans = 0;
    for(p=0;p<3;p++) {
      for(q=0;q<3;q++) {
        for(r=0;r<3;r++) {
          if (eval(s)==2)
            ans++;
        }
      }
    }
    cout << ans << endl;
  }
  
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int x, y, z;
    cin >> x >> y >> z;
    int ans = 1;
    x -= y + 2 * z;
    cout << ans + x /(y + z) << endl;
    return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

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

	set<char> K;
	fx(S.size()) {
		K.insert(S[x]);
	}

	if (K.size()==1) {
		ce(0)
	}
	else {
		int ans = 100;
		for (char c : K) {
			string T = S;
			int sum = 0;
			while (true) {
				sum++;
				fx(T.size() - 1) {
					if (T[x + 1] == c) {
						T[x] = c;
					}
				}
				T.erase(T.end() - 1);
				bool flag = true;
				fx(T.size()) {
					if (T[x] != c) {
						flag = false;
						break;
					}
				}
				if (flag) {
					ans = min(ans, sum);
					break;
				}
			}
		}
		ce(ans)
	}

    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define FOR(i, l, r) for(int i = l; i <= r; ++i)
using namespace std;

typedef long long ll;
const ll inf = 1LL << 50;
const int N = 110;

struct edge{int to, next; ll v;} e[N * N * 2];
int d[N], head[N], f[N], h[N];
int n, s, t, cnt;
ll ans, x;

void ins(int x, int y, ll z)
{
    e[++cnt].to = y; e[cnt].next = head[x]; e[cnt].v = z; head[x] = cnt;
    e[++cnt].to = x; e[cnt].next = head[y]; e[cnt].v = 0; head[y] = cnt;
}

bool bfs()
{
    FOR(i, s, t) d[i] = t + 10;
    d[s] = 0; h[1] = s; int l = 0, r = 1;
    while (l < r)
    {
        int x = h[++l];
        for(int i = head[x]; i; i = e[i].next)
            if (d[e[i].to] > d[x] + 1 && e[i].v)
            {
                d[e[i].to] = d[x] + 1;
                h[++r] = e[i].to;
            }
    }
    return d[t] != t + 10;
}

ll dfs(int x, ll flow)
{
    if (x == t) return flow; ll tt = 0;
    for(int i = f[x]; i && tt < flow; i = e[i].next)
        if (e[i].v && d[e[i].to] == d[x] + 1)
        {
            ll tmp = dfs(e[i].to, min(e[i].v, flow - tt));
            e[i].v -= tmp; e[i ^ 1].v += tmp; tt += tmp;
            if (e[i].v) f[x] = i;
        }
    if (!tt) d[x] = -1;
    return tt;
}

int main()
{
    scanf("%d", &n);
    t = n + 1; cnt = 1;
    FOR(i, 1, n)
    {
        scanf("%lld", &x);
        if (x > 0) ins(i, t, x), ans += x; else ins(s, i, -x);
    }
    FOR(i, 1, n) for(int j = 2 * i; j <= n; j += i) ins(i, j, inf);
    while (bfs())
    {
        FOR(i, s, t) f[i] = head[i];
        ans -= dfs(s, inf);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i<=b; i++)
#define FORD(i, a, b) for (int i = a; i>=b; i--)
#define REP(i, a) for (int i = 0; i<a; i++)
#define N 100100
#define pp pair<int, int>

using namespace std;
int n, a[N], cnt[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cin>>n;
    REP(i, n) cin>>a[i];
    int ans = 0;
    if (a[0] == 1) {
        ans++;
        swap(a[0], a[1]);
    }
    if (a[n - 1] == n) {
        ans++;
        swap(a[n - 2], a[n - 1]);
    }
    FOR(i, 1, n - 2) {
        if (a[i] == i + 1) {
            ans++;
            swap(a[i], a[i + 1]);
        }
    }
    cout<<ans;
}



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

using namespace std;

int main(){
    int n;

    cin >> n;

    vector<int> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }

    vector<int> r(0);
    bool h = false;
    while(true){
        h = false;
        for(int i = v.size() - 1; i >= 0; i--){
            if(v[i] == i + 1){
                r.push_back(i);
                v.erase(v.begin() + i);
                h = true;
                break;
            }
        }
        if(h){
            if(v.size() == 0) break;
            continue;
        }
        cout << -1 << endl;
        return 0;
    }

    for(int i = r.size() - 1; i >= 0; --i){
        cout << r[i] + 1 << endl;
    }

    return 0;
}

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

int main() {
    int N;
    cin >> N;
    int total = N % 10;
    int base = 10;
    int x = 1;
    while (N / base != 0) {
        x += 1;
        base *= 10;
    }
    base = 10;
    for (int i = 1; i < x; i++) {
        total = total + (N % (base * 10) - N % base) / base;
        base *= 10;
    }
    if (N % total == 0) {
        cout << "Yes" << endl;
    }
    else if (N % total != 0) {
        cout << "No" << endl;
    }
}


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

using namespace std;
typedef long long nagai;

nagai MOD = 1000000007LL;

int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	vector<int> x(n);
	vector<int> y(m);
	for (auto& a : x)
		scanf("%d", &a);
	for (auto& a : y)
		scanf("%d", &a);
	nagai ans = 0;
	nagai sum = 0;
	for (int j = 0; j < m - 1; ++j)
		sum += 1LL * (j + 1) % MOD * (m - (j + 1)) % MOD * (y[j + 1] - y[j]) % MOD;
	sum %= MOD;
	for (int i = 0; i < n - 1; ++i)
	{
		ans += 1LL * (i + 1) * (n - (i + 1)) % MOD * (x[i + 1] - x[i]) % MOD * sum;
		ans %= MOD;
	}
	cout << ans % MOD << endl;

}


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

using namespace std;

#define LL long long

int main() {
    // freopen("a.txt", "r", stdin);
    int mod = 998244353;
    int N, S, res = 0;
    cin >> N >> S;

    vector<int> A(N + 1, 0);
    for(int i = 1; i <= N; ++i) cin >> A[i];

    vector<int > dp(S+1, 0);
    for(int i = 1; i <= N; ++i) {
        if(S == A[i]) res = (res + 1ll * i * (N - i + 1) % mod) % mod;
        else if(S > A[i]) res = (res + 1ll * dp[S - A[i]] * (N - i + 1) % mod) % mod;
        for(int j = S; j >= A[i]; --j)
            dp[j] = (dp[j] + dp[j - A[i]] + (j == A[i]? i: 0)) % mod;
    }

    cout << res << endl;
    return 0;
}

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

void print(ll x[], ll n)
{
	for(int i = 0; i < n; i++)
		cout << x[i] << " ";
	cout << endl;
}
vector<int> graph[100009];
int dp[100009];
int func(int root)
{
	if(dp[root] != -1)
		return dp[root];
	int ans = 0;
	for(int i: graph[root])
	{
		ans = max(ans, func(i)+1);
	}
	dp[root] = ans;
	return ans;
}

int main()
{
	ios::sync_with_stdio(false);
	int n, m, x, y;
	memset(dp, -1, sizeof dp);
	cin >> n >> m;
	for(int i = 0; i < m; i++)
	{
		cin >> x >> y;
		graph[x].push_back(y);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++)
		ans = max(ans, func(i));
	cout << ans << endl;

	return 0;
}

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

#define F first
#define S second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()

using namespace std;

typedef long long llong;

const int MXN = (int)1e6 + 7;
const int MOD = (int)1e9 + 7;
const int N = (int)1e3 + 7;

int n, m;
char ch[N][N];
llong dp[N][N];

int main()
{
  cin >> n >> m;
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= m; j++){
      cin >> ch[i][j];
    }
  }
  dp[1][1] = 1;
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= m; j++){
      if(ch[i - 1][j] == '.' && ch[i][j] == '.'){
        dp[i][j] += dp[i - 1][j] % MOD;
      }
      if(ch[i][j - 1] == '.' && ch[i][j] == '.'){
        dp[i][j] += dp[i][j - 1] % MOD;
      }
    }
  }
  cout << dp[n][m] % MOD;
  /*for(int i = 1; i <= n; i++){
    for(int j = 1; j <= m; j++){
      cout << dp[i][j] << ' ';
    }
    cout << endl;
  }*/
  return 0;
}


Measured memory_bytes: 9088
def pow_k(x, n,mod = 10**9+7):
    res = 1
    for i in range(0,n):
        res = res * x % mod

    return res

def solve(n,mod = 10**9+7):
    total = pow_k(10,n)
    not_include_0 = pow_k(9,n)
    not_include_9 = not_include_0
    not_include_0_and_9 = pow_k(8,n)
    return (total%mod-(not_include_0 + not_include_9 - not_include_0_and_9)%mod)%mod

def main():
    n = int(input())
    print(solve(n))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9180
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		
		int K = sc.nextInt();
		
		int magic = 0;
		while(B<=A) {
			magic++;
			B*=2;
		}
		while(C<=B) {
			magic++;
			C*=2;
		}
		System.out.println(magic<=K ? "Yes" : "No");
		sc.close();
	}
}


Measured memory_bytes: 27056
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

using ll = long long;

/*void max_self(ll& a , ll b){
    a = max(a,b);
}*/

int main(){

    int n ,W ;
    scanf("%d%d", &n, &W);

    vector<ll> dp(W + 1);
    for (int item = 0; item < n; ++item) {
        int weight, value;
        scanf("%d%d", &weight, &value);
        for (int weight_already = W - weight; weight_already  >= 0 ; --weight_already) {
            dp[weight_already + weight] = max(dp[weight_already + weight],dp[weight_already] + value);
        }
    }

    ll res;
    for (int k = 0; k <= W ; ++k) {
        res = max(res,dp[k]);
    }

    printf("%lld\n ",res);

    return 0;
}


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

int main(){
  int N;
  cin >> N;
  int mi=1e9;
  int ans=0;
  for(int i=0;i<N;i++){
    int P;
    cin >> P;
    if(mi>P){
      mi=P;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
int main() {
	int n, k;
	cin >> n >> k;
	int ans = 0;
	int count = 0;
	for (int i = 0; n > 0; i++) {
		ans = ans + (n%k)*pow(10, i);
		n = n / k;
		count += 1;
	}
	string s = to_string(ans);
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 384
def isCLKWISE(ph):
    if (ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0 : return False
    else : return True
     
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            if isCLKWISE(phU) : break
            else :
                del phU[-2]
                if len(phU) == 2 : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            if isCLKWISE(phL) : break
            else :
                del phL[-2]
                if len(phL) == 2 : break
    ph = phU + phL[1:-1]
    return ph
 
n = int(input())
P = []
for i in range(n):
    P.append([int(x) for x in input().split()])
     
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R:
    print(r[0],r[1])

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

using namespace std;

int main()
{
    int n,k;
    cin>>n>>k;
    int h[n],dp[n];
    for(int i=0;i<n;i++)
        cin>>h[i];
    int m=INT_MAX;
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        m=INT_MAX;
        for(int j=i-1;j>=0 && j>=i-k;j--){
            if(dp[j]+abs(h[i]-h[j])<m)
                m = dp[j]+abs(h[i]-h[j]);
        }
        dp[i]=m;
        //cout<<dp[i-2]<<endl;
    }
    cout<<dp[n-1]<<endl;
   
}

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

template <typename T> T gcd(T m, T n) {
    return n == 0 ? abs(m) : gcd(n, m % n);
}
template <typename T> T lcm(T m, T n) { return abs(m / gcd(m, n) * n); }

int main() {
    int n;
    cin >> n;
    long long sum = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            for (int k = 1; k <= n; k++) {
                sum += gcd(i, gcd(j, k));
            }
        }
    }
    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 3572