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

#define pb push_back
#define fi first
#define se second
#define eb emplace_back

using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
const int N = 1000007, inf = 0x3f3f3f3f;

ll cnt[N];

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

	ll n; cin >> n;

	cnt[0] = 1;
	for(int i = 1; i < 15; ++i) {
		cnt[i] = cnt[i-1] * 26;
	}

	int sz = 1;
	for(int i = 1; i < 15; ++i) {
		sz = i;
		if(cnt[i] >= n) break;
		n -= cnt[i];
	}

	int cur = sz-1;
	string s = "";
	for(int i = 0; i < sz; ++i) {
		s += 'a';
		while(n - cnt[cur] > 0) {
			s.back()++;
			n -= cnt[cur];
		}
		cur--;
	}

	cout << s << endl;

}

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

using namespace std;

#define inf 1ll<<60
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> P;


int main(){
	int N, K;
	llong h[100000];
	llong dp[100000];
	fn(dp, 100000, inf);
	cin >> N >> K;
	for(int i = 0; i < N; i++)
		cin >> h[i];
	dp[0] = 0;
	for(int i = 0; i < N; i++){
		for(int j = i+1; j <= min(N-1, i+K); j++){
			dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
		}
	}

	cout << dp[N-1] << endl;

	return 0;
}

Measured memory_bytes: 1792
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

int n;
vector<vector<int>> g;

vector<int> cnt;

// int dfs(int v, int p) {
//     int res = 0;
//     for(auto nv: g[v]) {
//         if(nv == p) continue;
//         res += dfs(nv, v);
//     }
//     cnt[v] = res;
//     return res + 1;
// }

