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

int k,n,d[200006],ans=1e7+8;

int main()
{
	scanf("%d %d",&k,&n);
	for(int i=1;i<=n;++i) {
		scanf("%d",d+i);
	}
	sort(d+1,d+n+1);
	for(int i=2;i<=n;++i) {
		ans=min(ans,k-d[i]+d[i-1]);
	}
	ans=min(ans,d[n]-d[1]);
	printf("%d",ans);
}

Measured memory_bytes: 1024
N,D=map(int,input().split())
X=[list(map(int,input().split())) for _ in range(N)]
ans = 0
from itertools import combinations
from os import kill
for i, j in combinations(range(N), 2):
    d = sum([(X[i][k]-X[j][k])**2 for k in range(D)])
    if int(d**0.5) == d**0.5:
        ans += 1
print(ans)

Measured memory_bytes: 62300
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

long double l;

long double f(long double a){
  return a*a*(l-a-a);
}

int main(){
  ll L;
  cin>>L;
  l = 1.*L;
  long double left = 0.0;
  long double right = l;

  rep(i,0,300){
    long double d = (right - left) / 3.0;
    long double l = f(left + d);
    long double r = f(right - d);
    if(l < r){
      left = left + d;
    }else{
      right = right - d;
    }
  }
  printf("%20.20Lf\n",left*left*left);
  return 0;
}

Measured memory_bytes: 256
class WeightedUnionFind():
    def __init__(self,n):
        self.n=n
        self.parents=[-1]*n
        self.differ=[0]*n

    def find(self,x):
        if self.parents[x]<0:
            return x
        else:
            r=self.find(self.parents[x])
            self.differ[x]+=self.differ[self.parents[x]]
            self.parents[x]=r
            return self.parents[x]

    def unite(self,x,y,w):
        xp=self.find(x)
        yp=self.find(y)
        w=w+self.differ[x]-self.differ[y]

        if xp!=yp:
            if self.parents[xp]>self.parents[yp]:
                xp,yp=yp,xp
                w=-w

            self.parents[xp]+=self.parents[yp]
            self.parents[yp]=xp
            self.differ[yp]=w

    def diff(self,x,y):
        xp=self.find(x)
        yp=self.find(y)
        if xp==yp:
            return True,self.differ[y]-self.differ[x]
        else:
            return False,0

n,q=map(int,input().split())
WUF=WeightedUnionFind(n)
for i in range(q):
    query=list(map(int,input().split()))
    if query[0]==0:
        WUF.unite(query[1],query[2],query[3])
    elif query[0]==1:
        judge,diff=WUF.diff(query[1],query[2])
        if judge:
            print(diff)
        else:
            print("?")



Measured memory_bytes: 10248
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, x, n) for(int i = x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
//struct cww{cww(){ios::sync_with_stdio(false);cin.tie(nullptr);}}star;
const long long INF = numeric_limits<long long>::max();

int main() {
  int n;
  scanf("%d", &n);

  map<string, int> affix;

  REP2(i, 1, n + 1) {
    string aff = to_string(i).substr(0, 1) + to_string(i % 10);
    affix[aff] += 1;
  }

  int sum = 0;

  for(auto itr = affix.begin(); itr != affix.end(); ++itr) {
    string aff_rev = itr->first.substr(1, 1) + itr->first.substr(0, 1);
    sum += itr->second * affix[aff_rev];
  }

  printf("%d\n", sum);
  return 0;
}


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

using namespace std;

#define rep(i,x) for (int i = 0 ; i < x; ++i)
#define rrep(i,x) for (int i = x - 1; i >= 0; --i)
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sqr(x) ((x) * (x))
#define re return

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;


void GO(){
#ifdef DOD
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

const int INF = 1e9 + 1;
const ll mod = 1e9 + 7;






//Var
//
 void input() {
     ll n, m, k; cin >> n >> m >> k;
     vector<ll> a(n + 1), b(m + 1); a[0] = b[0] = 0;
     rep(i,n){ cin >> a[i + 1]; a[i + 1] += a[i];}
     rep(i,m){ cin >> b[i + 1]; b[i + 1] += b[i];}
     ll ans = 0, j = m;
     for (ll i = 0; i <= n; ++i){
         if (a[i] > k) break;
         while(j && b[j] + a[i] > k) j--;
         ans = max(ans, i + j);
     }
     cout << ans << '\n';
 }

void solve(){
     
}








///Я призер Всеросса
int main() {
    GO();
    int Q = 1;
    while(Q--){ input(); solve(); } re 0;
}
///Я Кондедат в мастера
	

Measured memory_bytes: 6312
#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;}

int32_t main(){

    int h,w,n;
    cin>>h>>w>>n;
    int s=max(h,w);
    cout<<(n+s-1)/s<<'\n';

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python

def main():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    ab_list = [list(map(int, input().split())) for _ in range(m)]

    cnt = [1 for _ in range(n)]

    for ab in ab_list:
        a, b = ab
        a -= 1
        b -= 1
        if h[a] == h[b]:
            cnt[a] = 0
            cnt[b] = 0
        elif h[a] < h[b]:
            cnt[a] = 0
        elif h[a] > h[b]:
            cnt[b] = 0

    print(sum(cnt))

if __name__ == '__main__':
    main()


Measured memory_bytes: 32036
import itertools

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

a=[]
for i in range(N):
    a.append(i+1)

L=list(itertools.permutations(a))


cnt=0

for l in L:
    tmp=1
    if l[0]!=1:
        break
    for j in range(N-1):
        if ([l[j],l[j+1]] in S) or ([l[j+1],l[j]] in S):
            tmp=1
        else:
            tmp=0
            break
    if tmp==1:
        cnt+=1

print(cnt)

Measured memory_bytes: 8052
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	while(kbd.hasNext()){
	    int n = kbd.nextInt();
	    int m = kbd.nextInt();
	    double p = kbd.nextInt();
	    if(!(n==0 && m==0 && p==0)){
		
		int[] a = new int[n];
		int i;
		int  money = 0;
		for(i=0; i<n; i++){
		    a[i] = kbd.nextInt();
		    money += a[i]*100;
		}

		money -= money*(p/100);

		if(a[m-1]==0){
		    System.out.println("0");
		}
		else {
		    money = money/a[m-1];
		    System.out.println(money);
		}
	    }
	}
    }
}

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

int main() {
  int a, b, c;
  int ansn = 0, ans1 = 0, ans2 = 0, ans3 = 0;
  while (cin >> a >> b >> c) {
    if (a + b > c && b + c > a && c + a > b) {
      ansn++;

      if (a < b) {
        int swap = a;
        a = b;
        b = swap;
      }
      if (a < c) {
        int swap = a;
        a = c;
        c = swap;
      }

      int A = b * b + c * c - a * a;

      if (A == 0) ans1++;
      else if (A > 0) ans2++;
      else ans3++;
    } else break;
  }

  cout << ansn << " " << ans1 << " " << ans2 << " " << ans3 << endl;

  return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e9)
using namespace std;
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll A[200010];
    cin >> N;
    rep(i,0,N){
        cin >> A[i];
    }
    ll sum[200010] = {};
    rep(i,0,N){
        sum[i+1] = sum[i] + A[i];
    }
    ll ans = 0;
    sort(sum, sum+N+1);
    ll cnt = 1;
    ll val = sum[0];
    rep(i,1,N+1){
        if(sum[i] == val){
            cnt++;
        }else{
            if(val == 0){
                // ans += cnt;
            }
            ans += cnt * (cnt-1) / 2;
            cnt = 1;
            val = sum[i];
        }
    }
    if(val == 0){
        // ans += cnt;
    }
    ans += cnt * (cnt - 1) / 2;
    print(ans);


}



