akhauriyash/Code-Regression huggingface dataset:
package main

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

// 文字列を1行取得
func StrStdin() (stringReturned string) {
    scanner := bufio.NewScanner(os.Stdin)

    scanner.Scan()
    stringInput := scanner.Text()

    stringReturned = strings.TrimSpace(stringInput)
    return
}

// 整数値1つ取得
func IntStdin() (int, error) {
    stringInput := StrStdin()
    return strconv.Atoi(strings.TrimSpace(stringInput))
}

// 空白や空文字だけの値を除去したSplit()
func SplitWithoutEmpty(stringTargeted string, delim string) (stringReturned []string) {
    stringSplited := strings.Split(stringTargeted, delim)

    for _, str := range stringSplited {
        if str != "" {
            stringReturned = append(stringReturned, str)
        }
    }

    return
}

// デリミタで分割して文字列スライスを取得
func SplitStrStdin(delim string) (stringReturned []string) {
    // 文字列で1行取得
    stringInput := StrStdin()

    // 空白で分割
    // stringSplited := strings.Split(stringInput, delim)
    stringReturned = SplitWithoutEmpty(stringInput, delim)

    return
}

// デリミタで分割して整数値スライスを取得
func SplitIntStdin(delim string) (intSlices []int, err error) {
    // 文字列スライスを取得
    stringSplited := SplitStrStdin(" ")

    // 整数スライスに保存
    for i := range stringSplited {
        var iparam int
        iparam, err = strconv.Atoi(stringSplited[i])
        if err != nil {
            return
        }
        intSlices = append(intSlices, iparam)
    }
    return
}

//////////////////////////////////////////
// 使い方の例
//////////////////////////////////////////
func main() {
    // 入力例)
    // alphonse
    //      alphonse
    //    alphonse      (後ろにも空白がある)
    // 出力)
    // alphonse
    // p := StrStdin()
    // fmt.Println(p)

    // 入力例)
    // 123
    //        123
    //     123          (後ろにも空白がある)
    // 出力)
    // 123
    // i, err := IntStdin()
    // if err != nil {
        // paizaなどではエラー処理は不要かもしれない
    //     fmt.Println(err)
    // }
    // fmt.Println(i)

    // 入力例)
    // foo bar baz
    //    foo     bar   baz
    // 出力)
    // foo
    // bar
    // baz
    pp, err := SplitIntStdin(" ")
    if err != nil {
        fmt.Println(err)
    }
    var product = 1
    for _, s := range pp {
        // fmt.Printf("%d\n", s)
        product *=s
    }
    // fmt.Println(product)
    if product%2==0{
      fmt.Println("Even")
    }else{
      fmt.Println("Odd")
    }
    // 入力例)
    // 123 042 9999
    //     123   042       9999
    // 出力)
    // 123
    // 42
    // 9999
    // ii, eerr := SplitIntStdin(" ")
    // if eerr != nil {
    //     fmt.Println(eerr)
    // }
    // for _, i := range ii {
    //     fmt.Printf("%d\n", i)
    // }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  
  vector<int> A(N);
  vector<int> D(200000);
for (int i = 0; i < N; i++) {
  cin >> A.at(i);
  D.at(A.at(i))++;
}
  
  long S=0;
  for(int i=0;i<N;i++){
    S=S+A.at(i);
  }
  
  int Q;
  cin>>Q;
  
 // int sw=0;
  
  vector<int> B(Q);
  vector<int> C(Q);
for (int i = 0; i < Q; i++) {
  cin >> B.at(i)>>C.at(i);
  S=S+(C.at(i)-B.at(i))*D.at(B.at(i));
  D.at(C.at(i))=D.at(C.at(i))+D.at(B.at(i));
  D.at(B.at(i))=0;
  cout<<S<<endl;
  
}
  
    
}




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

int main(void){
    int n, m;
    cin >> n;
    vector<string> blue(n);
    for (int i = 0; i < n; i++){
        cin >> blue[i];
    }
    cin >> m;
    vector<string> red(m);
    for (int i = 0; i < m; i++){
        cin >> red[i];
    }
    
    int max_cnt = 0;
    for (auto _b : blue){
        int cnt = 0;
        for (auto b : blue){
            if (b == _b) cnt++;
        }
        for (auto r : red){
            if (r == _b) cnt--;
        }
        if (cnt > max_cnt){
            max_cnt = cnt;
        }
    }
    cout << max_cnt << endl;
}


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