void solve() {
	cin >> n;
    g.assign(n, vector<int>());
    cnt.assign(n, 0);
    rep(i, n - 1) {
        int a; cin >> a; --a;
        g[a].pb(i + 1);
        g[i + 1].pb(a);
        cnt[a] ++;
    }
    rep(i, n) {
        cout << cnt[i] << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

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

using namespace std;

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

int main() {
  int x;
  cin >> x;
  string res = "NO";
  if (x == 7 || x == 5 || x == 3) {
    res = "YES";
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
fn main() {
	proconio::input!{
		mut h: usize,
		mut w: usize,
	}

	if h % 3 == 0 || w % 3 == 0 {
		println!("0");
		return;
	}

	let mut total: usize = 9999999999;

	let h1 = h / 3;
	let b1 = h1 * w;
	let w2 = w / 2;
	let b2 = (h-h1) * w2;
	let b3 = h*w - b1 - b2;
	let ans = std::cmp::max(std::cmp::max(b1, b2), b3) - std::cmp::min(std::cmp::min(b1, b2), b3);
	//println!("ans={}", ans);
	total = std::cmp::min(total, ans);

	let h2 = (h-h1) / 2;
	let b2 = h2 * w;
	let b3 = h*w - b1 - b2;
	let ans = std::cmp::max(std::cmp::max(b1, b2), b3) - std::cmp::min(std::cmp::min(b1, b2), b3);
	//println!("ans={}", ans);
	total = std::cmp::min(total, ans);

	let h1 = h / 3 + 1;
	let b1 = h1 * w;
	let w2 = w / 2;
	let b2 = (h-h1) * w2;
	let b3 = h*w - b1 - b2;
	let ans = std::cmp::max(std::cmp::max(b1, b2), b3) - std::cmp::min(std::cmp::min(b1, b2), b3);
	//println!("ans={}", ans);
	total = std::cmp::min(total, ans);

	let h2 = (h-h1) / 2;
	let b2 = h2 * w;
	let b3 = h*w - b1 - b2;
	let ans = std::cmp::max(std::cmp::max(b1, b2), b3) - std::cmp::min(std::cmp::min(b1, b2), b3);
	//println!("ans={}", ans);
	total = std::cmp::min(total, ans);

	let tmp = h;
	h = w;
	w = tmp;

	let h1 = h / 3;
	let b1 = h1 * w;
	let w2 = w / 2;
	let b2 = (h-h1) * w2;
	let b3 = h*w - b1 - b2;
	let ans = std::cmp::max(std::cmp::max(b1, b2), b3) - std::cmp::min(std::cmp::min(b1, b2), b3);
	//println!("ans={}", ans);
	total = std::cmp::min(total, ans);

	let h2 = (h-h1) / 2;
	let b2 = h2 * w;
	let b3 = h*w - b1 - b2;
	let ans = std::cmp::max(std::cmp::max(b1, b2), b3) - std::cmp::min(std::cmp::min(b1, b2), b3);
	//println!("ans={}", ans);
	total = std::cmp::min(total, ans);

	let h1 = h / 3 + 1;
	let b1 = h1 * w;
	let w2 = w / 2;
	let b2 = (h-h1) * w2;
	let b3 = h*w - b1 - b2;
	let ans = std::cmp::max(std::cmp::max(b1, b2), b3) - std::cmp::min(std::cmp::min(b1, b2), b3);
	//println!("ans={}", ans);
	total = std::cmp::min(total, ans);

	let h2 = (h-h1) / 2;
	let b2 = h2 * w;
	let b3 = h*w - b1 - b2;
	let ans = std::cmp::max(std::cmp::max(b1, b2), b3) - std::cmp::min(std::cmp::min(b1, b2), b3);
	//println!("ans={}", ans);
	total = std::cmp::min(total, ans);

	println!("{}", total);
}



Measured memory_bytes: 2132
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define PI 3.141592653589793238
int main()
{
    // #ifndef ONLINE_JUDGE
    // freopen("F:/cpp/input.txt", "r", stdin);
    // freopen("F:/cpp/output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k;
    cin >> n >> k;
    ll a[n], i, ans = 0;
    for (i=0;i<n;i++)
    cin >> a[i];
    sort(a, a+n);
    for (i=0;i<k;i++)
    ans += a[i];
    cout << ans;
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define int long long
#define mp make_pair
#define fr(i,a,b) for(i=a;i<b;i++)
#define mod 1000000007
#define FILEIO freopen("C:/Users/Aman/Desktop/kachda/input.txt", "r", stdin); freopen("C:/Users/Aman/Desktop/kachda/output.txt", "w", stdout);

using namespace std;
int n, W, dp[101][100001] = {{0}}, w[101], v[101];

signed main()
{
	//FILEIO
 	start_routine
	
	cin>>n>>W;
	int i;
	fr(i,1,n + 1)
	{
		cin>>w[i]>>v[i];
	}

	fr(i,1,n + 1)
	{
		int j;
		fr(j,0,W + 1)
		{
			if(w[i] <= j)
			{
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
			}
			else dp[i][j] = dp[i - 1][j];
		}
	}
	cout<<dp[n][W];


 	end_routine
}

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

using ll = long long;
using p = pair<ll, ll>;
constexpr ll INF = 1LL << 62;

int main(void) {
  ll N, K;
  cin >> N >> K;

  ll ans1 = N / K;

  ll ans2 = 0;
  if (K % 2 == 0) {
    ll m = 0;
    for (; K / 2 + m * K <= N; m++);
    ans2 = m;
  }

  cout << ans1 * ans1 * ans1 + ans2 * ans2 * ans2 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <bitset>
#include <iomanip>
#include <cmath>
#include <queue>
using namespace std;
using PP = pair<int, int>;
const int INF = 1e9;

template <class T> T Next() { T t; cin >> t; return t; }

int n, m;
set<PP> st[100000];
map<int, string> ans;

string f(string a) {
  while (a.size() < 6) {
    a = '0' + a;
  }
  return a;
}

string seg(int a, int b) {
  return f(to_string(a)) + f(to_string(b));
}

int main() {
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    st[a].insert(PP(b, i));
  }
  
  for (int i = 0; i < n; ++i) {
    int cnt = 0;
    for (PP p : st[i]) {
      int id = p.second;
      int a = i;
      int b = cnt;
      ans[id] = seg(a + 1, b + 1);
      ++cnt;
    }
  }
  
  for (auto p : ans) {
    cout << p.second << endl;
  }
}


Measured memory_bytes: 21888
x, y = map(int, input().split())
if y > x >= 0:
    cnt = y - x
elif x > y >= 0:
    cnt = min(x - y + 2, y + x + 1)
elif x < y < 0:
    cnt = y - x
elif y < x < 0:
    cnt = x - y + 2
elif y >= 0 & x <= 0:
    if y - abs(x) > 0:
        cnt = min(y-x, y - abs(x) + 1)
    else:
        cnt = min(y-x, abs(x) - y + 1)
elif x >= 0 & y <= 0:
    if abs(y) < x:
        cnt = x - abs(y) + 1
    else:
        cnt = abs(y) - x + 1

print(cnt)

Measured memory_bytes: 3188
#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<string>
using namespace std;
int a[100009], b[100009], n;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	a[0] = 0;
	a[1] = abs(b[0] - b[1]);
	for (int i = 2; i < n; ++i) {
		a[i] = min(a[i - 1] + abs(b[i] - b[i - 1]), a[i - 2] + abs(b[i] - b[i - 2]));
	}
	cout << a[n - 1];
	//system("pause");
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    if(s[a] == '-'){
        for(int i = 0; i < s.size(); i++){
            if(i != a){
                if(s[i] < '0' || s[i] >'9'){
                    cout << "No";
                    return 0;
                }
            }
        }
        cout << "Yes";
    }
    else cout << "No";
}

Measured memory_bytes: 256
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define deb(x) cout << #x << " is " << x << "\n";

using namespace std;
using namespace __gnu_pbds;

const double PI = 2 * acos(0.0);
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long N, W;
	cin >>N >>W;
	vector<pair<long long, long long>> arr(N);
	for(long long i = 0; i < N; i++)
		cin >>arr[i].first >>arr[i].second;
	// dp[i] = maximum possible weight by conidering weight exactly i
	vector<long long> dp(W + 1);
	for(long long i = 0; i < N; i++) {
		long long weight = arr[i].first;
		long long value = arr[i].second;
		for(long long w = W - weight; w >= 0; w--) {
			dp[w + weight] = max(dp[w + weight], dp[w] + value);
		}
	}
	cout <<*max_element(dp.begin(), dp.end());
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  vector<int> fri[200001];
  for(int i=0;i<M;i++){
    int A,B;
    cin>>A>>B;
    fri[A].push_back(B);
    fri[B].push_back(A);
  }
  int answer=0;
  int search[200001];
  for(int i=1;i<=N;i++) search[i]=0;
  for(int i=1;i<=N;i++){
    if(search[i]==0){
      search[i]=1;
      queue<int> que;
      que.push(i);
      int judge=0;
      while(!que.empty()){
        int x=que.front();
        que.pop();
        for(int j=0;j<fri[x].size();j++){
          if(search[fri[x][j]]==0){
            que.push(fri[x][j]);
            search[fri[x][j]]=1;
          }
        }
        judge++;
      }
      answer=max(answer,judge);
    }
  }
  cout<<answer<<endl;
  
  return 0;
}

Measured memory_bytes: 15452
import java.math.BigInteger;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String[] S = scanner.nextLine().split(" ");
    scanner.close();
    BigInteger N = new BigInteger(S[0]);
    BigInteger A = new BigInteger(S[1]);
    BigInteger B = new BigInteger(S[2]);
    BigInteger step = A.add(B);
    BigInteger[] dr = N.divideAndRemainder(step);
    BigInteger remainder = dr[1].compareTo(A) >= 0 ? A : dr[1];
    BigInteger blueCount = A.multiply(dr[0]).add(remainder);
    System.out.println(blueCount.toString());
  }
}

Measured memory_bytes: 23892
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, m;
    string s;
    cin >> n >> m >> s;
    reverse(all(s));

    ll now = 0;
    vl ans;
    while(1) {
        bool ok = false;
        for(ll i = min(m, n - now); i >= 1; i--) {
            if(s[now+i] == '0') {
                ok = true;
                ans.pb(i);
                now += i;
                break;
            }
        }
        if(ok == false) {
            out(-1);
            re0;
        }
        if(now == n) {
            reverse(all(ans));
            for(auto p : ans) {
                cout << p << " ";
            }
            cout << endl;
            re0;
        }
    }

    re0;
}

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