Measured memory_bytes: 3328
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <algorithm>
#include <string>

#define rep(i, n) for(int i=0;i<n;i++)
#define IOS() ios_base::sync_with_stdio(false)

using namespace std;
int a, b, c;

int input() {

    scanf("%d %d %d", &a, &b, &c);

    if(a == b && b == c) {
        printf("Yes");
    }
    else {
        printf("No");
    }



}

int main() {

    //IOS();

    input();

    return 0;
}

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

using namespace std;

void solve(const vector<int>& val)
{
	int tot_xor = 0;
	int res = 0;
	for(int i = 0; i < (int)val.size(); i++)
		tot_xor ^= val[i];
	for(int i = 0; i < (int)val.size(); i++) {
		res = 0;
		res = tot_xor ^ val[i];
		if(i != (int) val.size() - 1)
			cout << res << " ";
		else
			cout << res;
	}
}

int main()
{
	int N;
	cin >> N;
	vector<int> val(N);
	for(int i = 0; i < N; i++) {
		cin >> val[i];
	}
	solve(val);
	return 0;
}


Measured memory_bytes: 3968
import sys
input = sys.stdin.readline
n = int(input())
br = [input().rstrip() for i in range(n)]
ls = []
numsum = 0
charge = 0
for i in range(n):
  s = br[i]
  need = 0
  num = 0
  for t in s:
    if t == "(":
      num += 1
    else:
      num -= 1
    need = max(need,-num)
  numsum += num
  if need == 0:
    charge += num
  else:
    ls.append([need,num])
if numsum != 0:
  print("No")
  exit()
ls.sort()
l = len(ls)
vis = [0]*l
for i,x in enumerate(ls):
  need,num = x
  if need <= charge and num >= 0:
    charge += num
    ls[i][0] = -1
ls.sort(key = lambda x:x[0]+x[1],reverse=True)
for i in range(l):
  need,num = ls[i]
  if need == -1:
    continue
  if need > charge:
    print("No")
    exit()
  charge += num
print("Yes")

