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

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=998244353;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

int n,a[200010],ans;
ll two[35];
map<ll,int>mp;

void input(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		mp[a[i]]++;
	}
	return;
}

void solve(){
	two[0]=1;
	for(int i=1;i<32;i++){
		two[i]=two[i-1]*2;
	}
	sort(a,a+n);
	for(int i=n-1;i>0;i--){
		if(!mp[a[i]])continue;
		mp[a[i]]--;
		ll base;
		for(int j=0;j<32;j++){
			if(a[i]<two[j]){
				base=two[j];
				break;
			}
		}
		ll want=base-a[i];
		if(mp[want])mp[want]--,ans++;
	}
	cout<<ans<<endl;
	return;
}

int main(){
	input();
	solve();
	return 0;
}

Measured memory_bytes: 25984
N = int(input())

ans = N
for i in range(N + 1):

    temp_ans = 0
    first = i
    second = N - i

    while first != 0:
        temp_ans += first % 6
        first = first // 6
    while second != 0:
        temp_ans += second % 9
        second = second // 9

    ans = min(ans, temp_ans)

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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


int main(){
    string s;
    cin >> s;
    string a[] = {"maerd", "remaerd", "esare", "resare"};
    string t;
    for (int i = s.size() - 1; i >= 0; i--){
        t += s[i];
        if(t.size() == 5){
            if(a[0] == t || a[2] == t){
                t = "";
            }
        }
        if(t.size() == 6){
            if(a[3] == t){
                t = "";
            }
        }
        if(t.size() == 7){
            if(a[1] == t){
                t = "";
            }else{
                cout << "NO" << endl;
                return 0;
            }
        }
    }
    if(t.size() != 0){
        cout << "NO" << endl;
        return 0;
    }

    cout << "YES" << endl;
}


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

using namespace std;
 
void print_preorder
(const vector<pair<int, int> >& nodes, const vector<int>& node_val, const int r)
{
  if(r<0) return;
  cout << ' ' << node_val[r];
  print_preorder(nodes, node_val, nodes[r].first);
  print_preorder(nodes, node_val, nodes[r].second);
}
  
void print_inorder
(const vector<pair<int, int> >& nodes,  const vector<int>& node_val, const int r)
{
  if(r<0) return;
  print_inorder(nodes, node_val, nodes[r].first);
  cout << ' ' << node_val[r];
  print_inorder(nodes, node_val, nodes[r].second);
}
    
  
void print_postorder
(const vector<pair<int, int> >& nodes, const int r, int geta, bool& first_print)
{
  if(r<0) return;
  print_postorder(nodes, nodes[r].first, geta, first_print);
  print_postorder(nodes, nodes[r].second, geta, first_print);
   
  cout << (first_print ? "": " ")  << (r+geta);
  first_print = false;
}
  
