akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

struct card {
  char suit;
  int rank;
};

bool operator<(card c1, card c2)
{
  return c1.rank < c2.rank;
}

template<typename T>
vector<T> bubble_sort(vector<T> A)
{
  int n = A.size();
  for (int i = 0; i < n; ++i)
    for (int j = n-1; j > i; --j)
      if (A[j] < A[j-1])
        swap(A[j], A[j-1]);
  return A;
}

template<typename T>
vector<T> selection_sort(vector<T> A)
{
  int n = A.size();
  for (int i =0; i<n; ++i) {
    int minidx = i;
    for (int j = i; j < n; ++j) {
      if (A[j] < A[minidx])
        minidx = j;
    }
    swap(A[i], A[minidx]);
  }
  return A;
}

// Shell sort
int main()
{
  int n; cin >> n;
  vector<card> cards;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    card next_card;
    next_card.suit = s[0];
    next_card.rank = s[1] - '0';
    cards.push_back(next_card);
  }
  
  for (int s = 0; s <= 1; ++s) {
    auto sorted = cards;
    if (s == 0) { sorted = bubble_sort(cards); }
    else if (s == 1) { sorted = selection_sort( cards); }

    for (int i = 0; i < n; ++i) {
      if(i) cout << " ";
      cout << sorted[i].suit << sorted[i].rank;
    }
    cout << endl;

    // for each rank, check if the cards
    // have the same order
    // (ranks are 1..9)
    for (int r = 1; r < 10; ++r) {
      auto sorted_it = sorted.begin();
      auto uns_it = cards.begin();
      for (int s = 0; s < 4; ++s, ++sorted_it, ++uns_it) {
        sorted_it = find_if(sorted_it,
            sorted.end(),
            [&r](card c){return c.rank==r;}
            );
        uns_it = find_if(uns_it,
            cards.end(),
            [&r](card c){return c.rank==r;}
            );
        if (sorted_it == sorted.end()) continue;
        if (sorted_it->suit != uns_it->suit) {
          cout << "Not stable\n";
          goto done;
        }
      }
    } cout << "Stable\n"; done: { }
  }
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define Little 1
const long long INF = 1LL<<60;
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0,w=0,n=0,m=0,o=0;
  std::cin >> x>>y;
  if(x>y)std::cout << "safe" << '\n';
  else std::cout << "unsafe" << '\n';  
}


Measured memory_bytes: 3620
n = int(input())
uv = sorted([sorted(list(map(int, input().split()))) for i in range(n-1)])
ans = 0
for i in range(1,n+1):
    ans += i * (n-i+1)
for u,v in uv:
    ans -= (u) * (n-v+1)
print(ans)

Measured memory_bytes: 102884
#include<bits/stdc++.h>
#define ll long long int
#define sz  2010
using namespace std;

int main()
{

    string s;
    ll i,j,n;

    cin>>s;

    for(i=0;i<s.length();i++)
    {
        cout<<"x";
    }

    cout<<endl;

    return 0;
}



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

using namespace std;

typedef long long ll;
const ll mod = 1e9 + 7;
ll fac[1005], dp[1005][1005];

ll pow2(ll a, ll b) {
  ll res = 1;
  while(b) {
    if(b & 1) res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }

  return res;
}

ll get_inv(ll x) {
  return pow2(x, mod-2);
}

ll getP (int n, int m) {
  return fac[n] * get_inv(fac[n-m]) % mod;
}

int main () {
  int N,A,B,C,D;
  cin >> N >> A >> B >> C >> D;
  fac[0] = 1;
  for(int i = 1; i <= N; i++) 
    fac[i] = fac[i-1] * i % mod;
    dp[A-1][0] = 1;
    for(int i = A; i <= B; i++) {
      for(int j = 0; j <= N; j++) dp[i][j] = dp[i-1][j];
      for(int k = C; k <= D; k++) {
	for(int j = i * k; j <= N; j++) {
	  dp[i][j] = (dp[i][j] + (dp[i-1][j-i*k] * getP(j,i*k)%mod)*get_inv(pow2(fac[i],k)*fac[k]%mod)%mod)%mod;
	}
      }
    }
    cout << dp[B][N]<<endl;
    return 0;
  
} 
  
      
  
  


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,y,z,ans=0;
	cin>>x>>y>>z;
	for(int i=1; ;i++){
		if(i*y+(i+1)*z<=x) ans++;
		else{
			cout<<ans;
			return 0;
		}
	}
	return 0;
}

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

const int mod = 1e9+7;

long long int dp[302][302][302];

void add(long long int&x, long long int y){
	x=(x+y)%mod;
}

vector<pair<int,int> > event[301];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,m,k;
	cin>>n>>m;
	for(int i=1,l,r,x;i<=m;i++){
		cin>>l>>r>>x;
		event[r].push_back(make_pair(l,x));
	}
	dp[0][0][0]=1;
	for(int r=0;r<=n;r++)
		for(int g=0;g<=n;g++)
			for(int b=0;b<=n;b++){
				k=max(r,max(g,b));
				for(auto it:event[k]){
					if((r>=it.first)+(b>=it.first)+(g>=it.first)!=it.second)
						dp[r][g][b]=0;
				}
				add(dp[k+1][g][b],dp[r][g][b]);
				add(dp[r][k+1][b],dp[r][g][b]);
				add(dp[r][g][k+1],dp[r][g][b]);
			}
	long long int ans=0;
	for(int r=0;r<=n;r++)
		for(int g=0;g<=n;g++)
			for(int b=0;b<=n;b++)
				if(r==n||b==n||g==n)
					add(ans,dp[r][g][b]);
	cout<<ans<<endl;
}