Measured memory_bytes: 190708
//People only find me interesting because they can't tell whether I'm serious or not
//#include <boost/multiprecision/cpp_int.hpp> 
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
typedef long long int ll;
typedef double db;
typedef __int128 s128;
typedef __uint128_t u128;
typedef unsigned long long u64;
#define int long long int
#define P 1000000007
#define Q 1000000006
#define sz(a) (ll)a.size()
#define lt(a) (ll)a.length()
#define pll pair<ll,ll>
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define bac(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define umll unordered_map<ll,ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define teevra_gati ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define N 100005
#define PI 3.14159265359
#define inf LLONG_MAX
//using namespace boost::multiprecision; 
using namespace __gnu_pbds;
using namespace std;
ll dp[N];
void solve(){
    ll n,k;
    cin>>n>>k;
    vl h(n);
    f(i,0,n) cin>>h[i], dp[i] = inf;
    dp[0]=0;
    f(i,1,n){
        f(j,1,k+1){
            if(i-j>=0){
                dp[i] = min(dp[i], abs(h[i] - h[i-j]) + dp[i-j]);
            }
        }
    }
    cout<<dp[n-1];
}
signed main() {
    teevra_gati
    
    solve();

    return 0;
}

Measured memory_bytes: 1792
import scala.io.StdIn

object Main{
  def main(args: Array[String]){
    val dice1 = new Dice(StdIn.readLine.split(" ").toList.map(_.toInt))
    val dice2 = new Dice(StdIn.readLine.split(" ").toList.map(_.toInt))

    println(if(dice1.isEqual(dice2)) "Yes" else "No")
  }
}

class Dice(sur: List[Int]){
  private val index: List[Int] = sur

  def findRight(list: List[Int]): Int={
    val dice = new Dice(index)
    val kindOfDices = List[Dice](dice, dice.rotN, dice.rotS, dice.rotW, dice.rotE, dice.rotN.rotN)
    val finddice = for{
      kindOfDice <- kindOfDices
    }yield kindOfDice match{
      case x if(x.getVal(0) == list(0) && x.getVal(1) == list(1)) => x.getVal(2)
      case x if(x.rotR.getVal(0) == list(0) && x.rotR.getVal(1) == list(1)) => x.rotR.getVal(2)
      case x if(x.rotR.rotR.getVal(0) == list(0) && x.rotR.rotR.getVal(1) == list(1)) => x.rotR.rotR.getVal(2)
      case x if(x.rotR.rotR.rotR.getVal(0) == list(0) && x.rotR.rotR.rotR.getVal(1) == list(1)) => x.rotR.rotR.rotR.getVal(2)
      case _ => 0
    }

    finddice.sum
  }

  def isEqual(dice2:Dice): Boolean={
    val dice = new Dice(index)
    val kindOfDices = List[Dice](dice, dice.rotN, dice.rotS, dice.rotW, dice.rotE, dice.rotN.rotN)

    val torf = for{
      kindOfDice <- kindOfDices
    } yield kindOfDice match{
      case x if(x.index == dice2.index) => true
      case x if(x.rotR.index == dice2.index) => true
      case x if(x.rotR.rotR.index == dice2.index) => true
      case x if(x.rotR.rotR.rotR.index == dice2.index) => true
      case _ => false
    }

    def recConfirm(list: List[Boolean]): Boolean={
      if(list == Nil) false
      else list.head || recConfirm(list.tail)
    }

    recConfirm(torf)
  }

  def getVal(i: Int): Int = index(i)

  def rotR(): Dice =
    new Dice(index).rotS.rotW.rotN

  def rotN(): Dice =
    new Dice(List[Int](index(1), index(5), index(2), index(3), index(0), index(4)))

  def rotS(): Dice =
    new Dice(List[Int](index(4), index(0), index(2), index(3), index(5), index(1)))

  def rotW(): Dice =
    new Dice(List[Int](index(2), index(1), index(5), index(0), index(4), index(3)))

  def rotE(): Dice =
    new Dice(List[Int](index(3), index(1), index(0), index(5), index(4), index(2)))
}

Measured memory_bytes: 43816
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}

ll n;
ll a[200010];
ll b[200010];
int main(){
	scanf("%lld",&n);
	rep(i,0,n){
		scanf("%lld",a+i);
		b[i]=a[i];
	}
	sortup(b,n);
	rep(i,0,n)printf("%lld\n",a[i]<=b[n/2-1]?b[n/2]:b[n/2-1]);
}

Measured memory_bytes: 5216
#include <math.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;

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

const ll INF_ll = 1e17;
const int INF = 1e8;

int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N - K; i++) {
    if (A[i] < A[K + i]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 4744
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int K,T;
int a[101];
int main(){
	cin>>K>>T;
	REP(i,T){
	   cin>>a[i];
	}
        int m=a[0];
        REP(i,T){
            if(m<a[i]){
               m=a[i];
            }
        }
        int x=m-(K-m)-1;
        cout<<max(x,0)<<endl;
	return(0);
}

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

#define ll long long
#define endl '\n'

int sp[100001];

int bsf(vector<vector<int>>& G) {
    queue<int> Q;
    Q.push(1);
    sp[1] = 1;
    int ctr = 1;
    while (!Q.empty()) {
        int t = Q.front();
        Q.pop();
        for (auto& c : G[t]) {
            if (!sp[c]) {
                sp[c] = t;
                Q.push(c);
                ctr++;
            }
        }
    }
    return ctr;
}

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

    int n, m;
    cin >> n >> m;
    int a, b;
    vector<vector<int>> graph(n + 1, vector<int>());
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    int ctr = bsf(graph);
    if (ctr == n) {
        cout << "Yes" << endl;
        for (int j = 2; j <= n; j++) cout << sp[j] << endl;
    } else
        cout << "No" << endl;
    return 0;
}


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

using namespace std;

long long inf=1000000007;

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

	vector<long long> insu;

	for(long long i=2;i*i<=n;i++){
		long long cnt=0;

		while(n%i==0){
			cnt++;
			n/=i;
		}

		if(cnt>0){
			insu.push_back(cnt);
		}
	}

	if(n!=1) insu.push_back(1);

	long long ans=0;

	for(long long i=0;i<(long long)insu.size();i++){
		for(long long j=1;j<=insu.at(i);j++){
			insu.at(i)-=j;
			ans++;
		}
	}

	cout<<ans<<endl;

	return 0;
}


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

