akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;


public class Main {
	public void exec() throws IOException {
		InputUtil input = new InputUtil();
		PrintWriter out = new PrintWriter(System.out);
		int x=0;
		int y=0;
		while(true){
			x = input.nextInt();
			y = input.nextInt();
			if(x==0 && y==0){
				break;
			}else if(x < y){
				out.print(x);
				out.print(" ");
				out.println(y);
			}else{
				out.print(y);
				out.print(" ");
				out.println(x);
			}
		}
		out.flush();
		input.close();
	}

	public static void main(String[] args) throws IOException {
		new Main().exec();
	}
}
/**
 * --------------------------------------------------
 * Input Utility
 * --------------------------------------------------
 */
class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 40000;
	
	//Fields
	protected InputStream in;
	private char[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private BufferedReader br = null;
	
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {br = new BufferedReader(new InputStreamReader(this.in = in));}
	protected void initBuf(int bufsiz) {buf = new char[bufsiz];}
	
	//String Input Reader/Parser
	private void readBuf() throws IOException {
		if(ptr >= max && br.ready()) {
			max = br.read(buf);
			ptr = 0;
		}
	}
	//Number Input Reader/Parser
	private boolean isNum(char b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(char b) {return b=='-'; }
	private void next() throws IOException {ptr++; readBuf();}

	public int nextInt() throws IOException {return nextInt(new int[1])[0];}
	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			int sign = 1;
			int res = 0;
			char c;
			while (!isNum(c=buf[ptr]) && !isMinus(c)) 
				next();
			if (isMinus(buf[ptr])) {
				sign = -1;
				next();
			}
			while (isNum(c=buf[ptr])) {
				res *= 10;
				res += c - '0' ;
				next();
			}
			next();
			result[i] = sign * res;
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}

}

Measured memory_bytes: 25280
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <cmath>
#include <iomanip>
#include <map>
#include <unordered_set>

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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 <typename T>
T GCD(T x, T y)
{
    return (y ? GCD<T>(y, x % y) : x);
}

struct Item{
    Item(ll A, ll B) : A(A), B(B){};
    ll A;
    ll B;
    bool operator<(const Item& another) const {
        return A < another.A;
    }
};
int main() {
    string S;
    cin >> S;
    stack<char> stk;
    int answer=0;
    rep(i, S.size()){
        if(stk.empty()){
            stk.push(S[i]);
            continue;
        }

        if((stk.top()+S[i])==('0'+'1')){
            stk.pop();
            answer+=2;
        }else{
            stk.push(S[i]);
        }
    }

    cout<<answer<<endl;
}



Measured memory_bytes: 512
///スマホコーディング
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
typedef long long ll;
const int inf=1e9;
int main(){
  int x,a,b;cin>>x>>a>>b;
  int aa=abs(x-a);
  int bb=abs(x-b);
  if(aa>bb)puts("B");
  else puts("A");
  return 0;
}

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

using namespace std;

