akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cerr << v << " ";  \
  }                    \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  cin >> N;

  vec<int> a(BIT(N));
  vec<int> b;

  REP(i, BIT(N)) cin >> a[i];
  sort(ALL(a));
  reverse(ALL(a));
  b.pb(a[0]);
  a[0] = 0;

  REP(i, N) {
    sort(ALL(a));
    reverse(ALL(a));
    sort(ALL(b));
    reverse(ALL(b));
    int index = 0;
    REP(j, BIT(i)) {
      bool flg = false;
      while (1) {
        if (index == (int)a.size() || a[index] == 0) {
          flg = true;
          break;
        }
        if (b[j] > a[index]) {
          break;
        }
        index++;
      }
      if (flg) {
        print("No");
        return 0;
      }
      // DEBUG(a[index]);
      b.pb(a[index]);
      a[index] = 0;
      index++;
    }
  }
  print("Yes");
}
// 5 8 7 7 7 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
ll divisor(ll n){
  ll res = 0;
  for(ll i=1; i*i<=n ; i++){
    if(n%i == 0){
      res++;
      if(i != n/i) res++;
    }
  }
  return res;
}
int main(){
  ll N; cin >> N;
  vector<ll> memo(N+1);
  ll ans = 0;
  for(ll i=1 ; i<=N ; i++){
    for(ll j=i ; j<=N ; j+=i){
      memo[j]++;
    }
  }
  rep(i,1,N+1){
    ans += memo[i] * i;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 81380
#include <bits/stdc++.h>
#define ll long long

using namespace std;

ll a[1000];
ll b[1000];
ll c[1000];
int vis[10000];
ll sum;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;cin >> n;

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

    for(int i=1;i<=n;i++)
    {
        sum+=b[a[i]];
        if((i!=1&&a[i-1]==a[i]-1))
            sum+=c[a[i]-1];

    }

    cout << sum;



}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MM 1000000000;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 1000000005
#define NIL -1
ll mod = 1e9+7;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int dp[101010];
int main(){
    ll n; cin >> n;
    ll h[n];

    dp[0] = 0;
    for(ll i = 0; i < n; i++){
        cin >> h[i];
    }
    dp[1] = dp[0] + abs(h[0] - h[1]);
    for(ll i = 2; i < n; i++){
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 1408
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, L, R, H, W;


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

	cin >> N >> M;
	K = abs(abs(N) - abs(M));
	if (N < 0 && M > 0 || N >= 0 && M <= 0) {
		K++;
	}
	else if (N > M) {
		K += 2;
	}
	cout << K << endl;
	return 0;
}

Measured memory_bytes: 256
mod = 10 ** 9 + 7


class Combination:
    """
    SIZEが10^6程度以下の二項係数を何回も呼び出したいときに使う
    使い方:
    comb = Combination(SIZE, MOD)
    comb(10, 3) => 120
    """

    def __init__(self, N, MOD=10 ** 9 + 7):
        self.MOD = MOD
        self.fact, self.inv = self._make_factorial_list(N)

    def __call__(self, n, k):
        if k < 0 or k > n:
            return 0
        res = self.fact[n] * self.inv[k] % self.MOD
        res = res * self.inv[n - k] % self.MOD
        return res

    def _make_factorial_list(self, N):
        fact = [1] * (N + 1)
        inv = [1] * (N + 1)
        MOD = self.MOD
        for i in range(1, N + 1):
            fact[i] = (fact[i - 1] * i) % MOD
        inv[N] = pow(fact[N], MOD - 2, MOD)
        for i in range(N, 0, -1):
            inv[i - 1] = (inv[i] * i) % MOD
        return fact, inv


if __name__ == "__main__":
    N, M, K = map(int, input().split())
    comb = Combination(N * M + 10, mod)

    ans = 0
    for d in range(1, N):
        tmp = (N - d) * M * M % mod
        ans += d * tmp * comb(N * M - 2, K - 2)
        ans %= mod

    for d in range(1, M):
        tmp = (M - d) * N * N % mod
        ans += d * tmp * comb(N * M - 2, K - 2)
        ans %= mod

    print(ans)

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

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
    };
} init;