void trace(const vector<int>& A) {
    for(int i = 0; i < A.size(); i++) {
      if (i > 0) {
        cout << " ";
      }
      cout << A[i];
    }
    cout << endl;
}

int selectionSort(vector<int>& A) {
  int sw = 0;
  int minj;

  for (int i = 0; i < A.size() - 1; i++) {
    minj = i;
    for (int j = i; j < A.size(); j++) {
      if (A[j] < A[minj]) {
        minj = j;
      }
    }
    swap(A[i], A[minj]);
    if (i != minj) {
      sw++;
    }
  }
  return sw;
}

int main(){
  vector<int> A;
  A.reserve(100);

  int N, a;
  cin >> N;
  while(N--){
    cin >> a;
    A.push_back(a);
  }

  int sw = selectionSort(A);

  trace(A);
  cout << sw << endl;

  return 0;
}


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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

int main(){
    fIO
//    freopen("", "r", stdin);
//    freopen("", "w", stdout);

    string s;
    cin >> s;

    if(s[0] == '7' || s[1] == '7' || s[2] == '7') cout << "Yes";
    else cout << "No";

}








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

int main() {
    int n, m; std::cin >> n >> m;
    std::vector<unsigned int> h(n);
    std::vector<bool> f(n, true);
    for (int i = 0; i < n; i++) {
        std::cin >> h[i];
    }

    for (int i = 0; i < m; i++) {
        int a, b;
        std::cin >> a >> b;
        a--; b--;
        if (h[a] > h[b]) {
            f[b] = false;
        } else if (h[a] < h[b]) {
            f[a] = false;
        } else {
            f[a] = false;
            f[b] = false;
        }
    }

    int c = 0;
    for (const auto ff: f) {
        if (ff) {
            c++;
        }
    }

    std::cout << c << std::endl;

    return 0;
}

Measured memory_bytes: 3788
import itertools

N = int(input())
XY = [list(map(int,input().split())) for _ in range(N)]

P = list(itertools.permutations(range(N)))
l = 0
for p in P:
  for i in range(N-1):
    x0,y0 = XY[p[i]]
    x1,y1 = XY[p[i+1]]
    l += ((x1-x0)**2+(y1-y0)**2)**0.5
print(l/len(P))

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

int main()
{
    int d;
    cin >> d;
    vector<int> c(26);
    vector<vector<int>> s(d,vector<int>(26));
    vector<int> last(26,0);

    for (int i = 0; i < 26; i++)
    {
        cin >> c[i];
    }
    for (int i = 0; i < d; i++)
    {
        for (int j = 0; j < 26; j++)
        {
            cin >> s[i][j];
        }
    }

    vector<int> t(d);
    for (int i = 0; i < d; i++)
    {
        cin >> t[i];
    }
    
    long long ans = 0;
    for (int i = 0; i < d; i++)
    {
        ans += s[i][t[i] - 1];
        last[t[i] - 1] = i + 1;
        for (int j = 0; j < 26; j++)
        {
            ans -= c[j] * (i + 1 - last[j]);
        }
        cout << ans << endl;
    }
    
}


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

