akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int gcd(int x,int y){
    if (x%y==0) return y;
    else return gcd(y,x%y);
}

int main(){
    int N,K;cin>>N>>K;
    vector<int> a(N);
    REP(i,N)cin>>a[i];
    int m=a[0];
    FOR(i,1,N)m=gcd(a[i],m);
    bool f=false;
    REP(i,N){
        if(a[i]>=K && (a[i]-K)%m==0){f=true;break;}
    }
    cout<<(f?"POSSIBLE":"IMPOSSIBLE")<<endl;
    return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
//#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
                        
using namespace std;
                        
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
                        
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}

#define int long long
#define ghost signed
#define left left228
#define right right228
#define complex complex228
#define count count228
#define sin sin228
#define list list228

const int N = 200 * 1000 + 228;

vector<int> g[N];
int val[N];

void dfs(int v, int par = 0) {
	for (int to : g[v]) {
		if (to == par) continue;
		val[to] += val[v];
		dfs(to, v);
	}
}

ghost main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int n, q;
	cin >> n >> q;
	for (int i = 0; i < n - 1; ++i) {
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	while(q--) {
		int v, x;
		cin >> v >> x;
		val[v] += x;
	}
	dfs(1);
	for (int i = 1; i <= n; ++i) cout << val[i] << ' ';
	cout << '\n';
    return 0;
} // kek ;
// Ого! Кажетсья это $#@!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 