int main(){
  std::ios_base::sync_with_stdio(false);
  
  int n, r=-1, h=0;
  cin >> n;
  vector<pair<int, int> > nodes(n);
  vector<int> node_val(n, 0);
   
  
  for(int i=0; i<n; ++i){
    string inst;
    cin >> inst;
    if(inst[0] == 'p'){ //print
      print_inorder(nodes, node_val, r);
      cout << endl;
      print_preorder(nodes, node_val, r);
      cout << endl;
    }
    else if(inst[0] == 'i'){
      int v;
      cin >> v;
       
      if (h == 0) {
	r = h;
	node_val[h] = v;
	nodes[h].first = nodes[h].second = -1;
	++h;
	continue;
      }
 
      //h>0, r>=0
      node_val[h] = v;
      nodes[h].first = nodes[h].second = -1;
       
      int* p = &r;
      while(*p >= 0){
	if(node_val[*p] > node_val[h]){
	  p = &(nodes[*p].first);
	}
	else{
	  p = &(nodes[*p].second);
	}
      }
       
      //*p < 0
      *p = h;
      ++h;
    }
    else if(inst[0] == 'f'){
      //cout << "f" << endl;
      int v;
      cin >> v;

      int* p =&r;
      bool found = false;
      while(*p >= 0){
	// cout << "---" << endl;
	// cout << "p: " << *p << ", "
	//      << "fst: " << nodes[*p].first << ", "
	//      << "snd: " << nodes[*p].second << ", "
	//      << endl;
	// cout << "v: " << v << endl;
	// cout << "val[*p]: " << node_val[*p] << endl;
	if(node_val[*p] == v){
	  found = true;
	  break;
	}
	if(node_val[*p] > v){
	  p = &(nodes[*p].first);
	}
	else if(node_val[*p] < v){
	  p = &(nodes[*p].second);
	}
      }
      cout << (found ? "yes" : "no") << endl;
    }
    else{
      cout << "?" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 7008
n=int(input())
s=list(input())

r=[i for i, _x in enumerate(s) if _x == 'R']
g=[i for i, _x in enumerate(s) if _x == 'G']
b=[i for i, _x in enumerate(s) if _x == 'B']

ans=len(r)*len(g)*len(b)

for i in range(n-2):
  for j in range(i+1,n-1):
    k=2*j-i
    if k<n:
      if s[i]!=s[j] and s[j]!=s[k] and s[i]!=s[k]:
        ans-=1
        
print(ans)

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

int main()
{
    int N, d;
    cin >> N;
    set<int> st;
    for(int i = 0; i < N; ++i){
        cin >> d;
        st.insert(d);
    }
    cout << st.size() << "\n";

}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

int main(void){
    ll N, A, a[300000], tot=0;
    cin>>N;
    a[0]=0;
    rep1(i, N){
        cin>>A;
        a[i]=a[i-1]+A;
        tot+=abs(A);
    }
    ll Minim=tot;
    rep1(i, N-1){
        //cout<<Minim<<endl;
        Minim=min(abs((a[N]-a[i])-a[i]), Minim);
    }
    cout<<Minim<<endl;
    return 0;
}


Measured memory_bytes: 5152
#include <stdio.h>
#include<stdlib.h>
int main(void)
{
	int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    
    if(a < b && b < c)
    {
    	printf("Yes\n");
	}
	else 
	{
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 2144
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		char[] s = new char[n];
		String hoge;
		String A = "A";
		String B = "B";
		int a=0, b=0, c=0, sum=0;
		for(int i=0;i<n;i++) {
			hoge =sc.next();
			char[] chara = hoge.toCharArray();
			if(chara[0]==B.toCharArray()[0] && chara[hoge.length()-1]==A.toCharArray()[0]) {// head is B and tale is A
				c++;
			}
			else if(chara[0]==B.toCharArray()[0]) {//head is B
				b++;
			}
			else if(chara[hoge.length()-1]==A.toCharArray()[0]) {//tale is A
				a++;
			}
			for(int j=0;j<hoge.length()-1;j++) {//how many AB is in
				if(chara[j]==A.toCharArray()[0] && chara[j+1]==B.toCharArray()[0]) {
					sum++;
				}
			}
		}
		if(a==0 && b==0) {
			if(c>0) {
				sum+=c-1;
			}
		}
		else {
			sum+=min(a, b)+c;
		}
		System.out.print(sum);
		
	}
	
	public static int min(int a, int b) {
		if(a<=b) {
			return a;
		}
		else {
			return b;
		}
	}

	
}

Measured memory_bytes: 35328
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	int N, M;
	cin >> N >> M;

	int left = 1;
	int right = (M + 1) / 2 * 2;
	while (left < right) {
		cout << left++ << ' ' << right-- << "\n";
	}
	left = (M + 1) / 2 * 2 + 1;
	right = 2 * M + 1;
	while (left < right) {
		cout << left++ << ' ' << right-- << "\n";
	}

	return 0;
}

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

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

  for(int p = 0;p < q;p++){
    int c,a,n;
    cin >> c >> a >> n;
    int cc = 0;

    int ans = 0;
    int mi = min(min(a,c),n);
    ans += mi;
    c -= mi;
    a -= mi;
    cc = c/2;
    if(cc <= a){
      cout << ans + cc << endl;
    }else{
      ans += a;
      c -= 2 * a;
      ans += c/3;
      cout << ans << endl;
    }
  }
  return 0;
}





Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int n,l,cnt = 0,cst;
    cin >> n >> l;
    for(int i = 0;i < n;i++){
        cnt += l+i;
    }
    if(l >= 1) cnt -= l;
    else if(n+l >= 1) cnt -= 0;
    else cnt -= (n+l-1);
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

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

#define io ios_base::sync_with_stdio(false)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vll vector<long long>
#define pb push_back
#define mod  100000007
#define pii pair<int, int>
#define PI 2*acos(0.0)
#define forn(i, n) for(int i = 0; i < n; i++)


int main()
{
    io;
    int n;
    cin>>n;
    double dp[n+1] = {0};
    dp[0] = 1;
    for(int i = 0; i < n;i++)
    {
        double pro;
        cin>>pro;
        for(int j = i+1;j>=0; j--)
            dp[j] = (j==0?0:dp[j-1]*pro) + dp[j]* (1.0-pro);
    }
    double ans = 0;
    for(int i = n/2 +1; i <=n; i++)
        ans += dp[i];
    printf("%.12lf\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define M 1000

int main(void){
  int i,j;
  int n,ans[M],cd;

  scanf("%d",&n);
  ans[0]=1;
  cd=1;
  for(i=1;i<100;i++){
    ans[i]=0;
  }
  for(i=1;i<=n;i++){
    for(j=0;j<cd;j++){
      ans[j]*=i;
    }
    for(j=0;j<cd;j++){
      if(ans[j]>=10){
        if(j==cd-1)
          cd++;
        ans[j+1]+=ans[j]/10;
        ans[j]%=10;
      }
    }
  }
  for(j=cd-1;j>=0;j--){
    printf("%c",ans[j]+'0');
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 0
N, X = map(int, input().split())

a, p = [1], [1]
for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)

def f(N, X):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1 + a[N-1]:
        return f(N-1, X-1)
    else:
        return p[N-1] + 1 + f(N-1, X-2-a[N-1])


print(f(N,X))



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

#define lint long long


lint MOD = 1000000007;

class Combination_mod{
public:
    Combination_mod(lint mod);
    lint power_mod(lint a, lint p);
    lint div_mod(lint A, lint B);
    lint combi_mod(lint n, lint k);
    lint factorial_mod(lint n);
    
private:
    lint mod;
    lint MAX_N = 0; //for memory
    vector<lint> Factorial; //for memory
};

Combination_mod::Combination_mod(lint MOD){
    mod = MOD; //initialize mod
    Factorial.resize(100000, (lint)0); //@@@@@@@@@@@@@@@ ADJUST THE SIZE HERE!!! @@@@@@@@@@@@@@@
    
}

// calculate a^p
lint Combination_mod::power_mod(lint a, lint p){
    a %= mod;
    
    if(p == 1){
        return a;
    }
    
    if(p >= mod){
        return 0;
    }
    
    if(p % 2 == 0){
        lint tmp = power_mod(a, p / 2);
        return (tmp * tmp) % mod;
    } else {
        return (power_mod(a, p - 1) * a) % mod;
    }
}

lint Combination_mod::div_mod(lint A, lint B){
    A %= mod; B %= mod;
    lint ans;
    lint inv_B;
    inv_B = power_mod(B, mod - 2);
    ans = (A * inv_B) % mod;
    return ans;
}

lint Combination_mod::combi_mod(lint n, lint k){
    lint ans;
    if(k < 0 || n < k) return 0;
    if(k == 0 || n == k) return 1;
    
    lint div = (factorial_mod(k) * factorial_mod(n - k)) % mod;
    lint num = factorial_mod(n);
    
    ans = div_mod(num, div);
    return ans;
}

lint Combination_mod::factorial_mod(lint n){
    if(n==1) return 1;
    if(n < 1) return 0;
    if(Factorial[n] != 0){
        return Factorial[n];
    } else {
        lint tmp = factorial_mod(n - 1) * n;
        tmp %= mod;
        Factorial[n] = tmp;
        return tmp;
    }
}

int main(){
    lint N, K;
    cin >> N >> K;
    

    
    Combination_mod CM(MOD);
    
    for(int i = 1; i <= K; ++i){
        if(N == K){
            if(i == 1) cout << 1 << endl;
            else cout << 0 << endl;
            continue;
        }
        lint Blue;
        Blue = CM.combi_mod(K - 1, i - 1);
        //cout << Blue << " ";
        
        lint Red = 0;
        for(int j = -1; j < 2; ++j){
            Red += CM.combi_mod(N - K - 1, i - j - 1) * (j == 0 ? 2 : 1);
            
            //cout << CM.combi_mod(N - K - 1, i - j - 1) << " ";
            Red %= MOD;
            
        }
        
        cout << ((Blue * Red) % MOD) << endl;
    }

    
}

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

int main(){
	int n;
  	std::cin>>n;
  	std::vector<int> v(n);
  	for(int i=0;i<n;i++){
    	std::cin>>v[i];
    }
  	long long ans=0;
	int cur=0;
  	for (int i=0;i<n;i++){
		ans+=(v[i]+cur)/2;
      	if (v[i]!=0)
	      	cur=(v[i]+cur)%2;
    	else
          	cur=0;
    }
  	std::cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 640
import heapq

n,m = map(int,input().split())

a = list(map(int,input().split()))
b = list(map(lambda x:-x,a))

heapq.heapify(b)

for i in range(m):
  tmp = heapq.heappop(b)
  heapq.heappush(b,int(tmp/2))

res = 0

for i in range(n):
  
  res += heapq.heappop(b)
  
print(-res)

Measured memory_bytes: 14180
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    int n, t;
    cin >> n;

    vector <int> a, b;
    for (int i = 0; i < n; i++) {
        cin >> t;
        a.push_back(t);
    }
    for (int i = 0; i < n; i++) {
        cin >> t;
        b.push_back(t);
    }

    int ans = 0;
    for (int k = 29; k >= 0; k--) {
        for (int i = 0; i < n; i++) {
            a[i] %= 1 << (k + 1);
            b[i] %= 1 << (k + 1);
        }

        sort(b.begin(), b.end());

        ll count = 0;
        for (int i = 0; i < n; i++) {
            count += lower_bound(b.begin(), b.end(), 2*(1<<k)-a[i]) - lower_bound(b.begin(), b.end(), (1<<k)-a[i]);
            count += lower_bound(b.begin(), b.end(), 4*(1<<k)-a[i]) - lower_bound(b.begin(), b.end(), 3*(1<<k)-a[i]);
        }

        if (count % 2LL == 1LL) {
            ans += (1 << k);
        }
    }

    cout << ans << "\n";
    return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

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

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

const ll mod = (ll)1e9 + 7;

ll mpow(ll x, ll n) {
	ll ans = 1; x %= mod;
	while (n != 0) {
		if (n & 1) ans = ans * x % mod;
		x = x * x % mod;
		n = n >> 1;
	}
	return ans;
}

ll inv_mod(ll a) { return mpow(a, mod - 2); }

class Factorial {
private:
	vector<ll> fac;
	vector<ll> ifac;
public:

	Factorial(ll N) {
		fac.push_back(1);
		for (int i = 0; i < N; i++) fac.push_back(fac[i] * (i + 1) % mod);
		ifac.resize(N + 1);
		ifac[N] = inv_mod(fac[N]);
		for (int i = 0; i < N; i++) ifac[N - 1 - i] = (ifac[N - i] * (N - i)) % mod;
	}

	ll fact(ll a) { return fac[a]; }
	ll ifact(ll a) { return ifac[a]; }

	ll cmb(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		ll tmp = ifact(a - b) * ifact(b) % mod;
		return tmp * fac[a] % mod;
	}
	ll per(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		return fac[a] * ifac[a - b] % mod;
	}
};

int main(void)
{
	ll n,k;
	cin >> n >> k;
	vector<ll> as(n);
	rep(i, n)cin >> as[i];
	sort(as.begin(), as.end());
	if (k == 1) {
		cout << 0 << endl;
		return 0;
	}

	Factorial fc(n);
	ll sum = 0;
	for(int i = k - 1;i < n;i++) {
		ll elem = ((fc.cmb(i,k-1) * as[i]) % mod) + mod;
		elem %= mod;
		(sum += elem) %= mod;
	}	
	for (int i = n - k; i >= 0; i--) {
		ll elem = ((fc.cmb(n - 1 - i, k - 1) * as[i]) % mod) + mod;
		elem %= mod;
		sum += mod - elem;
		sum %= mod;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 2676
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,i=0;while(n/10>0){i++;d++;}return d;}
llfor;ll ans=0;////////////////////////////////////////////////////////////
int main(){
 ll card[5][5];
 rep(i,0,3){
  rep(j,0,3){
   cin>>card[i][j];
  }
 }
 bool al[200]={false};
 ll a;
 ll n;
 cin>>n;
 //cout<<"n "<<n<<endl;
 rep(i,0,n){
  cin>>a;
  al[a]=true;
 }

 ll cnt=0;
 rep(i,0,3){
  cnt=0;
  rep(j,0,3){
   if(al[card[i][j]])cnt++;
  }
  if(cnt==3){
   py;return 0;
  }
 }
 rep(i,0,3){
  cnt=0;
  rep(j,0,3){
   if(al[card[j][i]])cnt++;
  }
  if(cnt==3){
   py;return 0;
  }
 }

 cnt=0;
 rep(i,0,3){
  if(al[card[i][i]])cnt++;
 }
 if(cnt==3){
  py;return 0;
 }

 cnt=0;
 rep(i,0,3){
  if(al[card[i][2-i]])cnt++;
 }
 if(cnt==3){
  py;return 0;
 }
 pn;
 return 0;}



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

#define int long long
#define forn(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int) (x).size())


int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	set<int> x = {1, 2, 3};
	x.erase(a);
	x.erase(b);
	cout << *x.begin() << endl;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int l1,l2,res;
    char s1[100];
    char s2[100];
    while(gets(s1))
    {
        gets(s2);
        l1=strlen(s1) ;
        l2=strlen(s2) ;
        s2[strlen(s2)-1]='\0';
        res=strcmp(s1,s2);
        if(res==0)
        {
            printf("Yes\n") ;
        }
        else
        {
            printf("No\n");
        }
    }
    return 0 ;
}


Measured memory_bytes: 1528
import java.util.*;

public class Main {

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

        int[][] matrix = new int[row][column];
        for (int i = 0; i < row; i++) {
            for (int j = 0; j < column; j++) {
                matrix[i][j] = 0;
            }
        }

        int markedRow = sc.nextInt();
        int markedColumn = sc.nextInt();

        // 行をマークする
        for (int i = 0; i < column; i++) {
            for (int j = 0; j < markedRow; j++) {
                matrix[j][i] = 1;
            }
        }

        // 列をマークする
        for (int i = 0; i < row; i++) {
            for (int j = 0; j < markedColumn; j++) {
                matrix[i][j] = 1;
            }
        }

        int count = 0;
        for (int i = 0; i < row; i++) {
            for (int j = 0; j < column; j++) {
                if (matrix[i][j] == 0) count++;
            }
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 21844
using System;

namespace Range
{
    class Program
    {
        static int Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int c = int.Parse(str[2]);
            if (a < b)
            {
                if(b < c)
                {
                    Console.WriteLine("Yes");
                    return 0;
                }
            }
            Console.WriteLine("No");
            return 0;
        }
    }
}

Measured memory_bytes: 8872
#pragma region

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;
using vvb = vector<vector<bool>>;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &pair) {
  cin >> pair.first >> pair.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

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

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

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16);
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  init();

  ll N, M;
  cin >> N >> M;
  int l = (M + 1) / 2;
  int r = M - l;
  rep(i, l) {
    cout << l - i << ' ' << l + i + 1 << '\n';
  }
  rep(i, r) {
    cout << l * 2 + r - i << ' ' << l * 2 + r + i + 2 << '\n';
  }
}


Measured memory_bytes: 3660
n = int(input())
A = list(map(int, input().split()))
m = int(input())
B = list(map(int, input().split()))

l = min(n, m)

if A == B:
    print(0)
else:
    if n < m:
        A.append(-1)
    else:
        B.append(-1)

    for i in range(l+1):
        if A[i] == B[i]:
            pass
        elif A[i] < B[i]:
            print(1)
            break
        else:
            print(0)
            break


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

int main(){
  int a = 0;
  int b = 0;
  int c = 0;
  int d = 0;
  string s;
  cin >> s;
  if(s.size()%2==0){
    for(int i = 0; i < s.size(); i += 2){
      if(s[i] == '0'){
        a++;
      }
      else{
        c++;
      }
      if(s[i+1] == '1'){
        b++;
      }
      else{
        d++;
      }
    }
    if(a+b >= c+d){
      cout << s.size()-(a+b) << endl;
    }
    else{
      cout << s.size()-(c+d) << endl;
    }
  }
  
  else if(s.size()%2==1){
    for(int i = 0; i < s.size(); i += 2){
      if(s[i] == '0'){
        a++;
      }
      else{
        c++;
      }
      if(s[i+1] == '1' && i+1 != s.size()){
        b++;
      }
      else if( i+1 != s.size() && s[i+1] == '0'){
        d++;
      }
    }
    if(a+b >= c+d){
      cout << s.size()-(a+b) << endl;
    }
    else{
      cout << s.size()-(c+d) << endl;
    }
  }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;

#define LEN(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
using vpii = vector<pii>;

template<typename T, typename M = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, M, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
const int MOD = 1e9 + 7;
const double EPS = 1e-9;

inline int fcmp(double x, double y)
{ return (x < y + EPS ? (x < y - EPS ? -1 : 0) : 1);}

int main()
{
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    
    int k; cin >> k;
    string s;  cin >> s;

    if(LEN(s) <= k) cout << s << endl;
    else cout << s.substr(0, k) + "..." << endl;
    
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<int,int>;

int main(){
	int n, m;
	cin>>n>>m;
	scc_graph g(n);
	rep(i, m){
		int a, b;
		cin>>a>>b;
		g.add_edge(a, b);
	}
	auto vv=g.scc();
	cout<<(vv.size())<<endl;
	for(auto li : vv){
		cout<<(li.size())<<" ";
		for(int v : li) cout<<v<<" ";
		cout<<endl;
	}
	return 0;
}


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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int M, K; cin >> M >> K;
	if (K >= (1 << M)) {
		cout << -1 << endl;
		return 0;
	}

	if (M == 1) {
		if (K == 0) {
			cout << "0 1 1 0" << endl;
		} else {
			cout << -1 << endl;
		}
		return 0;
	}

	int N = 1 << M;
	vector<int> ans;
	for (int i = 0; i < N; i++) {
		if (i != K) {
			ans.push_back(i);
		}
	}
	ans.push_back(K);
	for (int i = N - 1; i >= 0; i--) {
		if (i != K) {
			ans.push_back(i);
		}
	}
	ans.push_back(K);

	assert((2 << M) == int(ans.size()));

	for (int i = 0; i < 2 * N; i++) {
		cout << ans[i] << " \n"[i == 2 * N - 1];
	}

	return 0;
}


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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline void chmin(T &l,T r){l=min(l,r);}
template <typename T>inline void chmax(T &l,T r){l=max(l,r);}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
typedef tuple<int,int,int,LL> T;
const LL INF=1e15;
LL a[212345];
LL b[212345];
LL c[212345];
LL t[212345];

int main(){
    int N,M,S,G;
    cin>>N>>M>>S>>G;
    priority_queue<T> sc;
    vector<LL> ame(N+1,INF);
    REP(i,M){
        cin>>a[i]>>b[i]>>t[i]>>c[i];
        sc.push(T(-t[i],0,i,0));
    }
    ame[S]=0;
    LL res=INF;
    while(sc.size()){
        int tt,type,e;LL cww;
        tie(tt,type,e,cww)=sc.top();
        sc.pop();
        LL bg=t[e];
        LL ed=t[e]+c[e];
        if(type==0){
            LL cost=ame[a[e]]+t[e];
            sc.push(T(-ed,1,e,cost));
        }
        else{
            if(b[e]==G)chmin(res,cww);
            chmin(ame[b[e]],cww-t[e]-c[e]);
        }

    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 14728
#include<iostream>
     
    using namespace std;
     
    int main(){
      string s;
      cin >> s;
      char a = s[0];
      if(a != s[1]){
        char b = s[1];
        if(b == s[2] && a == s[3]) cout<<"Yes";
        else if(b == s[3] && a == s[2]) cout << "Yes";
        else cout << "No";
      }else if(a != s[2] && s[2] == s[3]) cout << "Yes";
      else cout << "No";
      
      
      return 0;
    }

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

AA=str(A)
BB=str(B)

Aans=""
Bans=""

i=0
while i<B:
    Aans=Aans+AA
    i+=1
j=0
while j<A:
    Bans=Bans+BB
    j+=1


print(min(Aans,Bans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
using namespace std;
int lcm(int num1, int num2) {
  int num3 = __gcd(num1, num2);
  //return num1 * num2 / num3;
  return num1 / __gcd(num1, num2) * num2;
}
signed main() {
  int n;
  cin >> n;
  int num1;
  cin >> num1;
  int num2;
  for (int i = 1; i < n; i++) {
    cin >> num2;
    num1 = lcm(num1, num2);
  }
  cout << num1 << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
q=int(input())
bc=[list(map(int, input().split())) for _ in range(q)]

from collections import Counter
counter=Counter(a)
s=sum(a)
for b,c in bc:
    if b in counter:
        sa=counter[b]*(c-b)
        counter[c]+=counter[b]
        counter.pop(b)
        s+=sa
    print(s)


Measured memory_bytes: 37584
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<iomanip>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
const vector<VE> DIR{ {-1,0},{1,0},{0,-1},{0,1} };
const int z = 1000000007;
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
int main() {
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    int flag0 = 0, flag_over = 0;
    llong ans = 1;
    const llong sh = 1000000000000000000;
    llong tmp_now;
    REP(i, n) {
        cin >> tmp_now;
        if (tmp_now == 0) {
            flag0 = 1;
        }
        if (tmp_now > sh / ans) {
            flag_over = 1;
        }
        if (!flag0 && !flag_over) {
            ans *= tmp_now;
        }

    }
    if (flag0)
        cout << 0 << endl;
    else if (flag_over)
        cout << -1 << endl;
    else
        cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

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

    vector<int> A(N+1);
    vector<int> B(N);
    for (int i = 0; i < N+1; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];

    ll sum = 0;
    int A1 = 0, A2 = 0, B1 = 0;
    for (int i = 0; i < N; i++) {
        A1= A[i];
        A2 = A[i+1];
        B1 = B[i];
        A[i] = max(0, A[i] - B[i]);
        B[i] = max(0, B[i] - A1);
        A[i+1] = max(0, A[i+1] - B[i]);
        B[i] = max(0, B[i] - A2);
        sum += B1 - B[i];
    }

    cout << sum << endl;
}

Measured memory_bytes: 1024
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out)) {
            int n = in.nextInt();
            int[] v = new int[n];
            Set<Integer> set = new HashSet<>();
            for (int i = 0; i < n; i++) {
                v[i] = in.nextInt();
                set.add(v[i]);
            }
            for (int i = 1; i < n; i++) swap(v, (int) (Math.random() * (i - 1)), i);
            Arrays.sort(v);

            int ans = 2;
            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    int d = v[j] - v[i];
                    if (set.contains(v[i] - d)) continue;
                    int cnt = 2, cur = v[j];
                    while (set.contains(cur + d)) {
                        cur += d;
                        cnt++;
                    }
                    ans = Math.max(ans, cnt);
                }
            }
            out.println(ans);
        }
    }

    private static void swap(int[] a, int x, int y) {
        int t = a[x];
        a[x] = a[y];
        a[y] = t;
    }
}



Measured memory_bytes: 163132
#include<bits/stdc++.h>
using namespace std;
string s;
int a[30];
main(){
  cin>>s;
  for(int i=0;i<s.size();++i)a[s[i]-'a']++;
  for(int i=0;i<26;++i)if(a[i]==0){
      char c='a'+i;
      cout<<c<<endl;
      return 0;
    }
  cout<<"None\n";
}


Measured memory_bytes: 512
#include<stdio.h>
int main(void){
int m,f,r;
while(1){
scanf("%d %d %d",&m,&f,&r);
if(m==-1&&f==-1&&r==-1){
break;
}
else  if(m==-1||f==-1) printf("F\n");
else if(m+f>=80){
printf("A\n");
}
else if(m+f>=65 && m+f<80){
printf("B\n");
}
else if(m+f>=50 && m+f<65){
printf("C\n");
}
else if(m+f>=30 && m+f<50){
if(r>=50) printf("C\n");
else if(r<50) printf("D\n");
} 
else if(m+f<30){
printf("F\n");
}
}
return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
/* Type alias */
using ll = long long;
using ld = long double;

using vec_i = std::vector<int>;
using vec_ll = std::vector<ll>;
using vec_ld = std::vector<ld>;

using set_i = std::set<int>;
using set_ll = std::set<ll>;
using set_ld = std::set<ld>;

using uset_i = std::unordered_set<int>;
using uset_ll = std::unordered_set<ll>;
using uset_ld = std::unordered_set<ld>;

/* IO macros */
#define in(i)            int i; std::cin >> i
#define in2(i, j)        int i, j; std::cin >> i >> j
#define in3(i, j, k)     int i, j, k; std::cin >> i >> j >> k
#define in_(i)           std::cin >> i
#define in2_(i, j)       std::cin >> i >> j
#define in3_(i, j, k)    std::cin >> i >> j >> k
#define in_ll(i)         ll i; std::cin >> i
#define in2_ll(i, j)     ll i, j; std::cin >> i >> j
#define in3_ll(i, j, k)  ll i, j, k; std::cin >> i >> j >> k
#define in_ll_(i)        std::cin >> i
#define in2_ll_(i, j)    std::cin >> i >> j
#define in3_ll_(i, j, k) std::cin >> i >> j >> k
#define in_ld(i)         ld i; std::cin >> i
#define in2_ld(i, j)     ld i, j; std::cin >> i >> j
#define in3_ld(i, j, k)  ld i, j, k; std::cin >> i >> j >> k
#define in_ld_(i)        std::cin >> i
#define in2_ld_(i, j)    std::cin >> i >> j
#define in3_ld_(i, j, k) std::cin >> i >> j >> k
#define in_c(i)          char i; std::cin >> i
#define in2_c(i, j)      char i, j; std::cin >> i >> j
#define in3_c(i, j, k)   char i, j, k; std::cin >> i >> j >> k
#define in_c_(i)         std::cin >> i
#define in2_c_(i, j)     std::cin >> i >> j
#define in3_c_(i, j, k)  std::cin >> i >> j >> k
#define in_str(s)        std::string s; std::cin >> s

#define vec_in(v, n)    auto v=vec_i(n); for(auto &x:v){std::cin>>x;}
#define vec_in_ll(v, n) auto v=vec_ll(n);for(auto &x:v){std::cin>>x;}
#define vec_in_ld(v, n) auto v=vec_ld(n);for(auto &x:v){std::cin>>x;}

#define print(x)   std::cout << x
#define println(x) std::cout << x << "\n"
#define print_fixed(x)   std::cout << std::fixed << x
#define println_fixed(x) std::cout << std::fixed << x << "\n"
#define print_vec(v) for (auto &x:v) { std::cout << x << " ";}
#define println_vec(v) for (auto &x:v) { std::cout << x << " ";} std::cout << "\n";
#define print_long_vec(v) for (auto &x:v) { std::cout << x << "\n";}
#define println_long_vec(v) for (auto &x:v) { std::cout << x << "\n";} std::cout << "\n";

/* Loops */
#define rep(i, n) for (auto i = 0; i < n; ++i)

/* Vector manipulation */
#define vec_sort(v) std::sort(v.begin(), v.end())

using namespace std;
/* Code Starts Here*/
int main () {
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    in2(A, B);
    in2(H, M);
    double dM= -(2 * (M_PI / 60.0) * M);
    double dH= -(2 * (M_PI / 12.0) * H + 2 * (M_PI / (12.0 * 60.0)) * M);
    if (dH >= M_PI) { dH -= 2 * M_PI; }
    if (dH < -M_PI) { dH += 2 * M_PI; }
    if (dM >= M_PI) { dM -= 2 * M_PI; }
    if (dM < -M_PI) { dM += 2 * M_PI; }
    double xH = A * cos(dH);
    double yH = A * sin(dH);
    double xM = B * cos(dM);
    double yM = B * sin(dM);
    cout << setprecision(11) << (sqrt((xH - xM) * (xH - xM) + (yH - yM) * (yH - yM))) << endl;
    return 0;
}


Measured memory_bytes: 4124
N, Q =map(int,input().split())
S =input()
LR = [list(map(int,input().split())) for i in range(Q)]
ACnum =[0]*(N+1)
Sofar = 0
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
        Sofar+=1
    ACnum[i+1] = Sofar
ACnum[N]=Sofar
#print(ACnum)
for i in range(Q):
    print(ACnum[LR[i][1]-1]-ACnum[LR[i][0]-1])


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

int main() {
    int a,b;
    cin>>a>>b;
    double r=0;
    for(int i=1;i<=a;i++)
    {

        double t = 1.0/a;
        int n =i;
        while(n<b)
        {
            n = n*2;
            t = t/2;
        }
        r +=t;
    }
    printf("%.12f",r);
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

/**
 * Z-Algorithm or ローリングハッシュが想定解？
 * http://drken1215.hatenablog.com/entry/2019/09/16/014600
 * LCP(Longest Common Prefix)配列をどう求めるかで方針が異なる．
 * LCP Array: https://blog.shibayu36.org/entry/2017/01/06/103956
 */
public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "YES";
    private static final String NO = "NO";

    public static void main(String[] args) {
        // test();
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        String S = sc.next();

        int ans = solveX(N, S);

        System.out.println(ans);
    }
  
    /**
     * 自分の考えた実装に近い．実行時間は決して早くないが(他が300ms, これは1000ms)これで解けるなら十分．
     * https://atcoder.jp/contests/abc141/submissions/7531748
     * @param N
     * @param S
     * @return
     */
    private static int solveX(int N, String S) {
        int count = 0;

        for (int i=0; i<N; i++) {
            for (int j=i+count+1; j<N; j++) {
                if (0 < S.indexOf(S.substring(i, j), j)) {
                    count = j - i;
                } else {
                    break;
                }
            }
        }

        return count;
    }
}

Measured memory_bytes: 39036
#include<stdio.h>
int SelectionSort(int A[],int N){
  int i,j,temp,cnt=0,mini;
  for(i=0;i<N-1;i++){
    mini=i;
    for(j=i;j<N;j++){
      if(A[j]<A[mini]) mini=j;
    }
    temp = A[i];
    A[i]=A[mini];
    A[mini] = temp;
    if(i != mini) cnt++;
  }
  return cnt;
}
int main(){
  int A[100],N,i,j,cnt;
  scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);
    cnt = SelectionSort(A,N);

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



Measured memory_bytes: 2144
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::unordered_map;using std::unordered_set;using std::bitset;using std::pair;using std::set;using std::string;using std::vector;using std::sort;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}

const int N=101;
char f[N][N];
int dp[N][N];
bool g[N][N][N][N];

int32_t main(){

    int n,m;
    cin>>n>>m;
    forn(i,n)forn(j,m)cin>>f[i][j];
    forn(i,n)forn(j,m){
        dp[i][j]=N*N;
        forn(fi,i+1)forn(fj,j+1){
            if(f[i][j]!=f[fi][fj])continue;
            if(i==fi){
                if(j==fj){
                    g[i][j][fi][fj]=1;
                }else{
                    g[i][j][fi][fj]=(f[i][j]==f[i][j-1]&&g[i][j-1][fi][fj]);
                }
            }else if (j==fj){
                g[i][j][fi][fj]=(f[i][j]==f[i-1][j]&&g[i-1][j][fi][fj]);
            }else{
                g[i][j][fi][fj]=(f[i][j]==f[i-1][j]&&g[i-1][j][fi][fj])||(f[i][j]==f[i][j-1]&&g[i][j-1][fi][fj]);
            }
            if(!g[i][j][fi][fj])continue;
            int flip=f[i][j]=='#';
            if(!fi&&!fj)dp[i][j]=flip;
            if(fi&&f[fi][fj]!=f[fi-1][fj])upn(dp[i][j],dp[fi-1][fj]+flip);
            if(fj&&f[fi][fj]!=f[fi][fj-1])upn(dp[i][j],dp[fi][fj-1]+flip);
        }
    }
    cout<<dp[n-1][m-1]<<'\n';

    return 0;
}


Measured memory_bytes: 99712
# coding: utf-8
# Your code here!

a = list(map(int,input().split()))
a += list(map(int,input().split()))
a += list(map(int,input().split()))

b = [0 for i in range(9)]

n = int(input())

for i in range(n):
    k = int(input())
    for j in range(9):
        if k == a[j]:
            b[j] = 1
            break
ok = [[0,1,2],[3,4,5],[6,7,8],[0,4,8],[2,4,6],[0,3,6],[1,4,7],[2,5,8]]

clear = 0
for ok_i in ok:
    flag = 1
    for ok_i_j in ok_i:
        if b[ok_i_j] == 0:
            flag = 0
            break
    if flag == 1:
        print("Yes")
        clear = 1
        break
if clear == 0:
    print("No")

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

int main(){
    string s[3];
    cin>>s[0]>>s[1]>>s[2];
    string ans="";
    for(int i=0;i<3;i++){
        ans+=(char)(s[i][0]-'a'+'A');
    }
    cout<<ans<<endl;
}

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

int main()
{
	int S, h, m, s;
	scanf("%d", &S);
	
	h = S / 3600;
	m = S % 3600 / 60;
	s = S % 60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}


Measured memory_bytes: 2128
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
ll evaluate(VV &S,ll d,V &prev,V &C,ll j){
    
    ll temp = 0;
    temp+=S[d][j];
    rep(k, 26) {
        if (j == k) {
            continue;
        }
        temp -= C[k] * (d - prev[k]);
    }
    return temp;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll d;
    cin >> d;
    V C(26);
    rep(i, 26) cin >> C[i];
    VV S(d, V(26));
    rep(i, d) { rep(j, 26) cin >> S[i][j]; }
    ll width=300;
    vector<tuple<ll,V,V>> vec;
    V temp;
    rep(i,26)temp.push_back(-1);
    V temp2;
    vec.push_back({0,temp,temp2});
    rep3(i,0,d){
        priority_queue<tuple<ll, V, V>> q;
        for(auto j:vec){
            ll score=get<0>(j);
            V prev=get<1>(j);
            V history=get<2>(j);
            rep(k,26){
                ll value=evaluate(S,i,prev,C,k);
                V prev2=prev;
                prev2[k]=i;
                history.push_back(k);
                q.push({score+value,prev2,history});
                history.pop_back();
            }
        }
        vec={};
        for(ll j=0;j<width&&!q.empty();j++){
            vec.push_back(q.top());
            q.pop();
        }
    }
    for(auto i:get<2>(vec[0])){
        cout<<i+1<<endl;
    }
}


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

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

    getchar();

    int arr[n+1];
    string str[n+1];
    string s;

    for(int i=1;i<=n;i++)
        cin>>str[i]>>arr[i];


    getchar();

    cin>>s;
    int j;

    for(int i=1;i<=n;i++){
        if(str[i]==s)
        {
            j=i+1;
            break;
        }
    }

    int a=0;
    for(int i=j;i<=n;i++)
      a+=arr[i];


    cout<<a<<endl;
    
    return 0;

}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
   int a, i, count=0;
   char S[100], Sj, Sk, Si;

   scanf("%d", &a);
   for(i=0;i<a;i++)
      scanf("%c", &S[i]);
   for(i=0;i<a;i++){
      if(S[i] == 'Y')
         count = 1;
      if(S[i] == 'P')
         Si = 'P';
      if(S[i] == 'W')
         Sj = 'W';
      if(S[i] == 'G')
         Sk = 'G';
}
   if (count == 1)
       printf("Four\n");
   else
      printf("Three\n");
   return 0;
}

Measured memory_bytes: 128
import re

def calc(stack, ope):
    symbol = stack.pop()
    if re.match('[0-9]+', symbol):
        b = int(symbol)
    else:
        b = calc(stack, symbol)

    symbol = stack.pop()
    if re.match('[0-9]+', symbol):
        a = int(symbol)
    else:
        a = calc(stack, symbol)

    if ope == '+':
        return a + b
    elif ope == '-':
        return a - b
    elif ope == '*':
        return a * b
    else:
        raise RuntimeException("Unknown operator %s" % ope)

stack = input().split()

print(calc(stack, stack.pop()))


Measured memory_bytes: 6576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()
 
int main(){
  ll N,K;cin>>N>>K;
  vll A(N);rep(i,N)cin>>A[i];
  ll left=0,right=1e9+1;
  while(right-left>1){
    ll mid=(right+left)/2;
    ll cnt=0;
    rep(i,N){
      cnt += (A[i]-1)/mid;
    }
    if(cnt<=K) right=mid;
    else left=mid;
  }
  cout<<right<<endl;
}

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

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	bool ha = 0, hb = 0;
	for (char c : s) {
		if (c == 'A') ha = 1;
		else hb = 1;
	}
	if (ha && hb) cout << "Yes\n";
	else cout << "No\n";
}


Measured memory_bytes: 768