using ll = long long;

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;

	int N = 2 * n;
	vector<string> A(N, string(N, '1'));
	for(int i = 0; i < N; i++) cin >> A[i];
	vector<vector<vector<ll> > > dp(N, vector<vector<ll> > (N, vector<ll>(N, 0)));
	for(int i = 0; i < N; i++){
		dp[1][i][i] = 1;
	}
	for(int len = 3; len <= N; len += 2){
		for(int l1 = 1; l1 <= len; l1 += 2){
			for(int l2 = 1; l1 + l2 <= len; l2 += 2){
				int l3 = len - l1 - l2;
				for(int i = 0; i < N; i++){
					for(int f = 0; f < l1; f++){
						for(int g = l1; g < l1 + l2; g++){
							for(int h = l1 + l2; h < l1 + l2 + l3; h++){
								int x1 = (i + f) % N;
								int x2 = (i + g) % N;
								int x3 = (i + h) % N;
								if(A[x1][x3] == '1'){
									dp[len][i][x2] += dp[l1][i][x1]
										* dp[l2][(i + l1) % N][x2]
										* dp[l3][(i + l1 + l2) % N][x3];
								}
							}
						}
					}
				}
			}
		}
	}
	ll ans = 0;
	for(int i = 0; i < N-1; i++){
		if(A[i][N-1] == '1'){
			ans += dp[N-1][0][i];
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
ll INF = 1e6;
bool comp( vector<ll> a, vector<ll> b )
{
    return a[0]<b[0];
}
ll binpow(ll a,ll b) 
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1)
            res*=a;
        a*=a;
        b >>= 1;
    }
    return res;
}
void solve()
{
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
        cout<<"Yes";
    else
        cout<<"No";
}
 
int main()
{
    SPEED;
    ll t = 1;
    //cin>>t;
    while(t--) solve();
   return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int , input().split()))
pos = sorted([i for i in a if i >= 0], reverse=True)
neg = sorted([i for i in a if i < 0], reverse=True)

ans = []
if len(neg) == 0 and len(pos) == 2:
    print(pos[0] - pos[1])
    print(pos[0], pos[1])
    exit()
elif len(pos) == 0:
    tmp = neg[0]
    for i in range(1,len(neg)):
        ans.append([tmp, neg[i]])
        tmp -= neg[i]
    print(tmp)
    [print(*i) for i in ans]
    exit()
elif len(neg) == 0:
    neg.append(pos.pop())

tmp = neg.pop()
while len(pos) > 1:
    a = pos.pop()
    ans.append([tmp, a])
    tmp -= a
neg.append(tmp)

tmp = pos[0]
for i in neg:
    ans.append([tmp, i])
    tmp -= i

print(tmp)
[print(*i) for i in ans]


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

const long long mod=1000000007;

int main(int argc, char const *argv[])
{
	int n;
	string s;
	cin>>n>>s;
	int cnt[30]={};
	for (int i = 0; i < n; ++i)
	{
		++cnt[s.at(i)-'a'];
	}
	long long ans=1LL;
	for (int i = 0; i < 30; ++i)
	{
		ans*=(long long)cnt[i]+1LL;
		ans%=mod;
	}
	ans+=mod-1LL;
	ans%=mod;
	cout<<ans<<endl;
	return 0;
}


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

#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(long long i=0;i<(n);i++)
#define FOR(i,a,b) for(long long i=(a);i<=(b);i++)

int main() {
  float T, X;
  cin >> T >> X;
  float ans = T / X;
  cout << ans << endl;
  return 0;
}


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



class Program
{
    public const int INF = 1 << 25;

    static void Main()
    {
		for (int i = 1; i < 10; i++) {
			for (int j = 1; j < 10; j++) {
				Console.WriteLine("{0}x{1}={2}", i, j, i * j);
			}
		}
	}
}

Measured memory_bytes: 5540
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a < b && b < c)	System.out.printf("Yes\n");
		else	System.out.printf("No\n");
	}
}



Measured memory_bytes: 26292
#include <iostream>

using namespace std;