int main() {
  string s; cin >> s;
  for (int i = 0; i < s.size() - 1; i++) {
    if (s[i] == 'A' && s[i + 1] == 'C') {
      puts("Yes");
      return 0;
    }
  }
  puts("No");
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int N, A[2005], K, Q;
int smin[2005];

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

    cin >> N >> K >> Q;
    REP(i, N) cin >> A[i];

    int ans = INF;
    REP(mini, N) {
        vector<int> v[N + 1];
        int vi = 0;
        REP(i, N + 1) {
            if (i == N || A[i] < A[mini]) {
                vi++;
                continue;
            }
            v[vi].push_back(A[i]);
        }
        vector<int> sv;
        REP(i, vi) {
            if (v[i].size() < K) continue;
            sort(v[i].begin(), v[i].end());
            REP(j, v[i].size() - K + 1) { sv.push_back(v[i][j]); }
        }
        if (sv.size() < Q) continue;
        sort(sv.begin(), sv.end());
        ans = min(ans, sv[Q - 1] - A[mini]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
const int N=5005;
int n,ans=1<<30;char s[N],t[N];
vector<pair<int,int> >foo,bar;
void solve(){
	for(int i=0;i<foo.size();++i)
		if(foo[i].second==bar[0].second){
			int res=0;
			for(int j=0;j<bar.size();++j)
				res+=abs((i+j<foo.size()?foo[i+j].first:n)-bar[j].first);
			for(int j=0;j<i;++j)
				res+=foo[j].first;
			ans=min(ans,res);
		}
}
int main(){
	scanf("%d%s%s",&n,s+1,t+1);
	if(n<=2){
		ans=0;
		for(int i=1;i<=n;++i)ans+=(s[i]!=t[i]);
		printf("%d\n",ans);
		return 0;
	}
	for(int i=1;i<n;++i){
		if(s[i]!=s[i+1])
			foo.push_back({i,s[i]-'0'});
		if(t[i]!=t[i+1])
			bar.push_back({i,t[i]-'0'});
	}
	if(foo.size()>bar.size())
		swap(foo,bar);
	while(foo.size()<bar.size())
		foo.push_back({n,!foo.back().second});
	solve();swap(foo,bar);solve();
	printf("%d\n",ans);
	return 0;
}


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

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

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

  int n;
  cin >> n;
  vector<int> vec(n);
  rep(i, n) { cin >> vec.at(i); }

  sort(vec.begin(), vec.end());
  int mid_first = vec.at(n / 2 - 1);
  int mid_second = vec.at(n / 2);

  if (mid_first == mid_second) {
    cout << 0 << endl;
  } else {
    cout << mid_second - mid_first << endl;
  }

  return 0;
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    int mx = max({a, b, c});
    int ans = a + b + c - mx;
    for (int i = 0; i < k; ++i) mx *= 2;
    cout << ans + mx << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5+5;
const ll mod =   1e9+7;

int main()
{  fast
ll n;
cin>>n;
if(n==1){
	cout<<0;
	return 0;
}
if(n==2){
	cout<<2;
	return 0;
}
ll a=1,b=1,c=1;
for(int i=1;i<=n;i++){
	a=a*10;
	a%=mod;
	b=b*9;
	b%=mod;
	c=c*8;c%=mod;
}
b=b*2;
b%=mod;
a=(a-b+c+mod)%mod;
cout<<a;
}

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

int t[100001];
int x[100001];
int y[100001];

int main() {
    int N;
    cin >> N;
    for (int i = 0; i <= N; i++) {
        if (i == 0) {
            t[0] = 0;
            x[0] = 0;
            y[0] = 0;
        } else {
            cin >> t[i] >> x[i] >> y[i];
        }
    }

    for (int i = 1; i <= N; i++) {
        int dx = abs(x[i] - x[i - 1]);
        int dy = abs(y[i] - y[i - 1]);
        int dt = abs(t[i] - t[i - 1]);

        bool deven = (dx + dy) % 2 == 0;
        bool teven = dt % 2 == 0;

        if (dx + dy > dt || (deven != teven)) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

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

using namespace std ;

#define N 100010
#define inf 0x3f3f3f3f
#define ll long long

int n , t ;
int a[ N ] ;

int main() {
    scanf( "%d%d" , &n , &t ) ;
    for( int i = 1 ; i <= n ; i ++ ) scanf( "%d" ,&a[ i ] ) ;
    int ans = 0 , mx = 0 ;
    int tot = 0 ;
    for( int i = n ; i  ; i -- ) {
        mx = max( a[ i ] , mx ) ;
        ans = max( mx - a[ i ] , ans ) ;
    }
    mx = 0 ;
    for( int i = n ; i ; i -- ) {
        mx = max(  a[ i ] , mx ) ;
        if( mx - a[ i ] == ans ) tot ++ ;
    }
    printf( "%d\n" , tot ) ;
     return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 2e18;
const ll fact_table = 1200008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define endl "\n"
#ifdef ENJAPMA
    #undef endl
#endif
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
// const ll mod = 998244353ll;
const ll mod = 1000000007ll;
  
ll mypow(ll number1,ll number2, ll mod){
    if(number2 == 0){
        return 1ll;
    }else{
        ll number3 = mypow(number1,number2 / 2, mod);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5]; 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table],mod - 2, mod);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/

bool multicase = false;

ll n,m,num,a,b,c,d,e,h,q;
ll w, k;
ll x[500005], y[500005], z[500005];
string s;

void solve(){
    ll sum;
    cin >> sum >> n;
    for(ll i=0;i<n;i++){
        cin >> a;
        sum -= a;
    }
    if(sum >= 0){
        p(sum);
    }else{
        p(-1);
    }

    return;
}

int main(){
    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;
 
    if(multicase){
        cin >> q;
    }else{
        q = 1;
    }
    while(q--){
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    
    // solve();
    return 0;
 
}
















Measured memory_bytes: 3664
from collections import defaultdict, deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys
import random
import itertools
import math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt


def LI(): return list(map(int, input().split()))


def LF(): return list(map(float, input().split()))


def LI_(): return list(map(lambda x: int(x)-1, input().split()))


def II(): return int(input())


def IF(): return float(input())


def LS(): return list(map(list, input().split()))


def S(): return list(input().rstrip())


def IR(n): return [II() for _ in range(n)]


def LIR(n): return [LI() for _ in range(n)]


def FR(n): return [IF() for _ in range(n)]


def LFR(n): return [LI() for _ in range(n)]


def LIR_(n): return [LI_() for _ in range(n)]


def SR(n): return [S() for _ in range(n)]


def LSR(n): return [LS() for _ in range(n)]


def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)


def gcdx(x, y):
    g = 0
    if (x % y != 0):
        g = x % y
        gcdx(y, g)
    return g


mod = 1000000007
inf = float('INF')


def A():
    a = II()
    b = a//2
    p = b/a
    if a % 2:
        print(1-p)
    else:
        print(p)

    return

# B


def B():
    N, K = map(int, input().split())
    h = LI()
    count = 0

    for i in h:
        if i >= K:
            count += 1
        else:
            continue
    print(count)
    return

# C


def C():
    N = II()
    A = LI()
    J = [0] * N
    for i, n in enumerate(A):
        J[n-1] = i+1
    for s in J:
        print(s, end=" ")

    return

# D


def D():
    A, B = map(int, input().split())
    g = gcd(A, B)
    go = g
    myset = set([1])
    sq = int(sqrt(g)) + 2

    for i in range(2, sq):
        while g % i == 0:
            g /= i
            myset.add(i)
        if g == 1:
            break
        if i == sq - 1:
            myset.add(go)

    print(len(myset))

    return

# E


def E():
    N, M = LI()

    price = [-1] * N

    for i in range(M):
        a, b = LI()
        c = LI()
        for k in c:
            if price[k-1] > a or price[k-1] == -1:
                price[k-1] = a
    print(sum(price))

    return

# F


def F():
    return


# Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 40432
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        int min = 0;
        int max = 1_000_000;
        for (int i = 0; i < m; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            if (l > min) {
                min = l;
            }
            if (r < max) {
                max = r;
            }
        }
        sc.close();

        int ans;
        if (max < min) {
            ans = 0;
        } else {
            ans = max - min + 1;
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 64800
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  int N;
  cin >> N;
  vector<int> D(N);
  rep(i,N){
    cin >> D[i];
  }
  
  sort(all(D));
  cout << D[N/2]-D[N/2-1] << endl;
}



Measured memory_bytes: 640
n, m, x, y = map(int, input().split())

X = list(map(int, input().split()))
Y = list(map(int, input().split()))

if x < y:
    m_x = max(X)
    m_y = min(Y)
    if m_x < m_y and m_x < y and x < m_y:
        print("No War")
    else:
        print("War")


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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b;
    cin >> a >> b;

    cout << max( a*b , max(a -b, a+ b)) << endl;

    return 0;
}


Measured memory_bytes: 256
A, B, C, K = map(int, input().split())

max_num = 0

is_finish = False
if A>=K:
    print(K)
else:
    max_num += A
    K -= A
    is_finish = True

if is_finish:
    if B>=K:
        print(max_num)
    else:
        print(max_num-(K-B))


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

int N;
ll a0[100001];
ll a[100001];
ll a2[100001];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N;

    for(int i = 0; i < N; ++i){
        cin >> a0[i];
    }
    ll ans = 0;
    ll ans2 = 0;
    ll sum1 = 0;
    ll sum2 = 0;
    ll sum3 = 0;
    ll sum4 = 0;
    if(a0[0] == 0){
        sum1 = 1;
        sum2 = 1;
        ans = 1;
        sum3 = -1;
        sum4 = -1;
        ans2 = 1;
    }
    else if(a0[0] < 0){
        sum1 = 1;
        sum2 = 1;
        ans = 1 - a0[0];
        sum3 = a0[0];
        sum4 = a0[0];
        ans2 = 0;
    }
    else {
        sum1 = a0[0];
        sum2 = a0[0];
        ans = 0;
        sum3 = -1;
        sum4 = -1;
        ans2 = a0[0] + 1;
    }
    for(int i = 1; i < N; ++i){
        a[i] = a0[i];
        sum2 += a0[i];
        if(sum2 == 0){
            ++ans;
            if(sum1 > 0){
                --a[i];
            }
            else {
                ++a[i];
            }
        }
        else if(sum1 < 0 && sum2 < 0){
            ll b0 = 1 - sum2;
            a[i] += b0;
            ans += b0;
        }
        else if(sum1 > 0 && sum2 > 0){
            ll b0 = sum2 + 1;
            a[i] -= b0;
            ans += b0;
        }
        sum2 = sum1 + a[i];
        sum1 = sum2;
    }
    for(int i = 1; i < N; ++i){
        a2[i] = a0[i];
        sum4 += a0[i];
        if(sum4 == 0){
            ++ans2;
            if(sum3 > 0){
                --a2[i];
            }
            else {
                ++a2[i];
            }
        }
        else if(sum3 < 0 && sum4 < 0){
            ll b0 = 1 - sum4;
            a2[i] += b0;
            ans2 += b0;
        }
        else if(sum3 > 0 && sum4 > 0){
            ll b0 = sum4 + 1;
            a2[i] -= b0;
            ans2 += b0;
        }
        sum4 = sum3 + a2[i];
        sum3 = sum4;
    }
    cout << min(ans, ans2) << endl;

    return 0;
}
/*
1   -3  1   0
1   -2  -1  -1

1   -2  2   -2
1   -1  1   -1

-1  4   3   2   -5  4
-1  3   6   8   3   7
*/

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

ll solve() {
    ll N;
    cin >> N;
    vector<ll> A(N), c(N+1);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
        c[i+1] = c[i] + A[i];
    }
    const ll INF = 1LL<<60;
   
    vector<vector<ll>> dp(N, vector<ll>(N));
    for ( int d = 1; d < N; d++ ) {
        for ( int i = 0; i + d < N; i++ ) {
            int j = i + d;
            ll m = INF;
            for ( int k = 0; k < d; k++ ) {
                m = min(m, dp[i][i+k] + dp[i+k+1][j]);
            }
            dp[i][j] = m + c[j+1] - c[i];
        }
    }
    return dp[0][N-1];
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

int n;
vector<vector<int> > tree;
vector<int> color;

int main(){
    cin >> n;
    tree = vector<vector<int> >(n);
    color = vector<int>(n, 0);
    vector<int> d(n, 1e9);
    REP(i, 0, n-1){
        int a, b; cin >> a >> b;
        a--; b--;
        tree[a].pb(b);
        tree[b].pb(a);
    }
    queue<int> q, rq;
    q.push(0);
    d[0] = 0;
    while(!q.empty()){
        int now = q.front();
        q.pop();
        REP(i, 0, tree[now].size()){
            int next = tree[now][i];
            if(d[next] != 1e9){continue;}
            d[next] = d[now] + 1;
            q.push(next);
        }
    }
    int count = 0;
    rq.push(n-1);
    while(1){
        int now = rq.front();
        rq.pop();
        int f = 0;
        REP(i, 0, tree[now].size()){
            int next = tree[now][i];
            if(d[next] == d[now]-1){
                if(next == 0){f = 1;break;}
                rq.push(next);
                color[next] = -2;
                count++;
                break;
            }else{
                continue;
            }
        }
        if(f == 1){break;}
    }
    stack<int> s1, s2, ss1, ss2;
    int fc = 0, sc = 0;
    ss1.push(0);
    REP(i, 0, 1+(count+1)/2){
        int now = ss1.top();
        ss1.pop();
        fc++;
        color[now] = 1;
        s1.push(now);
        REP(i, 0, tree[now].size()){
            int next = tree[now][i];
            if(color[next] == -2){
                ss1.push(next);
            }
        }
    }
    ss2.push(n-1);
    count /= 2;
    REP(i, 0, 1+count){
        int now = ss2.top();
        ss2.pop();
        sc++;
        color[now] = -1;
        s2.push(now);
        REP(i, 0, tree[now].size()){
            int next = tree[now][i];
            if(color[next] == -2){
                ss2.push(next);
            }
        }
    }
    while(!s1.empty()){
        int now = s1.top();
        s1.pop();
        REP(i, 0, tree[now].size()){
            int next = tree[now][i];
            if(color[next] == 0){
                color[next] = 1;
                s1.push(next);
                fc++;
            }else{
                continue;
            }
        }
    }
    while(!s2.empty()){
        int now = s2.top();
        s2.pop();
        REP(i, 0, tree[now].size()){
            int next = tree[now][i];
            if(color[next] == 0){
                color[next] = -1;
                s2.push(next);
                sc++;
            }else{
                continue;
            }
        }
    }
    if(sc < fc){
        cout << "Fennec" << endl;
    }else{
        cout << "Snuke" << endl;
    }
}

Measured memory_bytes: 6912
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String str1 = scan.nextLine();
		String str2;
		while(!str1.equals(".")){
			str2 = scan.nextLine();
			if(str1.equals(str2)){
				System.out.println("IDENTICAL");
			}else{
				int i = 0;
				int j = 0;
				boolean check1 = false;
				boolean check2 = false;
				String tmp1;
				String tmp2;
				int start1 = 0;
				int start2 = 0;
				int cnt = 0;
				while(str1.length() > i || str2.length() > j){
					while(true){
						if(i == str1.length()){
							tmp1 = null;
							break;
						}else if(str1.charAt(i) == '"' && !check1){
							if(i == 0){
								tmp1 = str1.substring(start1, i + 1);
							}else{
								tmp1 = str1.substring(start1, i);
							}
							start1 = i;
							i++;
							check1 = true;
							break;
						}else if(str1.charAt(i) == '"'){
							tmp1 = str1.substring(start1, i + 1);
							start1 = i + 1;
							i++;
							check1 = false;
							break;
						}else if(i == str1.length() - 1){
							tmp1 = str1.substring(start1, i + 1);
							i++;
							check1 = true;
							break;
						}
						i++;
					}
					
					while(true){
						if(j == str2.length()){
							tmp2 = null;
							break;
						}else if(str2.charAt(j) == '"' && !check2){
							if(j == 0){
								tmp2 = str2.substring(start2, j + 1);
							}else{
								tmp2 = str2.substring(start2, j);
							}
							start2 = j;
							j++;
							check2 = true;
							break;
						}else if(str2.charAt(j) == '"'){
							tmp2 = str2.substring(start2, j + 1);
							start2 = j + 1;
							j++;
							check2 = false;
							break;
						}else if(j == str2.length() - 1){
							tmp2 = str2.substring(start2, j + 1);
							j++;
							check2 = true;
							break;
						}
						j++;
					}
					
					if(tmp1 != null && tmp2 != null && !check1 && !check2 && !tmp1.equals(tmp2)){
						cnt++;
					}
					
					if(tmp1 == null || tmp2 == null){
						System.out.println("DIFFERENT");
						break;
					}else if(check1 && check2 && !tmp1.equals(tmp2)){
						System.out.println("DIFFERENT");
						break;
					}else if(i == str1.length() && j == str2.length() && cnt == 1){
						System.out.println("CLOSE");
						break;
					}else if(i == str1.length() && j == str2.length()){
						System.out.println("DIFFERENT");
						break;
					}
				}
			}
			str1 = scan.nextLine();
		}
	}
}


Measured memory_bytes: 28556
def main():
    s = input()
    tmp = '0'
    ans = 0
    for i in range(len(s)):
        if tmp == '0':
            if s[i] != '0':
                ans += 1
            tmp = '1'
        else:
            if s[i] != '1':
                ans += 1
            tmp = '0'
    tmp = '1'
    ans2 = 0
    for i in range(len(s)):
        if tmp == '0':
            if s[i] != '0':
                ans2 += 1
            tmp = '1'
        else:
            if s[i] != '1':
                ans2 += 1
            tmp = '0'
    print(min(ans, ans2))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val Array(left, right): Array[String] = sc.nextLine.split(" ")
    if (left == right) println("=")
    else if (left > right) println(">")
    else println("<")
  }
}