int main() {
	int n;
	cin >> n;
	int s[505] = { 0 }, c[505] = { 0 }, f[505] = { 0 };
	for (int i = 0; i < n-1; i++) {
		cin >> c[i] >> s[i] >> f[i];
	}
	for (int i = 0; i < n-1; i++) {
		int nowtime = s[i];
		for (int j = i; j < n-1; j++) {
			int tn = s[j];
			while (tn < nowtime) {
				tn += f[j];
			}
			nowtime = tn + c[j];
		}
		cout << nowtime << endl;
	}
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

//List of Top 3 Hills
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Queue<Integer> q = new PriorityQueue<Integer>(10, new Comparator<Integer>(){
			public int compare(Integer o1, Integer o2) {
				return o2-o1;
			}
		});
		for(int i=0;i<10;i++)q.add(sc.nextInt());
		for(int i=0;i<3;i++)System.out.println(q.poll());
	}
}

Measured memory_bytes: 12000
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Scanner;
import java.util.Deque;
import java.util.ArrayDeque;

public class Main {
	
	public static <E> void print_array(E[] arr){
		int i=0;
		for(E element: arr){
			System.out.print(element);
			if(i != arr.length-1) System.out.print(" ");
			else System.out.print("\n");
			i++;
		}
	}
	
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String tmp_arr[] = new String[n];
		tmp_arr = br.readLine().split(" ");
		String tmp_arr1[] = new String[n];
		String base_arr[] = new String[n];
		
		// srcPos: beginning in tmp_arr, destPos: beginning in tmp_arr1
		System.arraycopy(tmp_arr, 0, base_arr, 0, n);		
		System.arraycopy(tmp_arr, 0, tmp_arr1, 0, n);
		
		String[] bubbled_arr = bubblesort(tmp_arr);
		print_array(bubbled_arr);
		if(check_stable(bubbled_arr, base_arr)) System.out.println("Stable");
		else System.out.println("Not stable");
		String[] selected_arr = selectionsort(tmp_arr1);
		print_array(selected_arr);
		if(check_stable(selected_arr, base_arr)) System.out.println("Stable"); 		
		else System.out.println("Not stable");

	}	
	
	public static String[] bubblesort(String[] arr){
		int n = arr.length;
		for(int i=0; i<n; i++){
			for(int j=1; j<n-i; j++){
				if(Character.getNumericValue(arr[j-1].charAt(1)) > Character.getNumericValue((arr[j].charAt(1)))){
					String tmp = arr[j-1];
					arr[j-1] = arr[j];
					arr[j] = tmp;
				}
			}
		}		
		return arr;
	}
	
	public static String[] selectionsort(String[] arr){
		for(int i=0; i<arr.length; i++){
			int min_ix = i;
			for(int j=i; j<arr.length; j++){
				if(Character.getNumericValue(arr[min_ix].charAt(1)) > Character.getNumericValue(arr[j].charAt(1))) min_ix = j;
			}
			if(min_ix != i){
				// swap
				String tmp = arr[min_ix];
				arr[min_ix] = arr[i];
				arr[i] = tmp;
			}
		}
		return arr;
	}
	public static boolean check_stable(String[] arr, String[] sorted_arr){
		int n = arr.length;
		for(int checknum=1; checknum<10; checknum++){
			String[] check_bff_1 = new String[n];
			String[] check_bff_2 = new String[n];
			
			int bff_ix_1 = 0;
			int bff_ix_2 = 0;
			
			for(int i=0; i<n; i++){
				if (Character.getNumericValue(sorted_arr[i].charAt(1)) == checknum){
					check_bff_1[bff_ix_1] = sorted_arr[i];
					bff_ix_1++;
				}
				if (Character.getNumericValue(arr[i].charAt(1)) == checknum){
					check_bff_2[bff_ix_2] = arr[i];
					bff_ix_2++;
				}
			}
			for(int j=0; j<n; j++){
				if(check_bff_1[j] == null && check_bff_2[j] == null) continue;
				if(check_bff_1[j] != check_bff_2[j]) return false;
			}
		}
		return true;
	}
}
		


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


int main() {
string s;
string t;
int ans=0;
   cin>>s>>t;
int tl=t.size();
for (long int i = 0; i < s.size()-t.size()+1; i++)
{
    int sum=0;
    for (long int j = 0; j < t.size(); j++)
    {


        if(t[j]==s[i+j])
        {
         sum++;
        }
if (sum>ans)
    {
       ans=sum;

    }
    }

    
    
}

cout<<tl-ans<<endl;
}

Measured memory_bytes: 3548
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		int i, j, w, cnt=0;
		for(i=0; i<N; i++){
			A[i] = sc.nextInt();
		}
		for(i=0; i<N-1; i++){
			for(j=N-1; j>=i+1; j--){
				if(A[j]<A[j-1]){
					w      = A[j];
					A[j]   = A[j-1];
					A[j-1] = w;
					cnt++;
				}
			}
		}
		for(i=0; i<N; i++){
			if(i!=0) System.out.print(" ");
			System.out.print(A[i]);
		}
		System.out.println();
		System.out.println(cnt);
	}
}

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

using namespace std;
const int N=2e5 + 5;
int n, a[N], dd[1000001], num[1000001];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if(fopen(".inp", "r")) freopen(".inp", "r", stdin);
    cin >> n;
    vector <int > v;
    for(int i=1 ; i<=n ; ++i) {
        cin >> a[i];
        ++num[a[i]];
        v.push_back(a[i]);
    }
    sort(v.begin(), v.end());
    v.resize(unique(v.begin(), v.end())-v.begin());
    for(int x:v) {
        for(int j=x*2 ; j<=1000000 ; j+=x)
            dd[j]=1;
    }
    int ans=0;
    for(int i=1 ; i<=n ; ++i) {
        ans += !dd[a[i]];
        if(!dd[a[i]] && num[a[i]]>1) --ans;
    }
    cout << ans;


    return 0;
}


