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

#define ll long long
#define ull unsigned long long
#define ld long double
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define fo(i,start,end) for(int i=start;start<end?i<end:i>end;start<end?i+=1:i-=1)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vop vector<pll>
#define vov vector<vector<ll>>
#define endl "\n"
using namespace std;
const ld pi=3.14159265358979323;

const long long mod1=1e9+7;
const long long mod2=1e18;
const ll mod3=9e18;
const ll N=1e9+7;

long long power(ll  x, ll n){if(n==0)return 1;ll temp=power(x,n/2);if(n%2==0)return temp*temp;else return x*temp*temp;}

ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return (a*b)/(gcd(a,b));}
void swap(int* a, int* b){int t = *a;*a = *b;*b = t;}
bool f(ll x,ll y){return x>y;}

ll MAX(ll a,ll b){return a>b?a:b;}
ll MIN(ll x,ll  y){return x>y?y:x;}

ll pmod(ll a, ll b,ll mod)//a^b%mod
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b/=2;
        a=(a*a)%mod;
    }
    return ans;
}

bool cmp2( pair<ll,ll> &a,
           pair<ll,ll> &b)
{
    return a.second>b.second;
}


void solve() {
    ll n ,W;
    cin>>n>>W;
    ll wt[n+1],val[n+1];
    ll sum=0;
    fo(i,1,n+1){
        cin>>wt[i]>>val[i];
        sum+=val[i];
    }

    ll ans[n+1][sum+1];
    memset(ans,1e9, sizeof(ans));
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<=sum;j++)ans[i][j]=9000000000;
    }




    ans[0][0]=0;
    ll pre[n+1];
    pre[1]=wt[1];
    for(ll i=2;i<=n;i++){
        pre[i]=MIN(pre[i-1],wt[i]);

    }
    for(ll i=1;i<=n;i++)ans[i][0]=0;
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=sum;j++){
            ans[i][j]=ans[i-1][j];
            if(j-val[i]>=0)ans[i][j]=MIN(ans[i-1][j-val[i]]+wt[i],ans[i][j]);
        }


    }

    for(ll i=sum;i>=0;i--){
        if(ans[n][i]<=W){
            cout<<i;
            return;
        }


    }







}

























int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin) ;
    freopen("output.txt" , "w" , stdout) ;
    //freopen("error.txt" , "w" , stderr) ;
#endif








    ll t;
    t=1;
    //cin>>t;
    //  cin.ignore();
    while(t--){

        solve();
    }




    return 0;


}

////vll adj[100001];
////ll vis[100001];
////ll sssp[100001];

Measured memory_bytes: 82448
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>

using namespace std;

int main() {
  cin.tie(0);

  int a[5],k;

  for (int i = 0; i < 5; i++) {
    cin >> a[i];
  }
  cin >> k;
int check = 0;
  for (int i = 0; i < 5; i++) {
    for(int j = i ; j < 5 ; j++){
      if(a[j]-a[i]>k){
        cout << ":("<<endl;
        i = 100;
        break;
      }
    }
    if(i==4)cout << "Yay!"<<endl;
  }
  return 0;
}


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

using namespace std;

int main()
{
    long long nMax=1e5+5,N, W, d[2][nMax], w[102], v[102];
    cin >> N >> W;
    for(int i=0;i<N;i++)
        cin >> w[i] >> v[i];
    for(int j = 1; j < nMax; j++)
        d[1][j] = LLONG_MAX/2;
    d[1][0] = 0;
    for(int i = 0; i < N; i++)
        for(int j = 0; j < nMax; j++)
            if(j >= v[i])
                d[i&1][j] = min(d[i&1^1][j-v[i]]+w[i], d[i&1^1][j]);
            else
                d[i&1][j] = d[i&1^1][j];
    for(int q = nMax-1; q > 0; q--)
        if(d[N&1^1][q] <= W)
            return 0*printf("%i\n",q);
}


Measured memory_bytes: 1792
using System;

class Program
{
    static void Main(string[] args)
    {
        String input = Console.ReadLine();
        int output = Conpute(input);
        Console.WriteLine(output);
    }
  
    public static int Conpute(String arg)
    {
        var input = arg.Split(' ');
        var inputs = Array.ConvertAll<String, int>(input, s => int.Parse(s));

        var a = inputs[0];
        var b = inputs[1];

        if (b % a == 0)
        {
            return a + b;
        }
        else
        {
            return b - a;
        }
    }
}

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

// 小数点以下桁数
// fixed << setprecision(i)