Measured memory_bytes: 25676
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "ctime"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

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

class UnionFind {
	vector<int>parent;
	vector<int>rank;
public:
	UnionFind(int num) {
		num++;
		parent.resize(num);
		rank.resize(num);
		for (int i = 0; i < num; i++) {
			parent[i] = i;
			rank[i] = 0;
		}
	}
	int Find(int node) {
		if (parent[node] == node)return node;
		else return parent[node] = Find(parent[node]);
	}
	void Unite(int u, int v) {
		u = Find(u);
		v = Find(v);
		if (u == v)return;
		if (rank[u] < rank[v])parent[u] = v;
		else {
			parent[v] = u;
			if (rank[u] == rank[v])rank[u]++;
		}
	}
	bool Check_Same(int u, int v) {
		return Find(u) == Find(v);
	}
};

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

	cin >> H >> W;
	vector<string>s(H);
	for (auto &i : s)cin >> i;
	UnionFind uf(H*W);
	int dir[] = { 1,0,-1,0,1 };
	vector<set<long long int>>vs(H*W);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (s[i][j] == '#')continue;
			for (int k = 0; k < 4; k++) {
				if (i + dir[k] < 0 || i + dir[k] >= H || j + dir[k + 1] < 0 || j + dir[k + 1] >= W)continue;
				for (int l = 0; l < 4; l++) {
					if (i + dir[l] < 0 || i + dir[l] >= H || j + dir[l + 1] < 0 || j + dir[l + 1] >= W)continue;
					if (s[i + dir[k]][j + dir[k + 1]] != '#' || s[i + dir[l]][j + dir[l + 1]] != '#')continue;
					uf.Unite((i + dir[k])*W + j + dir[k + 1], (i + dir[l])*W + j + dir[l + 1]);
				}
			}
		}
	}
	vector<long long int>num(H*W);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (s[i][j] != '#')continue;
			num[uf.Find(i*W + j)]++;
			for (int k = 0; k < 4; k++) {
				if (i + dir[k] < 0 || i + dir[k] >= H || j + dir[k + 1] < 0 || j + dir[k + 1] >= W)continue;
				if (s[i + dir[k]][j + dir[k + 1]] == '#')continue;
				vs[uf.Find(i*W + j)].insert((i + dir[k])*W + j + dir[k + 1]);
			}
		}
	}
	long long int ans = 0;
	for (int i = 0; i < H*W; i++) {
		ans += num[i] * vs[i].size();
	}
	cout << ans << endl;
	return 0;
}

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