Measured memory_bytes: 12656
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=(a),_ed=(b);i<=_ed;++i)
#define DREP(i,a,b) for(int i=(a),_ed=(b);i>=_ed;--i)
typedef long long ll;
inline int read(){
    register int x=0,f=1;register char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=0;ch=getchar();}
    while(isdigit(ch)){x=x*10+(ch^'0');ch=getchar();}
    return f?x:-x;
}

const int N=2e5+5;
int n,fa[N],p[N],c[N][2];
struct node{int cnt[2],id;inline bool operator<(const node& t)const{return 1ll*cnt[1]*t.cnt[0]>1ll*cnt[0]*t.cnt[1];}};
priority_queue<node> q;
inline int find(int x){return fa[x]=fa[x]==x?fa[x]:find(fa[x]);}

int main(){
    //freopen("in.in","r",stdin);
    n=read();
    REP(i,2,n)p[i]=read();
    REP(i,1,n){
	fa[i]=i;
	++c[i][read()];
	if(i==1)continue;
	node nw=(node){c[i][0],c[i][1],i};
	q.push(nw);
    }
    ll ans=0;
    while(!q.empty()){
	node nw=q.top();q.pop();
	if(nw.cnt[0]!=c[nw.id][0]||nw.cnt[1]!=c[nw.id][1])continue;
	int u=nw.id,f=find(p[u]);
	ans+=1ll*c[f][1]*c[u][0];
	c[f][0]+=c[u][0],c[f][1]+=c[u][1];fa[u]=f;
	if(f^1)q.push((node){c[f][0],c[f][1],f});
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 7284
#include <iostream>

using namespace std;

int compute(string& s, char from)
{
	int n = 0;
	for (int i = 0; i < (int)s.size(); i++) {
		if (s[i] != from) {
			++n;
		}

		from = (from == '0') ? '1': '0';
	}
	return n;
}

int main() {

	string s;
	getline(cin, s);	

	int v1 = compute(s, '0');
	int v2 = compute(s, '1');
	int r = std::min(v1, v2);
	cout << r << endl;

	return 0;
}	


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

using namespace std;

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

    int u, v;
    vector<pair<long long,long long>> a(n+1);
    for(int i = 1; i <= n; i++){
        cin >> u >> v;
        a[i] = make_pair(u, v);
    }

    long long dp[111][111111];
    //memset(dp, 0, sizeof(dp));

    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= w; j++){
            dp[i][j] = dp[i-1][j];
            if(j - a[i].first >= 0){
                dp[i][j] = max(dp[i][j], dp[i-1][j-a[i].first] + a[i].second);
            }
        }
    }

    long long ans = 0;
    for(int i = 0; i <= w; i++){
        ans = max(ans, dp[n][i]);
    }
    cout << ans;

}


Measured memory_bytes: 88576
#include <stdio.h>
#include <string.h>
 
int main(void){
  char s[12];
  scanf("%s", s);
  
  int flag=0;
  
  if(s[0]=='A') flag++;
  int l = strlen(s);
  int c=0;
  for(int i=2;i<=(l-2);i++){
    if(s[i]=='C') c++;
  }
  if(c==1) flag++;
  int d=0;
  for(int i=1;i<=l;i++){
    if(s[i]>='a' && s[i]<='z') d++;
  }
  if(d==l-2) flag++;
  if(flag==3) printf("AC\n");
  else printf("WA\n");
  return 0;
 
}

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

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

    char a, b, c, d;
    a = S.at(2);
    b = S.at(3);
    c = S.at(4);
    d = S.at(5);

    if ( a == b && c == d ) {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }


    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define P pair<ll,ll>
const ll mod = 1e9+7;
const ll INF = 2e12;
const int inf = -1*((1<<31)+1);
 
using namespace std;

struct edge{
	int to;
	int cost;
};
void dijkstra(ll S,vector<vector<ll>> &dist,vector<vector<edge>> &g){
	priority_queue<P,vector<P>,greater<P>> q;
	dist[S][0] = 0;
	q.push(P(0,S));
	//コスト0でSから開始する
	while(!q.empty()){
		P now = q.top();q.pop();
		ll c  = now.first;//(スタート地点からの移動回数)%3
		ll v  = now.second;//今いる頂点
		if(dist[v][c%3]<c)continue;
		for(int i=0;i<g[v].size();i++){
			edge nextedge = g[v][i];
			if(dist[nextedge.to][(c+1)%3]>dist[v][c%3]+nextedge.cost){
				dist[nextedge.to][(c+1)%3]=dist[v][c%3]+nextedge.cost;
				q.push(P(c+1,nextedge.to));
			}
		}
	}
}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,S,T;
	cin >> N >> M;
	vector<vector<ll>> dist(N,vector<ll>(3,INF));
	//dist[i][j]:= 頂点iにj歩目で行くのにかかる最短コスト
	vector<vector<edge>> g(N);
	rep(i,M){
		int a,b;
		cin >> a >> b;
		a--;b--;
		g[a].push_back({b,1});

	}
	cin >> S >> T;
	S--;T--;
	dijkstra(S,dist,g);
	cout << (dist[T][0] != INF?dist[T][0]/3:-1) << endl;
}