int main(void) {
    long long A, B, C, K;
    cin >> A >> B >> C >> K;

    if (abs(A - B) > 1000000000000000000) {
        cout << "Unfair" << endl;
    } else if (K % 2 == 0) {
        cout << A - B << endl;
    } else {
        cout << -(A - B) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n, k = [int(i) for i in input().split()]
al = [int(i) for i in input().split()]

index = 0
keiro = []
s_keiro = set()
loop_f = False

for i in range(k):
  index = al[index] - 1
  if index in s_keiro:
    start = keiro.index(index)
    mod = i - start
    loop_f = True
    break
  s_keiro.add(index)
  keiro.append(index)

if loop_f:
  pos = (k-start-1) % mod
  if mod == 1:
    print(keiro[start]+1)
  else:
    print(keiro[start + pos]+1)
else:
  print(keiro[-1] + 1)

Measured memory_bytes: 113676
#include<stdio.h>
void main(){
   int n;
   scanf("%d",&n);
   int a[n],i,judg;
   for(i=0;i<n;i++){
      scanf("%d",&a[i]);
   }
   judg=0;
   for(i=0;i<n;i++){
     if(a[i]%2==0){
        if(a[i]%3==0||a[i]%5==0){
        }else{
           judg++;
        }
     }
   }
   if(judg==0){
      printf("APPROVED");
   }else{
      printf("DENIED");
   }
}



Measured memory_bytes: 1704
#include <algorithm>
#include <cstdio>
#include <queue>

using namespace std ;

typedef long long LL ;
const int N=1e5+10 ;
const LL inf=1e18 ;

struct Edge { int to , nxt , w ; };
Edge e[N<<1] ;
int lst[N] ;
Edge r[N<<1] ;
int rst[N] ;
inline void add ( int u , int v , int w )
{
	static int cnt=0 ;
	e[++cnt]=(Edge){v,lst[u],w},lst[u]=cnt;
	r[cnt]=(Edge){u,rst[v],w},rst[v]=cnt;
}

LL d[N] ;
int tim[N] , v[N] ;
int vis[N] ;
int n , m , p ;
queue<int>Q;
inline LL spfa ( int s , int t )
{
	int i , x , y ;
	for ( i=1 ; i<=n ; i++ ) d[i]=-inf;
	d[s]=0,Q.push(s);
	while ( !Q.empty() )
	{
		x=Q.front(),Q.pop(),v[x]=0;
		for ( i=lst[x],y=e[i].to ; i ; i=e[i].nxt,y=e[i].to )
			if ( d[y]<d[x]+e[i].w && vis[y] )
			{
				d[y]=d[x]+e[i].w;
				if ( !v[y] )
				{
					Q.push(y),tim[y]++,v[y]=1;
					if ( tim[y]>n ) return -1ll ;
				}
			}
	}
	return max(0ll,d[t]);
}

queue<int>q;
inline void bfs ( int s )
{
	int i , x , y ;
	q.push(s),vis[s]=1;
	while ( !q.empty() )
	{
		x=q.front(),q.pop();
		for ( i=rst[x],y=r[i].to ; i ; i=r[i].nxt,y=r[i].to )
			if ( !vis[y] ) vis[y]=1,q.push(y);
	}
}

int main ()
{
	int i , u , v , w ;
	scanf("%d%d%d",&n,&m,&p);
	for ( i=1 ; i<=m ; i++ ) scanf("%d%d%d",&u,&v,&w),add(u,v,w-p);
	bfs(n);
	printf("%lld\n",spfa(1,n));
	return 0 ;
}


Measured memory_bytes: 4352
# A - A?C
# ABC ARC の二つのコンテストが開催される
# ABC → ARC → ABC → ARC → ... と 毎週開催される

# 文字列 S の入力
S = input()
# print(S)

if S == 'ABC':
    print('ARC')
elif S == 'ARC':
    print('ABC')


Measured memory_bytes: 9048
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        static int R;
        static int[] r;
        static bool[] checker = new bool[8];
        static int[][] path;
        static int limit = (int)1e9;
        static int answer = limit;

        public static void Solve()
        {
            var NMR = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var N = NMR[0];
            var M = NMR[1];
            R = NMR[2];
            r = Console.ReadLine().Trim().Split(' ').Select(x => int.Parse(x) - 1).ToArray();
            path = (new int[N][]).Select(x => x = Enumerable.Repeat(limit, N).ToArray()).ToArray();
            for (var i = 0; i < N; i++)
            {
                path[i][i] = 0;
            }
            for (var i = 0; i < M; i++)
            {
                var ABC = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
                var A = ABC[0] - 1;
                var B = ABC[1] - 1;
                var C = ABC[2];
                path[A][B] = path[B][A] = Math.Min(path[A][B], C);
            }

            for (var k = 0; k < N; k++)
            {
                for (var i = 0; i < N; i++)
                {
                    for (var j = 0; j < N; j++)
                    {
                        path[i][j] = Math.Min(path[i][j], path[i][k] + path[k][j]);
                    }
                }
            }

            Dfs();
            Console.WriteLine(answer);
        }

        public static void Dfs(int step = 0, int current = -1, int sum = 0)
        {
            if (step == R)
            {
                answer = Math.Min(answer, sum);
                return;
            }
            for (var next = 0; next < R; next++)
            {
                if (checker[next]) continue;
                checker[next] = true;
                if (current == -1) Dfs(step + 1, next);
                else Dfs(step + 1, next, sum + path[r[current]][r[next]]);
                checker[next] = false;
            }
        }
    }
}


Measured memory_bytes: 35168
#include <stdio.h>

int main(void){
  int hh, ww, h, w;
  scanf("%d %d", &hh, &ww);
  scanf("%d %d", &h, &w);
  
  int sum = hh*ww - (w*hh + h*ww) + h*w;
  printf("%d", sum);
  return 0;
}

  


Measured memory_bytes: 128
a, b, k = map(int, input().split())
while a != b:
    if a > b:
        a = a - b
    else:
        b = b - a
ans = []
for i in range(1, a+1):
    if a%i == 0:
        ans.append(i)
        ans.sort(reverse=True)
print(ans[k-1])

Measured memory_bytes: 3060
n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))

def binary_search(a, x):
    # aがxに含まれていればTrue,そうでなければFalse
    left = -1
    right = len(x)
    mid = (left + right) // 2
    if not x[0] <= a <= x[-1]:
        return False
    
    while True:
        if x[mid] == a:
            return True
        if a < x[mid]:
            right =  mid
            mid = (left + right) // 2
        else:
            left = mid
            mid = (left + right) // 2
        if right == mid or left == mid:
            return False
    return False

s.sort()
cnt = 0
for i in t:
    if binary_search(i, s):
        cnt += 1

print(cnt)


Measured memory_bytes: 16712
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
// dp[i] = TRUE if  first player wins if i stones remaining
 