int main(){
    int N,X,sum=0;
    cin>>N>>X;
    vector<int>m(N);

    for(int i=0;i<N;i++){
        cin>>m.at(i);
        sum+=m.at(i);
    }
    sort(m.begin(),m.end());
    cout<<(X-sum)/m.at(0)+N<<endl;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int a[12][10],j, i, n, b, f, r, v, k,l,m;
	for (i = 0; i < 12; i++) {
		for (j = 0; j < 10; j++) {
			a[i][j] = 0;
		}
	}
	cin >> n;
	for (k = 0; k < n; k++) {
		cin >> b >> f >> r >> v;

		if (b == 1) {
			a[f - 1][r - 1] += v;
		}
		else if (b == 2) {
			a[2 + f][r - 1] += v;
		}
		else if (b == 3) {
			a[5 + f][r - 1] += v;
		}
		else if (b == 4) {
			a[8 + f][r - 1] += v;
		}
	}
	for (l = 0; l < 12; l++) {
		if (l%3==0&&l!=0) {
			cout  << "####################"<<endl;
		}
		for (m = 0; m < 10; m++) {
			cout <<" "<< a[l][m];
		}
		
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3108
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int cn2 = 0;
		int count= 0;
		int L[] = new int [2*N];
		int TMP;
		for(int cn = 0 ; cn < 2*N;cn++)
		{
			L[cn] = sc.nextInt();
		}
		cn2 = L.length;
		Arrays.sort(L);
		while(true)
		{
			TMP = cn2 % 2;
			if(TMP == 0)
			{
				count = count + L[cn2 - 2];
				cn2 = cn2 - 2;
			}
			else
			{
				count = count + L[cn2 - 1];
				cn2 = cn2 - 1;
			}
			if(cn2 == 0)
			{
				break;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 9684
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
	

		Scanner n =  new Scanner(System.in);
		String N =new String();
		N = n.next();			//個数の入力

		
		String W =new String();
		W = n.next();			//最大の入力

		
		int A = 0;
		int B = 0; 
		
		if(N.equals("A")){
			A = 0;
		}if(N.equals("B")){
			A = 1;
		}if(N.equals("C")){
			A = 2;
		}if(N.equals("D")){
			A = 3;
		}if(N.equals("E")){
			A = 4;
		}if(N.equals("F")){
			A = 5;
		}
		if(W.equals("A")){
			B = 0;
		}if(W.equals("B")){
			B = 1;
		}if(W.equals("C")){
			B = 2;
		}if(W.equals("D")){
			B = 3;
		}if(W.equals("E")){
			B = 4;
		}if(W.equals("F")){
			B = 5;
		}
		
		
		if(A > B){
			System.out.println(">");
		}else if(A < B){
			System.out.println("<");
		}else {
			System.out.println("=");
		}
		
	}
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        int n = sc.nextInt();
        int a = sc.nextInt();

        System.out.println(n % 500 - a <= 0 ? "Yes" : "No");
    }
}

Measured memory_bytes: 21588
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<string, string> sP;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second



int main() {
	char c;
	cin >> c;
	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
		cout << "vowel" << endl;
	}
	else cout << "consonant" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

int main() {
    int N;
    scanf("%d", &N);
    int num = (int)pow(2, N);
    multiset<int> line, que;
    for (int i = 0; i < num; i++) {
        int tmp;
        scanf("%d", &tmp);
        que.insert(tmp);
    }
    line.insert(*que.rbegin());
    que.erase(prev(que.end()));
    for (int i = 0; i < N; i++) {
        auto cur_it = line.rbegin();
        vector<int> nline;
        while (cur_it != line.rend()) {
              auto tmp_it = que.lower_bound(*cur_it);
              if (tmp_it == que.begin()) break;
              cur_it++;
              tmp_it = prev(tmp_it);
              nline.push_back(*tmp_it);
              que.erase(tmp_it);
        }
        if ((int)line.size() != (int)nline.size()) {
           return !printf("No\n");
        }
        for (int i = 0; i < (int)nline.size(); i++) {
            line.insert(nline[i]);
        }
    }
    puts("Yes");

    return 0;
}


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

int main() {
  int n;
  long long d;
  cin>>n>>d;
  d *= d;
  int ans = 0;
  long long x, y;
  while(n--){
    cin>>x>>y;
    long long sq = x*x + y*y;
    if(d >= sq) ans++;
  } 
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 3664
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
string S, T;
int x[100], n, m, L[3], R, M;
int main() {
	while (true) {
		cin >> S; n = 0; m = 0; if (S == "#") { break; }M = 0;
		for (int i = S.size() - 1; i >= 0; i--) 
		{
			T += S[i];
		}

		S = T; T = "";

		while (n < S.size())
		{
			if (S[n] == 'h')
			{
				n += 5; x[m] = 0;
			}
			else
			{ 
				n += 4; x[m] = 1;
			}
			m++;
		}

		L[0] = 0;
		L[1] = 90 * (1 << 20);
		
		if (x[0] == 0) { L[0] = 0; }
		else { L[0] = L[1]; }

		for (int i = 1; i < m; i++)
		{
			L[1] /= 2;
			if (x[i] == 1) { L[0] += L[1]; }
			else { L[0] -= L[1]; }
			if (L[0] < 0) { L[0] = 0; }
			if (L[0] > 90 * (1 << 20)) { L[0] = 90; }
		}
		R = L[0];
		M = (1 << 20);
		while (R % 2 == 0 && M >= 2)
		{
			R /= 2; M /= 2;
		}
		cout << R; if (M >= 2) { cout << '/' << M; }cout << endl;
	}
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
    LLI n; cin>>n;
    LLI a[100000];
    LLI sum=0;
    FOR(i,0,n){
        cin>>a[i];
        sum+=a[i];
    }
    bool flag=true;
    if(sum%(n*(n+1)/2)==0){
        sum/=(n*(n+1)/2);
    }else{
        flag=false;
    }
    FOR(i,0,n){
        if(a[(i+1)%n]-a[i]-sum>0||abs(a[(i+1)%n]-a[i]-sum)%n!=0) flag=false;
    }
    YES(flag);
}


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

using namespace std;

int main(){
    int a;
    char s[11];
    cin >> a;
    cin >> s;
    if(a >= 3200){
        cout << s << endl;
    }
    else{
        cout << "red" << endl;
    }
    return 0;
}

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

int table[1000010];
int table2[1000010];

int main(void) {
	int y, z;
	int e;

	for(int i = 0, y = 0; i < 1000010; i++) {
		while(y * y <= i) y++;
		table[i] = (y - 1) + (i - (y - 1) * (y - 1));
	}

	for(int i = 0, z = 0; i < 1000010; i++) {
		table2[i] = table[i];
		for(z = 0; z * z * z <= i; z++) {
			if(table[i] > z + table[i - z * z * z]) {
				if(table2[i] > z + table[i - z * z * z])
					table2[i] = z + table[i - z * z * z];
			}
		}
	}

	while(cin >> e, e) {
		cout << table2[e] << endl;
	}
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll n;
ll k;
ll m;
vl u,v;

int main(){
  cin >> n >> k;
  if((n-1)*(n-2)/2 < k){
    cout << -1 << endl;
    return 0;
  }
  for(ll i = 1;i < n;i++){
    m++;
    u.push_back(i);
    v.push_back(n);
  }
  k -= (n-1)*(n-2)/2;
  for(ll i = 1;i < n;i++){
    for(ll j = i+1;j < n;j++){
      if(k < 0){
        m++;
        u.push_back(i);
        v.push_back(j);
        k++;
      }else{
        break;
      }
    }
  }
  cout << m << endl;
  for(ll i = 0;i < m;i++){
    cout << u[i] << " " << v[i] << endl;
  }
}


Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
	int b1,b2,b3;
	scanf("%d%d%d",&b1,&b2,&b3);
	if(b1==1&&b2==0&&b3==0)
	printf("Close\n");
	else if(b1==0&&b2==1&&b3==0)
	printf("Close\n");
	else if(b1==1&&b2==1&&b3==0)
	printf("Open\n");
	else if(b1==0&&b2==0&&b3==1)
	printf("Open\n");
	else
	printf("Close\n");
	return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (LLONG_MAX)
#define MOD (1000000007)
#define MAX (100000)
#define pii pair<int, int>

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

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
T1 mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  T1 tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

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

void Main(){
  int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
  A--; B--; C--; D--;
  string S; cin >> S;
  string res = "Yes";
  if(C < D){
    while(true){
      bool ok = false;
      if(B == D){
        S[B] = '#';
        break;
      }
      if(S[B + 1] == '.'){
        B += 1;
        ok = true;
      }
      else if(B + 2 <= D){
        if(S[B + 2] == '.'){
          B += 2;
          ok = true;
        }
      }
      if(!ok){
        res = "No";
        break;
      }
    }
    while(true){
      bool ok = false;
      if(A == C){
        S[A] = '#';
        break;
      }
      if(S[A + 1] == '.'){
        A += 1;
        ok = true;
      }
      else if(A + 2 <= C){
        if(S[A + 2] == '.'){
          A += 2;
          ok = true;
        }
      }
      if(!ok){
        res = "No";
        break;
      }
    }
  }else{
    bool ok1 = false;
    rep(i, B, D + 1){
      if(S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.'){
        ok1 = true;
        S[i] = '#';
      }
    }
    if(!ok1){
      res = "No";
    }else{
      while(true){
        bool ok = false;
        if(A == C){
          S[A] = '#';
          break;
        }
        if(S[A + 1] == '.'){
          A += 1;
          ok = true;
        }
        else if(A + 2 <= C){
          if(S[A + 2] == '.'){
            A += 2;
            ok = true;
          }
        }
        if(!ok){
          res = "No";
          break;
        }
      }
    }
  }
  cout << res << endl;
}

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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 592
//
//  main.cpp
//  C_ColorfulLeaderboard
//
//  Created by user1 on 2017/06/10.
//  Copyright © 2017年 user1. All rights reserved.
//


#include <iostream>
#define COLOR  8
int N;
int a[100 + 1];

int GRAY =399;
int BROWN =799;
int GREEN =1199;
int SKYBLUE =1599;
int BLUE =1999;
int YELLOW =2399;
int ORANGE =2799;
int RED =3199;

int color[8] = {399, 799, 1199, 1599,1999,2399,2799,3199};
int hitFrag[8] ={};
void solve(){
    std::cin >> N;
    int colorCount= 0;
    int multiColorCount = 0;
    int i;
    for(i=1; i<N+1; i++){
        std::cin >> a[i];
        int cFlag = 0;
        for(int cind = 0; cind < 8; cind++){
            if(a[i] <=  color[cind]){
                
                if(!hitFrag[cind]){
                    colorCount ++;
                    hitFrag[cind] = 1;
                }
                cFlag = 1;
                break;
            }
        }
        if(!cFlag){
            multiColorCount++;
        }
    }

    //printf("%d %d\n", colorCount==0 ? 1:colorCount, ((colorCount+multiColorCount)< COLOR ? colorCount+multiColorCount: COLOR));
    printf("%d %d\n", colorCount==0 ? 1:colorCount, colorCount+multiColorCount);
    
}

int main(int argc, const char * argv[]) {
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int N;
	while(cin >> N){
		int count=0;
		for(int a=0;a<=9;a++){
			for(int b=0;b<=9;b++){
				for(int c=0;c<=9;c++){
					for(int d=0;d<=9;d++){
						if(N == (a+b+c+d)){
							count ++;
						}
					}
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxn = 510;

int main()
{
    int N,i;
    while (cin >> N >> i) {
        const int ans = N-i+1;
        cout << ans  << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
letters=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
str = sys.stdin.read()

for i in letters:
    print('%s : %d' %(i, str.casefold().count(i)))


Measured memory_bytes: 5556
n, m = map(int, input().split())
P = list(map(int, input().split()))
X = [list(map(int, input().split())) for i in range(m)]

for i in range(n):
    P[i] -= 1
for i in range(m):
    for j in range(2):
        X[i][j] -= 1

M = [[] for i in range(n)]

for i in range(m):
    M[X[i][0]].append(X[i][1])
    M[X[i][1]].append(X[i][0])

G = [0] * n
clr = 0

for i in range(n):
    if G[i] == 0 and len(M[i]) > 0:
        clr += 1
        G[i] = clr
        
        Q = M[i][:]
        st = 0
        while st < len(Q):
            if G[Q[st]] == 0:
                G[Q[st]] = clr
                for item in M[Q[st]]:
                    Q.append(item)

            st += 1

# print(G)

ans = 0
for i in range(n):
    if G[i] == 0 and i == P[i]:
        ans += 1

G2 = [[[], []] for i in range(clr+1)]

for i in range(n):
    G2[G[i]][0].append(i)
    G2[G[i]][1].append(P[i])
# print(G2)
# print(ans)

for i in range(1, clr+1):
    ans += len(G2[i][0]) * 2 - len(set(G2[i][0] + G2[i][1]))

print(ans)

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

int main(){
	int a, b;
	string s;
	cin >> a >> b;
	cin >> s;
	for (int i=0; i<s.length(); i++){
		if (i==a){
			if (s[i]!='-'){
				printf("No\n");
				return 0;
			}
		}
		else if (s[i]<'0' || s[i]>'9'){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    string s;
    string t;
    cin >> s >> t;
    int cnt = 0;
    rep(i, 3)
    {
        if (s[i] == t[i])
            cnt++;
    }
    OP(cnt);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ll dp[111][111111];
const int C = 1000*100+100;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	vector<ii> vec;
	int n; ll w; cin>>n>>w;
	vec.pb(mp(-1,-1));
	for(int i=0;i<n;i++)
	{
		ll x,y; cin>>x>>y; vec.pb(mp(x,y));
	}
	for(int j=1;j<=C;j++)
	{
		dp[0][j]=ll(1e18);
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=C;j++)
		{
			dp[i][j]=dp[i-1][j];
			if(j-vec[i].se>=0) dp[i][j]=min(dp[i][j],dp[i-1][j-vec[i].se]+vec[i].fi);
		}
	}
	ll ans=0;
	for(ll j=0;j<=C;j++) 
	{
		if(dp[n][j]<=w) ans=max(ans,j);
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 88192
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C
{
	public class Program
	{
		static void Main(string[] args)
		{
			var N = Console.ReadLine();
			var line = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
			Console.WriteLine(GoToSchoolOrder(line));
		}

		public static string GoToSchoolOrder(int[] input)
		{
			var order = new int[input.Length+1];
			for(int i=0; i<input.Length; i++)
			{
				order[input[i]] = i+1;
			}
			var result = string.Join(" ", order).Substring(2);
			return result;
		}
	}
}


Measured memory_bytes: 32604
n, u, v, *L = map(int, open(0).read().split())
dist_f_v = [-1] * n
con = [[] for _ in range(n)]
for s, t in zip(*[iter(L)] * 2):
	con[s - 1].append(t - 1)
	con[t - 1].append(s - 1)
dist_f_v[v - 1] = 0
q = [v - 1]
while q:
	cur = q.pop()
	for nxt in con[cur]:
		if dist_f_v[nxt] < 0:
			dist_f_v[nxt] = dist_f_v[cur] + 1
			q.append(nxt)
dist_f_u = [-1] * n
dist_f_u[u - 1] = 0
q = [u - 1]
m = 0
while q:
	cur = q.pop()
	m = max(m, dist_f_v[cur])
	for nxt in con[cur]:
		if dist_f_u[nxt] > -1:
			continue
		if dist_f_u[cur] + 1 < dist_f_v[nxt]:
			dist_f_u[nxt] = dist_f_u[cur] + 1
			q.append(nxt)
		elif dist_f_u[cur] + 1 == dist_f_v[nxt]:
			dist_f_u[nxt] = dist_f_u[cur] + 1
print(m - 1)


Measured memory_bytes: 37988
n,k=map(int,input().split())
h=[]
for i in range(n):
    h.append(int(input()))

#n=5
#k=3
#h=[10,15,11,14,12]
#h=[5,7,5,7,7]

h.sort()
hd=[]
for i in range(n-k+1):
#    print(i,i+k-1,n-k)
    hd.append(h[i+k-1]-h[i])
print(min(hd))


Measured memory_bytes: 11288
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
// vector push_back push front top empty pop make_pair long long insert begin end  
typedef long long ll;
typedef vector<int> vi;
typedef vector<pair <int,int> > vpi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define B begin()
#define RB rbegin()
#define E end()
#define RE rend()
#define Z size()
#define REP(i,a,b) for (int i = a; i < b; i++)
#define L length()
#define show(a) cerr << " *** " << a << endl;
#define show1(a) cerr << " /// " << a << endl;
#define valid(a,b,c) (a >= b && a < c ? 1 : 0)
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int mod = (int)1e9 + 7;
void ads(ll &a, ll b){a += b;if (a >= mod)a -= mod;}
void mis(ll &a, ll b){a -= b;if (a >= mod)a -= mod; if (a < 0)a += mod;}
ll gcd(ll a, ll b) {return (b==0? a:gcd(b,a%b));}
ll egcd(ll a, ll b, ll & x, ll & y) {if (a == 0){x = 0;y = 1;return b;}ll x1, y1;ll d = egcd(b % a, a, x1, y1);x = y1 - (b / a) * x1;y = x1;return d;}
ll mbinp(ll a, ll b){a %= mod;if (b == 0)return 1;ll ans = mbinp(a, b/2);ll tmp = (ans * ans) % mod;if (b % 2)return ((tmp * a) % mod);return ((tmp) % mod);}
ll binp(ll a, ll b){if (b == 0)return 1;ll ans = binp(a, b/2);ll tmp = (ans * ans);if (b % 2)return ((tmp * a));return ((tmp));}
string str;
const int maax = 10 * 1000 + 50;
ll dp[maax][110][2];
int d;

ll solve(int pos, int rem, int f)
{
	if (pos == str.L)
		return (rem == 0 ? 1 : 0);
	if (dp[pos][rem][f] != -1)
		return (dp[pos][rem][f]%mod);
	int lim = (f == 0 ? str[pos]-'0' : 9);
	ll res = 0;
	if (f == 0)
		REP(i,0,lim+1)
			ads(res,solve(pos+1,(rem+i)%d,(i != lim)));
	else
		REP(i,0,10)
			ads(res,solve(pos+1,(rem+i)%d,1));
	return (dp[pos][rem][f] = res);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> str;
	cin >> d;
	memset(dp,-1,sizeof(dp));
	cout << (solve(0,0,0) - 1 +mod)%mod;	
}


Measured memory_bytes: 18304
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */
 
    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(ll i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(ll i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    #define te  ll ti;   cin >> ti;  while(ti--) solve();  
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 100100;

    void solve() {
        ll sum = 0, x = 0, val = 0;
        ll a[5];
        rep(i, 5) {
            cin >> a[i];
            if((ceil(a[i]*1.0/10)*10 - a[i]) > x) x = (ceil(a[i]*1.0/10)*10 - a[i]), val = a[i]; 
        }
        rep(i, 5) sum+=ceil(a[i]*1.0/10)*10;
        sum+=val - ceil(val*1.0/10)*10;
        cout << sum << endl;
    }
 
    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
     /*
      #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        #endif
     */
      //te
      solve();
      return 0;
    } 

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int topping = 0;
  for (auto& c : s) {
    if (c == 'o') topping++;
  }
  cout << 700 + 100 * topping << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



int h, w;
char c[300][300];

int cost[300][600];

int calc(int x) {
	int dp[301][301];
	rep(i, h+1)rep(j, h+1)dp[i][j] = INF;
	dp[0][0] = 0;

	memset(cost, 0, sizeof(cost));
	rep(i, h)rep(j, h)if (c[i][x] == c[j][x + 1])cost[i][i - j + 300]++;
	for (int i = h - 2; i >= 0;i--)rep(j, 600)cost[i][j] += cost[i + 1][j];


	rep(i,h)rep(j,h){
		int _cost = cost[i][i - j + 300];

		dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + _cost);
		dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + _cost);
	}
	int res = INF;
	rep(i, h + 1)res = min(res, dp[h][i]);
	rep(i, h + 1)res = min(res, dp[i][h]);
	return res;
}


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

	cin >> h >> w;
	rep(i, h)rep(j, w)cin >> c[h-1-i][j];
	int ans = 0;
	rep(i, w - 1) {
		ans += calc(i);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main(){
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  if(s < t)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


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

using namespace std;

int main() {
    int N;
    cin >> N;
    set<string>s;
    while(N--){
        string buf;
        cin >> buf;
        s.insert(buf);
    }
    if(s.size() == 4) cout << "Four" << endl;
    else{
        if(s.find("Y") != s.end()) cout << "Four" << endl;
        else cout << "Three" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/**
 * 
 */
import java.util.*;
/**
 * @author akira
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n;
		n = scan.nextInt();
		ArrayList<fisher> alf = new ArrayList<fisher>();
		for(int i = 0;i < n;i++){
			alf.add(new fisher(scan.nextInt(),scan.nextInt()));
		}
		Collections.sort(alf,new Compare());
		System.out.println(alf.get(0).a + " " + alf.get(0).v);
	}

}

class fisher{
	int a;
	int v;
	fisher(int arg1,int arg2){
		a = arg1;
		v = arg2;
	}
}

class Compare implements Comparator<fisher>{
	public int compare(fisher f1,fisher f2){
		if(f1.v < f2.v){
			return 1;
		}else if(f1.v > f2.v){
			return -1;
		}else{
			if(f1.a < f2.a){
				return -1;
			}else{
				return 1;
			}
		}
	}
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define int long long int 
#define mp make_pair
#define pb push_back
#define f first
#define s second



int32_t main()
{
     IOS; 
     
     vector < pair <pair<int,int>,pair<int,int> > > v;
     
     int n,m,a[502][502];
     
     cin>>n>>m;
     
     for(int i=1;i<=n;i++)
     {
          for(int j=1;j<=m;j++)
          cin>>a[i][j];
     }
     
     for(int i=1;i<=n;i++)
     {
          for(int j=1;j<m;j++)
          {
               if(a[i][j]%2!=0)
               {
                    
                  int k;
                  for( k=j;k<m;k++)
                  {
                        v.pb(mp(mp(i,k),mp(i,k+1)));
                       if(a[i][k+1]%2!=0)
                       {
                        break;   
                       }
                  }
                  j=k+1;
               }
          }
          
     }
     for(int i=1;i<=n;i++)
     {
          int cnt=0;
          for(int j=1;j<m;j++)
          {
               if(a[i][j]%2!=0)
               cnt++;
          }
          if(cnt%2!=0)
               a[i][m]+=1;
     }
     //cout<<a[1][3]<<" "<<a[2][3]<<endl;
     for(int i=1;i<n;i++)
     {
          if(a[i][m]%2!=0)
          {
               int j;
               for(j=i;j<n;j++)
               {
                    v.pb(mp(mp(j,m),mp(j+1,m)));
                    if(a[j+1][m]%2!=0)
                         break;
               }
               //cout<<i<<endl;
               i=j+1;
          }
     }
     
     cout<<v.size()<<endl;
     
     for(int i=0;i<v.size();i++)
          cout<<v[i].f.f<<" "<<v[i].f.s<<" "<<v[i].s.f<<" "<<v[i].s.s<<endl;
     
     return 0;
}

Measured memory_bytes: 8432
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <random>
 
using namespace std;
 
using i32 = int;
using i64 = long long;
using u32 = unsigned;
using u64 = unsigned long long;
 
#define rep(i, n) for (i32 i = 0; i < (n); ++i)
#define repr(i, n) for (i32 i = ((n)-1); i >= 0; --i)
#define urep(i, n) for (u32 i = 0; i < (n); ++i)
#define urepr(i, n) for (u32 i = ((n)-1); i >= 0 && i < (n); --i)
#define all(v) v.begin(), v.end

int main() {
    i32 N;
    cin >> N;
    vector<i32> p(N + 1);
    p[0] = 0;
 
    rep(i, N) {
        cin >> p[i + 1];
    }

    bool swapped = false;
    rep(i, N) {
        if (p[i+1] < p[i]) {
            if (swapped) {
                puts("NO");
                return 0;
            }
            const auto res = std::find(p.begin() + (i + 1), p.end(), i);
            if (res != p.end()) {
                std::swap(p[res - p.begin()], p[i]);
                swapped = true;
            } else {
                puts("NO");
                return 0;
            }
        }
    }
    puts("YES");
    return 0;
}


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

int main() {
    int A[3][3], N, b[10];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> A[i][j];
        }
    }
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> b[i];
    }

    int flag[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            flag[i][j] = 0;
        }
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (b[i] == A[j][k]) {
                    flag[j][k] = 1;
                }
            }
        }
    }

    bool bingo = false;
    for (int i = 0; i < 3; i++) {
        if (flag[i][0] * flag[i][1] * flag[i][2]) {
            bingo = true;
        }
        if (flag[0][i] * flag[1][i] * flag[2][i]) {
            bingo = true;
        }
    }
    if (flag[0][0] * flag[1][1] * flag[2][2]) {
        bingo = true;
    }
    if (flag[0][2] * flag[1][1] * flag[2][0]) {
        bingo = true;
    }
    
    if (bingo) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

int index(char c){
	return (int)c - 48;
}

int main(){
	int num[10];
	char c;
	while(cin >> c){
		for(int i = 0; i < 10; i++){
			num[i] = index(c);
			if(i == 9) break;
			cin >> c;
		}
		for(int i = 10; i > 1; i--){
			for(int j = 0; j < i - 1;j++){
				num[j] = (num[j] + num[j+1]) % 10;
			}
		}
		cout << num[0] << endl;
	}
	return 0;
}

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

int cx, cy, n, x[104], y[104], h[104], xt, yt, ht;

int main() {
	cin>>n;
	ht = -1;
	for(int i = 0;i<n;i++){
		cin>>x[i]>>y[i]>>h[i];
		if(h[i])	xt = x[i], yt = y[i], ht = h[i];
	}
	for(cx = 0; cx<=100; cx++)
		for(cy = 0; cy<=100; cy++){
			int height = ht + abs(xt-cx) + abs(yt - cy);
			if(ht == -1)	height = 1;
			bool ok = true;
			for(int i = 0;i<n;i++)
				if(max(height - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i])
					ok = false;
			if(ok){
				cout<<cx<<' '<<cy<<' '<<height;
				return 0;
			}
		}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;

signed main(){
  string s;
  cin>>s;
  int c=0;
  vector<int> ch(26,0);
  vector<int> ch2(26,0);
  int cnt;
  int id=0;
  while(true){
    c=0;
    cnt=0;
    for(int i=s.size()-1;i>=id;i--){
      c=(c|(1<<(s[i]-'a')));
      ch[s[i]-'a']++;
      if(c==67108863){
        c=0;
        for(int j=0;j<26;j++){
          if(ch[j]==1){
            break;
          }
        }
        ch=ch2;
        //for(int j=0;j<26;j++)ch[j]=0;
        cnt++;
      }
    }
    char x;
    for(int i=0;i<26;i++){
      if(!(c&(1<<i))){
        x='a'+i;
        cout<<x;
        break;
      }
    }
    for(int i=id;i<s.size();i++){
      if(s[i]==x){
        id=i+1;
        break;
      }
    }
    if(cnt==0){
      cout<<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 640
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Sat Dec 22 21:23:01 2018
//
package main

import (
	"fmt"
	"math"
)

func main() {
	var N, P int
	fmt.Scan(&N, &P)
	if N == 1 {
		fmt.Println(P)
		return
	}

	ans := 0
	for i := 1; ; i++ {
		p := math.Pow(float64(i), float64(N))
		if p == math.Inf(+1) {
			break
		}

		n := int(p)
		if P%n == 0 {
			ans = i
		}
		if n > P {
			break
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())


H,A=LI()

ans = math.ceil(H / A)

print(ans)

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

struct Card
{
    char suit;
    int value;
};


void traceArray(struct Card A[],int N){
    for(int i = 0; i < N; i++){
        if(i > 0){
            cout << " ";
        }
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

void selectionSort(struct Card A[],int N){
    int cnt = 0;
    for(int i = 0;i < N;i++){
        int minj = i;
        for(int j = i; j < N; j++){
            if(A[minj].value > A[j].value){
                minj = j;
            }
        }
        swap(A[minj], A[i]);
        if(minj != i){
            cnt++;
        }
        
    }
}

void bubbleSort(struct Card A[],int N){
    int cnt = 0;
    for(int i = 0; i< N; i++){
        for(int j = N-1; j >= i+1; j--){
            if(A[j].value < A[j-1].value){
                swap(A[j],A[j-1]);
                cnt++;
            }
        }
    }
}

bool isStable(struct Card C1[], struct Card C2[], int N){
    for(int i = 0; i < N; i++){
        if(C1[i].suit != C2[i].suit){
            return false;
        }
    }
    return true;
}

int main(){
    int n;
    cin >> n;
    Card a[n],b[n];
    for(int i = 0; i< n; i++){
        cin >>a[i].suit >> a[i].value;
        b[i] = a[i];
    }
    
    bubbleSort(a,n);
    selectionSort(b,n);

    traceArray(a,n);
    cout << "Stable" << endl;

    traceArray(b,n);
    if(isStable(a,b,n)){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }

    return 0;
}


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

#define debug(x) cout<<#x<<"="<<x<<endl
#define RD(x) freopen((x),"r",stdin)
#define WT(x) freopen((x),"w",stdout)
#define pii pair<int,int>
#define PQ priority_queue
#define ll long long
#define pb push_back
#define mp make_pair
const int INF=0x7fffffff;

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if (a==b) cout<<c;
	if (b==c) cout<<a;
	if (a==c) cout<<b;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <iterator>

using namespace std;

#if 1
#define PRINT(x) { cout << #x << ": " << (x) << endl; }
#define PRINT_CONTAINER(x)  { cout << #x << ": ";                       \
        for (size_t ix = 0; ix < (x).size(); ++ix) cout << (x)[ix] << ", "; \
        cout << endl; }
#else
#define PRINT(x)
#define PRINT_CONTAINER(x)
#endif

int main(int argc, char *argv[])
{
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);
    long long int cnt = 0;
    for (int i = 1; i <= n; ++i)
    {
        int c1, c2, c3, c4, c5;
        c5 = i / 10000;
        c4 = (i - c5 * 10000) / 1000;
        c3 = (i - c5 * 10000 - c4 * 1000) / 100;
        c2 = (i - c5 * 10000 - c4 * 1000 - c3 * 100) / 10;
        c1 = (i - c5 * 10000 - c4 * 1000 - c3 * 100 - c2 * 10);
        int c = c1 + c2 + c3 + c4 + c5;
        if (a <= c && c <= b) cnt += i;
    }
    printf("%lld\n", cnt);
}


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

int main(void){
    int a,b;
    cin >> a >> b;
    if(a%2 != 0 && b%2 != 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    VI pv;
    REP(i, n){
        int p;
        cin >> p;
        pv.push_back(p - 1);
    }

    int cnt = 0;
    REP(i, n - 1){
        if(pv[i] == i && pv[i + 1] == i + 1){
            cnt++;
            swap(pv[i], pv[i + 1]);
        }
    }

    REP(i, n - 1){
        if(pv[i] == i){
            cnt++;
            swap(pv[i], pv[i + 1]);
        }
    }
    if(pv[n - 1] == n - 1) cnt++;
    cout << cnt << "\n";

    return 0;
}


Measured memory_bytes: 892
// C - Count Order
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N; cin>>N;
	vi P(N), Q(N);
	rp(i, 0, N) cin>>P[i];
	rp(i, 0, N) cin>>Q[i];
	vi p,q; tie(p,q) = minmax(P,Q);
	int c = 0;
	while(p != q){
		c++;
		next_permutation(p.begin(), p.end());
	}
	cout<< c <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using vc=vector<char>;
using vvc=vector<vc>;
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using tiii = tuple<int,int,int>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int N;
  ll D;
  cin >> N >> D;
  int ans=0;
  rep(i,N) {
    ll X,Y;
    cin >> X >> Y;
    if(X*X+Y*Y<=D*D) ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ll long long int
#define cin(a,n) for(i=0;i<n;i++){cin>>a[i];sum+=a[i];}
#define ll long long int
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rf1(i,a,n) for(int i=a;i>n;i--)
#define cases() int q;cin>>q;while(q--)
#define ld long double
#define cout(a,n) for(i=0;i<n;i++)cout<<a[i]<<" ";
#define inf 1e9;
#define mod 1000000007;
#define PI 3.14159265358979323846264338327950L
using namespace std;
int main(){
  int a,b,h,m;
  cin>>a>>b>>h>>m;
 long double rad = PI * 2 * ((long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long double)m / 60.0);
 long double rsq = (long double)(a * a + b * b) - (long double)(2 * a * b) * cosl(rad);
 cout<<fixed<<setprecision(20)<<sqrtl(rsq);
return 0;
}



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

ll pow5(ll n) {
	return n*n*n*n*n;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int X; cin >> X;
	for (ll i = 0; i <= 5000; i++) {
		ll A = pow5(i);

		ll lo = -5000, hi = 5000, mid;
		for (int j = 0; j < 20; j++){
			mid = (lo + hi) / 2;
		//	cout << mid << '\n';
			ll B = pow5(mid);
			if (A - B > X) lo = mid + 1;
			else hi = mid;
		}

		if (A - pow5(hi) == X){
			cout << i << ' ' << hi << '\n';
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>
#define MAX 20001
  

struct pair {
  int x;
  int ar;
};
  

void push_stack1(int);
void push_stack2(int, int);
int returnTopElement(void);
int pop_stack1(void);
struct pair pop_stack2(void);
  

int top_stack1 = 0, top_stack2 = 0;
  

int stack1[MAX];
struct pair stack2[MAX];
  
int main() {
  int i, j;
  int sum = 0, a;
  struct pair c;
  char input[MAX];
  

  scanf("%s", input);
  

  for (i = 0; input[i] != '\0'; i++) {
    if(input[i] == '\\') push_stack1(i);
    else if((input[i] == '/') && (top_stack1 > 0)) {
      j = pop_stack1();
      sum += i - j;
      a = i - j;
      while ((top_stack2 > 0) && stack2[top_stack2 - 1].x > j) {
        a += stack2[top_stack2 - 1].ar ;
        c = pop_stack2();
      }
      push_stack2(j, a);
    }
  }
  

  printf("%d\n", sum);
  printf("%d", top_stack2);
  for(i = 0; i < top_stack2; i++) {
    if(i < top_stack2) printf(" ");
    printf("%d", stack2[i].ar);
  }
  printf("\n");
  
  
  return 0;
}
  
void push_stack1(int x) {
  stack1[top_stack1] = x;
  top_stack1++;
}
  
void push_stack2(int j, int a) {
  stack2[top_stack2].x = j;
  stack2[top_stack2].ar = a;
  top_stack2++;
}
  
int pop_stack1(void) {
  int r = 0;
  
  top_stack1--;
    
  if(top_stack1 < 0) {
    top_stack1 = 0;
    return 0;
  }
  r = stack1[top_stack1];
  return r;
  
}
  
struct pair pop_stack2(void) {
  struct pair s;
  
  top_stack2--;
    
  if(top_stack2 < 0) {
    top_stack2 = 0;
    return;
  }
  s = stack2[top_stack2];
  return s;
  
}

Measured memory_bytes: 640
///* BISMILLAH *///
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c,d,e,f;
cin>>a;
b=a%10;
c=a%100/10;
d=a%1000/100;
e=a/1000;
if(e==d && d==c || d==c && c==b)
cout<<"Yes";
else
cout<<"No";
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		Scanner scan = new Scanner(System.in);
		String word = "";		//???????????????string
		int[] shuffleBegin = new int[100]; //?????£?????????????§????
		String temp = "";
		while(true){
			temp = scan.next();
			if(temp.equals("-")){
				break;
			}
			char[] targetChar = temp.toCharArray();
			int targetLength = temp.length();
			
			int shuffleTimes = scan.nextInt();
			for(int i=0; i<shuffleTimes; i++){
				shuffleBegin[i] = scan.nextInt();
			}
			
			for(int i =0;i<shuffleTimes; i++){
			word = "";
				for(int j=0; j<(targetLength - shuffleBegin[i]) ; j++){
					word = word + targetChar[j + shuffleBegin[i]];
				}
				
				for(int j=0; j<shuffleBegin[i]; j++){
					word = word + targetChar[j];
				}
				
			targetChar = word.toCharArray();

			}
			System.out.println(word);		
			
		}
	}
}

Measured memory_bytes: 46156