Measured memory_bytes: 11264
#include "stdio.h"
#include <stdlib.h>

int compare_int(const void *a, const void *b)
{
    return *(long long int*)a - *(long long int*)b;
}

int main(int argc, char const *argv[]) {
  int N,K,i;
  scanf("%d%d", &N,&K);
  long long int h[N];
  for ( i = 0; i < N; i++) {
    scanf("%lld", &h[i]);
  }
  qsort(h, N, sizeof(long long int), compare_int);
  long long int ans=h[K-1]-h[0];
  for (i = 1; i <= N-K; i++) {
    if (ans>h[i+K-1]-h[i]) {
      ans=h[i+K-1]-h[i];
    }
  }
  printf("%lld", ans);
  return 0;
}


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

int main() {
	int n; cin >> n;
	int ans = n;
	for (int i = 0; i <= n; i++) {
		int cnt = 0;
		int t = i;
		while (t > 0) {
			cnt += t % 9;
			t /= 9;
		}
		t = n - i;
		while (t > 0) {
			cnt += t % 6;
			t /= 6;
		}
		if (ans > cnt) ans = cnt;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import itertools
import math

N = int(input())
pointXY = []
for _ in range(N):
    x, y = map(int, input().split())
    pointXY.append((x, y))
ans = 0
for xy in itertools.permutations(pointXY):
    tmpx = xy[0][0]; tmpy = xy[0][1]
    for (x, y) in xy[1:]:
        ans += math.sqrt((tmpx-x)**2 + (tmpy-y)**2)
        tmpx = x; tmpy = y
print(ans/math.factorial(N))

Measured memory_bytes: 3064
/*||>>>> Praveen Ojha <<<<>>>> 27 July 2019 <<<<>>>> 17:39:19 <<<<||*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
//Read Problems Carefully & Check for corner cases N=0,1 ?
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////

int32_t main(){__
    int n;
    cin>>n;
    vi mon(n+1),her(n);
    for(int i=0;i<=n;i++)
        cin>>mon[i];
    for(int i=0;i<n;i++)
        cin>>her[i];
    int ans=0;
    for(int i=0;i<n;i++){
        if(mon[i]>=her[i]){
            mon[i]-=her[i];
            ans+=her[i];
            her[i]=0;
        }
        else{
            her[i]-=mon[i];
            ans+=mon[i];
            mon[i]=0;
        }
        if(mon[i+1]>=her[i]){
            mon[i+1]-=her[i];
            ans+=her[i];
            her[i]=0;
        }
        else{
            her[i]-=mon[i+1];
            ans+=mon[i+1];
            mon[i+1]=0;
        }
    }
    cout<<ans<<"\n";
return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
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; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    int n, k, p = 0;
    string s;
    cin >> n >> k >> s;
    char c = '0';
    for(auto x: s){
        if(x == c) p++;
        c = x;
    }
    cout << p + min(2*k, n-p-1) << endl;
    return 0;
}


Measured memory_bytes: 512
s=input()
left=0
right=len(s)-1
ans=0
while left<right:
    if s[left]==s[right]:
        left+=1
        right-=1
    elif s[left]=="x":
        left+=1
        ans+=1
    elif s[right]=="x":
        right-=1
        ans+=1
    else:
        print(-1)
        exit()
print(ans)

Measured memory_bytes: 67544
# -*- coding: utf-8 -*-
n = int(input())
ret = {"AC":0,
       "WA":0,
       "TLE":0,
       "RE":0
       }
for i in range(n):
    s = input()
    ret[s]+=1

print("AC x {}".format(ret["AC"]))
print("WA x {}".format(ret["WA"]))
print("TLE x {}".format(ret["TLE"]))
print("RE x {}".format(ret["RE"]))

Measured memory_bytes: 9200
void main(){
	int[] ab = _scanln();
	if( ab[0]>ab[1] )writeln(ab[0]+ab[0]-1);
	else if( ab[0]<ab[1] )writeln(ab[1]+ab[1]-1);
	else writeln(ab[0]*2);
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


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

using namespace std;

int gcd(int x, int y) {
    int r = x % y;
    while (r > 0) {
        x = y;
        y = r;
        r = x %y;
    }
    return y;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a * b) / (gcd(a, b) * gcd(a, b)) * c << '\n';
    return 0;
}


Measured memory_bytes: 3192
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;




int main() {
  int N;
  cin >> N;
 ll ans = 1,a;
 ll inf = 1e18;
 bool f = false;
  rep(i,N) {
    cin >> a;
    if(a == 0) {
      cout << 0 << endl;
      return 0;
    }
    if(ans > inf/a) {
      f = true;
    }

    ans *= a;
  }
  if(f) {
    cout << -1 << endl;
    return 0;
  }
   
  cout << ans << endl;

  return 0;
}










Measured memory_bytes: 3188
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<58;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
const double PI = 4.0*atan(1.0);

int n;

int main(){
	cin>>n;
	vp a(n);
	for(int i=0;i<n;i++){
		cin>>a[i].first>>a[i].second;
	}
	sort(a.begin(),a.end());
	cout<<a[n-1].first+a[n-1].second<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,m,i,j,a,b;
   string str,str1;
   cin>>str>>str1;
   n = str.size() + str1.size();
   a= 0,b = 0;
   for(i = 1;i <= n;i++)
   {
       if(i%2!=0)
        cout<<str[a++];
       else
        cout<<str1[b++];
   }
   cout<<endl;
    return 0;
}


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

using namespace std;

#define int long long

#ifndef bhupixb
    #define var(...)
    #define stl(...)
#endif

#define single_test


constexpr int mod = 1e9 + 7;

struct M {
    unsigned v;
    M(long long a = 0) : v((a %= mod) < 0 ? a + mod : a) {}
    M& operator+=(M r) { if ((v += r.v) >= mod) v -= mod; return *this; }
    M& operator-=(M r) { if ((v += mod - r.v) >= mod) v -= mod; return *this; }
    M& operator*=(M r) { v = (uint64_t)v * r.v % mod; return *this; }
};

uint32_t add(M a, M b) { return (a += b).v; }
uint32_t mul(M a, M b) { return (a *= b).v; }
uint32_t sub(M a, M b) { return (a -= b).v; }

uint32_t po(M x, int n) {
    M res(1);
    while (n > 0) {
        res *= (n & 1 ? x : 1);
        x *= x; n /= 2;
    }
    return res.v;
}

vector<int32_t> dp;

int go(int sum) {
    if (!sum) {
        return 1;
    }
    auto &ref = dp[sum];
    if (~ref) return ref;
    int ans = 0;
    for (int i = 3; i <= sum; ++i) {
        ans = add(ans, go(sum - i));
    }
    return ref = ans;
}

void solve() {

    int n;
    cin >> n;
    dp.assign(n + 1, -1);
    cout << go(n) << '\n';
}

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    #ifndef single_test
        cin >> t;
    #endif
    for (int i = 1; i <= t; ++i) {
        // cout << "Case #" << i << ": ";
        solve();
    }

    return 0;
}

Measured memory_bytes: 3676
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
//Tariquzzaman Faisal
//_Faisal101_
//IUT_CSE'19
//190041101
 
#include<iostream>
#include<stdio.h>
#include<vector>
#include<deque>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#include<cstring>
#include<climits>
#include<cmath>
#include<iterator>
#include<set>
#define fileOut freopen("out.txt","w",stdout)
#define fileIn freopen("in.txt","r",stdout)
#define testcases ll TC,T; cin >> TC; for(T=1; T<=TC; T++)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define INFLL 9223372036854775807
#define INF 2147483647
#define pi acos(-1.0)
#define ll long long
#define endll printf("\n")
#define CASE printf("Case %lld: ",T)
#define ff first
#define ss second
#define mem(ara,n) memset(ara,n,sizeof ara)
#define ull unsigned long long
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mid3(a,b,c) min(max(a,b),max(b,c),max(a,b))
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define endl '\n'
#define ld long double
 
 
using namespace std;


int main(){
	ll n;
	cin >> n;
	ll x;
	set <ll> st;
	while(n--){
		cin >> x;
		if(!st.count(x)){
			st.insert(x);
		}
		else{
			st.erase(st.find(x));
		}
	}
	cout<< st.size() <<endl;
	return 0;
}

Measured memory_bytes: 8080
// ABC147A.cpp
//#include "pch.h"
#include <iostream>
using namespace std;
int main()
{
	int a1, a2, a3;
	cin >> a1 >> a2 >> a3;
	if (a1+a2+a3>=22)
	{
		cout << "bust";
	}
	else
	{
		cout << "win";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll x;
    cin >> x;
    ll ans = 0;
    ans += x / 500 * 1000;
    x -= x / 500 * 500;
    ans += x / 5 * 5;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int data[100001];
  int data2[100001];
  int q;
  cin>>q;
  data[0]=0;
  data[1]=0;
  data[2]=1;
  for(int i=3;i<100001;i++){
  	if(i%2==0){
  		data[i]=0;
  	}else{
  	    bool check=true;
  		for(int j=2;j<=sqrt(i);j++){
  			if(i%j == 0){
  				check=false;
  				break;
  			}
  		}
  		if(check){
  			data[i]=1;
  		}else{
  			data[i]=0;
  		}
  	}
  }
  data2[0]=0;
  data2[1]=0;
  data2[2]=0;
  for(int i=3;i<100001;i++){
  	if(i%2==0){
  		data2[i]=data2[i-1];
  	}else{
  		if(data[i]==1 && data[(i+1)/2]==1){
  			data2[i]=data2[i-1]+1;
  		}else{
  			data2[i]=data2[i-1];
  		}
  	}
  }
  for(int i=0;i<q;i++){
  	int l,r;
  	cin>>l>>r;
  	if(l==r){
  	  cout<<data2[l]-data2[l-1]<<endl;
  	}else{
  	  cout<<data2[r]-data2[l-1]<<endl;
  	}
  }
  return 0;
}

Measured memory_bytes: 1408
from sys import stdin

n = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]

for i in range(n - 1):
    pot = []
    pot.append(min(a))
    a.pop(a.index(min(a)))
    pot.append(min(a))
    a.pop(a.index(min(a)))
    a.append(sum(pot)/2)

print(*a)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

ll t[200000];

int main()
{
	int n;
	ll s;
	int index=0;
	ll ans=0;
	
	cin>>n>>s;
	for(int i=0;i<n;i++)
	{
		cin>>t[i];
	}
	for(int i=0;i<n-1;i++)
	{
		ans += min(t[i+1]-t[i],s);
	}
	ans+=s;
	cout<<ans<<endl;
	return 0;
}

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

int read() {
	int x = 0, f = 1; char ch = getchar();
	for (; ch > '9' || ch < '0'; ch = getchar()) if (ch == '-') f = -1;
	for (; ch <= '9' && ch >= '0'; ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ '0');
	return x * f;
}

int n, m, cnt, S, T;
int head[20005], pre[1000005], to[1000005], val[1000005], sz, dis[20005];
bool v[20005];
char mp[205][205]; 

inline int o(int x, int y) {
	return (x - 1) * m + y;
}

inline void addedge(int u, int vv, int w) {
	pre[++sz] = head[u]; head[u] = sz; to[sz] = vv; val[sz] = w;
}

priority_queue<pair<int, int> , vector<pair<int, int> > , greater<pair<int, int> > > que;

void dijkstra() {
	memset(dis, 0x3f, sizeof(dis));
	memset(v, 0, sizeof(v));
	dis[S] = 0;
	que.push(make_pair(0, S));
	while (!que.empty()) {
		int x = que.top().second; que.pop();
		if (v[x]) continue;
		else v[x] = 1;
		for (int i = head[x]; i; i = pre[i]) {
			int y = to[i];
			if (dis[x] + val[i] < dis[y]) {
				dis[y] = dis[x] + val[i];
				que.push(make_pair(dis[y], y));
			}
		} 
	}
}

int main() {
	n = read(); m = read();
	for (int i = 1; i <= n; i++) scanf("%s", mp[i] + 1);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (i < n) {
				if (mp[i][j] == '.' && mp[i+1][j] == '#') addedge(o(i, j), o(i+1, j), 1);
				else addedge(o(i, j), o(i+1, j), 0);
			}
			if (j < m) {
				if (mp[i][j] == '.' && mp[i][j+1] == '#') addedge(o(i, j), o(i, j+1), 1);
				else addedge(o(i, j), o(i, j+1), 0);
			}
		}
	}
	S = 0, T = n * m + 1;
	if (mp[1][1] == '#') addedge(S, o(1, 1), 1);
	else addedge(S, o(1, 1), 0);
	addedge(o(n, m), T, 0);
	dijkstra();
	printf("%d", dis[T]);
	return 0;
}

Measured memory_bytes: 6656
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
    A[i] -= i + 1

A.sort()
mid = A[(N + 2 - 1) // 2 - 1]
ans = 0
for a in A:
    ans += abs(a - mid)

print(ans)


Measured memory_bytes: 86612
import sys
sys.setrecursionlimit(10000)
def resolve():
    N = int(input())
    candidates = []
    x6 = 6
    x9 = 9
    while True:
        if x6 > N and x9 > N:
            break
        if x6 <= N:
            candidates.append(x6)
        if x9 <= N:
            candidates.append(x9)
        x6 = x6 * 6
        x9 = x9 * 9
    candidates.sort()
    # print(candidates)
    dic = {}
    res = rec(candidates, N, dic)
    print(res)

def rec(ary, target, dic):
    # print(dic)
    if target in dic:
        return dic[target]
    if len(ary) < 1:
        return target
    if ary[0] > target:
        dic[target] = target
        return target
    counts = []
    for i in ary:
        if target - i < 0:
            continue
        counts.append(rec(ary, target - i, dic)+1)
    dic[target] = min(counts)
    return dic[target]
        

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 70236
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++) //これでiやjを定義しなくていいらしい
using namespace std;

int main(){
  int x,y;
  cin >> x >> y;
  bool flag=false;

  rep(i,x+1){
    if(y==(2*i + 4*(x-i))){
      flag=true;
      break;
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
int N, M;
	cin >> N >> M;
	string S;
	cin >> S;
	vec(ANS);
	for (int i = N; i > 0;) {
		for (int j = M; j > 0;j--) {
			if (i-j>=0&&S[i-j]=='0') {
				pb(ANS, j);
				i -= j;
				break;
			}
			if (j==1) {
				ce(-1);
				return 0;
			}
		}
	}

	reverses(ANS);
	fx(ANS.size()) {
		cout << ANS[x] << ' ';
	}

    return 0;
}



Measured memory_bytes: 1144
def reverse_polish_notation(formula)
  stack = []
  while !formula.empty? do
    if formula[0].match(/\d/)
      stack << formula.shift.to_i
    elsif formula[0] == "+"
      formula.shift
      a = stack.pop
      b = stack.pop
      stack << b + a
    elsif formula[0] == "-"
      formula.shift
      a = stack.pop
      b = stack.pop
      stack << b - a
    elsif formula[0] == "*"
      formula.shift
      a = stack.pop
      b = stack.pop
      stack << b * a
    elsif formula[0] == "/"
      formula.shift
      a = stack.pop
      b = stack.pop
      stack << b / a
    end
  end
  stack
end

formula = gets.split
puts reverse_polish_notation(formula)



Measured memory_bytes: 6872