Measured memory_bytes: 20096
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    int N;
    cin>>N;
    vector<ll> A(N);
    REP(i, N) cin>>A[i];
    ll tmp = INF;
    ll res = 0;
    REP(i, N){
        if(A[i]<tmp){
            res++;
            tmp = A[i];
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
#pragma GCC diagnostic ignored "-Wunused-result"
#define NDEBUG

#include <algorithm>
#include <cassert>
#include <cinttypes>
#include <cstdio>
#include <tuple>
#include <vector>
#include <set>
#include <queue>

#ifdef NDEBUG
#  define debug(...)
#else
#  define debug(...)                                \
  do {                                              \
    fprintf(stderr, "%s:%d: ", __FILE__, __LINE__); \
    fprintf(stderr, __VA_ARGS__);                   \
    fputc('\n', stderr);                            \
  } while (false)
#endif

using namespace std;
using tii = tuple<int, int>;

const int MAX = 2e5;
int N, M;
char s[MAX+1];
vector<int> adj[MAX];
bool v[MAX];

int main() {
  scanf("%d %d %s", &N, &M, s);
  for (int i = 0; i < M; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--, b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  queue<int> q;
  for (int i = 0; i < N; i++) {
    bool a = false, b = false;
    for (int j: adj[i]) {
      if (s[j] == 'A') a = true;
      else b = true;
    }
    if (!(a && b)) q.push(i);
  }
  while (!q.empty()) {
    int i = q.front();
    q.pop();
    v[i] = true;
    for (int j: adj[i]) {
      if (!v[j]) {
        bool a = false, b = false;
        for (int j2: adj[j]) {
          if (!v[j2]) {
            if (s[j2] == 'A') a = true;
            else b = true;
          }
        }
        if (!(a && b)) q.push(j);
      }
    }
  }
  bool ans = false;
  for (int i = 0; i < N; i++) if (!v[i]) ans = true;
  puts(ans ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 11136
#include <stdio.h>
int main()
{
  char c;
  int n=0,s = 0;
  while((scanf("%c",&c))!=EOF){
    if('0'<=c && c<='9'){
      n = n*10 + (c-'0');
    }else if(n!=0){
      s += n;
      n = 0;
    }
  }
  printf("%d\n",s);
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
char a[105],b[105];
int lena,lenb;
int main(){
	cin>>a>>b;
	lena=strlen(a),lenb=strlen(b);
	sort(a,a+lena);
	sort(b,b+lenb,greater<char>());
	string aa=a,bb=b;
	if(aa<bb){
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
int main()
{
    ll n;
    cin>>n;
    for(ll x=1;x<=4000;x++)
    {
        for(ll y=x;y<=4000;y++)
        {
            ll p=4*x*y-(x+y)*n;
            if(p<=0)
            continue;
            ll q=x*y*n;
            if(q%p==0)
            {
                cout<<x<<" "<<y<<" "<<q/p<<endl;
                return 0;
            }
        }
    }

    
}

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

using namespace std;

void solve()
{
	int N, H;
	cin >> N >> H;
	vector<int> as(N), bs(N);
	for (int i = 0; i < N; i++)
	{
		cin >> as[i] >> bs[i];
	}
	sort(as.rbegin(), as.rend());
	sort(bs.rbegin(), bs.rend());
	int a = as[0], ans = 0;
	for (int b : bs)
	{
		if (H <= 0 || a >= b) break;
		H -= b;
		ans++;
	}
	if (H > 0) ans += (H + a - 1) / a;
	cout << ans << endl;
}

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


Measured memory_bytes: 1024
//bool imba(string s){
//    map<char,int> cnt;
//    for(char c : s)
//        cnt[c]++;
//    for(auto _ : cnt)
//        if(_.Y*2 > sz(s))
//            return true;
//    return false;
//}
//pii _(){
//    string s;
//    cin >> s;
//    for(int i = 0; i < sz(s); ++i)
//        for(int j = i+1; j < min(sz(s),ll(i+3)); ++j)
//            if(imba(s.substr(i,j-i+1)))
//                return mp(i+1,j+1);
//    return mp(-1,-1);
//}
#include <map>
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define sz(v) ll(v.size())
#define Y second
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template <typename F, typename S> static
ostream& operator<<(ostream& stream, const pair<F, S>& t){
    return stream << t.first << ' ' << t.second;
}
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
bool imba(string s){
    map<char,int> cnt;
    for(char c : s)
        cnt[c]++;
    for(auto _ : cnt)
        if(_.Y*2 > sz(s))
            return true;
    return false;
}
pii _(){
    string s;
    cin >> s;
    for(int i = 0; i < sz(s); ++i)
        for(int j = i+1; j < min(sz(s),ll(i+3)); ++j)
            if(imba(s.substr(i,j-i+1)))
                return mp(i+1,j+1);
    return mp(-1,-1);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        cout << _() << '\n';
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    int q;
    cin >> q;
    while(q--){
        ll a, b;
        cin >> a >> b;
        if(a < b) swap(a, b);
        ll right = 1000000007, left = 0;
        while(right - left > 1){
            ll mid = (right + left) / 2;
            if(mid * mid < a * b) left = mid;
            else right = mid;
        }
        ll ans;
        if(left * (left + 1) < a * b) ans = left * 2;
        else ans = left * 2 - 1;
        if(a <= left) ans--;
        if(b <= left) ans--;
        cout << ans << endl;
    }
}


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

int main(){
  int n;
  cin >> n;
  int m = sqrt(n)+5;
  map<int,int> c;
    for(int x=1;x<m;++x){
      for(int y=1;y<m;++y){
        for(int z=1;z<m;++z){
          if(c.count(x*x+y*y+z*z+x*y+y*z+z*x)){
            ++c[x*x+y*y+z*z+x*y+y*z+z*x];
          }
          else c.insert(make_pair(x*x+y*y+z*z+x*y+y*z+z*x, 1));
      }
    }
  }
    rep(i,n){
      cout << c[i+1] << endl;
    }
  return 0;
}

Measured memory_bytes: 5512
import java.util.Scanner;

/**
 * Created by kazuki on 2014/07/10.
 */
public class Main{
    static Scanner s = new Scanner(System.in);

    public static void main(String[] args) {
        int N, Nx, Ny, M, Mmove, x, y, catchNum;
        char Mdir;
        int[][] map = new int[21][21];

        while (true) {
            N = s.nextInt();
            if (N == 0) break;

            x = 10;
            y = 10;
            catchNum = 0;
            for(int i=0;i<21;i++){
                for (int j=0;j<21;j++)
                    map[i][j]=0;
            }

            for (int i = 0; i < N; i++) {
                Nx = s.nextInt();
                Ny = s.nextInt();
                map[Nx][Ny] = 1;
            }

            M = s.nextInt();

            if (map[x][y] == 1) {
                map[x][y] = 0;
                catchNum++;
            }

            for (int i = 0; i < M; i++) {
                Mdir = s.next().charAt(0);
                Mmove = s.nextInt();

                switch (Mdir) {
                    case 'N':
                        for (int j = 0; j < Mmove; j++) {
                            y++;
                            if (map[x][y] == 1) {
                                map[x][y] = 0;
                                catchNum++;
                            }
                        }
                        break;
                    case 'S':
                        for (int j = 0; j < Mmove; j++) {
                            y--;
                            if (map[x][y] == 1) {
                                map[x][y] = 0;
                                catchNum++;
                            }
                        }

                        break;
                    case 'E':
                        for (int j = 0; j < Mmove; j++) {
                            x++;
                            if (map[x][y] == 1) {
                                map[x][y] = 0;
                                catchNum++;
                            }
                        }
                        break;
                    case 'W':
                        for (int j = 0; j < Mmove; j++) {
                            x--;
                            if (map[x][y] == 1) {
                                map[x][y] = 0;
                                catchNum++;
                            }
                        }
                        break;
                }
            }

            if (N == catchNum) System.out.println("Yes");
            else System.out.println("No");
        }
    }
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, A, B; scanf("%d %d %d", &N, &A, &B);
  vector<ll> V(N);
  for (int i = 0; i < N; ++i) {
    scanf("%lld", &V[i]);
  }

  sort(V.begin(), V.end(), greater<ll>());
  ll sum = accumulate(V.begin(), V.begin() + A, 0LL);
  double ans_avg = sum * 1.0 / A;

  vector<vector<ll> > combi(55, vector<ll>(55, 0));
  for (int i = 0; i < 55 - 1; ++i) {
    combi[i][0] = 1;
    for (int j = 0; j <= i; ++j) {
      combi[i + 1][j] += combi[i][j];
      combi[i + 1][j + 1] += combi[i][j];
    }
  }
  ll ans_cnt = 0;
  int left = 0, right = 0;
  for (int i = A - 1; i >= 0 and V[i] == V[A - 1]; --i) {
    ++left;
  }
  for (int i = A; i < N and V[i] == V[A - 1]; ++i) {
    ++right;
  }
  ans_cnt += combi[left + right][left];

  if (V[0] == V[A - 1]) {
    int cnt = count(V.begin(), V.end(), V[0]);
    for (int i = A + 1; i <= min(cnt, B); ++i) {
      ans_cnt += combi[cnt][i];
    }
  }

  printf("%.10f\n", ans_avg);
  printf("%lld\n", ans_cnt);
  return 0;
}


Measured memory_bytes: 256
class Main {
    public static void main(String args[]) {
        java.util.Scanner sc = new java.util.Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] parent = new int[n];
        int[] left = new int[n];
        int[] right = new int[n];
        for(int i=0; i<n; i++){
            parent[i] = Integer.parseInt(sc.next());
            left[i] = Integer.parseInt(sc.next());
            right[i] = Integer.parseInt(sc.next());
        }
        Tree tree = new Tree(parent, left, right);
        System.out.println("Preorder");
        tree.preorderParse(tree.getRoot());
        System.out.println();
        System.out.println("Inorder");
        tree.inorderParse(tree.getRoot());
        System.out.println();
        System.out.println("Postorder");
        tree.postorderParse(tree.getRoot());
        System.out.println();
    }

    static class Node{
        public  int parent;
        public  int left;
        public  int right;
    }

    static class Tree{
        private final Node[] nodes;

        public Tree(int[] parent, int[] left, int[] right){
            Node[] nodes = new Node[parent.length];
            for(int i=0; i<parent.length; i++)  nodes[i] = new Node();
            for(int i=0; i<parent.length; i++)  nodes[i].parent = -1;
            for(int i = 0; i<parent.length; i++){
                nodes[parent[i]].left = left[i];
                nodes[parent[i]].right = right[i];
                if(left[i] != -1)   nodes[left[i]].parent = parent[i];
                if(right[i] != -1)   nodes[right[i]].parent = parent[i];
            }
            this.nodes = nodes;
        }
        public int getRoot(){
            for(int i=0; i<nodes.length; i++){
                if(nodes[i].parent == -1)   return i;
            } 
            return -1;
        }
        public void preorderParse(int index ){
            if( index != -1 ){
                System.out.print(" "+index);
                int left = this.nodes[index].left;
                preorderParse(left);
                int right = this.nodes[index].right;
                preorderParse(right);
            }
        }

        public void inorderParse(int index ){
            if( index != -1 ){
                int left = this.nodes[index].left;
                inorderParse(left);
                System.out.print(" "+index);
                int right = this.nodes[index].right;
                inorderParse(right);
            }
        }

        public void postorderParse(int index ){
            if( index != -1 ){
                int left = this.nodes[index].left;
                postorderParse(left);
                int right = this.nodes[index].right;
                postorderParse(right);
                System.out.print(" "+index);
            }
        }

    }
}




Measured memory_bytes: 26264
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll a[5];
	ll c;
	for(ll i=0;i<5;i++){
		cin>>a[i];
		if(a[i]==0){
			c=i+1;
		}
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 3548
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
 
int main() {
  int k,a,b,ans=0;
  cin>>k>>a>>b;
  
  for(int i=a;i<b+1;i++){
     if(i%k==0){
        cout<<"OK";
        ans=1;
        break;
     }
  }
  
  if(ans==0){
        cout<<"NG";
   }
  return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
using namespace std;

class UF{
    public:
    int *id, *sz;
    int pp;
    set<int> things;
    UF(int n){
        id = new int[n]; sz = new int[n];
        for (int i = 0; i < n; i++)
        { 
            id[i] = i;
            sz[i] = 1;
        }
        pp = n;
    }
    
    int find(int a){
        while(id[a] != a){
            id[a] = id[id[a]];
            a = id[a];
        }
        return a;
    }
    void un(int s, int t){
        int a = find(s);
        int b = find(t);
        if(connected(a,b)) return;
        if (sz[a] <= sz[b])
        {
            id[a] = b;
            sz[b] += sz[a];
        }
        else
        {
            id[b] = a;
            sz[a] += sz[b];
        }
    }
    bool connected(int s, int t){
        return find(s) == find(t);
    }
    int biggestGroup(){
        int uul = 0;
        for(int i = 0; i < pp; i++){
            uul = max(uul, sz[i]);
        }
        return uul;
    }
};

int main(){
    int N, M;
    int temp1, temp2;
    cin >> N >> M;
    UF hue(N);
    for(int i = 0; i < M; i++){
        cin >> temp1 >> temp2;
        hue.un(temp1-1, temp2-1);
    }
    cout << hue.biggestGroup();
}

Measured memory_bytes: 5132
import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.util.TreeMap;

public class Main {
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = in.nextInt();
        int m = in.nextInt();
        int k = in.nextInt();
        TreeMap<Integer,Integer> hm = new TreeMap<Integer,Integer>();
        for(int i = n, count = 0; i<=m && count<k; i++, count++ ){
            if(!hm.containsKey(i)){
                hm.put(i,1);
            }
        }
        for(int i = m, count = 0; i>=n && count<k; i--, count++ ){
            if(!hm.containsKey(i)){
                hm.put(i,1);
            }
        }
        for(Map.Entry<Integer,Integer> e : hm.entrySet()){
            out.println(e.getKey());
        }
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext() {
            String next = null;
            try {
                next = reader.readLine();
            } catch (Exception e) {
            }
            if (next == null) {
                return false;
            }
            tokenizer = new StringTokenizer(next);
            return true;
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
    }
}



Measured memory_bytes: 33072
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int ans = 0; 
  int n, arr[100];
  int i;
  
  cin >> n;
  
  for(i = 0; i < n; i++){
    cin >> arr[i];
  }
  for(i = 0; i < n; i++){
    if(i >= 1 && arr[i] == arr[i - 1]){
      ans++;
      arr[i] = arr[i + 1] - 1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int a, b, n;
pair<int, int> c[64];
int reachCount;

void walk(int x, int y) {
	if (a < x || b < y) return;
	if (x == a && y == b) {
		reachCount++;
		return;
	}
	pair<int, int>* pos = find(c, c + n, pair<int, int>(x, y));
	if (pos == c + n) {
		walk(x + 1, y);
		walk(x, y + 1);
	}
}

int main() {
	while (cin >> a >> b, a || b) {
		cin >> n;
		for (int i = 0; i < n; i++) {
			cin >> c[i].first >> c[i].second;
		}
		reachCount = 0;
		walk(1, 1);
		cout << reachCount << endl;
	}
	return 0;
}

Measured memory_bytes: 864
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

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

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

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

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





///////////////////////////

ll p(ll n) {
	if (n == 0) { return 1; }
	return 2 * p(n - 1);
}


int main() {

	ll N;
	cin >> N;

	vector<ll> A(N + 1);

	repn(i, N) cin >> A[i];

	sort(++A.begin(), A.end(), greater<ll>());

	vector<vector<ll>> d(N + 1,vector<ll>(60));

	vector<ll> count1(60);

	repn(i, N) {
		ll t = A[i];
		rep(j,60){
			d[i][59-j] = t%2;
			count1[59-j]+= d[i][59-j];
			t /= 2;
		}
	}
	
	repn(i, N) {
		rep(j, 60) {
			if (count1[j] % 2 == 1) { d[i][j] = 0; }
		}
	}

	/*
	repn(i, N) {
		rep(j, 60) {
			cout << d[i][j];
		}
		cout << endl;
	}
	*/


	repn(i, N) {
		ll K=-1;
		rep(j,60){
			if (d[i][j] == 1) { K = j; break; }
		}

		//cout << i << K << endl;

		if (K == -1) { continue; }

		repn(l, N) {
			if (l == i) { continue; }

			if (d[l][K] == 1) {
				for (int j = K; j < 60; j++) {
					d[l][j] = (d[i][j] + d[l][j]) % 2;
				}
			}
		}

		/*
		repn(i, N) {
			rep(j, 60) {
				cout << d[i][j];
			}
			cout << endl;
		}
		*/
		
	}

	vector<ll> sum(60, 0);

	repn(i, N) {
		rep(j, 60) {
			sum[j]+=d[i][j];
		}
	}

	//rep(j, 60) { cout << count1[j] << endl; }

	ll ans=0;

	rep(j, 60) {
		ans += (count1[j]%2+2*(sum[j]%2)) * p(59-j);
	}

	cout << ans;

	

	system("PAUSE");

}


Measured memory_bytes: 52088
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a>=b)
	{
		while(a--)
		cout<<b;
	}
	else
	{
		while(b--)
		cout<<a;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class C
{
	static List<int> Read() => Console.ReadLine().Split().Select(int.Parse).ToList();
	static void Main()
	{
		var h = Read();
		int k = h[0], n = h[1];
		var a = Read();
		a.Add(k + a[0]);
		Console.WriteLine(k - Enumerable.Range(0, n).Max(i => a[i + 1] - a[i]));
	}
}


Measured memory_bytes: 44516
A=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a 

B=[0]*15
for i in range(1,int(input())+1):
    w=prime_factorize(i)
    for j in w:
        if j<=47:
            B[A.index(j)]+=1

def num(m):
    return len(list(filter(lambda x:x>=m,B)))

print((num(2)-2)*num(4)*(num(4)-1)//2+num(14)*(num(4)-1)+num(24)*(num(2)-1)+num(74))

Measured memory_bytes: 3064
n = int(input())
p = list(map(int, input().split()))

ans = 0
tmp = 0
for i in range(n):
  if i+1 != p[i] :
    ans += (tmp+1)//2
    tmp = 0
  else:
    tmp += 1
    
ans += (tmp+1)//2
print(ans)
    
    


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

using namespace std;

#define rep(i, a, b)  for(int i = (a); i < (b); i++)
#define rrep(i, a, b) for(int i = (a); i > (b); i--)
#define sq(x) ((x) * (x))
#define bit(x) bitset<32>(x)
#define vsort(v)  sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<llint>())
#define debug(x) cout << #x << " " << (x) << endl
#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


template<typename Tn> Tn __lcm(Tn a, Tn b)
{
    return a / __gcd(a, b) * b;
}

struct UF
{
    vi par, sizes;

    UF() {}
    UF(int size) : par(size, -1), sizes(size, 1) {
	for(int i = 0; i < size; i++) par[i] = i;
    }

    int root(int x)
    {
        return par[x] == x ? x : par[x] = root(par[x]);
    }

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

    int size(int x)
    {
        return sizes[root(x)];
    }

    void unite(int x, int y)
    {
        x = root(x);
        y = root(y);

        if(x == y) return ;

        if(sizes[x] < sizes[y]) swap(x, y);
        par[y] = x;
        sizes[x] += sizes[y];
        sizes[y] = 0;
    }
};

int n;
vi u(100001);
vi v(100001);
vi w(100001);
vi edge[100001];

int main()
{
    int n;
    ci >> n;

    UF uf(n + 1);
    
    rep(i, 0, n - 1) {
	ci >> u[i] >> v[i] >> w[i];
	w[i] %= 2;
	
	if(w[i] == 0) uf.unite(u[i], v[i]);
    }

    rep(i, 0, n - 1) {
	if(w[i] == 1) {
	    int a = uf.root(u[i]), b = uf.root(v[i]);
	    edge[a].pb(b);
	    edge[b].pb(a);
	}
    }
    
    rep(i, 1, n + 1) {
	rep(j, 0, edge[i].size()) uf.unite(edge[i][0], edge[i][j]);
    }
    
    rep(i, 1, n + 1) co << (uf.same(1, i) ? 0 : 1) << en;
    
    return 0;
}


Measured memory_bytes: 7680
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int a,b,c;
  cin>>a>>b;
  c=b/(a-1);
  if(a==2)
    cout<<c-1;
  else{
  if(((c-1)*(a-1))+a>=b) cout<<c;
  else cout<<c+1;
  }
  return 0;
  
}

Measured memory_bytes: 256
#!/usr/bin/perl
#abc081_d.pl
#Fri Feb  9 21:22:58 2018
#

use warnings;
use strict;

my $n = <STDIN>;
chomp $n;

my $line = <STDIN>;
chomp $line;
my @num = split(" ",$line);

my $plus = 0;
my $minus = 0;
my %index;
my $count = 1;

foreach (@num){
	$index{$_} = $count;
	$count++;
	if ($_ > 0){
		$plus = 1;
	}elsif ($_ < 0){
		$minus = 1;
	}
}

my @sortnum = sort {$a <=> $b} @num;

my @anslines;
my @tempnum;
my $eachline;

#print $sortnum[0]," and ",$sortnum[-1],"\n";
my $min = $sortnum[0];
my $max = $sortnum[-1];

if ($plus == 1 && $minus == 1){
	$count = 0;
	if (abs($min) < abs($max)){
		while ($count<=$#num){
			if ($num[$count] < 0){
				$eachline = $index{$max}." ".($count+1);
				$num[$count] = $num[$count] + $max;
				push (@anslines, $eachline);
			}
			$count++;
		}
		$minus = 0;
	}else{
		while ($count<=$#num){
			if ($num[$count] > 0){
				$eachline = $index{$min}." ".($count+1);
				$num[$count] = $num[$count] + $min;
				push (@anslines, $eachline);
			}
			$count++;
		}
		$plus = 0;
	}
}

if ($minus == 0){
	$count = 1;
	while ($count <= $#num){
		if ($num[$count-1] > $num[$count]){
			$eachline = $count." ".($count+1);
			$num[$count] = $num[$count]+$num[$count-1];
			push (@anslines, $eachline);
		}
		$count++;
	}
}elsif($plus == 0){
	$count = $#num;
	while ($count > 0){
		if ($num[$count] < $num[$count-1]){
			$eachline = ($count+1)." ".$count;
			$num[$count-1] = $num[$count-1]+$num[$count];
			push (@anslines, $eachline);
		}
		$count--;
	}
}

if (defined $anslines[0]){
	print $#anslines+1,"\n";
}else{
	print 0,"\n";
}
foreach(@anslines){
	print $_,"\n";
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll div_num(ll n){
  vl div(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      div[i]++;
    }
  }
  if(n!=1)div[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=div[i];
  }
  return num;
}
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}
long long lopow(ll a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a ;
        a = a * a ;
        n >>= 1;
    }
    return res;
}


//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;

int main(){
 int N;cin>>N;
  vs S(N);
  int a=0,w=0,t=0,r=0;
  rep(i,N){
    cin>>S[i];
    if(S[i]=="AC")a++;
    else if(S[i]=="WA")w++;
    else if(S[i]=="TLE")t++;
    else if(S[i]=="RE")r++;
    
  }
  
  cout<<"AC x "<<a<<endl;
  cout<<"WA x "<<w<<endl;
  cout<<"TLE x "<<t<<endl;
  cout<<"RE x "<<r<<endl;
}






Measured memory_bytes: 6420
while(m,n=gets.split.map &:to_i)[0]>t=0
l=(1..n).map{|i|[i,gets.to_i]}
a=[]
s=(1..m).map{[]}
until a[n-1]
t+=1
s.map{|d|a<<d.pop[0]while d[0]&&d[-1][1]<=t}
(x,y=l.shift
i=y+=t
s.min_by{|d|i+=1;d[1]?[1e9]:d[0]?[1,(y<(e=d[0][1])?(e-y):1e9),y-e,i]:[0,i]}<<[x,y])while l[0]&&l[0][0]*10<t&&!s.all?{|d|d[1]}end
puts a*" "end

Measured memory_bytes: 6132
import math

N = int(input())
L = list(map(int, input().split()))

ave = 0
ans1 = 0
ans2 = 0
for i in range(len(L)):
    ave += L[i]
ave = ave / len(L)
ave_under = math.floor(ave)
ave_up = math.ceil(ave)

for i in range(len(L)):
    ans1 += (L[i] - ave_under) ** 2
    ans2 += (L[i] - ave_up) ** 2
if ans2 > ans1:
    print(ans1)
else:
    print(ans2)



Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
//istringstream iss(sentence);
long long mod = 998244353;
 
// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
  
const int biggg = 2000000000;
const long long bigggest = 1000000000000000000LL;
const double eps = .0000000001;

vector<int> graph[100001];
bool vis[100001];
int post[100001];
int main(){
    prep();
    int n, m;
    cin >> n >> m;
    for (int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    queue<pair<int, int> > q;
    q.emplace(1, -1);
    while (!q.empty()){
        int node = q.front().first;
        int last = q.front().second;
        q.pop();
        if (vis[node]) continue;
        vis[node] = true;
        post[node] = last;
        for (int i : graph[node]) q.emplace(i, node);
    }
    for (int i=1; i<=n; i++){
        if (!vis[i]){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes\n";
    for (int i=2; i<=n; i++) cout << post[i] << '\n';
}

Measured memory_bytes: 12376
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
  int n;
  vector<int> v;
  int sum = 0;
  cin >> n;
  for(int i = 0; i < n; i++){
    int s;
    cin >> s;
    sum += s;
    v.push_back(s);
  }
  sort(v.begin(), v.end());
  if(sum%10 != 0){
    cout << sum << endl;
    return 0;
  }
  for(int i = 0; i < n; i++){
    if(v[i]%10 != 0){
      cout << sum-v[i] << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 2e5+5;
char s[110], t[110];
int N;

int main(int argc, char ** argv) {
	scanf("%d", &N);
	scanf(" %s", s);
	scanf(" %s", t);
	rep(i, 0, N) printf("%c%c", s[i], t[i]);
	printf("\n");
	return 0;
}





Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# include <stack>
# include <deque>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

int main() {
	ll n=0, k=0, mini = 999999999;
	ll vec[100001];
	cin >> n>> k;
	rep(i, n) {
		cin >> vec[i];
	}
	rep(i, n - k + 1) {
		int ab = abs(vec[i] - vec[i + k - 1]);
		mini = min(mini, min(ab + abs(vec[i]), ab + abs(vec[i + k - 1])));

	}

cout << mini << endl;
}


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

int main(){
  string o,e;
  cin >> o >> e;
  string ans;
  auto itrO = o.cbegin();
  auto itrE = e.cbegin();
  while(itrO != o.cend()){
    ans.push_back(*itrO++);
    if(itrE != e.cend())
      ans.push_back(*itrE++);
    else
      break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
int main() {
    string a;
    int t,f,q,num=0;
    char c;
    cin>>a;
    cin>>q;
    for (int i=0;i<q;i++)
    {
        cin>>t;
        if (t==2)
        {
            cin>>f>>c;
            if (f==1 and num%2==0)a.insert(0,1,c);
            if (f==1 and num%2==1)a.push_back(c);
            if (f==2 and num%2==0)a.push_back(c);
            if (f==2 and num%2==1)a.insert(0,1,c);

        } else num+=1;
    }
    if (num%2!=0)reverse(a.begin(),a.end());
    cout<<a;

}

Measured memory_bytes: 900
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust, fromMaybe )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.IntMap.Lazy            as IML
import qualified Data.Map.Strict               as M
import           Data.Char
import qualified Data.Array.IArray as A
import qualified Data.Array.Unboxed as UA
import Data.Bits
import Control.Monad.State.Strict
import qualified Data.Array.ST as STA
import qualified Data.Array.IO as IOA
import qualified Data.Array.MArray as MA
import Control.Monad.ST
import System.IO (stdin)
import Control.Arrow
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as UV
import qualified Data.Vector.Generic as GV
import qualified Data.Vector.Mutable as MV
import Data.Ix
import Data.Ord (Down(Down))
import qualified Data.Sequence as Seq
import Data.Foldable (toList)
-- import Control.Lens

debug = False

ts :: Show a => a -> a
ts a = if debug then traceShowId a else a


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- readInts
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- readInts
    return (a, b, c)


readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las

mkStartEnd :: Int -> (Int, Int)
mkStartEnd i = (digitToInt $ head s, digitToInt $ last s) where
  s = show i

inverse :: (Int, Int) -> (Int, Int)
inverse (a, b) = (b, a)

solve :: Int -> Int
solve n = foldl' (\b a -> b + M.findWithDefault 0 (inverse (mkStartEnd a)) d) 0 [1..n] where
  d = M.fromListWith (+) $ (,1) . mkStartEnd <$> [1..n]

main :: IO ()
main =
  readInt >>= print . solve




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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
signed main(){
    gearup;
    int d; cin >> d;
    cout << fixed << setprecision(10) << 2.0*PI*d << endl;
}


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

int fun(int x, int y, int z) {
	return x*x+y*y+z*z+x*y+y*z+z*x;
}
int cnt[10005];
int main() {
	int n;
	cin >> n;
	for (int i = 1; i*i < n; i++)
	{
		for (int j = 1; j*j < n; j++)
		{
			for (int k = 1; k*k < n; k++)
			{
				int now = fun(i,j,k);
				if (now > 10000) continue;
				cnt[now]++;
			}	
		}
	}
	for (int i = 1; i <= n; i++)
	{
		cout << cnt[i] << endl;
	}
	
			
		
	
	
	return 0;
}

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

using namespace std;

long long ab[2010];
long long cd[2010];
vector<long long> vab, vcd;

int main() {
    unsigned int n;
    long long v;
    cin >> n >> v;

    for (int i = 0; i < 2 * n; ++i) {
        cin >> ab[i];
    }

    for (int i = 0; i < 2 * n; ++i) {
        cin >> cd[i];
    }

    for (int i = 0; i < n; ++i) {
        for (int j = n; j < 2 * n; ++j) {
            vab.emplace_back(ab[i] + ab[j]);
            vcd.emplace_back(cd[i] + cd[j]);
        }
    }
    sort(vcd.begin(), vcd.end());

    long long ans = 0;
    for (auto x:vab) {
        ans += upper_bound(vcd.begin(), vcd.end(), v - x) -
               lower_bound(vcd.begin(), vcd.end(), v - x);
    }

    cout << ans << endl;
    return 0;
}


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

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

    if(n < 10){
    	int ans = 100*(10-n);
    	cout<<ans+r<<endl;

    }else{
    	cout<<r<<endl;
    }

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

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

        }
    }
    for(i = 0;i < N; i++){
        if(i!=0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
    printf("%d\n", counter);
    return;
}

int main(void){
    int i = 0;
    int N = 0;
    int A[100];
    scanf("%d\n", &N);
    for(i=0; i<N; i++){
        scanf("%d",&A[i]);
    }
    selectionSort(A, N);
    return 0;
}

Measured memory_bytes: 1828
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

tuple<ll, ll> divide2(ll H, ll W)
{
    if (H % 2 == 0 || W % 2 == 0){
        return make_tuple(H * W / 2, H * W / 2);
    }else{
        if (!(W <= H)) swap(H, W);
        // W <= H
        return make_tuple((H / 2) * W, (H / 2 + 1) * W);
    }
}

int main()
{
    scanLLInt(H);
    scanLLInt(W);
    if (H % 3 == 0 || W % 3 == 0){
        printf("%lld\n", 0);
    }else{
        ll result = INT_MAX;
        ll h1, w1, S1;
        tuple<ll, ll> t;

        h1 = H / 3;
        w1 = W;
        S1 = h1 * w1;
        t = divide2(H - h1, W);
        result = min(result, max({abs(get<0>(t) - S1), abs(get<1>(t) - S1), abs(get<0>(t) - get<1>(t))}));

        h1 = H / 3 + 1;
        w1 = W;
        S1 = h1 * w1;
        t = divide2(H - h1, W);
        result = min(result, max({abs(get<0>(t) - S1), abs(get<1>(t) - S1), abs(get<0>(t) - get<1>(t))}));

        h1 = H;
        w1 = W / 3;
        S1 = h1 * w1;
        t = divide2(H, W - w1);
        result = min(result, max({abs(get<0>(t) - S1), abs(get<1>(t) - S1), abs(get<0>(t) - get<1>(t))}));

        h1 = H;
        w1 = W / 3 + 1;
        S1 = h1 * w1;
        t = divide2(H, W - w1);
        result = min(result, max({abs(get<0>(t) - S1), abs(get<1>(t) - S1), abs(get<0>(t) - get<1>(t))}));

        printf("%lld\n", result);
    }
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long[] U = new long[N];
		long[] V = new long[N];
		for(int i=0;i<N;i++){
			U[i] = X[i] - Y[i];
			V[i] = X[i] + Y[i];
		}
		
		List<long> ans = new List<long>();
		int midx = -1, madx = -1;
		long mi = (long) 1e18, ma = (long) -1e18;
		for(int i=0;i<N;i++){
			if(U[i] < mi){ mi = U[i]; midx = i;}
			if(U[i] > ma){ ma = U[i]; madx = i;}
		}
		
		ans.Add(Math.Abs(X[midx] - X[madx]) + Math.Abs(Y[midx] - Y[madx]));
		
		midx = -1;
		madx = -1;
		mi = (long) 1e18;
		ma = (long) -1e18;
		for(int i=0;i<N;i++){
			if(V[i] < mi){ mi = V[i]; midx = i;}
			if(V[i] > ma){ ma = V[i]; madx = i;}
		}
		
		ans.Add(Math.Abs(X[midx] - X[madx]) + Math.Abs(Y[midx] - Y[madx]));
		
		Console.WriteLine(ans.Max());
		
	}
	int N;
	long[] X,Y;
	public Sol(){
		N = ri();
		X = new long[N];
		Y = new long[N];
		for(int i=0;i<N;i++){
			var d = rla();
			X[i] = d[0]; Y[i] = d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 47716
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int count = 1;
        while (true) {
            if (s == 4 || s == 2 || s == 1)
                break;
            if (s % 2 == 0) {
                s /= 2;
                count++;
            } else {
                s = s * 3 + 1;
                count++;
            }
        }
        System.out.println(count + 3);
    }
}


Measured memory_bytes: 23764
#include<stdio.h>
int x,S[1000],top;

void push(int x)
{
  S[++top]=x;
}

int pop()
{
  int x=S[top--];
  return x;
}

int main(){
  int i;
  
  while(scanf("%d",&x)!=EOF)
    {
      if(x==0)
	{
	  printf("%d\n",S[top]); 
	  pop();
	}
      else
	{     
	  push(x);
	} 
    }
  
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

static const int N = 100;
static const int INFTY = (1 << 21);

int n, M[N][N] = { 0 }, d[N];

void bfs(int s);

int main() {

	int u, k, v;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		u--;
		for (int j = 0; j < k; j++) {
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}
	bfs(0);

	return 0;
}

void bfs(int s) {
	queue<int> q;
	q.push(s);

	for (int i = 0; i < n; i++) {
		d[i] = INFTY;
	}
	d[s] = 0;
	int u;
	while (!q.empty()) {
		u = q.front();
		q.pop();
		for (int v = 0; v < n; v++) {
			if (M[u][v] == 0)continue;
			if (d[v] != INFTY)continue;
			d[v] = d[u] + 1;
			q.push(v);
		}
	}
	for (int i = 0; i < n; i++) {
		cout << i + 1 << " " << ((d[i] == INFTY) ? (-1) : d[i]) << endl;
	}
}

Measured memory_bytes: 3160