Measured memory_bytes: 215424
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9,MOD = 1e9+7,ohara = 1e6;
const ll LINF = 1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt=0,ans=0,a[ohara],b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos,cou=0;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>n;
    rep(i,n){
        cin>>a[i];
        if(a[i]%4==0)cnt++;
        else if(a[i]%2==0)cou++;
    }
    cou--;
    cou=max(cou,0LL);
    n-=cou;
    if(n/2<=cnt)Cout("Yes");
    else Cout("No");
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
 ll n;
 cin >> n;
 ll ans=1 ;
 for(ll i=1;i*i<=n;i++){
 if(n%i==0) ans=i;
 }
ll rans = n/ans ;
ll kotae=0 ;
ll ru=1 ; 
 for(int i=1;i<20;++i){
ru*=10 ;
kotae++ ;
if(ru>rans) break ;
 }
cout <<kotae <<endl ;
     return 0;
}

Measured memory_bytes: 256
// 2016-12-04
#include <iostream>
using namespace std;

int main() {
	int r0, w0, c, r;
	while (cin >> r0 >> w0 >> c >> r, r0) {
		int s = w0 * c - r0;
		if (s > 0) {
			cout << (s - 1) / r + 1 << endl;
		} else {
			cout << 0 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define ull         unsigned long long int
#define ll          long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
#define ordered_set     tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> 
 
const long long INF = (long long) 1e11+1;
const long long mod = (long long) 998244353;
const long long hell = (long long) 1000000007;

ll power(ll x,ll y,ll m){
  ll res=1;
  while(y>0){
    if(y%2) res=(x%m*res%m)%m;
    x=(x%m*x%m)%m;    
    y=y/2;
  }
  
  return res%m;
}
 
ll modinv(ll x){
  return power(x,hell-2,1);
}

ll gcd(ll a,ll b){
    while(b!=0){
		ll t=b;
		b=a%t;
		a=t;
	}
	return a;
}    
    
void fastIO(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
} 
vi gr[200005];
ll ans,n;

void dfs(int v,int p){
    for(auto u:gr[v]){
        if(u!=p){
            dfs(u,v);
            ll x,y;
            x=u;
            y=v;
            
            if(x>y)
            swap(x,y);
            ans-=(x*(n-y+1));
        }
    }
}

void solve(){
    cin>>n;
    forn(i,1,n){
        int u,v;
        cin>>u>>v;
        gr[u].pb(v);
        gr[v].pb(u);
    }
    ans=0;
    forn(i,1,n+1){
        ans+=(i*(n-i+1));
    }
    dfs(1,-1);
    cout<<ans;
}    
    
int main(){
   fastIO();
   int test;
   //cin>>test;
   test=1;    
   
   while(test--)
   solve();
}

Measured memory_bytes: 27036
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	final int LEN = 0;

	void doIt() {
		int M1 = sc.nextInt();
		int D1 = sc.nextInt();
		int M2 = sc.nextInt();
		int D2 = sc.nextInt();
		System.out.println((M1 == M2)?0:1);
	}

	public static void main(String[] args) {
		new Main().doIt();
	}
}



Measured memory_bytes: 21844
#include <set>
#include <cmath>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(int i = 0; (i)<(n); ++(i))
#define rep1(i, n) for(int i = 1; (i)<(n); ++(i))
#define rev_rep(i, n) for(ll i = (n) - 1; (i) >= 0; --(i))
#define range(a, i, b) for(ll i = (a); (i) < (b); ++(i))
#define dump(x) cout << #x << ":" << x << "\n";
#define all(v) v.begin(), v.end()
#define readl(N) ll N; cin >> N
#define readlv(N, vec) vector<ll> vec(N); rep(i, N){cin >> vec[i];}
#define greater_than [](ll l, ll r){return l > r;}
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair);
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair){
  os << '(' << pair.first << ',' << pair.second << ')';
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(int i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::set<T>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

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

#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){
  readl(N);  readl(M);

  ll max = M / N;
  vector<ll> cands;
  
  range(1, i, (ll)floor(sqrt(M)) + 1){
    if(M % i == 0){
      cands.push_back(i);
      cands.push_back(M/i);
    }
  }
  ll res = 1;
  for(auto && x:cands){
    if(x <= max){
      res = std::max(x, res);
    }
  }
  
  // sort(all(cands), greater_than);

  // dump(cands);
  cout << res;
}
#endif


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

void print(int A[], int N) {
	for (int i = 0; i < N; i++) {
		if (i) cout << " ";
		cout << A[i];
	}
	cout << endl;
}

int selectionSort(int A[], int N) {
	int count = 0;
	for (int i = 0; i < N; i++) {
		int minj = i;
		for (int j = i; j < N; j++) {
			if (A[j] < A[minj]) minj = j;
		}
		if (A[i] != A[minj]) {
			int temp = A[i];
			A[i] = A[minj];
			A[minj] = temp;
			count++;
		}
	}
	return count;
}

int main() {
	int N, A[100], count;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];

	count = selectionSort(A, N);
	print(A, N);
	cout << count << endl;
}