int main(){
	int n,k;
	cin >> n >> k;
	
	vector<int> v(n);
	for(int i=0;i<n;i++){
		cin >> v[i];
	}
 
	vector<bool>dp(k+1);
	for(int stones = 0;stones <= k; stones++){
		for(int j=0;j<n;j++){
			if(stones >= v[j] && !dp[stones-v[j]]){
				dp[stones] = true;
			}
		}
	}
	
	puts(dp[k] ? "First" : "Second");
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <limits>
#include <map>
#include <vector>
#include <queue> 
#define LL long long
#define ft first
#define sd second
#define mp(x,y) make_pair(x,y)
#define P pair <int ,int>
//#define int LL
using namespace std;
const int N   = 1e5+10;
//const int mod = ;
const int INF =numeric_limits<int >::max();
 
#define rep(i,x,y) for (int i=x;i<=y;++i)
void read(int &x)
{
	x=0;
	char ch=getchar();
	int f=1;
	while (!isdigit(ch)) (ch=='-'?f=-1:0),ch=getchar();
	while ( isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	x*=f;
}
bool f[50][N];
int K;

queue <pair<int ,int > >q;

signed main()
{
	read(K);
//	while (K%2==0) K/=2;
	//while (K%5==0) K/=5;
	rep(i,1,9) if (!f[i][i%K]) q.push(mp(i,i%K)),f[i][i%K]=1;
	while (!q.empty())
	{
		int i=q.front().ft;
		int j=q.front().sd;
		q.pop();
	     rep(nxt,0,9)
	      if (i+nxt<=45)
	      	if (!f[i+nxt][(j*10+nxt)%K]) 
			    q.push(mp(i+nxt,(j*10+nxt)%K)),f[i+nxt][(j*10+nxt)%K]=1;
	}
	rep(i,1,45) if (f[i][0]) return printf("%d",i),0;
	return 0;
}

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

const int maxN = 200010;
typedef long long ll;

int vis[2][maxN];
vector<int> G[2][maxN];

queue<int> Q;
void bfs(int u, int d, int c){
	while(!Q.empty()) Q.pop();
	vis[d][u] = c; Q.push(u);
	while(!Q.empty()){
		u = Q.front(); Q.pop();
		for(int i = 0; i < G[d][u].size(); ++i){
			int v = G[d][u][i];
			if(!vis[d][v]) vis[d][v] = c, Q.push(v);
		}
	}
}

map<ll, int> mp;

int main (){
	int n, k, l, u, v, i, c0 = 0, c1 = 0;
	scanf("%d%d%d", &n, &k, &l);
	while(k--){
		scanf("%d%d", &u, &v);
		G[0][u].push_back(v);
		G[0][v].push_back(u);
	}
	while(l--){
		scanf("%d%d", &u, &v);
		G[1][u].push_back(v);
		G[1][v].push_back(u);
	}
	for(i = 1; i <= n; ++i) if(!vis[0][i]) bfs(i, 0, ++c0);
	for(i = 1; i <= n; ++i) if(!vis[1][i]) bfs(i, 1, ++c1);
	for(i = 1; i <= n; ++i) ++mp[vis[0][i] * 1ll * maxN + vis[1][i]];
	for(i = 1; i <= n; ++i){
		printf("%d", mp[vis[0][i] * 1ll * maxN + vis[1][i]]);
		if(i < n) printf(" ");
	}
	return 0;
}


Measured memory_bytes: 30876
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void msort(int *a,int n,int *tmp){
  if(n<=1) return;
  int m=n/2;
  msort(a,m,tmp);
  msort(a+m,n-m,tmp);
  int i=0;
  int j=m;
  int k=0;
  while(i<m && j<n){
    if(a[i]<=a[j]){
      tmp[k++]=a[i++];
    } else {
      tmp[k++]=a[j++];
    }
  }
  while(i<m) tmp[k++]=a[i++];
  while(j<n) tmp[k++]=a[j++];
  for(i=0;i<n;i++) a[i]=tmp[i];
  return;
}

void run(void){
  int n,h;
  scanf("%d%d",&n,&h);
  int *a=(int *)malloc(sizeof(int)*n);
  int *b=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++){
    scanf("%d%d",a+i,b+i);
  }
  int maxA=0;
  for(i=0;i<n;i++) maxA=MAX(maxA,a[i]);
  msort(b,n,a);
  int k=0;
  i=n-1;
  while(i>=0 && h>0 && b[i]>maxA){
    h-=b[i--];
    k++;
  }
  if(h>0){
    k+=(h+maxA-1)/maxA;
  }
  printf("%d\n",k);
  return;
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <cstdlib>
#include <map>
#include <set>
using namespace std;
#pragma comment(linker, "/stck:1024000000,1024000000")
#define lowbit(x) (x&(-x))
#define max(x,y) (x>=y?x:y)
#define min(x,y) (x<=y?x:y)
#define MAX 100000000000000000
#define MOD 1000
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.1415926535897932384626433832
#define ios() ios::sync_with_stdio(true)
#define INF 1044266558
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
int main()
{
    int a,b;
    char s[110];
    cin>>a>>b>>s;
    bool flag=true;
    for(int i=0;i<=(a+b);i++)
    {
        if(i==a && s[i]!='-') flag=false;
        if(i!=a && !(s[i]>='0' && s[i]<='9')) flag=false;
    }
    puts(flag?"Yes":"No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main()
{
  ifstream fIn("input.txt");
  if (fIn.is_open())
    cin.rdbuf(fIn.rdbuf());

  int N, X;
  cin >> N >> X;
  vector<int> L(N + 1);
  for (int i = 1; i <= N; i++)
    cin >> L.at(i);

  int D = 0, ans = 1;
  for (int i = 2; i <= N + 1; i++)
  {
    D += L.at(i - 1);
    if (D <= X)
      ans++;
  }
  cout << ans;
}


Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	var n, count, prev, p int

	sc.Split(bufio.ScanWords)
	n = next()

	count, prev = 0, math.MaxInt64
	for i := 0; i < n; i++ {
		p = next()
		if p < prev {
			prev = p
			count++
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 2048
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String T = sc.next();
    sc.close();
    int cnt = 0;
    for (int i = 0; i <= 2; i++) {
      if (S.charAt(i) == T.charAt(i)) {
        cnt++;
      }
    }
    System.out.println(cnt);
  }
}

Measured memory_bytes: 23124
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int K = scanner.nextInt();
		scanner.close();
		long svn = 7;
		boolean flag = false;

		int i = 0;
		while (i < K) {
			i++;
			if (svn % K == 0) { flag = true; break; }
			svn = (svn * 10 + 7) % K;
		}

		if (flag) System.out.println(i);
		else System.out.println(-1);
	}
}

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

#define loop(i,a,b) for(ll i=a; i<b; i++)
#define rloop(i,a,b) for(ll i=a; i>b; i--)
#define all(var) var.begin(), var.end()
#define eloop(var) for(auto elem : var)
#define debug(x) cerr<<#x<<" ----> "<<x<<endl;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define TC ll _t; cin>>_t; while(_t--)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define INF 0x7fffffff
#define LINF 2000000000000000007
#define MOD 1000000007
#define MAX 100005
#define sz(var) (ll)var.size()
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<pair<ll, ll> > vpl;

const int maxN= 1e6+5;
int N;
int tree[maxN], ans[maxN], freq[maxN];

typedef struct node{
    int l, r, val, pos;
    bool operator<(const node& n) const{
        if(r != n.r) return r < n.r;
        return val > n.val;
    }
    node(){};
    node(int s, int e, int v, int p){
        l = s;
        r = e;
        val = v;
        pos = p;
    }
}node;
int query(int x);
void update(int x, int val){
    while(x <= N){
        tree[x] += val;
        x += x & -x;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    // TC
    {
        ll q;
        cin>>N>>q;
        vector<node> num;
        loop(i,0,N) {
            ll l;
            cin>>l;
            num.PB(node(i+1, i+1, l, -1));
        }
        loop(i,0,q) {
            ll l,r;
            cin>>l>>r;
            num.PB(node(l,r,0, i));
        }
        sort(all(num));
        loop(i,0,sz(num)) {
            if(num[i].val==0) {
                ans[num[i].pos] = query(num[i].r)-query(num[i].l-1);
            }
            else {
                if(freq[num[i].val] != 0) update(freq[num[i].val], -1);
                update(num[i].l, 1);
                freq[num[i].val] = num[i].l;
            }
        }

        loop(i,0,q) {
            cout<<ans[i]<<'\n';
        }
    }
    return 0;
}

int query(int x){
    int ret = 0;
    while(x > 0){
        ret += tree[x];
        x -= x & -x;
    }
    return ret;
}


Measured memory_bytes: 25372
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg,x.ed
#define rall(x) x.rbg,x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    string s;  cin >> s;
    rep(i,3){
        if(s[i] == s[i+1]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using std::cout;
using std::cin ;

int main(){
  std::string S;
  cin >> S;
  const char *cs = S.c_str(); 
  for(int i = 0;i<S.length();++i){
    if( ((i % 2 == 0) && cs[i] == 'L')
      ||((i % 2 == 1) && cs[i] == 'R') ){
      cout << "No" << std::endl;
      break;
    }
    if(i + 1 == S.length()){
      cout << "Yes" << std::endl;
      break;
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int h[10];
int main(){
	ios::sync_with_stdio(false);
	int k;
	for(int i=1;i<=5;i++)cin>>h[i];
	cin>>k;
	for(int i=1;i<=5;i++){
		for(int j=i+1;j<=5;j++){
			if(abs(h[i]-h[j])<=k)continue;
			cout<<":("<<endl;
			return 0;
		}
	}
	cout<<"Yay!"<<endl;
}

Measured memory_bytes: 256
/*
    Selection Sort
    https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/all/ALDS1_2_B
*/
#include <bits/stdc++.h>
using namespace std;

void SelectionSort(vector<int> &vi) {
    int cnt = 0;
    int len = vi.size();
    for (int i = 0; i < len; i++) {
        int minj = i;
        for (int j = i; j < len; j++) {
            if (vi[j] < vi[minj]) {
                minj = j;
            }
        }
        swap(vi[i], vi[minj]);
        if (i != minj) {
            cnt++;
        }
    }

    // result
    for (size_t i = 0; i < vi.size(); i++) {
        cout << vi[i];
        cout << ((i != vi.size() - 1) ? " " : "\n");
    }
    cout << cnt << endl;
}

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

    int n;
    cin >> n;
    vector<int> vi(n);

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

    SelectionSort(vi);
}


Measured memory_bytes: 3224
n = gets.to_i
as = gets.split.map(&:to_i)
counts = as.each_with_object(Hash.new(0)) do |a, h|
  h[a] += 1
end

ans = counts.inject(0) do |r, (n, c)|
  r += n > c ? c : (c - n)
end

puts ans


Measured memory_bytes: 25292
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


int main() {
    
    string s,t;
    cin >> s >> t;

    t.pop_back();
    if(s == t) {
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }

    
 return 0;
}


Measured memory_bytes: 3628
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 22;
char dn[dm], * di = dn;
inline void putint(int X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

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


	int N = getint();
	int S[600000];
	rep(i, N) S[i + N] = getint();
	rep(i, N) S[i] = getint();
	int A0 = S[N];
	int B0 = S[0];

	if (N == 1) {
		printf("%d %d\n", 0, A0 ^ B0);
		Would you please return 0;
	}

	rep(i, N - 1) S[i] ^= S[i + 1];
	S[N - 1] ^= B0;
	for (int i = N; i < N + N - 1; i++) {
		S[i] ^= S[i + 1];
		S[i + N] = S[i];
	}
	S[N + N - 1] ^= A0;
	S[N + N + N - 1] = S[N + N - 1];

	int Z[600000];
	N = 3 * N;
	Z[0] = N;
	int i = 1;
	int j = 0;
	while (i < N) {
		while (i + j < N && S[j] == S[i + j]) j++;
		Z[i] = j;
		if (j == 0) {
			i++;
			continue;
		}
		int k = 1;
		while (i + k < N && k + Z[k] < j) {
			Z[i + k] = Z[k];
			k++;
		}
		i += k;
		j -= k;
	}
	N /= 3;
	
	int AB = A0 ^ B0;
	rep(i, N) {
		if (Z[i + N] >= N) {
			putint(i);
			putint(AB);
		}
		AB ^= S[i + N];
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 12288
#include<bits/stdc++.h>
#define forn(i, n) for(int i=0;i<(int)(n);i++)
#define for1(i, n) for(int i=1;i<=(int)(n);i++)
#define fore(i, l, r) for(int i=(int)(l);i<=(int)(r);i++)
#define ford(i, n) for(int i=(int)(n)-1;i>=0;i--)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"
#define MAX 1000000007
using namespace std;
typedef int64_t ll;
typedef vector<int> vi;
typedef vector<int64_t> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
int h[100001];
vector<int> dp(100000,-1);
int f(int i,int n){
if(i==n)return 0;
if(dp[i]!=-1)return dp[i];
int cost=abs(h[i+1]-h[i])+f(i+1,n);
if(i+2<=n)
cost=min(cost,abs(h[i+2]-h[i])+f(i+2,n));
return dp[i]=cost;}
int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
	cin>>h[i];
	}
int ans=f(1,n);
cout<<ans;

	return 0;
}



Measured memory_bytes: 10200
#include<cstdio>
#include<algorithm>

using namespace std;

const int MAX_N = 300010;

int n;
int a[MAX_N];
int dp[MAX_N];
int sum[2][MAX_N];
int s[2];

int quadratic_dp ()
{
	dp[0] = (1 << 30);
	for (int i = 1; i * 2 <= (n + 1); i ++)
	{
		dp[i] = -(1 << 30); /// infinty
		for (int j = 0; j < i; j ++)
        	dp[i] = max (dp[i], min (dp[j], sum[1][i * 2 - 1] - sum[1][j * 2] - (sum[0][i * 2 - 1] - sum[0][j * 2])));
	}

	return dp[(n + 1) / 2];
}

bool check (int x)
{
    int sum = 0;
    for (int i = 1; i <= n; i += 2)
    {
        if (sum >= x)
            sum = max (sum - a[i - 1] + a[i], a[i]);
        else
            sum = sum - a[i - 1] + a[i];
    }
    return sum >= x;
}

int nlogn ()
{
    int l, r, mid;

    l = -1;
    r = s[1] + 1;
    while (r - l > 1)
    {
        mid = (l + r) >> 1;

        if (check (mid))
            l = mid;
        else
            r = mid;
    }

    return l;
}

int main ()
{
	scanf ("%d", &n);
	for (int i = 1; i <= n; i ++)
		scanf ("%d", &a[i]);

	for (int i = 1; i <= n; i ++)
		s[i & 1] += a[i];

	if (!(n & 1))
	{
		printf ("%d %d\n", max (s[0], s[1]), min (s[0], s[1]));
		return 0;
	}

	sum[0][0] = sum[1][0] = 0;
	for (int i = 1; i <= n; i ++)
	{
		sum[0][i] = sum[0][i - 1];
		sum[1][i] = sum[1][i - 1];
		sum[i & 1][i] += a[i];
	}

	int ans;

	///ans = quadratic ();
	ans = nlogn ();

	printf ("%d %d\n", s[0] + ans, s[1] - ans);
	return 0;
}


Measured memory_bytes: 4864
#include <iostream>
#include <algorithm>

#define Nmax int(1e5 + 1)
using namespace std;

int Max,N,s,Hans;
int a[Nmax],L[Nmax],R[Nmax];

int main() {
    ios_base::sync_with_stdio(0);
    cin >> N;
    for(int i = 1; i <= N; ++i)
        cin >> a[i];
    for(int i = 1; i <= N; ++i)
        L[i] = __gcd(L[i - 1],a[i]);
    for(int i = N; i >= 1; --i)
        R[i] = __gcd(R[i + 1],a[i]);
    for(int i = 1; i <= N; ++i)
        Hans = max(Hans,__gcd(L[i - 1],R[i + 1]));
    cout << Hans;
    return 0;
}
/**

5
2 4 7 6 8
L[i] = 2 2 1 1 1
R[i] = 1 1 1 2 2
*/


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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int32_t main() {
    //ios::sync_with_stdio(false); cin.tie(nullptr);

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

    if (b >= a + 2) {
        k -= a;
        if (k >= 1) {
            int n = (k - 1) / 2;
            int ans = n * (b - a);
            ans += (k + 1) % 2;
            cout << b + ans << "\n";
        } else {
            cout << 1 + k + a << "\n";
        }
    } else {
        cout << 1 + k << "\n";
    }

    return 0;
}


Measured memory_bytes: 256