int main()
{
  int a, b, h, m;
  double ta, tb, t;

  cin >> a >> b >> h >> m;
  ta = 30 * h + (double)m / 2;
  tb = 6 * m;
  t = min(abs(ta - tb), 360 - abs(ta - tb));
  t = sqrt(a * a + b * b - 2 * a * b * cos(t / 180 * M_PI));
  cout << fixed << setprecision(9) << t << endl;
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*{
}*/

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

//constexpr int mod = 1e9+7;
//constexpr int inf = 1LL<<60;

signed main() {
  int n, k;
  cin >> n >> k;

  vi a(n), s(n+1);
  rep(i, 0, n){
    cin >> a[i];
    s[i+1] = (s[i] + a[i]-1 + k)%k;
  }

  map<int, int> m;
  m[0] = 1;
  int ans = 0;
  rep(i, 1, n+1){
    if(i - k >= 0) m[s[i-k]]--;
    ans += m[s[i]];
    m[s[i]]++;
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 15872
#include<iostream>
#include<vector>
#include<cmath>
static const long long int mod= 1000000000+7;
using namespace std;

vector<long long int>a(1005, 1);

void prime(int n) {
	if (n == 1)return;
	prime(n - 1);
	for (int i = 2; i <= n; ++i) {
		if (n % i == 0) {
			++a[i];
			n /= i;
			--i;
			if (n == 1)return;
		}
	}
}


int main() {
	int n;
	cin >> n;
	prime(n);
	long long int sum = 1;
	for (int i = 2; i < n; ++i) {
	}
	for (int i = 2; i <= n; ++i) {
		sum *= a[i];
		sum %= mod;
	}
	cout << sum << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

#define p(x) cout << x << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define range(i, begin, end) for (int i = begin; i < (int)(end + 1); i++)
#define all(x) (x).begin(), (x).end()

ll MOD = 1000000007;

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

  vector<ll> as(n);
  rep(i, n) { cin >> as[i]; }

  ll m = 0;
  rep(i, n) {
    rep(j, n) {
      if (i < j) {
        if (as[i] > as[j]) {
          m += 1;
        }
      }
    }
  }

  ll a_m = 0;
  rep(i, n) {
    rep(j, n) {
      if (as[i] > as[j]) {
        a_m += 1;
      }
    }
  }

  ll ans = 0;
  ll cal = k * (k - 1) / 2 % MOD;
  ans += m * k % MOD;
  ans %= MOD;
  ans += a_m * cal % MOD;
  ans %= MOD;

  p(ans);

  return 0;
}


Measured memory_bytes: 256
import collections

h, w = map(int, input().split())
ls = [input().rstrip() for _ in range(h)]
ds = [[float('inf') for _ in range(w)] for _ in range(h)]
ds[0][0] = 1

dxdy = [(-1, 0), (1, 0), (0, -1), (0, 1)]


def bfs(x, y):
    for i in range(4):
        dx, dy = dxdy[i]
        nx = x + dx
        ny = y + dy
        if 0 <= nx < w and 0 <= ny < h and ls[ny][nx] == '.':
            if ds[ny][nx] == float('inf'):
                ds[ny][nx] = ds[y][x] + 1
                q.append([nx, ny])


q = collections.deque([[0, 0]])
while q:
    x, y = q.popleft()
    bfs(x, y)
d = ds[h - 1][w - 1]
if d < float('inf'):
    s = sum([l.count('.') for l in ls])
    print(s - d)
else:
    print(-1)

Measured memory_bytes: 3436
//soale C
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 20;
typedef long long ll;
ll n, a[N], c[10], d = 0;
int main(){
	cin >> n;
	for(int i = 0; i < n; i ++){
		cin >> a[i];
		if(a[i] % 4 == 0){
			a[i] = 2;
			c[0] += 1;
		}
		else if(a[i] % 4 == 2){
			a[i] = 1;
			c[1] += 1;
		}
		else{
			a[i] = 0;
			c[2] += 1;
		}
	}
	if(c[1] != 0){
		if(c[2] > c[0]){
			d = 1;
		}
	}
	else{
		if(c[2] > c[0] + 1){
			d = 1;
		}
	}
	if(d == 1){
		cout << "No";
	}
	else{
		cout << "Yes";
	}
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<set>
#include<vector>
#include<array>
#include<algorithm>
#include<chrono>

int const INF = 1e9;

uint64_t xor64(void) {
  static uint64_t x = 88172645463325252ULL;
  x = x ^ (x << 7);
  return x = x ^ (x >> 9);
}

auto b_cl = std::chrono::system_clock::now();
inline double get_time() {
  auto e_cl = std::chrono::system_clock::now();
  double msec = std::chrono::duration_cast<std::chrono::milliseconds>(e_cl - b_cl).count();
  return msec;
}

struct state {
  int score_k;
  int type;
  int last[26];
  int score;
  std::vector<state>::iterator prev;
  bool operator< (state const& rhs) const { return score_k > rhs.score_k; } // reverse order
};

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int D; std::cin >> D;
  int c[26];
  for(auto& ci: c) std::cin >> ci;
  std::vector<std::array<int,26>> s(D);
  for(int d = 0; d < D; ++d) {
    for(auto& si: s[d]) std::cin >> si;
  }
  int const B = 830;
  int const K = 3;
  std::vector<int> t(D);
  
  std::vector<std::vector<state>> states(D+1);
  auto beam_step = [&](int d, int k) {
    auto& prev = states[d];
    auto& curr = states[d+1];
    curr.reserve(prev.size()*26);
    int dd = std::min(d+k, D-1);
    for(auto it = prev.begin(); it != prev.end(); ++it) {
      for(int T = 0; T < 26; ++T) {
        curr.push_back(*it);
        state& st = curr.back();
        st.prev = it;
        st.last[T] = d;
        st.type = T;
        st.score_k = st.score + s[d][T];
        for(int cx = 0; cx < 26; ++cx) {
          st.score_k -= c[cx]*(d+dd - 2*st.last[cx])*(dd-d+1)/2;
        }
      }
    }
    std::sort(curr.begin(), curr.end());
    if(curr.size() > B) curr.resize(B);
    for(auto& st: curr) {
      st.score += s[d][st.type];
      for(int cx = 0; cx < 26; ++cx) {
        st.score -= c[cx]*(d - st.last[cx]);
      }
    }
  };
  
  auto beam_search = [&](int k) {
    states.assign(D+1, std::vector<state>());
    states[0].emplace_back();
    states[0][0].score = 0;
    states[0][0].score_k = 0;
    std::fill_n(states[0][0].last, 26, -1);
    for(int d = 0; d < D; ++d) beam_step(d, k);
    auto it = states[D].begin();
    for(int d = D-1; d >= 0; it = it->prev, --d) {
      t[d] = it->type;
    }
  };
  beam_search(K);
  for(auto ti: t) std::cout << ti+1 << "\n";
  return 0;
}


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

int dfs(vector<int> &l,vector<vector<int>> r, vector<int> a, int k){
	int m = 1e9;
	if(k==l.size()){
		int sum{};
		for(int i=0; i<3; i++){
			if(r.at(i).size()==0) return (int)1e9;
			sum += (r.at(i).size()-1)*10;
			int le{};
			for(auto j:r.at(i)) le += j;
			sum += abs(a.at(i)-le);
		}
		m = sum;
	}
	else {
		for(int i=0; i<3; i++){
			r.at(i).push_back(l.at(k));
			m = min(m,dfs(l,r,a,k+1));
			r.at(i).pop_back();
		}
		m = min(m,dfs(l,r,a,k+1));
	}
	return m;
}

int main(){
	int n; cin>>n;
	vector<int> a(3);
	for(int i=0; i<3; i++) cin>>a.at(i);
	vector<int> l(n);
	for(auto &i:l) cin>>i;
	vector<vector<int>> r(3);
	cout << dfs(l,r,a,0) << endl;
	
}

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

string s, t;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> s >> t;
	long long dp[s.length()+1][t.length()+1];
	for (int i=0; i<s.length()+1; i++) dp[i][0] = 0;
	for (int i=1; i<t.length()+1; i++) dp[0][i] = 0;
	for (int i=1; i<=s.length(); i++) {
		for (int j=1; j<=t.length(); j++) {
			if (s[i-1] == t[j-1]) {
				dp[i][j] = dp[i-1][j-1] + 1;
			}
			else {
				if (dp[i][j-1] > dp[i-1][j]) {
					dp[i][j] = dp[i][j-1];
				}
				else dp[i][j] = dp[i-1][j];
			}
		}
	}
	long long intans = dp[s.length()][t.length()];
	// cout << "intans = " << intans << endl;
	char ans[intans];
	long long temp = intans, temps = s.length(), tempt = t.length();
	while (temp) {
		while (dp[temps][tempt] == temp) temps--;
		temps++;
		while (dp[temps][tempt] == temp) tempt--;
		ans[temp - 1] = t[tempt];
		// cout << "temp = " << temp << " string s tempt: " << tempt << endl;
		temps--;
		temp--;
	}
	for (int i=0; i<intans; i++) {
		// cout << "ans i=" << i << " " << ans[i] << endl;
		cout << ans[i];
	}
	cout << endl;
}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define _GLIBCXX_DEBUG
const int INF=1e15;

signed main(){
    int a,b;cin>>a>>b;
    cout<<a*b/2<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	int ans=1e9;
	for(int i=0;i<s.size()-t.size()+1;i++){
		int cnt=0;
		for(int j=0;j<t.size();j++)
			if(s[i+j]!=t[j])
				cnt++;
		ans=min(ans,cnt);
	}
	cout<<ans<<endl;
	return 0;
}

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

#define MAX_NUM (1000000000 + 7)

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

int main() {
  cout << setprecision(18);
  i64 a, b, c;
  cin >> a >> b >> c;
  i64 calc = 4 * a * b;
  i64 calc2 = c - a - b;
  if (calc2 < 0) {
    cout << "No" << endl;
  } else {
    calc2 *= calc2;
    if (calc < calc2) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace sumitb2019_c
{
    class Program
    {
        static void Main(string[] args)
        {
            int X = int.Parse(Console.ReadLine());
            int[] S = new int[] { 100, 101, 102, 103, 104, 105 };
            bool b = false;
 
            for (int i = 0; i <= X / S[0]; i++)
            {                
                for (int j = 0; j <= (X - (S[0]* i)) / S[1]; j++)
                {
                    for (int k = 0; k <= (X - (S[0] * i) - (S[1] * j)) / S[2]; k++)
                    {
                        for (int l = 0; l <= (X - (S[0] * i) - (S[1] * j) - (S[2] * k)) / S[3]; l++)
                        {
                            for (int m = 0; m <= (X - (S[0] * i) - (S[1] * j) - (S[2] * k) - (S[3] * l)) / S[4]; m++)
                            {
                                int x1 = 100 * i + 101 * j + 102 * k + 103 * l + 104 * m;
                                int n = (X - x1) / S[5];
                                int xr = x1 + (S[5] * n);
                                if (xr == X)
                                {
                                    b = true; 
                                    break;
                                }
                            }
                            if (b) break;
                        }
                        if (b) break;
                    }
                    if (b) break;
                }
                if (b) break;
 
            }
            Console.WriteLine(b ? "1" : "0");
        }
    }
}

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

using namespace std;
typedef long long ll;
typedef double ld;
#define MAX (1LL << 63LL) - 1LL

ll a, b, c, d;
ll maxx = -1000000000000000010;

int main(void)
{
	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
	
	maxx = max(maxx, a * c);
	maxx = max(maxx, a * d);
	maxx = max(maxx, b * c);
	maxx = max(maxx, b * d);
	
	printf("%lld", maxx);
	return 0;
}

Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
const int MAXN=200005;
const long long mod=1e9+7;
vector<int>G[MAXN];
int sz[MAXN],n,u,v;
long long dp[MAXN],fac[MAXN],invfac[MAXN],inv[MAXN],ans[MAXN];
long long quickpow(long long x,long long y)
{
    long long ans=1;
    while(y)
    {
        if(y&1)
        {
            ans=(x*ans)%mod;
        }
        x=(x*x)%mod;
        y>>=1;
    }
    return ans;
}
long long get_inv(long long x)
{
    return quickpow(x,mod-2);
}
///----------------------------
void dp_link(int root1,int root2)
{
    dp[root1]=dp[root1]*invfac[sz[root1]-1]%mod;
    sz[root1]+=sz[root2];
    dp[root1]=dp[root1]*fac[sz[root1]-1]%mod;
    dp[root1]=dp[root1]*invfac[sz[root2]]%mod;
    dp[root1]=dp[root1]*dp[root2]%mod;
}
void dp_cut(int root1,int root2)
{
    dp[root1]=dp[root1]*invfac[sz[root1]-1]%mod;
    sz[root1]-=sz[root2];
    dp[root1]=dp[root1]*fac[sz[root1]-1]%mod;
    dp[root1]=dp[root1]*fac[sz[root2]]%mod;
    dp[root1]=dp[root1]*get_inv(dp[root2])%mod;
}
void get_leaf(int root)
{
    sz[root]=1;
    dp[root]=1;
}
///-----------------------------
void change_root(int root1,int root2)
{
    dp_cut(root1,root2);
    dp_link(root2,root1);
}
void dp_dfs(int x,int fa)
{
    get_leaf(x);
    for(auto &i:G[x])
    {
        if(i!=fa)
        {
            dp_dfs(i,x);
            dp_link(x,i);
        }
    }
    return;
}
void dfs(int x,int fa)
{
    ans[x]=dp[x];
    for(auto &i:G[x])
    {
        if(i!=fa)
        {
            change_root(x,i);
            dfs(i,x);
            change_root(i,x);
        }
    }
    return;
}
void init(int n)
{
    invfac[0]=1;
    fac[0]=1;
    inv[1]=1;
    for(int i=2;i<=n;++i) inv[i]=((mod-mod/i)*inv[mod%i])%mod;
    for(int i=1;i<=n;++i) fac[i]=fac[i-1]*i%mod,invfac[i]=invfac[i-1]*inv[i]%mod;
}
int main()
{
    scanf("%d",&n);
    init(200000);
    for(int i=1;i<n;++i)
    {
        scanf("%d %d",&u,&v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    dp_dfs(1,-1);
    dfs(1,-1);
    for(int i=1;i<=n;++i)
    {
        printf("%lld\n",ans[i]);
    }
    return 0;
}


Measured memory_bytes: 22516
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

void recPrint(string& cur, char act, int k) {
	if (k == 0) cout << cur << '\n';
	else {
		for (char c = 'a'; c <= act + 1; ++c) {
			cur.push_back(c);
			recPrint(cur, max(act, c), k-1);
			cur.pop_back();
		}
	}
}

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

	int n;
	cin >> n;

	string cur = "";
	recPrint(cur, 'a' - 1, n);
}


Measured memory_bytes: 1536
# WIP
N, K = map(int, input().split())
hhh = list(map(int, input().split()))

dp = [0] * N
dp[0] = 0

for i in range(1, N):
    if i < K:
        dp[i] = \
            min([abs(hhh[i] - hhh[i-k]) + dp[i-k] for k in range(1, i+1)])
    else:
        dp[i] = \
            min([abs(hhh[i] - hhh[i-k]) + dp[i-k] for k in range(1, K+1)])

print(dp[-1])


Measured memory_bytes: 52448
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		int sx=stdIn.nextInt();
		int sy=stdIn.nextInt();
		int tx=stdIn.nextInt();
		int ty=stdIn.nextInt();
		boolean fin=false;
		int x=sx,y=sy;
		while(true){
			if(x==tx)
				break;
			if(x<tx){
				System.out.print("R"); x++;
			}
			else{
				System.out.print("L"); x--;
			}
		}
		while(true){
			if(y==ty)
				break;
			if(y<ty){
				System.out.print("U"); y++; fin=true;
			}
			else{
				System.out.print("D"); y--; fin=false;
			}
		}
		if(fin){
			System.out.print("U"); y++;
		}
		else{
			System.out.print("D");y--;
		}
		while(true){
			if(x==sx)
				break;
			if(x<sx){
				System.out.print("R"); x++; fin=true;
			}
			else{
				System.out.print("L"); x--; fin=false;
			}
		}
		if(fin){
			System.out.print("R"); x++;
		}
		else{
			System.out.print("L");x--;
		}
		while(true){
			if(y==sy)
				break;
			if(y<sy){
				System.out.print("U"); y++;
			}
			else{
				System.out.print("D"); y--;
			}
		}
		if(fin){
			System.out.print("L"); x--;
		}
		else{
			System.out.print("R");x++;
		}
		while(true){
			if(y==ty)
				break;
			if(y<ty){
				System.out.print("U"); y++;
			}
			else{
				System.out.print("D"); y--;
			}
		}
		while(true){
			if(x==tx)
				break;
			if(x<tx){
				System.out.print("R"); x++; fin=true;
			}
			else{
				System.out.print("L"); x--; fin=false;
			}
		}
		if(fin){
			System.out.print("R"); x++;
		}
		else{
			System.out.print("L");x--;
		}
		while(true){
			if(y==sy)
				break;
			if(y<sy){
				System.out.print("U"); y++; fin=true;
			}
			else{
				System.out.print("D"); y--; fin=false;
			}
		}
		if(fin){
			System.out.print("U"); y++;
		}
		else{
			System.out.print("D");y--;
		}
		while(true){
			if(x==sx)
				break;
			if(x<sx){
				System.out.print("R"); x++;
			}
			else{
				System.out.print("L"); x--;
			}
		}
		if(fin){
			System.out.print("D"); y--;
		}
		else{
			System.out.print("U");y++;
		}
	}
}


Measured memory_bytes: 23492
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prarr(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
template<typename S, typename T> 
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.ff<<", "<<p.ss<<')';return out;}
template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}
template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
const int inf = 1e9+10;
const ll INF = 1e18+10;
const int MOD = 1e9+7;
const int MAXN = 2e5+10;
void get_bin(int sm){
	string s="";
	while(sm>0){
		if(sm&1) s+="1";
		else s+="0";
		sm/=2;
	}
	reverse(all(s));
	cout<<s<<endl;
}
set<string> ans;
int mi[26] = {0};
void comp(int mask, int ind, string s, int cnt){
	if(ind > s.length()) return;

	if(cnt == s.length())
		ans.insert(s);
	// get_bin(mask);
	int n = s.length();
	int sm = (1<<n) - mask-1;
	// tr(sm, s, ind, n, mask);
	// get_bin(sm);
	// get_bin(mask);
	for(int m1 = sm ; m1; m1 = (m1-1)&sm){
		string s1 = s;
		int cnt1 = cnt;
		int mii = n;
		rep(i, n){
			if(m1&(1<<i)){
				if(i < mi[ind-1]){
					s1 = s;
					break;
				}
				cnt1++;
		    	s1[i] = 'a'+ind;
		    	mii = min(mii, i);
			}
		}
		// tr(m1, sm, s1);
		mi[ind] = mii;
		comp(m1|mask, ind+1, s1, cnt1);
	}
}
void solve()
{
	int n;
	cin>>n;
	if(n == 1){
		cout<<'a'<<endl;
		return;
	}
	// else if( n == 2){
	// 	cout<<"aa"<<endl;
	// 	cout<<"ab"<<endl;
	// 	return;
	// }
	// get_bin(n);
	string s;
	rep(i, n){
		s+="a";
	}
	rep(msk, 1<<n){
		// tr(msk, __builtin_popcount(msk));
		if((msk & 1)!=0){
		// get_bin(msk);
		// get_bin((1<<n) - msk -1);

		comp(msk, 1, s, __builtin_popcount(msk));
		}
	}
	for(auto i: ans){
		cout<<i<<endl;
		string s = i;
		rep(j, 25){
			rep(k, n)
				s[k]+=j+1;
			if(ans.find(s)!=ans.end()){
				cout<<"this is a problem"<<endl;
				return;
			}	
		}
	}
}
int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin>>t;
	while(t--){
		solve();
	}
	return 0;

}
    

Measured memory_bytes: 12416
from bisect import bisect_left
n = int(input())
a_list = sorted([int(x) for x in input().split()])
base = a_list[-1] / 2
i = bisect_left(a_list, base)
if i > 0:
    i -= 1
ans = [a_list[-1], a_list[i], abs(a_list[i] - base)]
for i in range(i + 1, n):
    temp = abs(a_list[i] - base)
    if temp >= ans[2]:
        break
    ans[1] = a_list[i]
    ans[2] = temp
print(ans[0], ans[1])

Measured memory_bytes: 14052
import itertools

n = int(input())

p = tuple(list(map(int, input().split(' '))))
q = tuple(list(map(int, input().split(' '))))

n_list = [i for i in range(1, n+1)]

a = 0
b = 0

for i, j in enumerate(itertools.permutations(n_list)):
    if j == p:
        a = i
    if q == j:
        b = i
        
print(abs(a - b))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i, s, n) for(int i=s; i<n; i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

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

  return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7
res = 0

def resolve():
    def dfs(v, p):
        global res
        c = C.pop(0)
        T[v] = c
        for u in edge[v]:
            if u == p:
                continue
            else:
                res += min(T[v], C[0])
                dfs(u, v)

    n = int(input())
    edge = [[] for _ in range(n)]
    cnt_edge = [0] * n
    for _ in range(n - 1):
        a, b = map(int, input().split())
        edge[a - 1].append(b - 1)
        edge[b - 1].append(a - 1)
        cnt_edge[a - 1] += 1
        cnt_edge[b - 1] += 1
    C = list(map(int, input().split()))
    C.sort(reverse=True)

    start = cnt_edge.index(max(cnt_edge))

    T = [0] * n
    dfs(start, -1)
    print(res)
    print(*T)


if __name__ == '__main__':
    resolve()


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

int main() {
  int N, K;
  cin >> N >> K;
  
  int x = 1;
  int y = K;
  int ans = 1;
  
  while(true){
    if(x <= N && N < y)
      break;
    x *= K;
    y *= K;
    
    ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(long long i=0;i<(n);i++)
#define ll long long
using namespace std;
int main(){
    string s,ans;
    cin >> s;
    ans += s[0];
    int right = 7;
    for(int i=0; i<(1 << 3); i++){
        int sum = s[0] - '0';
        string op;
        for(int j = 0; j<3; j++){
            if(i & (1 << j)) op += '+';
            else op += '-';
        }
        rep(k,3){
            if(op[k] == '+') sum += s[k+1] - '0';
            else sum -= s[k+1] - '0'; 
        }
        if(sum == right){
            rep(l,3){
                ans += op[l];
                ans += s[l+1];
            }
            ans += "=7";
            break;
        }
    }
    cout << ans << endl;    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.IO.Pipes;
using System.Linq;

class Program
{ 
	public static int Main()
	{
    Scanner cin = new Scanner();
	  int[][] array = new int[3][];
	  int n = cin.nextInt();
	  for (int i = 0; i < 3; i++)
	  {
	    array[i] = new int[n];
	  }
	  for (int i = 0; i < n; i++)
	  {
	    for (int j = 0; j < 3; j++)
	    {
	      array[j][i] = cin.nextInt();
	    }
	  }
    int[] score = new int[n];
	  for (int i = 0; i < 3; i++)
	  {
	    for (int j = 0; j < n; j++)
	    {
        if (Array.IndexOf(array[i], array[i][j]) == Array.LastIndexOf(array[i], array[i][j]))
	      {
	        score[j] += array[i][j];
	      }
	    }
	  }
	  for (int i = 0; i < n; i++)
	  {
	    Console.WriteLine(score[i]);
	  }
	  return 0;
	}

}

class Scanner {
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner() {
		s = new string[0];
		i = 0;
	}

	public string next() {
		if (i < s.Length) return s[i++];
		do {
			s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
		} while ((s.Length == 1 && s[0] == "") || s.Length == 0);
		i = 0;
		return s[i++];
	}

	public int nextInt() {
		return int.Parse(next());
	}

	public long nextLong() {
		return long.Parse(next());
	}

	public double nextDouble() {
		return double.Parse(next());
	}

}

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

int main(void) {
	int A, B, C;
	cin >> A >> B >> C;
	int a = A * 10 + B + C;
	int b = B * 10 + C + A;
	int c = C * 10 + A + B;
	cout << max({ a, b, c }) << endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
g=[[] for _ in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  g[a-1].append((b-1,i))

vc=[0]*n
ec=[0]*(n-1)
h=1

for v,c in enumerate(g):
  t=1
  for b,i in c:
    if vc[v]==t:
      t+=1
    vc[b]=t
    ec[i]=t
    h=max(h,t)
    t+=1

print(h)
for i in range(n-1):
  print(ec[i])

Measured memory_bytes: 27744
import math
n=int(input())
xli=list(map(float,input().split()))
yli=list(map(float,input().split()))
a=0
b=0
c=0
d=0
 
for x,y in zip(xli,yli):
    base = math.fabs(x-y)
    a += base
    b += base**2
    c += base**3
    if d < base : d = base
 
print(a)
print(b**(1/2))
print(c**(1/3))
print(d)

Measured memory_bytes: 7788
let [| X; N |] = stdin.ReadLine().Split() |> Array.map int

let solver =
    let p = stdin.ReadLine()
    if N = 0 then X
    else
        let pi = p.Split() |> Array.map int
        let np = [ 0..102 ] |> List.filter (fun i -> Array.contains i pi |> not)

        let idx =
            np
            |> List.mapi (fun i y -> i, abs (y - X))
            |> List.minBy snd
            |> fst
        np.[idx]

solver |> stdout.WriteLine


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

#include <set>
#include <iterator>
using namespace std;
// using namespace __gnu_pbds;


#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF (ll)1e17
#define matrix vector<vector<ll> >

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
#define maxbits 9
#define maxmask (1ll<<maxbits)
// typedef tree<pll, null_type, less<pll>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
const int  N=1e6 +10, M=(ll)1e9+1 ;
const int mod =998244353 ,sz=5, MAX=(ll)1e6+10;
string fir="Monocarp",sec="Bicarp";


ll maxi(ll a,ll b,ll c,ll d){
	return max(a,max(b,max(c,d)));
}

void work(){
	ll n;
	cin >> n;

	vl a(n+1);
	for(ll i=1;i<=n;i++)
		cin >> a[i];

	ll dp[n+1][2];
	memset(dp,0,sizeof(dp));

	dp[2][0]=a[1];
	dp[2][1]=a[2];
	for(ll i=3;i<=n;i++){
		if(i&1){
			dp[i][1]=max({dp[i-2][1],dp[i-3][1],dp[i-2][0],dp[i-3][0]})+a[i];
			dp[i][0]=max(dp[i-1][1],dp[i-1][0]);
		}
		else{
			dp[i][1]=max({dp[i-2][1],dp[i-2][0],dp[i-1][0]})+a[i];
			dp[i][0]=dp[i-2][0]+a[i-1];
		}
	}

	cout << max(dp[n][0],dp[n][1]) ;
}

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

	
	// precomp();
	ll t;
	// cin >> t;
	t=1;
	while(t--){
	        work();
	
	}
return 0;
}
	

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

int main(void){
    int n;
    cin >> n;

    int a, b, f, cnt;
    cnt = 0;
    f = 0;
    rep(i,n) {
        cin >> a >> b;
        if (a == b) {
            cnt++;
        } else {
            cnt = 0;
        }
        if (cnt == 3) {
            f = 1;
        }
    }

    if (f == 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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


int main()
{
	string a;
	string b;
	cin>>a>>b;
	int length=a.size();

	for(int i=0;i<length;i++)
	{
		int flag=0;
		for(int j=i,k=0;k<length;k++,j++)
		{	
			if(a[(j+length)%length]==b[j-i])continue;
			else {flag=1;break;}
		}
		if(flag==0)
		{
			cout<<"Yes";
		//	system("pause");
			return 0;
		}
	}
	cout<<"No";
	//system("pause");
}

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

signed main(){
  int n; std::cin >> n;
  std::string s; std::cin >> s;
  int R = 0, ans = 0;
  for(int i = 0; i < n; i++){
    if(s[i] == 'R') R++; 
  }
  for(int i = 0; i < R; i++){
    if(s[i] == 'W') ans++;
  }
  std::cout << ans << std::endl;
}

Measured memory_bytes: 3728
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

vector<pair<ll, ll> > prime_factorize(ll n) {
    vector<pair<ll, ll> > res;
    for (ll p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main(){
    ll N;
    cin>>N;
    vector<pair<ll,ll>> pri=prime_factorize(N);
    ll cnt=0;
    ll a,b;
    REP(i,pri.size()){
      a=pri[i].first;
      b=pri[i].second;
      ll j=1;
      while(true){
        if(b-j>=0){
          b-=j;
          j++;
          cnt++;
        }else{
          break;
        }
      }
    }
    cout<<cnt<<endl;

}

Measured memory_bytes: 3628
def mapint_inp():
    return map(int, input().split())

def intinp():
    return int(input())

N, K = mapint_inp()
MOD = 10**9+7

ans = 0
for i in range(K, N+2):
    mn = i*(i-1) // 2
    mx = i*(2*N-i+1) // 2
    ans += mx - mn + 1

print(ans%MOD)

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int H,W,h,w; cin>>H>>W>>h>>w;
	cout << (H-h)*(W-w) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main()
{
	int h, w;
	char a[111][111];
	int r[111] = {0}, c[111] = {0};
	scanf("%d %d", &h, &w);
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			scanf("\n%c", &a[i][j]);
			if (a[i][j] == '#')
			{
				r[i]++;
				c[j]++;
			}
		}
	}
  for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			if (r[i] > 0 && c[j] > 0)
			{
				printf("%c", a[i][j]);
			}
		}
		if (r[i] > 0)
		{
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<50
#define fst first
#define sec second
#define pb push_back
#define int long long
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(int itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(int itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define debug(x)  cout << #x << " = " << (x) << endl;
typedef long long ll;
typedef pair<ll,ll> P;

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

  map<int,int>mp;
  REP(_,3){
    int a;
    cin >>a;
    mp[a]++;
  }
  
  cout << mp.size() << endl;

  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  string S, T;

  cin >> S >> T;

  if (S == T.substr(0, S.size())) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}

Measured memory_bytes: 3544
#include<iostream>
#include<math.h>
#include<iomanip>
#include<string.h>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<algorithm>

using namespace std;

class card{
public:
  int num;
  char pic;
};

int partition(card a[], int j, int r){
  int x = a[r].num;
  int i = j - 1;

  while(j < r){
    if(a[j].num <= x){
      i++;
      swap(a[i], a[j]);
    }
    j++;
  }
  swap(a[++i], a[r]);
  return i;
}

void quicksort(card a[], int left, int right){
  if(left  < right){
    int r = partition(a, left, right);
    quicksort(a, left, r - 1);
    quicksort(a, r + 1, right);
  }

}

void merge(card a[], int left, int mid, int right){
  int n1 = mid - left;
  int n2 = right - mid;
  card l[n1], r[n2];
  for(int i = 0; i < n1; i++){
    l[i] = a[left + i];
  }
  l[n1].num = 1000000000;
  for(int i = 0; i < n2; i++){
    r[i] = a[mid + i];
  }
  r[n2].num = 1000000000;
  int j = 0, k = 0;
  for(int i = 0; i < n1 + n2; i++){
    if(l[j].num <= r[k].num){
      a[left + i] = l[j];
      j++;
    }
    else{
      a[left + i] = r[k];
      k++;
    }
  }
}

void mergesort(card a[], int left, int right){
  if(left + 1 < right){
    int mid = (left + right) / 2;
    mergesort(a, left, mid);
    mergesort(a, mid, right);
    merge(a, left, mid, right);
  }
}

int main(){
  int n;
  cin >> n;
  card a[n], b[n];
  for(int i = 0; i < n; i++){
    cin >> a[i].pic >> a[i].num;
    b[i] = a[i];
  }

  mergesort(b, 0, n);

  for(int i = 0; i < n; i++){
  //  cout << b[i].pic << " " << b[i].num << endl;
  }

  quicksort(a, 0, n - 1);

  int sum = 0;
  for(int i = 0; i < n; i++){
    if(a[i].pic == b[i].pic) sum++;
    else break;
  }
  if(sum == n) cout << "Stable" << endl;
  else cout << "Not stable" << endl;

  for(int i = 0; i < n; i++){
    cout << a[i].pic << " " << a[i].num << endl;
  }


}


Measured memory_bytes: 5428
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
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 main () {
  int d, n;
  cin >> d >> n;

  auto f = [&](int n) {
    int res = 0;
    while (n%100 == 0) {
      n /= 100;
      res++;
    }
    return res;
  };

  int cnt = 0;
  int i = 1;
  while (true) {
    if (f(i) == d) cnt++;
    if (cnt == n) break;
    i++;
  }

  cout << i << endl;
}

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

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    vector<ll> a;
    ll aa[3];
    ll c=0;
    ll sum=0;
    for(ll i=0;i<3;i++){
        cin>>aa[i];
        sum=sum+aa[i];
        if(aa[i]%2==0){
            c++;
        }
        a.push_back(aa[i]);
    }
    sort(a.begin(),a.end());
    ll ans;
    if(a[2]%2==0){
        if(c==2){
            ans=(a[2]+1)*3-sum;
        }else{
            ans=a[2]*3-sum;
        }
    }else{
        if(c==0 || c==2){
            ans=a[2]*3-sum;
        }else{
            ans=(a[2]+1)*3-sum;
        }
    }
    cout<<ans/2<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define PD(x) printf("%d",x)
#define PL(x) printf("%lld",x)
#define PC(x) printf("%c",x)
#define PS(x) printf("%s",x)
#define PF(x) printf("%f",x)
#define SP printf(" ")
#define BR printf("\n")
#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define ALL(x) (x).begin(),(x).end()
#define scanf scanf_s

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;

using namespace std;
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int32 a[4];
	char b[4];
	rep(i, 0, 4) {
		cin >> b[i];
		a[i] = b[i] - '0';
	}
	int32 n;
	int32 t;
	rep(i, 0, 8) {
		n = a[0];
		rep(j, 1, 4) {
			if (bitget(i, 3 - j)) {
				n += a[j];
			}
			else {
				n -= a[j];
			}
		}
		if (n == 7) {
			t = i;
			break;
		}
	}
	cout << a[0];
	rep(j, 1, 4) {
		if (bitget(t, 3 - j)) {
			cout << "+";
		}
		else {
			cout << "-";
		}
		cout << a[j];
	}
	cout << "=7" << endl;
	return 0;
}

Measured memory_bytes: 256
module.exports=function(t){var r={};function e(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,e),i.l=!0,i.exports}return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:n})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,r){if(1&r&&(t=e(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var i in t)e.d(n,i,function(r){return t[r]}.bind(null,i));return n},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},e.p="",e(e.s=0)}([function(t,r,e){e(1)(e(3).readFileSync("/dev/stdin","UTF-8"))},function(t,r,e){function n(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=[],n=!0,i=!1,o=void 0;try{for(var u,s=t[Symbol.iterator]();!(n=(u=s.next()).done)&&(e.push(u.value),!r||e.length!==r);n=!0);}catch(t){i=!0,o=t}finally{try{n||null==s.return||s.return()}finally{if(i)throw o}}return e}(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var i=e(2);t.exports=function(t){for(var r=t.split("\n"),e=n(r[0].split(" ").map(function(t){return Number(t)}),2),o=e[0],u=e[1],s=new Array(o),a=0;a<o-1;a++){var l=n(r[a+1].split(" ").map(function(t){return Number(t)-1}),2),f=l[0],c=l[1];s[f]||(s[f]=[]),s[c]||(s[c]=[]),s[f].push(c),s[c].push(f)}for(var p=new Array(o).fill(0),d=0;d<u;d++){var v=n(r[d+o].split(" ").map(function(t){return Number(t)}),2),y=v[0],h=v[1];p[y-1]+=h}var m=new i,b=new Array(o).fill(0);for(m.enq(0);m.size>0;){var x=m.deq();b[x]=1;var g=!0,w=!1,j=void 0;try{for(var S,O=s[x][Symbol.iterator]();!(g=(S=O.next()).done);g=!0){var q=S.value;1!=b[q]&&(p[q]+=p[x],m.enq(q))}}catch(t){w=!0,j=t}finally{try{g||null==O.return||O.return()}finally{if(w)throw j}}}console.log(p.join(" "))}},function(t,r,e){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e4;this.size=0,this.items=[],this.ind=0,this.maxGap=t}enq(t){this.size+=1,this.items.push(t),this.items.size-this.ind>this.maxGap&&(this.items=this.items.slice(this.ind))}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}}},function(t,r){t.exports=require("fs")}]);

Measured memory_bytes: 129528
#pragma GCC optimize ("Ofast")
#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;

struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); } } ___;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);
}

#define ll long long
#define pii pair<int,int>
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ff first
#define ss second
#define endll '\n'
#define rep(i,n) for(int i=0;i++<n;)
#define scl(i) scanf("%lld",&i)
#define int long long int
#define all(n) n.begin(),n.end()
#define mem(n,i) memset(n,i,sizeof n)
#define em(a) emplace_back(a)
#define pb(a) push_back(a)
#define srep(it,vv) for(auto &it : vv)
#define prep(it,vv) for(auto it : vv)
//vector<vector<int>>arr(n + 5, vector<int>(m + 5,0));

typedef vector<int> vii;
typedef vector<string> vss;
/*

*/
signed main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int x; cin >> x;
	x ? cout << 0 : cout << 1;
}

Measured memory_bytes: 3636