Measured memory_bytes: 3112
i;main(void){
	char str[20];
	int r = 999;
	gets(str);
	for (; i < 9; i++) {
		char s[5] = {};
		sprintf(s, "%c%c%c", str[i], str[i + 1], str[i + 2]);
		if (abs(753 - atoi(s)) < r) {
			r = abs(753 - atoi(s));
		}
	}
	printf("%d\n", r);	
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>

using namespace std;

#define N 100007
#define WHITE 0  // 未訪問
#define BLACK 1  // 訪問ずみ


int component[N];

// 連結成分の番号を振る関数
void dfs(int n, int comp[], vector<int> G[]) {
    int i, j, vertex, neighbor, color[N] ,inst[N];
  stack<int> S;
  // 初期状態
    for (i = 0; i < n; i++) {
        color[i] = WHITE;
        inst[i]=WHITE;
    }

  for (i = 0; i < n; i++) {
    if (color[i] == WHITE) {
      // dfs
      S.push(i);
      while (!S.empty()) {
        vertex = S.top();
        S.pop();
        color[vertex] = BLACK;  // 訪問済みにする
        comp[vertex] = i;  // 連結成分の番号を振る
          if(inst[vertex]==WHITE){
              component[i]+=1;
              inst[vertex]=BLACK;
          }
          //cout << component[i] << endl;
        for (j = 0; j < (int) G[vertex].size(); j++) {
          neighbor = G[vertex][j]; // 隣接している頂点：友人
            if (color[neighbor] == WHITE) {
                S.push(neighbor);
                
            }
        }
      }
    }
  }
}

int main() {
for(int i=0;i<N;i++) component[i]=0;
  int i, n, m, s, t;
    int k;
  int comp[N];  // 連結成分の番号
  vector<int> G[N];  // グラフを表現する隣接リスト

    cin >> n >> m >>k;
  // 隣接リストを作成
  for (i = 0; i < m; i++) {
    cin >> s >> t;
    G[s-1].push_back(t-1);
    G[t-1].push_back(s-1);
  }
    int friends[n];
    for(int i=0;i<n;i++) {
        friends[i] = G[i].size();
       // cout << friends[i] << endl;
    }
    vector<int> B[N];//ブロック
    
    for(i=0;i<k;i++){
        int r,l;
        cin >> r >> l;
        B[r-1].push_back(l-1);
        B[l-1].push_back(r-1);
    }

  // グラフを連結成分に分ける
  dfs(n, comp, G);

  
  for (i = 0; i < n; i++) {
      int ans=component[comp[i]];
      ans--;
      
      for(auto itr=B[i].begin();itr!=B[i].end();itr++){
          if(comp[i]==comp[*itr]) ans--;
      }
      if(i!=n-1) cout << ans-friends[i] <<" ";
      else cout << ans-friends[i] << endl;
  }
  
}



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

using namespace std;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

const int d4[4][2] = {
        {1, 0}, {0, 1}, {-1, 0}, {0, -1}
};

int main() {
    int n;
    string s;
    cin >> n >> s;
    int mp[9][9] = {};
    for (int i = 0; i < n - 1; i++) {
        mp[s[i] - '1'][s[i + 1] - '1']++;
    }

    V<int> idx(9);
    iota(idx.begin(), idx.end(), 0);
    int mv = TEN(9);
    V<int> ans;
    do {
        int di[9][9] = {};
        for (int i = 0; i < 9; i++) {
            for (int j = 0; j < 9; j++) {
                di[i][j] = TEN(9);
            }
            di[i][i] = 0;
        }
        for (int i = 0; i < 9; i++) {
            int y = i / 3, x = i % 3;
            for (int d = 0; d < 4; d++) {
                int ny = y + d4[d][0], nx = x + d4[d][1];
                if (ny < 0 || 3 <= ny || nx < 0 || 3 <= nx) continue;
                int j = ny * 3 + nx;
                di[idx[i]][idx[j]] = 1;
            }
        }
        for (int k = 0; k < 9; k++) {
            for (int i = 0; i < 9; i++) {
                for (int j = 0; j < 9; j++) {
                    di[i][j] = min(di[i][j], di[i][k] + di[k][j]);
                }
            }
        }
        int sm = 0;
        for (int i = 0; i < 9; i++) {
            for (int j = 0; j < 9; j++) {
                sm += di[i][j] * mp[i][j];
            }
        }
        if (sm < mv) {
            mv = sm;
            ans = idx;
        }
    } while (next_permutation(idx.begin(), idx.end()));

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cout << ans[i * 3 + j] + 1;
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3296
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL =LONG_LONG_MAX;
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {
    int n,a,b,c;cin>>n>>a>>b>>c;
    vector<int> l(n);cin>>l;
    sort(all(l));
    
    int ans = INF;
    
    do{
        
        for(auto i = 1; i<=n-2;i++){
            for(auto j = 1; j<=n-i-1;j++){
                for(auto k = 1; k<=n-i-j;k++){
                    
                    int temp = 0;
                    
                    temp += (i-1)*10 + (j-1)*10 + (k-1)*10;
                    int A,B,C;
                    A = B = C = 0;
                    rep(x,i)A+=l[x];
                    rep(x,j)B+=l[x+i];
                    rep(x,k)C+=l[x+i+j];
                    
                    vector<int> ABC(3);
                    ABC[0] = A;ABC[1]=B;ABC[2]=C;
                    sort(all(ABC));
                    
                    do{
                        ans = min(ans, temp + abs(a-ABC[0])+abs(b-ABC[1])+abs(c-ABC[2]));
                        
                    }while(next_permutation(all(ABC)));
                }
            }
        }
        
        
    }while(next_permutation(all(l)));
    
    cout<<ans<<endl;
    return 0;
}








Measured memory_bytes: 256
#include <iostream>
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl "\n"
#define ALL(x) x.begin(),x.end()
using namespace std;

ll a;
int main() {
	cin >> a;
	cout << a + a*a + a*a*a << endl;
    return 0;
}


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

ll modpower(ll a, ll r, ll mod){ //a^r
    ll x = 1;
    a %= mod;
    while (r > 0) {
        if (r & 1) x = x * a % mod;
        r >>= 1;
        a = a * a % mod;
    }
    return x;
}

ll modinv(ll a, ll mod){
    return modpower(a, mod-2, mod);
}

vector<ll> fact;
vector<ll> invfact;

void set_fact(ll n, ll mod){
    fact.resize(n+1, 1);
    invfact.resize(n+1, 1);
    for (ll i = 2; i <= n; i++) {
        fact[i] = fact[i-1] * i % mod;
    }
    invfact[n] = modinv(fact[n], mod);
    for (ll i = n-1; i >= 2; i--) {
        invfact[i] = invfact[i+1] * (i+1) % mod;
    }
    return;
}

ll comb(ll n, ll k, ll mod) {
    if (k > n || k < 0) return 0;
    if (k == n || k == 0) return 1;
    return fact[n] * invfact[n-k] % mod * invfact[k] % mod;
}

int main() {
    ll K;
    cin >> K;
    string S;
    cin >> S;
    ll N = S.size();
    ll mod = 1e9+7;
    
    set_fact(N+K+2, mod);
    ll ans = 0;
    for (ll i = N; i <= N+K; i++) {
        ans += comb(i-1, N-1, mod) * modpower(25, i-N, mod) % mod * modpower(26, N+K-i, mod) % mod;
    }
    cout << ans%mod << endl;
    return 0;
}


Measured memory_bytes: 35648
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<queue>
#include<set>
#include<map>
using namespace std;
int n;
int dp[100100];
int height[100100];

int main() {
	cin >> n;
	dp[0] = 9999999;
	for (int i = 1; i <= n; i++) {
		dp[i] = 9999999;
		int a;
		cin >> a;
		height[i] = a;
	}

	dp[1] = 0; dp[2] = abs(height[2] - height[1]);

	for (int i = 3; i <= n; i++) {
		dp[i] = min(dp[i - 1] + abs(height[i - 1] - height[i]), dp[i - 2] + abs(height[i - 2] - height[i]));
	}

	cout << dp[n] << endl;

	return 0;
}

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

using namespace std;

void doc() {
    freopen("OB.inp", "r", stdin);
    freopen("OB.out", "w", stdout);
}

void solve(){
    int n;
    cin >> n;
    int f[n], a[n];
    for(int i = 0; i < n; i++)
        cin >> a[i];
//    memset(f, LONG_MAX, sizeof(f));
//    cout << f[0] << endl;
    for(int i = 0; i < n; i++)
        f[i] = 2*1e9;
    f[0] = 0;
    for(int i = 1; i < n; i++){
        if (i >= 1) f[i] = min(f[i], f[i - 1] + abs(a[i] - a[i - 1]));
        if (i >= 2) f[i] = min(f[i], f[i - 2] + abs(a[i] - a[i - 2]));
        //cout << f[i] << '\n';
    }
    cout << f[n - 1] << '\n';
}


int main()
{
//    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
   // doc();
    solve();
}



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

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

    vector<long long> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    sort(v.begin(), v.end());

    vector<pair<long long, long long>> q(m);
    for (int i = 0; i < m; i++) {
        cin >> q[i].second >> q[i].first;
    }
    sort(q.begin(), q.end());
    reverse(q.begin(), q.end());

    int pos = 0; //position
    for (int i = 0; i < q.size(); i++) {
        int red = q[i].second;
        while (pos < n && red) {
            if (v[pos] < q[i].first) {
                v[pos] = q[i].first;
                red--;
            }
            else {
                break;
            }
            pos++;
        }
    }

    long long sum = 0;
    for (int i = 0; i < n; i++) {
        sum += v[i];
    }

    cout << sum << endl;
    return 0;
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

ll dp[1000][1000];

void init(){
    rep(i, 1000) rep(j, 1000) dp[i][j] = 0;
}

int main(void){
    init();
    int H, W; cin >> H >> W;
    string grid[H];
    rep(i, H) cin >> grid[i];
    dp[0][0] = 1;
    bool flg = true;
    rep(i, H){
        if(grid[i][0] == '#') flg = false;
        if(flg) dp[i][0] = 1;
    }
    flg = true;
    rep(i, W){
        if(grid[0][i] == '#') flg = false;
        if(flg) dp[0][i] = 1;
    }
    for(int i = 1; i < H; i++){
        for(int j = 1; j < W; j++){
            if((grid[i-1][j] == '#' && grid[i][j-1] == '#') || grid[i][j] == '#') dp[i][j] = 0;
            else if(grid[i][j-1] == '#') dp[i][j] = dp[i-1][j];
            else if(grid[i-1][j] == '#') dp[i][j] = dp[i][j-1];
            else dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod;
        }
    }
    /*
    rep(i, H){
        rep(j, W){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    */
    cout << dp[H-1][W-1] << endl;
    return 0;
}

Measured memory_bytes: 9088
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <map>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <memory>

using namespace std;

#if 1
#define PRINT(x) { cout << #x << ": " << (x) << endl; }
#define PRINT_CONTAINER(x)  { cout << #x << ": ";                       \
        for (size_t ix = 0; ix < (x).size(); ++ix) cout << (x)[ix] << ", "; \
        cout << endl; }
#else
#define PRINT(x)
#define PRINT_CONTAINER(x)
#endif

typedef pair<int, int> p;
typedef long long int ll;
ll n, k;

int main(int argc, char *argv[]) {
    scanf("%lld%lld", &n, &k);
    ll cnt = 0;
    for (int b = k+1; b < n+1; ++b) {
        int p = n / b;
        cnt += p * (b - k);
        if (k == 0) {
            cnt -= 1;
        }
        ll r = n - p * b;
        cnt += max<ll>(0, r - k + 1);
    }
    printf("%lld\n", cnt);
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vit vector<lint>::iterator
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define graph_set(n) struct edge{int to,int cost;} vector<edge> G((n))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define range(x,y) ((x) >= 0 && (x) < h && (y) >= 0 && (y) < w)
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
#define fin return 0
typedef vector<long long> vi;
typedef vector<pair<long long, long long>> vp;
typedef vector<vector<long long>> vvi;
typedef pair<long long, long long> pi;
typedef long long lint;
typedef long long ll;
lint qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(ll a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e19;

int r[100], l[100];
int a, b;

#define MAX 9223372036854775807
//////////////////////////////////////////////////////////////////////

int main() {
	ll n; cin >> n;
	vi a(n+1); rep(n) cin >> a[i+1];
	vi b(n+1);
	vi xx;
	int nm = 0;
	for (int i = n; i >= 1; i--) {
		if (i > n / 2) {
			//b[i] = a[i];
			if(a[i] == 1){
			   nm++;
			   xx.pb(i);
			   b[i] = 1;
			}else b[i] = 0;
		}
		else {
			int k = i;
			int c = 0;
			while (k + i<= n) {
				if (b[k + i] == 1) c++;
				k += i;
			}
			if (c % 2 != a[i]){
			    nm++;
			    xx.pb(i);
			    b[i] = 1;
			}else b[i] = 0;
		}
	}
	cout << nm << endl;
	rep(nm) {
		cout << xx[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 5108
import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.IO as T
import qualified Data.Text.Lazy.Read as T
import qualified Data.Vector.Unboxed as VU

main :: IO ()
main = do
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  as <- map unsafeTextToInt . T.words <$> T.getContents :: IO [Int]
  let
    as' = VU.fromList as :: VU.Vector Int
    x1 = VU.sum . VU.zipWith (*) (VU.iterateN n negate 1) $ as' :: Int
    xs = VU.tail . VU.prescanl subtract x1 . VU.map (2 *) $ as' :: VU.Vector Int
  putStr . show $ x1
  VU.mapM_ (\x -> putChar ' ' >> putStr (show x)) $ xs

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


Measured memory_bytes: 7264
n,m=[int(x) for x in input().split()]
a=[0 for _ in range(n)]
b=[0 for _ in range(n)]
xg=0
for _ in range(m):
  p,q=input().split()
  #print(p,q)
  if q=="AC": 
    #print("fir")
    rg=a[int(p)-1]
    if rg==0: a[int(p)-1]=1; xg+=b[int(p)-1]
  else : 
    #print("sec")
    b[int(p)-1]+=1
print(sum(a),xg)


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

using namespace std;

#define ll long long int

int main()
{
ios_base::sync_with_stdio(false);
cout.tie(NULL);
cin.tie(NULL);
              ll i,j,coun=0;
  string s;
  cin>>s;
  i=0;j=s.length()-1;
  while(i<=j)
  {
    if(s[i]!=s[j])
    {
      coun++;
    }
    i++;
    j--;
  }
  cout<<coun;
  return(0);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N;
	string S, ans;
	cin >> N >> S;
	int count = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == '(') {
			ans.push_back('(');
			count++;
		}
		else {
			if (count != 0) {
				ans.push_back(')');
				count--;
			}
			else {
				ans.push_back(')');
				reverse(ans.begin(), ans.end());
				ans.push_back('(');
				reverse(ans.begin(), ans.end());
			}
		}
	}
	for (int i = 0; i < count; i++) {
		ans.push_back(')');
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			if (a == 0 & b == 0)
				break;
			for (int i = 0; i < a; i++) {
				for (int j = 0; j < b; j++) {
					if(i==0||i == a-1)
						System.out.print("#");
					else if(j==0||j==b-1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}


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

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

    map<int, int> M;
    ll S = 0;
    rep(i, N){
        int A; cin >> A;
        S += A;
        M[A]++;
    }
    int Q; cin >> Q;
    rep(i, Q){
        ll b, c; cin >> b >> c;
        int n = M[b];
        M[c] += n;
        M[b] = 0;
        ll sa = (c - b) * n;
        S += sa;
        cout << S << endl;
    }

    return 0;
}

Measured memory_bytes: 8008
local n, m = io.read("*n", "*n")
local edge = {}
local pos = {}
for i = 1, n do
  edge[i] = {}
  pos[i] = false
end
for i = 1, m do
  local l, r, d = io.read("*n", "*n", "*n")
  edge[l][r] = d
  edge[r][l] = -d
end
local f = true
local function solve(start)
  local tasks = {start}
  if not pos[start] then pos[start] = 0 end
  while 0 < #tasks do
    local src = tasks[#tasks]
    table.remove(tasks)
    for dst, len in pairs(edge[src]) do
      if pos[dst] then
        if pos[dst] ~= pos[src] + len then
          f = false
          break
        end
      else
        pos[dst] = pos[src] + len
        edge[dst][src] = nil
        table.insert(tasks, dst)
      end
    end
    edge[src] = {}
    if not f then break end
  end
end

for i = 1, n do
  solve(i)
  if not f then break end
end
print(f and "Yes" or "No")


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

#define ll long long

using namespace std;
const int MX = 200'000 + 5; // check bounds!

int main() {
    ll n, m, x;
    cin >> n >> m >> x;
    
    vector<ll> c(n);
    vector<vector<ll>> a(n, vector<ll>(m));
    for (int i = 0; i < n; ++i) {
        cin >> c[i];
        for (int j = 0; j < m; ++j)
            cin >> a[i][j];
    }

    ll sol = LLONG_MAX;
    for (int mask = 0; mask < (2 << n); ++mask) {
        ll cost = 0;
        ll k[13];
        memset(k, 0, sizeof(k));
        
        for (int j = 0; j < n; ++j)
            if (mask & (1 << j)) {
                cost += c[j];
                for (int i = 0; i < m; ++i)
                    k[i] += a[j][i];
            }
        
        bool ok = true;
        for (int i = 0; i < m; ++i)
            if (k[i] < x)
                ok = false;

        if (ok)
            sol = min(sol, cost);                
    }
    
    if (sol == LLONG_MAX)
        cout << -1;
    else
        cout << sol;
    return 0;
}


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

using namespace std;

int main(){
	int n, k;
	scanf("%d %d", &n, &k);
	int num = 1;
	int a, b;
	while(n--){
		a = num * 2;
		b = num + k;
		if(a < b)num = a;
		else num = b;
	}
	printf("%d\n", num);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
map<int,int>num;
int N;


int main(){
	scanf("%d",&N);int x;int cnt=0;
	for(int i=0;i<N;i++){
		scanf("%d",&x);
		if(num.find(x-1)==num.end()){
			num.insert(pair<int,int>(x,1));
			cnt=cnt>1?cnt:1;
		}else{
			int now=num[x-1];
			num.insert(pair<int,int>(x,now+1));
			cnt=cnt>now+1?cnt:now+1;
		}
	}
	cout<<N-cnt<<endl;
	return 0;
}

Measured memory_bytes: 9600
#include <cstdio>
#include <cstring>

int main()
{
  char a[102], b[102];
  scanf("%s %s", a, b);
  int alen = strlen(a);
  int blen = strlen(b);
  if (alen != blen)
  {
    puts(alen > blen ? "GREATER" : "LESS");
    return 0;
  }
  
  for (char *pa = a, *pb = b; *pa; ++pa, ++pb)
  {
    if (*pa != *pb)
    {
      puts(*pa > *pb ? "GREATER" : "LESS");
      return 0;
    }
  }
  puts("EQUAL");
  return 0;
}

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

int main(int argc, char *argv[])
{
    string str;
    //cin >> str;
    getline(cin, str);
    for (unsigned i = 0; i < str.size(); i++)
    {
        if (str[i] >= 'a' && str[i] <= 'z')
        {
            str[i] = str[i] - 'a' + 'A';
        }
        else if (str[i] >= 'A' && str[i] <= 'Z')
        {
            str[i] = str[i] - 'A' + 'a';
        }
    }
    cout << str << endl;
    return 0;
}



Measured memory_bytes: 3204
#include <iostream>
#include <cstdio>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
#define int long long  
signed main(){
    int N,A,B;
    cin >> N >> A >> B;
    if(A>B || (N==1&&A!=B) ){
        cout << 0 << endl;
    }else if(A>B || (N==1&&A==B) ){
        cout << 1 << endl;
    }else{
        cout << (B-A)*(N-2)+1 <<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
use std::io;
use std::str;

pub struct Scanner<R> {
    reader: R,
    buffer: Vec<String>,
}

impl<R: io::BufRead> Scanner<R> {
    pub fn new(reader: R) -> Self {
        Self {
            reader,
            buffer: vec![],
        }
    }

    pub fn token<T: str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            self.reader.read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }

    pub fn tokens<T: str::FromStr>(&mut self) -> Vec<T> {
        assert!(self.buffer.is_empty());
        let mut input = String::new();
        self.reader.read_line(&mut input).expect("Failed read");
        input
            .split_whitespace()
            .map(|x| x.parse().ok().expect("Failed parse"))
            .collect()
    }
}

fn max_self(a: &mut i64, b: i64) {
    *a = (*a).max(b);
}

// dp[w]: the maximum total value of items with total weight w exactly.
fn push_dp(n: usize, max_weight: usize, weights: &[i64], values: &[i64]) -> i64 {
    let mut dp = vec![0; max_weight+ 1];
    for i in 0..n {
        for w in (0..=max_weight).rev() {
            let new_weight = w + weights[i] as usize;
            let prev = dp[w];
            if new_weight <= max_weight {
                max_self(&mut dp[new_weight], prev + values[i]);
            }
        }
    }
    let mut ans = 0;
    for w in 0..=max_weight {
        ans = ans.max(dp[w]);
    }
    ans
}

// f(0, W) = 0
// f(n, W) = f(n - 1, W)
// f(n, W) = f(n - 1, W - weights[n]) + values[n]
fn solve<R: io::BufRead, W: io::Write>(scan: &mut Scanner<R>, out: &mut W) {
    let n: usize = scan.token();
    let max_weight: usize = scan.token();
    let mut weights = Vec::new();
    let mut values = Vec::new();
    for _ in 0..n {
        weights.push(scan.token::<i64>());
        values.push(scan.token::<i64>());
    }
    let ans = push_dp(n, max_weight, &weights, &values);
    writeln!(out, "{}", ans).ok();
}

fn main() {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut scan = Scanner::new(stdin.lock());
    let mut out = io::BufWriter::new(stdout.lock());
    solve(&mut scan, &mut out);
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

#include <bits/stdc++.h>
using namespace std;

static const ll INF = 1e15;

static const ll mod = 1e9 + 7;

int main() {
	ll n;
	cin >> n;
	vector<ll> as(n);
	rep(i, n) cin >> as[i];	
	vector<vector<ll>> dp(n, vector<ll>(n, INF));
	vector<vector<ll>> costs(n, vector<ll>(n, INF));
	rep(i, n) {
		dp[i][i] = as[i];
		costs[i][i] = 0;
	}
	for (int length = 1; length < n; length++) {
		for (int left = 0; left + length < n; left++) {
			int right = left + length;
			ll s = INF;
			ll ndp = INF;
			for (int split = 0; left + split < right; split++) {
				ll a = dp[left][left + split] + dp[left + split + 1][right];
				ll ncost = a
					+ costs[left][left + split] + costs[left + split + 1][right];
				if (s > ncost) {
					s = min(s, ncost);
					ndp = a;
				}
			}
			dp[left][right] = ndp;
			costs[left][right] = s;
		}
	}
	cout << costs[0][n-1] << endl;
	return 0;
}
	

Measured memory_bytes: 6112
#include"bits/stdc++.h"
#define INFLL        1e18
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define DELNL        cin.ignore(numeric_limits<streamsize>::max(),'\n')
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll=long long;
using ull=unsigned long long;
template<typename T>using pqg=priority_queue<T,vector<T>,greater<T>>;
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}

int main()
{
    ll a=in(),b=in();
    cout<<max({a+b,a-b,a*b})<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100000
#define NIL -1

struct Node{
  int parent;
  int left;
  int right;
};
struct Node T[N];
int n, depth[N], h;
int setDepth(int );
void print(int );
int main(){
  int i, j, id, k, c, left, right;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    T[i].parent = NIL;
    T[i].left = NIL;
    T[i].right = NIL;
  }
  for(i = 0; i < n; i++){
    scanf("%d", &id);
    scanf("%d", &k);
    for(j=0; j<k; j++){
      scanf("%d", &c);
      if(j==0){
	      T[id].left = c;
      }
      else{
	      T[left].right = c;
      }
      left = c;
      T[c].parent = id;
    }
  }

  for( i = 0; i < n; i++) {
    depth[i] = setDepth(i);
    if ( depth[i] > h ){
      h = depth[i];
    } 
  }
  for( i = 0; i < n; i++){
    print(i);
  }
  return 0; 
}

int setDepth(int id){
  int i;
  for(i = 0; T[id].parent != NIL; i++){
    id = T[id].parent;
  }
  return i;
}

void print(int id){
  int i, c;
  printf("node %d: parent = %d, depth = %d, ", id, T[id].parent, depth[id]);

  if( T[id].parent == NIL ){
    printf("root, [");
  }
  else if(T[id].left == NIL){
    printf("leaf, [");
  }
  else{
    printf("internal node, [");
  }
  for(i = 0, c = T[id].left; c != NIL; i++, c = T[c].right){
    if (i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
}


Measured memory_bytes: 3260
#include <iostream>
using namespace std;
int main()
{
	int y, m, d, x;
	while (cin >> y >> m >> d)
	{
		x = y*366*12 + m*12 + d;
		if (1868*12*366 + 9*12 + 8 <= x && x <= 1912*12*366 + 7*12 + 29)
			cout << "meiji " << y-1867;
		else if (1912*12*366 + 7*12 + 30 <= x && x <= 1926*12*366 + 12*12 + 24)
			cout << "taisho " << y-1911;
		else if (1926*12*366 + 12*12 + 25 <= x && x <= 1989*12*366 + 1*12 + 7)
			cout << "showa " << y-1925;
		else if (1989*12*366 + 1*12 + 8 <= x)
			cout << "heisei " << y-1988;
		if (x <= 1868*12*366 + 9*12 + 7)
			cout << "pre-meiji" << endl;
		else
			cout << " " << m << " " << d << endl;
	}
}

Measured memory_bytes: 0
using System;


namespace ConsoleApplication35
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string[] ss = s.Split(' ');
            int a = int.Parse(ss[0]);
            int b = int.Parse(ss[1]);
            if(a < b)
            {
                Console.WriteLine("a < b");
            }
            else if (a > b)
            {
                Console.WriteLine("a > b");
            }
            else
            {
                Console.WriteLine("a == b");
            }
        }
    }
}

Measured memory_bytes: 8748
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int ka = 1;
    rep(i,k) ka *= 2;
    PRINT(max({a+b+c*ka,a+b*ka+c,a*ka+b+c}));
}


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


int main(){
  int i=0,j,min,element,temp;//temp = temporary
  int nowline=0,count=0,exchangeline=0;
  int *matrix;

  scanf("%d",&element);

  matrix = malloc(sizeof(int) * element);

  
  while(i < element){
    scanf("%d",&matrix[i]);
    i++;
  }

  while( nowline != element){ //element = endline

    for( i = nowline ; i < element-1 ; i++){
      
      if( i == nowline ) min = matrix[i];//startline

      if( min > matrix[i+1]){
	min = matrix[i+1];
	exchangeline = i+1;
      }
    }
    if(exchangeline != nowline){
      temp = matrix[nowline];
      matrix[nowline] = matrix[exchangeline];
      matrix[exchangeline] = temp;
      count++;
    }
    nowline++;
    exchangeline = nowline; //lnitialization
  }

  i = 0;
  while( i < element){
    printf("%d",matrix[i]);
    if(i != element-1) printf(" ");
    i++;
}
  printf("\n");
  printf("%d\n",count);
  free(matrix);

  return 0;

}

Measured memory_bytes: 604
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  [n, k] <- getl $ wrds toInt
  solve k <$> replicateM n getLine >>= print

solve :: Int -> [String] -> Int
solve k xs = f 0 ys
  where
    ys = map length . group . sort . map head $ xs
    f c zs
      | length zs < k = c
      | otherwise = f (c + sn) ((filter (/= 0) . map (subtract sn) $ szs1) ++ szs2)
      where
        szs = sortBy (flip compare) zs
        szs1 = take k szs
        szs2 = drop k szs
        sn = if null szs2 then last szs1 else (last szs1) - (head szs2) + 1

toInt :: String -> Int
toInt = read

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine


Measured memory_bytes: 7548
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N_MAX = 100002;

int n;

int a[N_MAX];

int dpinc, dpdec;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    dpinc = dpdec = 1;
    for(int i = 2; i <= n; i++)
    {
        int dpinc1 = dpdec + 1, dpdec1 = dpinc + 1;
        dpinc1 = min(dpinc1, dpinc + (a[i - 1] > a[i]));
        dpdec1 = min(dpdec1, dpdec + (a[i - 1] < a[i]));
        dpinc = dpinc1;
        dpdec = dpdec1;
    }
    cout << min(dpinc, dpdec) << "\n";
    return 0;
}


Measured memory_bytes: 3972
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
maxval = 0
for i in range(100000):
    x = c[i] if i in c else 0
    y = c[i+1] if i+1 in c else 0
    z = c[i+2] if i+2 in c else 0
    maxval = max(maxval, x+y+z)
print(maxval)

Measured memory_bytes: 14564
#include "bits/stdc++.h"

using namespace std;

void solve(void)
{
	int n;
	cin >> n;
	vector<int> xs(n), ls(n+2), rs(n+2);
	for (int i = 0; i < n; i++) cin >> xs[i];
	ls[1] = xs[0];
	for (int i = 2; i <= n; i++) ls[i] = max(ls[i-1], xs[i-1]);
	rs[n] = xs[n-1];
	for (int i = n; i > 1; i--) rs[i-1] = max(rs[i], xs[i-2]);
	for (int i = 0; i < n; i++) cout << max(ls[i], rs[i+2]) << '\n';
}

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



Measured memory_bytes: 3968
#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...) 
#define hash _hash
#define next _next
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)
 
#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 200010
 
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}
 
//FILE* outFile;
inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}


int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}


char t[]="CODEFESTIVAL2016",s[20];
int main(){
	int i,j,k,ca=0,n=0,m;
	scanf("%s",s);
	int ans=0;
	rep(i,0,16)ans+=s[i]!=t[i];
	printf("%d\n",ans);
    return 0;
}




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

using namespace std;
	
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define endl '\n'
#define boost ios::sync_with_stdio(false); cin.tie(NULL);
typedef long long li;
const int N = 1e5 + 10;


void solve(){

	string s;
	cin>>s;
	int ans = 0;
	int n = (int)s.size();
	for(int i = 0 ; i < n; ++i){

		if(i&1 && s[i]!='0')
			ans++;
		if(i%2==0 && s[i]!='1')
			ans++;
	}

	int temp = 0;

	for(int i = 0 ; i < n ; ++i){

		if(i&1 && s[i]!='1')
			temp++;
		if(i%2==0 && s[i]!='0')
			temp++;
	}

	cout<<min(ans,temp)<<endl;

}
signed main(){

	int t;
	t = 1;
	//cin>>t;

	while(t--)
		solve();

}

Measured memory_bytes: 512