typedef pair<int,int> P;
typedef long long ll;

#define int ll

int ans[300][300];

main(){
	int h,w,k;
	string s[300];

	cin >> h >> w >> k;
	for(int i=0;i<h;i++) cin >> s[i];

	
	int c = 0;
	for(int i=0;i<h;i++){
		bool exist = false;
		int e;
		for(int j=0;j<w;j++){
			if(s[i][j]=='#'){
				if(!exist) e = c;
				exist = true;
				c++;
			}
			if(exist) ans[i][j] = c;
		}
		if(exist) for(int j=0;s[i][j]!='#';j++) ans[i][j] = e+1;
	}
	for(int i=1;i<h;i++){
		for(int j=0;j<w;j++){
			if(ans[i][j]==0) ans[i][j] = ans[i-1][j];
		}
	}
	for(int i=h-2;i>=0;i--){
		for(int j=0;j<w;j++){
			if(ans[i][j]==0) ans[i][j] = ans[i+1][j];
		}
	}

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 4488
#include<stdio.h>
#include<math.h>
#define true 1
#define false 0
#define N 10000
int isprime(int);

int main(){
  int x,n,i,cnt=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&x);
    cnt = cnt + isprime(x);
  }
  printf("%d\n",cnt);
  return 0;
} 
int isprime(int x){
  int i;
  if (x == 2)
    return true;

  if (x < 2 || x % 2==0)
    return false;

  i = 3;
  while (i <=  sqrt(x)){
    if (x % i==0)
      return false;
    i = i + 2;
  }
  return true;
}