int M, D;
signed main() {
    cin >> M >> D;
    int ans = 0;
    for (int i = 1; i <= M; i++) {
        for (int j = 1; j <= D; j++) {
            if (j / 10 >= 2 && j % 10 >= 2 && (j / 10) * (j % 10) == i) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[500][500];
ll arr[500];
ll sum(int i,int j)
{
    ll ans=0;
    for(int a=i;a<=j;a++)
    {
        ans+=arr[a];
    }
    return ans;
}

ll ans(int i,int j)
{
    if(i>=j)
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    dp[i][j]=1000000000000000;
    for(int k=i;k<=j;k++)
    {
        dp[i][j]=min(dp[i][j],ans(i,k)+ans(k+1,j)+(sum(i,k)+sum(k+1,j)));
    }
    return dp[i][j];
}
int main()
{
    int n;
    cin>>n;
        for(int i=0;i<n;i++)
            cin>>arr[i];
        for(int i=0;i<=n;i++)
            for(int j=0;j<=n;j++)
            dp[i][j]=-1;
        cout<<ans(0,n-1)<<"\n";
}


Measured memory_bytes: 1792
#include <stdio.h>
#define NUM 100
int main(void) {
    int i, a, b[NUM], e=0;

    scanf("%d", &a);

    for (i = 0; i < a; i++) {
        scanf("%d", &b[i]);
    }

    for (i = 0; i < a; i++) {
        if (i % 2 == 0) {
            if (b[i] % 2 != 0) {
                e++;
            }
        }
    }
    printf("%d", e);
    return 0;
}


Measured memory_bytes: 2120
#include <stdio.h>
#include <string.h>
bool W, E, N, S, pos=true;
int n;
char s[1111];
int main(void)
{
	scanf("%s",&s[1]);
	n=strlen(&s[1]);
	for(int i=1 ; i<=n ; i++)
	{
		if(s[i]=='W')
		{
			W=true;
		}
		if(s[i]=='E')
		{
			E=true;
		}
		if(s[i]=='N')
		{
			N=true;
		}
		if(s[i]=='S')
		{
			S=true;
		}
	}
	if(N==true && S==false || S==true && N==false || W==true && E==false || E==true && W==false)
	{
		pos=false;
	}
	if(pos==true)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
}

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

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

  bitset<101> bits;
  bits.set(0); bits.set(4);
  for(int i=7; i<=N; i++){
    if(bits.test(i-7) || bits.test(i-4)){
      bits.set(i);
    }
  }
  
  if(bits.test(N)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=1000000007;
int mpow(int n,int m){
    int ret=1;
    while(m){
        if(m&1)ret=ret*n%mod;
        n=n*n%mod;
        m>>=1;
    }
    return ret;
}

int fact[555555],inv[555555];

int C(int n,int k){
    return fact[n]*inv[k]%mod*inv[n-k]%mod;
}

signed main(){
    int W,H,K;
    cin>>W>>H>>K;

    fact[0]=inv[0]=1;
    for(int i=1;i<555555;i++){
        fact[i]=fact[i-1]*i%mod;
        inv[i]=mpow(fact[i],mod-2);
    }


    int ans=0;
    for(int k=0;k<=K;k++){
        int l=K-k;
        int hoge=(C(W+2*k,k)-(k?C(W+2*k,k-1):0)+mod)%mod;
        int piyo=(C(H+2*l,l)-(l?C(H+2*l,l-1):0)+mod)%mod;

        ans+=C(W+H+2*K,W+2*k)*hoge%mod*piyo%mod;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}

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

int getans(int x){
	if(x==0) return 2;
	else return x%2;
}

int t[200100];
int lowbit(int x){
	return x&(-x);
}
int add(int x,int y){
	while(x<=200000){
		t[x]=min(y,t[x]);
		x+=lowbit(x);
	}
}

int query(int x){
	int ans=4000000;
	if(x==0) return 0;
	while(x){
		ans=min(ans,t[x]);
		x-=lowbit(x);
	}
	return ans;
}
long long a[200010],ans0[200010],ans1[200100],sum[200100],sum0[200010];
int main(){
	int n;
	memset(t,0,sizeof(t));
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	sum[0]=0;
	ans0[0]=0;
	sum0[0]=0;
	
	int myans=400000;
	for(int i=1;i<=200000;i++)
		t[i]=400000;
	for(int i=1;i<=n;i++){
		sum[i]=sum[i-1]+a[i];
		ans0[i]=min(ans0[i-1]+getans(a[i]),sum[i]);
		sum0[i]=sum0[i-1]+1-(a[i]%2);
		add(i,ans0[i]-sum0[i]);
	}
	myans=min((long long)sum0[n],sum0[n]+query(n));
	ans1[n+1]=0;
	sum[n+1]=0;
	for(int i=n;i>=1;i--){
		sum[i]=sum[i+1]+a[i];
		ans1[i]=min(ans1[i+1]+getans(a[i]),sum[i]);
		//cout << ans1[i] << " " << sum0[i-1] << endl;
		myans=min((long long)myans,ans1[i]+sum0[i-1]);
		myans=min((long long)myans,sum0[i-1]+ans1[i]+query(i-1));
		//cout << myans << " " << query(i) << endl;
	}
	printf("%d\n",myans);
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vpi = vector<pii>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpl = vector<pll>;
using vs = vector<string>;

int main()
{
    int n, m;
    cin >> n >> m;
    if(n==m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pl = pair<long long, long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
    int N; cin >> N;
    vecl A(N), B(N);
    REP(i,N) cin >> A[i] >> B[i];
    ll ans = 0;
    for(int i = N-1; i >= 0; i--) {
        A[i] += ans;
        if(A[i] == 0) continue;
        //cout << A[i] << endl;
        if(A[i] <= B[i]) {
            ans += B[i]-A[i];
        } else {
            if(A[i]%B[i] != 0) {
                ans += (A[i]/B[i]+1)*B[i]-A[i];
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4824
#include<iostream>
using namespace std;
int main(void){
	int k,s;
		cin >> k >> s;
	int res=0;
	for(int x=0;x<=k;x++){
		int yz=s-x;
		for(int y=max(0,yz-k);y<=k && x+y<=s;y++)
			res++;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <map>
#include <cmath>
#include <bitset>
#include <deque>
#include <queue>
#define INF (1LL<<31)
#define fst first
#define snd second
typedef long long ll;
typedef std::pair<int,int> ii;
using namespace std;

int main(){
  int H,W,N;
  int a[10000];
  int m[100][100];
  int idx=0;
  cin>>H>>W>>N;
  for(int i=0;i<N;i++){
    cin>>a[i];
  }

  for(int i=0;i<N;i++){
    for(int j=0;j<a[i];j++){
      int col,raw;
      raw=idx/W;
      col=idx%W;
      m[raw][(raw%2?col:W-col-1)]=i+1;
      idx++;
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(j!=0)cout<<" ";
      cout<<m[i][j];
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void) {
	// input integer
	int a, b;
	string result;
	cin >> a >> b;
	// judge small learge or equal
	if (a > b) result = "a > b\n";
	else if (a < b) result = "a < b\n";
	else result = "a == b\n";
	// output
	cout << result;
	return 0;
}
	

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

int main() {
    int N,K; cin >> N >> K;
    int ans=10000;
    for(int i=0;i < (1<<N);i++){
        int c=1;
        for(int j=0;j<N;j++){
            if(i >> j & 1)
                c += K;
            else c *= 2; 
        }
        ans = min(ans,c);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
   using namespace std;
   #define bolt ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   #define text_wali_bakchodi freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
   #define F first
   #define S second
   #define pb push_back
   #define lb lower_bound
   #define ub upper_bound
   #define endl "\n"
   typedef long long ll;
   typedef long double ld;
   const ll mod = 998244353 ;
   const ld pi=3.1415926535897932384626433;
   const ll inf = 1e18;
   bool isprime(ll n){for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}
   ll factorial(ll n){return (n==1 || n==0) ? 1:n*factorial(n-1);}
   ll power(ll x,ll y){ll res=1;x=x%mod;while(y>0){if(y&1)res=((res%mod)*(x%mod))%mod;y=y>>1;x=((x%mod)*(x%mod))%mod;}return res;}
   ll gcd(ll a,ll b){if (a==0)return b;return gcd(b%a,a);}
   ll lcm(ll a,ll b){return (a/gcd(a,b)*b);}
   ll max(ll a,ll b){ll sol=a>b?a:b;return sol;}
   ll min(ll a,ll b){ll sol=a<b?a:b;return sol;}
   ll mul(ll a,ll b){return ((a%mod)*(b%mod))%mod;}
   ll add(ll a,ll b){return ((a%mod)+(b%mod))%mod;}
   int main()
   {
      bolt;
      ll n,x,y;
      cin>>n>>x>>y;
      map <ll,ll> mp;
      if (x==1 and y==n)
      {
         for (ll i=1;i<=n;i++)
         {

            ll sd=0;
            for (ll j=i+1;j<=n;j++)
            {//cout<<i<<" "<<j<<endl;;
               sd=min(j-i,i+n-j);
               //cout<<sd<<endl;
                mp[sd]++;
            }

         }
      }
      else{
      for (ll i=1;i<=n;i++)
      {
         ll sd=0;
         for (ll j=i+1;j<=n;j++)
         {
            if (i<x and y<j)
               sd=x-i+j-y+1;
            else if (i==x and j==y)
            {
               sd=1;
            }
            else
            {
               sd=min({j-i,abs(i-x)+1+abs(y-j)});
            }
            mp[sd]++;
            //cout<<i<<" "<<j<<" "<<sd<<endl;
         }
      }}
      for (ll i=1;i<n;i++)
         cout<<mp[i]<<endl;
   }


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

static const int N = 100;

int main() {
    int n;
    cin >> n;
    int ans[N][N] = {0};
    for (int i = 0; i < n; ++i) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; ++j) {
            int ad;
            cin >> ad;
            ans[i][ad-1] = 1;
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (j == n-1) {
                cout << ans[i][j] << endl;
            } else {
                cout << ans[i][j] << " " << flush;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
#include<string.h>
#include <math.h>
#include<iostream>
using namespace std;
typedef long long           ll;
typedef unsigned long long  ull;
typedef long double         ld;

#define sf                  scanf
#define pf                  printf
#define srev                reverse(s.begin(),s.end())
#define sortstr             sort(s.begin(), s.end());
#define gtl(x)              getline(cin, (x))
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define PI                  acos(-1)
#define Precision(a) cout << fixed << setprecision(a)
#define FasterIO     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


template <typename T> T Sqr(T x) { T n = x * x ; return n ;}
template <typename T> T Pow(T B,T P){ if(P==0) return 1; if(P&1) return B*Pow(B,P-1);  else return Sqr(Pow(B,P/2));}
template <typename T> T Abs(T a) {if(a<0)return -a;else return a;}
template <typename T> T Gcd(T a,T b){if(a<0)return Gcd(-a,b);if(b<0)return Gcd(a,-b);return (b==0)?a:Gcd(b,a%b);}
template <typename T> T Lcm(T a,T b) {if(a<0)return Lcm(-a,b);if(b<0)return Lcm(a,-b);return a*(b/Gcd(a,b));}
//scanf("%[^\n]", str);
//sort(s,s+n,greater<int>());

int main()
{
    double r, x;
    cin >> r;
    x = 2*PI*r;
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 3792
#include <stdio.h>
#include <stdlib.h>
#define N 100

void Matrix(int *p, int (*m)[N],int n){
  
  int i,j,k,l;
  int x,y;

  for(i=1;i<=n;i++) m[i][i] = 0;
  for(j=2;j<=n;j++){
    for(i=1;i<=n-j+1;i++){
      k = i+j-1;
      m[i][k]=10000000;
      for(l=i;l<=k-1;l++){
	x = m[i][k];       
	y = m[i][l] + m[l+1][k] + p[i-1] * p[l] * p[k];
	if(y < x){
	  m[i][k] = y;
	}
      }
    }
  }
  printf("%d\n",m[1][n]);
}

int main(void){

  int i,j,k,n;
  int p[N],m[N][N];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&p[i],&p[i+1]);
  }
  Matrix(p,m,n);
  return 0;
}

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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<ll,ll> P;

int main(){
    int N; cin >> N;
    ll a[N+1]; for(int i=0;i<=N;i++) cin >> a[i];
    ll sum[N+1]={};
    sum[0]=a[0];
    for(int i=1;i<=N;i++){
        sum[i]=sum[i-1]+a[i];
    }
    ll ans=0; ll cur=1;
    for(int i=0;i<=N;i++){
        ans+=cur;
        if(cur<a[i]){
            cout << -1 << endl;
            return 0;
        }
        cur-=a[i];
        cur=min(2*cur,sum[N]-sum[i]);
    }
    cout << ans << endl;
}


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

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

    int socket = 1;
    int tap = 0;
    while (socket < b){
        socket -= 1;
        socket += a;
        tap++;
    }

    cout << tap << endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
n = len(s)
ans = (-1, -1)
for i in range(n-1):
    ts = s[i:i+2]
    if len(set(ts))==1:
        ans = (i+1, i+2)
        print(*ans)
        exit()
    
for i in range(n-2):
    ts = s[i:i+3]
    a,b,c = ts[0], ts[1], ts[2]
    if (a==b and b!=c) or (b==c and c!=a) or (c==a and a!=b):
        ans = (i+1, i+3)
        break
print(*ans)

Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))){
            String s = in.readLine();
            String p = in.readLine();

            if ((s + s).contains(p)) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}



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

using namespace std;

int ans,N,X,m;
int tempo = 2000;

int main(){

  cin >> N >> X;

  for (int i=0;i<N;i++){
    cin >> m;
    tempo =min(tempo,m);
    X -= m;
    ans++;
  }
  ans += X/tempo;
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder(sc.next());
		sc.close();

		sb.reverse();
		String s = sb.toString();
		int n = s.length();
		String[] sa = {"maerd", "remaerd", "esare", "resare"};
		int idx = 0;
		while (idx < n) {
			boolean flg = false;
			for (int i = 0; i < sa.length; i++) {
				if (s.indexOf(sa[i], idx) == idx) {
					idx += sa[i].length();
					flg = true;
					break;
				}
			}
			if (!flg) {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
	}
}


Measured memory_bytes: 28068
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int n, x;
  cin >> n >> x;
  vector<int> l(n);
  REP(i,n) cin >> l[i];
  int d = 0;
  int cnt = 1;
  REP(i,n){
    d += l[i];
    if(d <= x) ++cnt;
    else break;
  }

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main(){
  int x,y,z;
  scanf("%d %d",&x,&y);
  if (x < y);
  while (y > 0){
    z = x % y;
    x = y;
    y = z;
  }
  printf("%d\n",x);  
    return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007


void solve()
{
	string s;
	cin>>s;
	cout<<s[0]<<s.size()-2<<s[s.size()-1];
	return;
}
int main()
{
	fast;
	int q;
	q=1;
	// cin>>q;
	while(q--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3636
from itertools import product
 
n, m = map(int, input().split())
k = []
s = []
for i in range(m):
    tmp = list(map(int, input().split()))
    k.append(tmp[0])
    s.append(tmp[1:])
p = list(map(int, input().split()))
 
ans = 2 ** n
for prod in (product([0, 1], repeat=n)):
    for i in range(m):
        tmp = 0
        for j in s[i]:
            tmp += prod[j - 1]
        if (tmp % 2 != p[i]):
            ans -= 1
            break
print(ans)

Measured memory_bytes: 39792
($x,$y)=glob<>;
@l=map{[glob<>]}(0..2);
@p=sort{$$b[1]<=>$$a[1]}map{$c=$_;map{[$c,$_]}@{$l[$c]}}(0..2);
$a=$x+$y;
for(;0<$a;$i++){
  ($e,$f)=@{$p[$i]};
  $e?($e==1)&&($y?$y--:next):($x?$x--:next);
  $d+=$f;$a--
}
print$d

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

int main() {
	long long l, r;
	scanf("%lld %lld", &l, &r);
	if(r - l + 1 >= 2020) {
		printf("%d\n", 0);
	}else {
		int mi = 1e9;
		for(int i = l % 2019; i <= (r - 1) % 2019; i++) {
			for(int j = i + 1; j <= r % 2019; j++) {
				mi = min((i * j) % 2019, mi);
			}
		}
		printf("%d\n", mi);
	}
}

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

using ll=long long;
using int64=int64_t;
const int inf=100000000;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int fib(int x){
  if (x <= 2) return x;
  int a[x];
  a[0]=1;
  a[1]=2;
  for (int i=2;i<x;i++){
    a[i]=a[i-1]+a[i-2];
  }
  return a[x-1];
}//(x) フィボナッチ数列のx番目

int div1(ll x){
  return x%1000000007;
}

main(){
    int n=in(),h[n],th=0,ans=0;
    forin(h,n);
    for (int i=1;i<n;i++){
        if (h[i-1]>=h[i]) th++;
        else th=0;
        if (ans<th) ans=th;
    }
    cout << ans << endl;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c;
  cin >> a >> b >> c;
  if((a == 1 && b == 1) || c == 1){
    cout << "Open"<<endl;
  }
  else
    cout << "Close"<<endl;
  return 0;

}

Measured memory_bytes: 3140
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

c = Counter(a)
ans = 0
for i in c.items():
    if i[0]>i[1]:
        ans += i[1]
    elif i[0]<i[1]:
        ans += i[1]-i[0]

print(ans)

Measured memory_bytes: 18676
#include <iostream>

using namespace std;

int main(){
	int n, m;
	int p[20];
	while(cin >> n >> m, n){
		bool ok = true;
		for(int i=0;i<m;i++){
			cin >> p[i];
			if(p[i]==1) ok = false;
		}
		printf("%.6lf\n", ok ? 0.5*n : 0);
	}
	return 0;
}

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

using namespace std;

int main(int qtd, char* nome[])
{
    ios::sync_with_stdio(false);

    int a, b;
    cin >> a >> b;
    int maior;
    maior = max(a+b, a-b);
    cout << max(maior, a*b);

    return 0;
}


Measured memory_bytes: 256
N, K = list(map(int, input().split()))
N_i = [0 for i in range(N)]

for i in range(K):
    d = int(input())
    #print(d)

    A_d = list(map(int, input().split()))
    for i in A_d:
        N_i[i-1] = 1
        




print(N_i.count(0))

Measured memory_bytes: 67480
def cumsum(xs):
    result = [0,xs[0]]
    for x in xs[1:]:
        result.append(result[-1] + x)
    return result
a,b=map(int,input().split())
c=list(map(int,input().split()))
n=cumsum(c)
ans=[]
for i in range(len(n)):
    if n[i]<=b:
        ans.append(n[i])
print(len(ans))

Measured memory_bytes: 9196
s = int(input())
for m in range(1, 1000001):
    for k in range(1, m + 1):
        if k == 1:
            a = s
        else:
            if a % 2 == 0:
                a = int(a / 2)
            else:
                a = 3 * a + 1
    for n in range(1, m):
        if n == 1:
            b = s
            if a == b:
                print(m)
                break
        else:
            if b % 2 == 0:
                b = int(b / 2)
            else:
                b = 3 * b + 1
            if a == b:
                print(m)
                break
    else:
        continue
    break


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

int main(){
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	
	string s;
	long long sum = 0;
	
	getline(cin,s);
	
	for(int i=0;i<s.size();i++){
		sum += (s[i] - '0');
	}
	if (sum % 9 == 0){
		cout<<"Yes"<<endl;
	} else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3684
#include <stdio.h>
#include <stdlib.h>

int main()
{
  int i, j, n, q, *S, cnt = 0, num;

  scanf("%d", &n);

  /* n個の整数を含む数列Sを格納する配列を動的に確保 */
  S = (int *)malloc( sizeof(int) * n );

  for( i = 0; i<n; i++ )
    scanf("%d", &S[i]);

  scanf("%d", &q);

  for( i = 0; i<q; i++ )
    {
      /* Tの数字がSに含まれる個数を数える */
      scanf("%d", &num);
      for( j = 0; j<n; j++ )
	{
	  if( num == S[j] )
	    {
	      cnt++;
	      break;
	    }
	}
    }

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

  return 0;
}



Measured memory_bytes: 2108
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main {
  int n;
  cin >> n;
  set<pair<char, int>> s;
  rep(i, n) {
    char c;
    int x;
    cin >> c >> x;
    s.emplace(c, x);
  }
  rep(i, 4) rep(j, 13) {
    char c = "SHCD"[i];
    int x = j + 1;
    if (!s.count({c, x})) cout << c << ' ' << x << endl;
  }
}



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

using namespace std;

#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll modpow(ll a, ll b){

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

int inp[3010];

ll dp[3010][3010];

int main(){

    int n;

    cin>>n;

    for(int i = 0; i < 3010; i++) {
        for(int j = 0; j < 3010; j++) {
            dp[i][j] = -1000000000000000000ll;
        }
    }
    
    for(int i = 0; i < n; i++) {
        cin>>inp[i];
        dp[i][i] = inp[i];
    }

    for(int i = 2; i <= n; i++) {
        for(int j = 0; j <= n - i; j++) {
            int st = j;
            int end = j + i - 1;

            dp[st][end] = max(dp[st][end], inp[st] - dp[st+1][end]);
            dp[st][end] = max(dp[st][end], inp[end] - dp[st][end-1]);

        }
    }

    cout<<dp[0][n-1]<<endl;


}


Measured memory_bytes: 71040
K=int(input())
K1=K//50
K2=K%50

answer_list=[]
for i in reversed(range(50-K2)):
  answer_list.append(i)
for i in range(K2):
  answer_list.append(50-i)
#print(answer_list)

for i in range(50):
  answer_list[i]+=K1

print(50)
print(*answer_list)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; 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(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
struct State {
  int vtx;
  ll money,spent;
  State(int _vtx,ll _money,ll s): 
  vtx(_vtx),money(_money),spent(s){};
  bool operator<(const State &s) const {
    return spent > s.spent;
  }
};

const ll maxs = 50*50+100;

int main() {
  int N,M;
  ll s;
  cin >> N >> M >> s;
  vv(ed) E(N);
  rep(i,M) {
    int f,t,a,b;
    cin >> f >> t >> a >> b;
    f--;t--;
    E[f].push_back(ed(t,P(a,b)));
    E[t].push_back(ed(f,P(a,b)));
  }
  vv(ll) dist(N,vl(maxs+10,LINF));
  chmin(s,maxs);
  vl c(N),d(N);
  rep(i,N) {
    cin >> c[i] >> d[i];
  }
  priority_queue<State> que;
  auto push = [&](int vtx,ll money,ll spent) {
    if(money<0) return;
    if(dist[vtx][money]<= spent) return;
    dist[vtx][money]=spent;
    que.emplace(vtx,money,spent);
  };
  push(0,s,0);
  while(!que.empty()) {
    State now = que.top();
    que.pop();
    int vtx = now.vtx;
    ll money = now.money;
    ll spent = now.spent;
    if(dist[vtx][money] < spent) continue;
    push(vtx,min(money+c[vtx],maxs),spent+d[vtx]);
    for(ed e: E[vtx]) {
      push(e.first,money-e.second.first,spent+e.second.second);
    }
  }
  srep(i,1,N) {
    ll ans = LINF;
    rep(j,maxs+10) {
      chmin(ans,dist[i][j]);
    }
    cout << ans << endl;
  }
  return 0;
}

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

using ll = long long;

int main() {
    string S, ans = "Good";
    cin >> S;
    rep(i,3) if (S[i] == S[i + 1]) ans = "Bad";
    cout << ans << endl;
}

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

using namespace std;


int main() {
	int a, b;
	cin >> a >> b;
	if (a < b) {
		cout <<"a < b"<< endl;
	}
	else if (a == b) {
		cout << "a == b" << endl;
	}
	else {
		cout << "a > b" << endl;
	}
}


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

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

	string O, E;
	cin >> O >> E;
	int o = O.length();
	int e = E.length();
	for (int i = 0; i < e; i++) {
		cout << O[i] << E[i];
	}
	if (o > e)cout << O[o - 1];
}


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

int calc_digit_sum(int num) {
  int res = 0;
  while(num) {
    res += num % 10;
    num /= 10;
  }
  return res;
}

int main(void) {
  char line[11];
  FILE *fp = stdin;
  if(!fgets(line, 11, fp)) return 0;

  int num;
  sscanf(line, "%d", &num);
  int sum = calc_digit_sum(num);
  printf("%s\n", num % sum ? "No" : "Yes");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x,a,b;
  cin >> x >> a>> b;
  if(a>=b){
    cout << "delicious" << "\n";
  }else if(b-a<=x){
    cout << "safe" << "\n";
  }else{
    cout << "dangerous" << "\n";
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int name[10],sum1,sum2,money,peo;
  int i;
  for(i=0;i<9;i++){
    sum1=0;
    sum2=0;
    money=0;
    peo=0;
    scanf("%s %d %d",name,&sum1,&sum2);
    money=sum1*200+sum2*300;
    peo=sum1+sum2;
    printf("%s %d %d\n",name,peo,money);
  }
  return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
#include<stdlib.h>
#define N 20000
#define K 10000

int main(){
  int n,i;
  int C[K+1];
  unsigned short *A,*B;

  scanf("%d",&n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for( i=0 ; i<=K ; i++){
    C[i]=0;
  }

  for( i=0 ; i<n ; i++ ){
   scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }

  for( i=1 ; i<=K ; i++){
    C[i] = C[i] + C[i-1];
  }

  for( i=1 ; i<=n ; i++ ){
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }
 
   for ( i=1 ; i<=n ; i++ ){
   if(i > 1) printf(" ");
     printf("%d",B[i]);
  }
  printf("\n");

  return 0;
} 

Measured memory_bytes: 8464
N, K = map(int, input().split())
H = list(map(int, input().split()))
INF = 10**9

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

for i in range(N-1):
  for j in range(1, min(K+1, N-i)):
    dp[i+j] = min(dp[i+j], dp[i] + abs(H[i+j] - H[i]))

print(dp[-1])

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

					using namespace std;
					int main()
					{
                      string c;
                      cin >> c;
                      int a = 0, b = 0;
                      a += c[0] == 'A';
                      b += c[0] == 'B';
                      a += c[1] == 'A';
                      b += c[1] == 'B';
                      a += c[2] == 'A';
                      b += c[2] == 'B';
                      if(a && b)
                        cout << "Yes";
                      else cout << "No";	 
                    }

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


int main() {

    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        string s = to_string(i);
        int sum = 0;
        for (int j = 0; j < s.size(); ++j) {
            sum += s[j] - '0';
        }
        if (a <= sum && sum <= b) ans += i;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

vu64 sum;
vector<vs32> g;
vector<bool> done;
vs32 ans;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, Q;
    cin >> N >> Q;

    sum.resize(N, 0);
    g.resize(N);
    done.resize(N, false);
    ans.resize(N, 0);

    int a, b;
    rep (i, N - 1)
    {
        cin >> a >> b;
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }

    int p, x;
    rep (i, Q)
    {
        cin >> p >> x;
        sum[p - 1] += x;
    }

    ans[0] = sum[0];
    done[0] = true;
    queue<int> que;
    que.push(0);
    while (!que.empty())
    {
        int root = que.front();
        que.pop();
        done[root] = true;

        for (auto leaf : g[root])
        {
            if (done[leaf]) continue;

            ans[leaf] += ans[root] + sum[leaf];
            que.push(leaf);
        }
    }

    rep (i, N)
    {
        cout << ans[i] << " ";
    }
    cout << "\n";
    return 0;
}



Measured memory_bytes: 17140
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1ll, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main(void) {
	int n, k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i, 0, n)cin >> a[i];
	vector<ll> t;
	ll ans = 1ll << 60;
	rep(i, 0, 1 << n) {
		t.resize(0);
		bool ok = true;
		ll low = 0ll;
		ll sum = 0ll;
		rep(i2, 0, n) {
			if (i >> i2 & 1) {
				t.push_back(a[i2]);
				if (low >= a[i2]) { ok = false; break; }
			}
			else low = max(low, a[i2]);
		}
		if (!ok || t.size() != k)continue;
		rep(i2, 0, k - 1) {
			ll d = max(0ll, t[i2] + 1 - t[i2 + 1]);
			t[i2 + 1] += d;
			sum += d;
		}
		ans = min(sum, ans);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, k;cin>>n>>k;
	int arr[n], dp[n];
	for(int i = 0; i < n; ++i) cin>>arr[i];
	dp[0] = 0;
	dp[1] = abs(arr[1] - arr[0]);
	for(int i = 2; i <=k;++i){
		if(k >= n) break;
		dp[i]=INT_MAX;
		for(int j = 1;i-j>=0;++j){
			dp[i] = min(dp[i], dp[i - j] + abs(arr[i] - arr[i-j]));
		}
	}
	for(int i = k + 1;i<n;++i){
		dp[i]=INT_MAX;
		for(int j = 1;j<=k;++j){
			dp[i] = min(dp[i], dp[i - j] + abs(arr[i] - arr[i-j]));
		}
	}
	// for(auto x : dp){
	// 	cout<<x<<" ";
	// }
	cout<<dp[n-1]<<endl;
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define loope(i,a,b) for(ll i=a;i<=b;i++)
#define test() ull t;cin>>t;while(t--)
#define pll pair<ll,ll>
#define puu pair<ull,ull>
#define f first
#define s second
#define pb push_back
#define mkp make_pair
#define ins insert
#define Vint vector<int>
#define Vll vector<ll>
#define Vull vector<ull>
#define nl cout<<endl
#define sp cout<<" "
#define MOD 1000000007
#define all(x) x.begin(),x.end()
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

ull power(ull n){
	ull ans = 1;
	while(n--){
		ans = ((ans%MOD)*10)%MOD;
	}

	return ans%MOD;
}




int main() 
{
	// ios::sync_with_stdio(0);
	// cin.tie(0);
	// cout.tie(0);
	ull n;
	cin>>n;
	ll mx1,mx2,mn1,mn2;
	mx1 = mx2 = LLONG_MIN;
	mn1 = mn2 = LLONG_MAX;
	ll ans = LLONG_MIN;
	loop(i,0,n){
		ll x,y;
		cin>>x>>y;
		if(x+y>mx1)
			mx1 = x + y;
		if(x+y<mn1)
			mn1 = x + y;
		if(x-y>mx2)
			mx2 = x-y;
		if(x-y<mn2)
			mn2 = x-y;
	}

	ans = max(ans,mx1-mn1);
	ans = max(ans,mx2-mn2);

	cout<<ans;
}

Measured memory_bytes: 3632
from collections import Counter
import sys
sys.setrecursionlimit(200000)


def read():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    G = [[] for i in range(N)]
    for i in range(M):
        a, b =  map(int, input().split())
        G[a-1].append(b-1)
        G[b-1].append(a-1)
    return N, M, H, G


def solve(N, M, H, G):
    ans = []
    for i in range(N):
        best = True
        for j in G[i]:
            if H[j] >= H[i]:
                best = False
        if best:
            ans.append(i+1)
    return len(ans)


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("{}".format(outputs))


Measured memory_bytes: 32696