Measured memory_bytes: 596
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>

int main(void){
    int N,i,j,temp;
    char S[10003],a = 'A',z = 'Z';
    
    scanf("%d",&N);
    scanf("%s",S);
    
    for(i = 0;S[i] != '\0';i++){
        S[i] += N;
        if(S[i] > z){
            S[i] -= (z - a + 1);
        }
    }
    
    printf("%s\n",S);
  
    return 0;
}

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

ll gcd(ll n, ll m){
    if(n == 0 || m == 0) return 0;
    if(n % m == 0) return m;
    return gcd(m, n % m);
}

int main()
{
    ll n, x, d;
    cin >> n >> x >> d;
    if(d == 0){
        if(x == 0) cout << 1 << endl;
        else cout << n + 1 << endl;
        return 0;
    }
    if(x == 0){
        cout << n * (n - 1) / 2 + 1 << endl;
        return 0;
    }
    if(d < 0) x = -x, d = -d;
    ll g = d / gcd(abs(x), d);
    ll s[200003]{0}, l[200003]{0};
    for(int i = 1; i <= n; i++) s[i] = s[i - 1] + (i - 1) * d + x;
    for(int i = 1; i <= n; i++) l[i] = l[i - 1] + (n - i) * d + x;
    ll ans = 0;
    if(x >= 0){
        for(int i = 0; i <= n; i++){
            if(i < g) ans += (l[i] - s[i]) / d + 1;
            else ans += min((l[i] - s[i]) / d + 1, (l[i] - l[i - g]) / d);
        }
    }
    else{
        for(int i = 0; i <= n; i++){
            if(i < g) ans += (l[i] - s[i]) / d + 1;
            else{
                if(l[i] > l[i - g]){
                    if(s[i] > l[i - g]) ans += (l[i] - s[i]) / d + 1;
                    else if(s[i] > s[i - g]) ans += (l[i] - l[i - g]) / d;
                    else ans += ((l[i] - s[i]) / d + 1) - ((l[i - g] - s[i - g]) / d + 1);
                }
                else if(l[i] >= s[i - g]){
                    if(s[i] <= s[i - g]) ans += (s[i - g] - s[i]) / d;
                }
                else ans += (l[i] - s[i]) / d + 1;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
N = int(input())
cake = 7
donut = 4
count = 0
for i in range(16):
    for j in range(26):
        if N == cake*i + donut*j:
            count = count + 1
        else:
            continue

if count > 0:
    print('Yes')
elif count == 0:
    print('No')

Measured memory_bytes: 3060
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#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 long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
struct edge { int to, cap, rev; };
vector<edge> G[300000];
bool used[300000];
void init(int V) {
	rep(i, V) {
		G[i].clear();
	}
}
void add_edge(int from, int to, int cap) {
	G[from].push_back(edge{ to, cap, (int)G[to].size() });
	G[to].push_back(edge{ from, 0, (int)G[from].size() - 1 });
}
int dfs(int v, int t, int f) {
	if (v == t)return f;
	used[v] = true;
	for (int i = 0; i < (int)G[v].size(); i++) {
		edge &e = G[v][i];
		if (!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s, int t) {
	int flow = 0;
	for (;;) {
		memset(used, 0, sizeof(used));
		int f = dfs(s, t, (int)MOD);
		if (f == 0)return flow;
		flow += f;
	}
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	while (y > 0) {
		int r = x % y; x = y; y = r;
	}
	return x;
}
int main() {
	int m; int n;
	while (cin >> m >> n, m) {
		init(300000);
		int a[501], b[501];
		rep1(i, m) {
			cin >> a[i];
			add_edge(0, i, 1);
		}
		rep1(i, n) {
			cin >> b[i];
			add_edge(i + m, 1 + m + n, 1);
		}
		rep1(i, m) {
			rep1(j, n) {
				if (gcd(a[i], b[j]) > 1) {
					add_edge(i, m + j, 1);
				}
			}
		}
		cout << max_flow(0, 1 + m + n) << endl;
	}
	return 0;
}


Measured memory_bytes: 16580
import sys
input = sys.stdin.readline
from collections import *

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

N = int(input())
zero1 = 0
zero2 = 0
zero3 = 0
cnt = defaultdict(int)
MOD = 10**9+7

for _ in range(N):
    A, B = map(int, input().split())
    
    if A==0 and B==0:
        zero1 += 1
    elif A>0 and B>0:
        G = gcd(A, B)
        A //= G
        B //= G
        cnt[(A, B)] += 1
    elif A>0 and B<0:
        B *= -1
        G = gcd(A, B)
        A //= G
        B //= G
        cnt[(-A, B)] += 1
    elif A<0 and B>0:
        A *= -1
        G = gcd(A, B)
        A //= G
        B //= G
        cnt[(-A, B)] += 1
    elif A<0 and B<0:
        A *= -1
        B *= -1
        G = gcd(A, B)
        A //= G
        B //= G
        cnt[(A, B)] += 1
    elif A==0:
        zero2 += 1
    elif B==0:
        zero3 += 1

s = set()
ans = 1

for k in cnt.keys():
    if k in s:
        continue
    
    k2 = (-k[1], k[0])
    
    if k2[0]<0 and k2[1]<0:
        k2 = (-k2[0], -k2[1])
        
    a = cnt[k]
    
    if k2 not in cnt:
        ans *= pow(2, a, MOD)
        ans %= MOD
    else:
        b = cnt[k2]
        ans *= pow(2, a, MOD)+pow(2, b, MOD)-1
        ans %= MOD
        s.add(k2)

ans *= pow(2, zero2, MOD)+pow(2, zero3, MOD)-1
ans += zero1
ans %= MOD
ans -= 1
ans %= MOD

print(ans)


Measured memory_bytes: 119136
from collections import deque
s=input()
q=int(input())
rev=0
head=deque()
tail=deque()
for _ in range(q):
    Q=input().split()
    if len(Q)==1:
        rev=1-rev
    if len(Q)==3:
        if(rev==0 and Q[1]=="1" )or (rev==1 and Q[1]=="2"):
            head.appendleft(Q[2])
        else :
            tail.append(Q[2])
if rev==0:
    ans="".join(head)+s+"".join(tail)

else:
    ans="".join(tail)[::-1]+s[::-1]+"".join(head)[::-1]

print(ans)

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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

signed main(){

  int n; cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  int ans = 0,j = 0;
  int x = 0,sum = 0;
  for(int i = 0; i < n; i++){
    while(j < n && (x ^ a[j]) == sum + a[j]){
      x ^= a[j];
      sum += a[j];
      j++;
    }
    ans += j - i;
    x ^= a[i];
    sum -= a[i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1920
#include <iostream>
using namespace std;
int main() {
  int n;
  int a;
  double bunbo = 0.0;
  
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    bunbo += 1.0 / a;
  }
  printf("%1.8lf\n", 1.0 / bunbo);
  return 0;
}

Measured memory_bytes: 256
use std::collections::{BTreeMap, BinaryHeap};

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };

    let n: usize = sc.read();
    let s: Vec<usize> = sc.vec(1 << n);

    let mut tree = vec![vec![]; (1 << (n + 1)) - 1];
    for i in 0..((1 << n) - 1) {
        tree[i].push(2 * i + 1);
        tree[i].push(2 * i + 2);
    }

    let count = s.into_iter().fold(BTreeMap::new(), |mut map, s| {
        *map.entry(s).or_insert(0) += 1;
        map
    });

    let mut heap = BinaryHeap::new();
    heap.push((1 << n, 0));
    for (_, count) in count.into_iter().rev() {
        if heap.len() < count {
            println!("No");
            return;
        }
        let vs = (0..count).map(|_| heap.pop().unwrap()).collect::<Vec<_>>();
        for (mut size, mut cur) in vs.into_iter() {
            while !tree[cur].is_empty() {
                heap.push((size / 2, tree[cur][1]));
                cur = tree[cur][0];
                size /= 2;
            }
        }
    }

    println!("Yes");
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 35068
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

/*
max 448,000,000
count_map['0']=0;
for(auto x : count_map) {
    string key = x.first;
    ll value = x.second;
}
*/

map<ll,ll> count_map;
vll keys;


int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> N;
    cin >> M;

    rep(ni,N){
        cin >> ltmp;
        count_map[ltmp]++;
    }

    rep(mi,M){
        cin >> B >> C;
        count_map[C]+=B;
    }

    for(auto x : count_map) {
        keys.push_back(x.first);
    }

    sort(keys.rbegin(),keys.rend());

    ll total = 0;
    ll ki = 0;
    ll count_ki = 0;
    ll count = 0;
    while(count < N){
        ll val = keys[ki];
        total += val;

        count_ki++;
        if(count_ki >= count_map[val]){
            ki++;
            count_ki = 0;
        }

        count++;
    }

    cout << total << endl;


}

Measured memory_bytes: 17820
def resolve():
  N = int(input())
  result = {
    'AC': 0,
    'WA': 0, 
    'TLE': 0,
    'RE': 0
  }
  for i in range(N):
    result[input()] += 1
  print('AC x', result['AC'])
  print('WA x', result['WA'])
  print('TLE x', result['TLE'])
  print('RE x', result['RE'])

if __name__ == "__main__":
  resolve()

Measured memory_bytes: 69824
#include <iostream>
using namespace std;
int main()
{
	int s;
	cin>>s;
	int ans=0;
	for(int i=1;i<=6;i++)
	{
		if(s%10==1)
		{
			ans++;
		}
		s/=10;
	} 
	cout<<ans;
	return 0;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct card{char mark; int number;};

vector<card> bubblesort(vector<card> a, int n){
  int i, j;
  card tmp;
  for(i = 0; i < n; i++){
    for(j = n - 1 ; j > i; j--){
      if(a.at(j).number < a.at(j - 1).number){
        tmp = a.at(j);
        a.at(j) = a.at(j - 1);
        a.at(j - 1) = tmp;
      }
    }
  }
  for(i = 0;i < n - 1; i++) cout << a.at(i).mark << a.at(i).number << " ";
  cout << a.at(n - 1).mark << a.at(n - 1).number << endl;
  return a;
}

vector<card> selectionSort(vector<card> a, int n){
  int i, minj, j;
  card tmp;
  for(i = 0; i < n; i++){
    minj = i;
    for(j = i; j < n; j++){
      if(a.at(minj).number > a.at(j).number) minj = j;
    }
    if(i != minj){  
      tmp = a.at(minj);
      a.at(minj) = a.at(i);
      a.at(i) = tmp;      
    }
  }
  for(i = 0;i < n - 1; i++) cout << a.at(i).mark << a.at(i).number << " ";
  cout << a.at(n - 1).mark << a.at(n - 1).number << endl;
  return a;
}

int main(){
  int n, i, p;
  char tp[3];
  scanf("%d", &n);
  vector<card> bubble(n), select(n);
  for(i = 0; i < n; i++){
    scanf("%s", tp);
    bubble.at(i).mark = tp[0];
    bubble.at(i).number = tp[1] - '0';
  } 
  select = bubble;

  
  bubble = bubblesort(bubble, n);
  printf("Stable\n");
  select = selectionSort(select, n);
  for (p = 0; p < n; p++){
    if(bubble.at(p).mark != select.at(p).mark || bubble.at(p).number != select.at(p).number)
      break;
  }
  if(n == p) printf("Stable\n");
  else printf("Not stable\n");
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    string s;
    cin >> s;
    if (s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3592
//
//$$$$$$$$$$$$$$$$$$$$$$
//$$                  $$
//$$   gyoubu_oniwa   $$
//$$                  $$
//$$$$$$$$$$$$$$$$$$$$$$
//
#include<bits/stdc++.h>
using namespace std;
#define DBG(a) if(DBGDO) cout<<#a<<':'<<a<<endl;
#define PB push_back
#define EB emplace_back
#define btoe(v) (v).begin(),(v).end()
#define etob(v) (v).rbegin(),(v).rend()
#define F first
#define S second
#define SZ size()
#define pow(a,b) (pow(a,b)+0.5)

typedef unsigned long long int ulli;
typedef long long int lli;
typedef long double ldbl;
#define f(i,a,b) for(int i=(a); i<(b); ++i)
#define fr(i,a,b) for(int i=(a); i>(b); --i)
#define fl(i,a,b) for(lli i=(a); i<(b); ++i)
#define flr(i,a,b) for(lli i=(a); i>(b); --i)
#define w(x) lli x; cin>>x; while(x--) 
#define inpn(n,v,T) T n; cin>>n; vector<T> v(n); fl(i,0,n) cin>>v[i];
#define inp(n,v,T) vector<T> v(n); fl(i,0,n) cin>>v[i];

typedef pair<int,int> pii;typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<pii> vpii;typedef vector<vector<pii>> vvpii;typedef pair<lli,lli> plli;typedef vector<lli> vlli;typedef vector<vlli> vvlli;typedef vector<plli> vplli;typedef vector<vector<plli>> vvplli;typedef vector<bool> vb;typedef vector<string> vs;typedef vector<vector<string>> vvs;

#define unmp unordered_map

#define PRIME ((lli)(1e9+7ll))
#define PRIME2 (998244353ll)
const lli TEN_18 = 1e18;
const lli TEN_9 = 1e9;
const lli TEN_5 = 1e5;

inline void debugORfast(int a=1,int b=1){
    if(a){
        #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
        #endif
    }
    if(b){ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
}}

template<typename T>
void print(const T &v, int begin=-1, int end=-1, int w=2)
{
	if(begin<=end){
		if(begin==-1) fl(i,0,v.SZ) cout<<setw(w)<<v[i]<<' ';
		else if(end==-1) fl(i,begin,v.SZ) cout<<setw(w)<<v[i]<<' ';
		else fl(i,begin,end) cout<<setw(w)<<v[i]<<' ';
		cout<<endl;}
	else{
		if(begin==-1) flr(i,v.SZ-1,-1) cout<<setw(w)<<v[i]<<' ';
		else if(end==-1) flr(i,begin,-1) cout<<setw(w)<<v[i]<<' ';
		else flr(i,begin,end) cout<<setw(w)<<v[i]<<' ';
		cout<<endl;
	}
}

void pans(char v){
	switch(v){
		case 'y' : cout<<"yes"<<endl; break;
		case 'n' : cout<<"no"<<endl; break;
		case 'Y' : cout<<"Yes"<<endl; break;
		case 'N' : cout<<"No"<<endl; break;
		case 'B' : cout<<"YES"<<endl; break;
		case 'S' : cout<<"NO"<<endl; break;
	}
}

int DBGDO=0;

lli brute(){
	return 0;
}

lli solve(){
    return 0;
}

int main()
{
	debugORfast(0,1);
	//w(ttt)
	{
		inpn(n,a,lli);
		lli allxor = accumulate(btoe(a),0ll,[](auto a, auto b){
				return a^b;});
		f(i,0,n){
			cout<<(allxor^a[i])<<' ';
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 4688