akhauriyash/Code-Regression huggingface dataset:
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "main.cpp"

long long solve(std::string S, std::string T) {
  int len = S.length();
  int tlen = T.length();
  int ans = T.length();
  REP(i, len) {
    if (i + T.length() > S.length())
      continue;
    int tmp = 0;
    REP(j, tlen) {
      if (S[i + j] == T[j])
        tmp++;
    }
    chmin(ans, tlen - tmp);
  }
  return ans;
}

// generated by online-judge-template-generator v4.4.0 (https://github.com/kmyk/online-judge-template-generator)
int main() {
  std::string S, T;
  std::cin >> S >> T;
  auto ans = solve(S, T);
  std::cout << ans << std::endl;
  return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF = 1e18;

LL fact_histo[1001];
const LL mod = 1e9 + 7;

bool is_prime(long long N)
{
    if (N <= 1)
        return false;
    if (N == 2)
        return true;
    if (N % 2 == 0)
        return false;
    LL ub = std::sqrt(N);
    if (ub * ub == N)
        return false;
    for (long long i = 3; i <= ub; i += 2)
    {
        if (N % i == 0)
            return false;
    }
    return true;
}

void solve()
{
    int N;
    cin >> N;

    REP1(n, N)
    {
        fact_histo[n] = 1;
        for (int i = 2; i <= n; i++)
        {
            if (!is_prime(i))
                continue;
            LL k = n;
            LL cnt = 0;
            while (k % i == 0 and k > 1)
            {
                k /= i;
                cnt++;
            }

            fact_histo[i] += cnt;
        }
    }

    LL ans = 1;
    FOR(i, 2, N + 1)
    {
        ans *= (fact_histo[i] % mod);
        ans %= mod;
    }
    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;

#define INF 1000000000

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> shops(n,0);

  rep(i,m){
    int c,d;
    scanf("%d %d", &c,&d);
    shops[c-1]++;
    shops[d-1]--;
  }

  repl(i,1,n){
    shops[i] += shops[i-1];
  }

  int res=n+1;
  bool flg=false;
  int start;
  rep(i,n){
    if((!flg) && shops[i]>0){
      flg=true;
      start=i;
    }
    else if(flg && shops[i]==0){
      flg=false;
      res += (i-start)*2;
    }
  }

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

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

#define mx 100005

using namespace std;

long long n, m, a[mx], b[mx], ans[mx], p[mx], nm[mx];

void ufini(int n){
  for(int i = 1; i <= n; i++) p[i] = i;
  fill(nm+1, nm+n+1, 1);
}

int find(int x){return (x == p[x] ? x : p[x] = find(p[x]));}

long long uni(int x, int y){
  if(find(x) != find(y)){
    long long tx = nm[p[x]], ty = nm[p[y]];
    nm[p[x]] += nm[p[y]];
    p[p[y]] = p[x];
    return (tx+ty)*(tx+ty-1)/2 - tx*(tx-1)/2 - ty*(ty-1)/2;
  }else return 0;
}

int main(){
  scanf("%d%d", &n, &m);
  for(int i = 0; i < m; i++) scanf("%d%d", a+i, b+i);
  ans[m-1] = n*(n-1)/2;
  ufini(n);
  for(int i = m-1; i > 0; i--) ans[i-1] = ans[i] - uni(a[i], b[i]);
  for(int i = 0; i < m; i++) printf("%lld\n", ans[i]);
}

Measured memory_bytes: 5248
#include <stdio.h>
#include <string.h>
char t[1010];
int main(){
	int i;
	int n;
	int ans;
	while(scanf("%s",&t)){
		n=strlen(t);
		ans=0;
		if(n==1&&t[0]=='0') break;
		for(i=0;i<n;i++){
			ans+=t[i]-'0';
		}
		printf("%d\n",ans);
	}
	return 0;
}



Measured memory_bytes: 2088
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
using namespace std;

int main()
{
	long long n, d;
	cin >> n >> d;
	long long cnt = 0;
	for (int i = 0; i < n; i++) {
		long long x, y;
		cin >> x >> y;
		if (sqrt(x * x + y * y) <= d)
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MAX_HIGHT 500
const int MOD = 1000000007LL;
const int INF = LLONG_MAX;

signed main(){
    
    int n; cin >> n;
    vector<double> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];
    vector<vector<double> > dp(n + 1, vector<double> (MAX_HIGHT + 10, 1e18));
    dp[0][1] = 0.0;
    for(int i = 0; i < n; i++){
        for(int j = 1; j <= MAX_HIGHT; j++){
            if(dp[i][j] == 1e18) continue;

            for(int k = 1; k <= MAX_HIGHT; k++){

                double L = abs(h[i] - j);
                double R = abs(h[i] - k);
                double S;
                if((h[i] - j) * (h[i] - k) <= 0){
                    
                    //三角形二つ
                    if(abs(L * L + R * R) < 1e-8) S = 0.0;
                    else S = (L * L + R * R) / (2.0 * (L + R));                    
                }else{
                    //台形
                    if(abs(L + R) < 1e-8) S = 0.0;
                    else S = (L + R) / 2.0;
                }


                dp[i + 1][k] = min(dp[i + 1][k], dp[i][j] + S);
            }
        }
    }

    double ans = 1e18;
    for(int i = 0; i <= MAX_HIGHT; i++) ans = min(ans, dp[n][i]);
    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 3508
/**
*    author:  yuya1234
*    created: 09.07.2020 08:58:45
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define ALL(v) (s).begin(), (s).end()
#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

  int n,a,b;
  string s;
  cin>>n>>a>>b>>s;

  int cnt=0,kaigai=1;
  REP(i,n)
  {
    if(s[i]=='a' && cnt<a+b)
    {
      cout<<"Yes"<<endl;
      cnt++;
    }
    else if(s[i]=='b' && cnt<a+b && kaigai<=b)
    {
      cout<<"Yes"<<endl;
      cnt++;
      kaigai++;
    }
    else
    {
      if(s[i]=='b')kaigai++;
      cout<<"No"<<endl;
    }
  }

  return 0;
}

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

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

  string s, t;
  cin >> s >> t;
  string ans = "No";
  for (int i = 0; i < s.size(); i++) {
    if (s == t) {
      ans = "Yes";
      break;
    }
    s = s.substr(1) + s[0];
  }
  cout << ans << '\n';
  return 0;
}

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

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

    map<int, int> s;
    int n, m = 0;
    for (cin >> n; n--;) {
        int x;
        cin >> x;
        if (x > m)
            m = x;
        s[x]++;
    }
    for (auto const& p : s) {
        if (p.second) {
            int i = p.first;
            for (int j = i * 2; j <= m; j += i)
                s.erase(j);
        }
    }
    int r = 0;
    for (auto const& p : s) {
        if (p.second == 1)
            r++;
    }
    cout << r << '\n';
    return 0;
}


Measured memory_bytes: 12864
#include <bits/stdc++.h>
using namespace std;
int main(void){
	int a,b,c,i;
	string A;
	cin>>A;
	if(A[0]==A[1]&&A[1]==A[2]||A[1]==A[2]&&A[2]==A[3]){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    ll N, K; cin >> N >> K;
    map<ll, ll> M;
    for(int i = 0; i < N; i++) {
        ll a, b; cin >> a >> b;
        if(!M.count(a)) M[a] = b;
        else M[a] += b;
    }
    ll ans = 0, cnt = 0;
    for(auto p: M) {
        ans = p.first;
        cnt += p.second;
        if(cnt >= K) break;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> L(n);
  rep(i,n) cin >> L[i];
  sort(L.begin(), L.end());
  int ans = 0;
  rep(b,n)rep(a,b) {
    int ab = L[a]+L[b];
    int r = lower_bound(L.begin(), L.end(), ab) - L.begin();
    int l = b+1;
    // c = [l,r)
    ans += max(0,r-l);
  }
  cout << ans << endl;
  return 0;
}

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

ll a[51],p[51];

ll f(ll N, ll X) {
  if (N == 0 && X >= 1) {
    return 1;
  } else if (X <= 0) {
    return 0;
  } else if (X <= 1 + a[N - 1]) {
    return f(N - 1, X - 1);
  } else {
    return p[N - 1] + 1 + f(N - 1, X - 2 - a[N - 1]);
  }
}

int main() {
  ll n, x;
  cin >> n >> x;
  a[0] = 1;
  p[0] = 1;
  for (int i = 1; i <= 50; ++i) {
    a[i] = 2 * a[i - 1] + 3;
    p[i] = 2 * p[i - 1] + 1;
  }
  cout << f(n, x) << "\n";
  return 0;
}
//s=B+S+P+S+B

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define N 1000005
typedef long long int ll;
// int n,m;
// vector<int> adj[mx];

//---dfs--
// bool visited[mx];
// vector<int> val(n,0);

// void dfs(int s, int & cnt_vert, int & cnt_edge){
// 	assert(!visited[s]);
// 	visited[s]=true;
// 	++cnt_vert;
// 	cnt_edge+=adj[s].size();
// 	for(int b:adj[s]){
// 		if(!visited[b]){
// 			dfs(b,cnt_vert,cnt_edge);
// 		}
// 	}
// }
//---dfs---

//---primes---
// const int N = 1e7 + 10;
 
// bool prime[N];
 
// int spf[N];
 
// void calc(){
// 	for(int i = 2; i<1e4; i++){
// 		if(prime[i])
// 			continue;
// 		spf[i] = i;
// 		for(int j = i * i; j < N; j += i){
// 			prime[j] = 1;
// 			spf[j] = i;
// 		}
// 	}
// 	for(int i = 2; i < N; i++)
// 		if(!spf[i])
// 			spf[i] = i;
// }

// vector<pair<int,int>> getp(int x){
// 	int curr=x;
// 	vector<pair<int,int>> ans;
// 	while(curr>1){
// 		int a=spf[curr];
// 		int count=0;
// 		while(curr%a==0){ curr/=a; count++;}
// 		ans.push_back(make_pair(a,count));
// 	}
// 	return ans;
// }

// bool ispr(int n) {
//     for (int i=2;i*i<=n;++i){
//         if(n%i==0){
//             return false;
//         }
//     }
//     return true;
// }
//---primes---

//---segment_tree---
// int upd(int t,int val,int l,int r,int y, int z){
// 	if(y<l||y>r) return tr[val];
// 	if(l==r) return tr[val]=z;
// 	int s=(l+r)/2;
// 	upd(t^1,2*val+1,l,s,y,z);
// 	upd(t^1,2*val+2,s+1,r,y,z);
// 	if(t) tr[val]=tr[2*val+1]|tr[2*val+2];
// 	else tr[val]=tr[2*val+1]^tr[2*val+2];
// 	return tr[val];
// }
//int query(){}
//---segment_tree---
//vector<int> a(1003);
// int mex(vector<int> &a){
// 	vector<int> b=a;
// 	sort(b.begin(),b.end());
// 	int ans;
// 	set<int> s;
// 	for(int i=0;i<n;i++){
// 		s.insert(b[i]);
// 	}
// 	for(int i=0;i<=n;i++){
// 		if(s.find(i)==s.end()){ans=i; break;}
// 	}
// 	return ans;
// }

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int t=1;
	//cin>>t;
	while(t--){
		int n;
		cin>>n;
		map<string,int> mp;
		for(int i=0;i<n;i++){
			string s;
			cin>>s;
			mp[s]++;
		}
		cout<<"AC x "<<mp["AC"]<<"\n";
		cout<<"WA x "<<mp["WA"]<<"\n";
		cout<<"TLE x "<<mp["TLE"]<<"\n";
		cout<<"RE x "<<mp["RE"]<<"\n";
	}
}


Measured memory_bytes: 3660
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int ans = (N*(N-1)/2)+((M*(M-1))/2);
        System.out.print(ans);
        
    }
}

Measured memory_bytes: 23764
n = int(input())
s = input()
L = []
for i in range(len(s)):
  L.append(s[i])
Alp = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
for i in range(len(L)):
  cur = 0
  for j in range(26):
    if Alp[j] == L[i]:
      cur = j
  if cur+n < 26:
    L[i] = Alp[cur+n]
  else:
    L[i] = Alp[cur+n-26]
print(''.join(map(str, L)))

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

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
  long long n,m;
  scanf("%lld %lld\n",&m,&n);
  printf("%lld\n",modpow(m,n,1000000007));
  return 0;
}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define rep(i,l,r)  for(int i=l;i<=r;i++)
#define pre(i,r,l)  for(int i=r;i>=l;i--)
#define pii pair<int,int>
using namespace std;
const int inf = 0x3f3f3f3f;
const int mod = 1000000007;
const int maxn = 1000005;
inline int read(){
    int x=0,f=1;char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar()) x=x*10+c-'0';
    return x*f;
}

map<string, int> mp;

int main() {
   int n = read();
   int sum = 0;
   rep(i, 0, n-1) {
     string s; cin >> s;
     if(mp[s]) continue;
     else sum++, mp[s] = 1;
   }
   cout << sum << endl;
}


Measured memory_bytes: 19196
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 25, M = 1e6 + 25, oo = 1e9, mod = 1e9 + 7;
const long long OO = 1e18+25;

int n, a[N],mem[N];

int dp(int idx=0)
{
    if(idx >= n) return 0;
    int &ret = mem[idx];
    if(ret != -1) return ret;
    return ret = min(dp(idx+1)+abs(a[idx]-a[idx+1]), dp(idx+2)+abs(a[idx]-a[idx+2]));
}

int main()
{
    memset(mem, -1, sizeof mem);
    scanf("%d",&n);
    for(int i=0; i<n; i++) scanf("%d",a+i);
    a[n+1] = oo;
    a[n] = a[n-1];
    printf("%d",dp());
    return 0;
}
	     		 					   	 	 								 	

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

int main() {
    int a, b, c, k;
    cin>>a >>b >>c >>k;
    int x=0;
    while(a>=b){
        b*=2;
        x++;
    }
    while(b>=c){
        c*=2;
        x++;
    }
    if(x<=k) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3624
import java.util.Scanner;

class Main {
    public static int n;
    public static int s;
    public static int c;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            n = sc.nextInt();
            s = sc.nextInt();
            if (n == 0 && s == 0) {
                break;
            }
            c = 0;
            //dfs(0, s, s);
            dfs2(n, s, 0);
            System.out.println(c);

        }
    }

    static void dfs(int k, int rest, int x) {
        if (k == n && rest == 0) {
            c++;
        }
        if (rest >= 0) {
            for (int i = Math.min(x, 9); i >= 0; i--) {
                dfs(k + 1, rest - i, i - 1);
            }
        }
    }

    static void dfs2(int k, int rest, int x) {
        if (k == 0 && rest == 0) {
            c++;
        }
        if (rest >= 0) {
            for (int i = x; i <= 9; i++) {
                dfs2(k - 1, rest - i, i + 1);
            }
        }
    }
}


Measured memory_bytes: 26324
import sys
input = sys.stdin.readline

H, W = [int(x) for x in input().strip().split()]
C = [0 for _ in range(10)]
for i in range(10):
    C[i] = [int(x) for x in input().strip().split()]

for k in range(10):
    for i in range(10):
        for j in range(10):
            if C[i][j] > C[i][k] + C[k][j]:
                C[i][j] = C[i][k] + C[k][j]
                isChanged = True

ans = 0
for h in range(H):
    W = [int(x) for x in input().strip().split()]
    for w in W:
        if w == -1:
            continue
        ans += C[w][1]

print(ans)


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

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

	set <long long int> s;
	priority_queue <long long int,vector<long long int>,greater<long long int>> pque;
	int n;

	cin >> n;
	
	for(int i=1;i<=9;i++)
	{
		s.insert(i);
		pque.push(i);
	}

	while(!pque.empty())
	{
		if(s.size() > 110000)
		{
			break;
		}
		long long int val = pque.top();
		pque.pop();
		int x = val%10;
		if(x==0)
		{
			long long int next = 10*val + 1;
			s.insert(next);
			pque.push(next);
			next = 10*val;
			s.insert(next);
			pque.push(next);
		}
		else if(x==9)
		{
			long long int next = 10*val + 8;
			s.insert(next);
			pque.push(next);
			next = 10*val + 9;
			s.insert(next);
			pque.push(next);
		}
		else
		{
			long long int next = 10*val + (x-1);
			s.insert(next);
			pque.push(next);
			next = 10*val + (x+1);
			s.insert(next);
			pque.push(next);	
			next = 10*val + x;
			s.insert(next);
			pque.push(next);					
		}
	}

	vector <long long int> res;
	for(auto it : s)
	{
		res.push_back(it);
	}

	cout << res[n-1] << '\n';

	return 0;
}

Measured memory_bytes: 10400
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int ans=0;
	for(int i=0;i<n;i++)
	{
		int cnt=0;
		for(char c='a';c<='z';c++)
		{
		   bool left=false,right=false;
		   for(int j=0;j<i;j++)
		   {
		   	    if(s[j]==c)
		   	    {
		   	    	left=true;
				}
		   }
		   for(int j=i;j<n;j++)
		   {
		   	    if(s[j]==c)
		   	    {
		   	    	right=true;
				}
		   }
		   if(left&&right)
		   {
		   	  cnt++;
		   }
		}
		if(ans<cnt)
		{
			ans=cnt;
		}
	}
	cout<<ans;
	return 0;
 } 

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
  
public class Main {
    private static final String CRLF = System.lineSeparator();
    public void exec() throws IOException {
    	SimpleInputUtil in = new SimpleInputUtil();
        PrintWriter out = new PrintWriter(System.out);
        StringBuilder sb = new StringBuilder();
        int count=0;
        int N = in.readInt();
        int[] A = in.readIntArray(N);
        int tmp;
        for(boolean flag=true;flag;){
        	flag=false;
        	for(int j=N-1;j>=1;j--){
        		if(A[j] < A[j-1]){
        			tmp = A[j];
        			A[j] = A[j-1];
        			A[j-1] = tmp;
        			count++;
        			flag=true;
        		}
        	}
        }
        intArrayToString(A,sb);
        out.print(sb.toString());
        out.println(count);
        out.flush();
    }
    
    private void intArrayToString(int[] a, StringBuilder sb) {
        for(int i=0; i<a.length; i++) {
            if (i>0)
                sb.append(" ");
            sb.append(a[i]);
        }
        sb.append(CRLF);
    }
     
    public static void main(String[] args) throws IOException {
        new Main().exec();
    }
}

class SimpleInputUtil {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public int readInt() throws NumberFormatException, IOException{
    	return Integer.parseInt(br.readLine());
    }
    public int[] readIntArray(int len) throws NumberFormatException, IOException{
        int[] a = new int[len];
        int i=0;
        for(String s: br.readLine().split(" ")){
            a[i++] = Integer.parseInt(s);
        }
        return a;
    }
    
}

Measured memory_bytes: 24376
// 5/20
// ANT2-4-3. Union Find Tree, 食物連鎖
// 類題
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using LLP = pair<ll, ll>;

struct Edge {
    int to, cost;
    Edge(int t, int c) : to(t), cost(c) {}
};
// using Graph = Vector<vector<int>>;
using Graph = vector<vector<Edge>>;


const int INF = 1000000009;

vector<bool> seen;
vector<int> d;

bool dfs(const Graph &G, int v, int dist) {
    if (seen[v]) {
        if (d[v] != dist) {
            return true;
        } else {
            return false;
        }
    }

    seen[v] = true;
    d[v] = dist;

    // for (auto n : G) {
    //     for (auto e : n) {
    //         if (dfs(G, e.to, d[v] + e.cost)) {
    //             return true;
    //         }
    //     }
    // }
    for (auto e : G[v]) {
        if (dfs(G, e.to, d[v] + e.cost)) {
            return true;
        }
    }
    return false;
}

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

    vector<int> L(M), R(M), D(M);
    rep(i, M) {
        cin >> L[i] >> R[i] >> D[i];
        L[i]--;
        R[i]--;
    }

    // vector<int> x(N, -INF);  // 距離

    // vector<Edge> G[200010];
    Graph G(N);

    rep(i, M) {
        G[L[i]].push_back(Edge(R[i], D[i]));
        G[R[i]].push_back(Edge(L[i], - D[i]));
    }

    seen.assign(N, false);
    d.assign(N, -1);

    rep(i, N) {
        if (!seen[i] && dfs(G, i, 0)) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 14336
#include<iostream>
#include<string>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
    string s,ans;
    int k;
    ans = "ABC";
    cin >> k >> s;
    (int)(s.length());
    int a = (s.length());
    if(a<=k){
        cout << s << endl;
    }else{
        rep(i,k){
            cout << s[i];
        }
        cout << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
import std.stdio;
import std.array;
import std.conv;

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

void main() {
    int a, b;
    while(true) {
        string[] input = split(readln());
        if(input.length == 0) break;
        a = to!int(input[0]);
        b = to!int(input[1]);
        int gcd_ab = gcd(a, b);
        int lcm_ab = a / gcd_ab * b;
        writeln(gcd_ab, " ", lcm_ab);
    }
}

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

#define FOR(i,a,n) for (int i = a; i < (int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = int_fast64_t;

constexpr ll INF = (1e9);
constexpr ll MOD = (1e9+7);

int main() {
  int n; cin >> n;
  int res = 0;
  int cnt = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  if ( res == 1) cout << 10 << endl;
  else cout << res << endl;
  return 0;
}


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

#define lli long long int
#define ld long double
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)

////////////////////////////////////////////////////////    By: Umang Srivastava

/*
lli extgcd(lli a, lli b, lli *x , lli *y)
{
	if(a==0)
	{
		*x=0;
		*y=1;
		return b;
	}
	lli x1 , y1;
	lli gcd = extgcd(b%a , a , &x1 , &y1);
	*x=y-(b/a)*x1;
	*y=x1;
	return gcd;
}

lli modinv(lli a, lli m)
{
	lli x,y;
	lli g = extgcd(a,m,&x,&y);
	if(g!=1)
		return -1;
	return (x%m+m)%m;
}

lli moddiv(lli a, lli b, lli m)
{
	a=a%m;
	lli inv = modinv(b,m);
	if(inv!=-1)
		return ((a*inv + m)%m);
	else
		return -1;
}
*/
lli binpow(lli a, lli b, lli m)
{
	lli res=1;
	a=a%m;
	while(b>0)
	{
		if(b & 1)
		{
			res = (res * a)%m;
		}
		b=b>>1;
		a=(a*a)%m;
	}
	return res;
}
/*
lli gcd(lli a, lli b)
{
    // if(b<a)
    // {
    //     lli t=a;
    //     a=b;
    //     b=t;
    // }
    if(a==0)
        return b;
    return gcd(b%a,a);
}
*/
/////////////////////////////////////////////////////////

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli n,i,j;
    cin>>n;
    lli dp[2001]={0};
    dp[0]=1;
    dp[1]=dp[2]=0;
    for(i=3;i<=n;i++)
    {
        for(j=0;j<=i-3;j++)
            dp[i]=(dp[i]+dp[j])%mod;
    }
    cout<<dp[n]<<endl;

}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <list>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

int main(){
	queue <int> que1;
	queue <string> que2;
	int n, q;
	cin >> n >> q;
	for (int i = 0; i < n; i++){
		string name;
		cin >> name;
		que2.push(name);
		int time;
		cin >> time;
		que1.push(time);
	}
	int t = 0;
	while (!que1.empty()){
		string nows = que2.front();
		int nowi = que1.front();
		if (nowi > q){
			t += q;
			que1.pop();
			que1.push(nowi - q);
			que2.pop();
			que2.push(nows);
		}
		else{
			t += nowi;
			que1.pop();
			que2.pop();
			cout << nows << " " << t << endl;
		}
	}

return 0;
}

Measured memory_bytes: 4176
import java.util.*;

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

		Scanner src = new Scanner(System.in);

		String s = src.nextLine();
      	String t = src.nextLine();
      
      	

		System.out.println(solve(s,t));
	}

  	public static int solve(String s,String t){
      
      int ans = 0;
      
      int i =0;
      int j = 0;
      
      while(i<s.length() && j<t.length()){
        
        if(s.charAt(i)!=t.charAt(j))
          ans++;
        
        i++;
        j++;
        
      }
      
      return ans;
      
    }

}

Measured memory_bytes: 33944
#include <iostream>
#include <assert.h>
#include <algorithm>
#include <string>

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

    int64_t N;
    std::cin >> N;
    int64_t march_cnt[5] = {};
    std::string s;
    for(int32_t i = 0; i < N; i++){
        std::cin >> s;
        switch(s[0]){
            case 'M' :
                march_cnt[0]++;
                break;
            case 'A' :
                march_cnt[1]++;
                break;
            case 'R' :
                march_cnt[2]++;
                break;
            case 'C' :
                march_cnt[3]++;
                break;
            case 'H' :
                march_cnt[4]++;
                break;
            default:
                break;
        }
    }
    int64_t res = 0;
    for(int32_t i = 0; i < 5; i++){
        for(int32_t j = i+1; j < 5; j++){
            for(int32_t k = j+1; k < 5; k++){
                res += march_cnt[i] * march_cnt[j] * march_cnt[k];
            }
        }
    }

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


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

using namespace std;

const int MOD = 1000 * 1000 * 1000 + 7;

long long addm(long long a, long long b)
{
	return (a + b) % MOD;
}

long long subm(long long a, long long b)
{
	return addm(a, MOD - b);
}

long long mulm(long long a, long long b)
{
	return (a * b) % MOD;
}

long long powm(long long a, long long n)
{
	if (n == 0) {
		return 1;
	}
	else if (n % 2 == 0) {
		return powm(mulm(a, a), n / 2);
	}
	else {
		return mulm(a, powm(mulm(a, a), n / 2));
	}
}

int main()
{
	int N, K;
	cin >> N >> K;
	vector<long long> dp(K + 1);

	for (int i = K; i >= 1; --i) {
		dp[i] = powm(K / i, N);
		for (int j = 2 * i; j <= K; j += i) {
			dp[i] = subm(dp[i], dp[j]);
		}
	}

	long long ans = 0;
	for (int i = 1; i <= K; ++i) {
		ans = addm(ans, mulm(i, dp[i]));
	}
	cout << ans << endl;
}


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

string s;
int K;

int main(){
    cin >> s;
    cin >> K;

    vector<string> substrings;

    for(int i = 0; i < s.length(); i++){
        for(int j = 1; i + j <= s.length() && j <= K; j++){
            substrings.push_back(s.substr(i, j));
        }
    }
    
    
    sort(substrings.begin(), substrings.end());
    vector<string>::iterator itr = unique(substrings.begin(), substrings.end());
    substrings.erase(itr, substrings.end());

    cout << substrings[K-1] << endl;
    
}


Measured memory_bytes: 1660
#include <stdio.h>
int main(void){
    int n,a[120]={},c75=0,c25=0,c15=0,c5=0,c3=0;
    scanf("%d",&n);
    for (int i=1; i<=n; i++){
        int k=i;
        for (int j=2; j<=i; j++){
            while(k%j==0){
                a[j]++;
                k/=j;
            }
        }
    }
    for (int i=0; i<120; i++){
        if (a[i]>=74){
            c75++;
        }
        if (a[i]>=24){
            c25++;
        }
        if (a[i]>=14){
            c15++;
        }
        if (a[i]>=4){
            c5++;
        }
        if (a[i]>=2){
            c3++;
        }
    }
    printf("%d\n",c75+c25*(c3-1)+c15*(c5-1)+c5*(c5-1)*(c3-2)/2);
    return 0;
}

Measured memory_bytes: 128
#include<cmath>
#include<iostream>
using namespace std;
#define PI 3.141592

int winding_number(double x, double y, double p[][2], int n)
{
  double x1 = p[n - 1][0] - x, y1 = p[n - 1][1] - y;
  double s = 0;
  for(int i = 0; i < n; i++)
  {
    double x2 = p[i][0] - x, y2 = p[i][1] - y;
    double tx = acos((x1 * x2 + y1 * y2) / sqrt((x1 * x1 + y1 * y1) * (x2 * x2 + y2 * y2)));
    s += tx;
    x1 = x2; y1 = y2;
  }
  return (abs(s) + 0.000001) / 2 / PI;
}


double p[3][2];
int main()
{
  while(cin >> p[0][0] >> p[0][1] >> p[1][0] >> p[1][1] >> p[2][0] >> p[2][1])
  {
    double x, y;
    cin >> x >> y;
    cout << (winding_number(x, y, p, 3) ? "YES" : "NO") << endl;;
  }
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
int a,b;
int main () {
	scanf("%d%d",&a,&b);
	for (int i=1;i<=10000;i++) {
		if (i*8/100==a&&i/10==b) {printf("%d\n",i);return 0;}
	}
	printf("-1\n");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        String S = scan.next();
        String[] s = S.split("");
        String T = scan.next();
        String[] t = T.split("");
        int count = 0;
        for(int i = 0; i < S.length(); i++){
            if(!(s[i].equals(t[i]))){
                s[i] = t[i];
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 68860
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

signed main() {
  ll N;
  cin >> N;
  COUT(N * N);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<cctype>
#include<cmath>
#include<queue>
#include<stack> 
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
//const int MAX_V=105;

int main(){
  
  int N,n;
  cin >> N;
  n=N;
  n = n/10;
  N = N%10;
  
  if(n-9==0){
    cout << "Yes" << endl;
  }else if(N-9==0){ 
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

    return 0;
}
 

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

int main(){
    long long N,M;
    cin >> N >> M;
    vector<long long> x(N),y(N),z(N);
    for(int i=0;i<N;i++){
        cin >> x[i] >> y[i] >> z[i];
    }
    long long ans=0;
    for(int bit=0;bit<(1<<3);bit++){
        priority_queue<long long> que;
        long long tmp=0;
        for(int j=0;j<N;j++){
            long long a,b,c;
            a=x[j];
            b=y[j];
            c=z[j];
            if(!(bit&(1<<0))) a=-x[j];
            if(!(bit&(1<<1))) b=-y[j];
            if(!(bit&(1<<2))) c=-z[j];
            que.push(a+b+c);
        }
        for(int i=0;i<M;i++){
            tmp+=que.top();
            que.pop();
        }
        ans=max(ans,tmp);
    }
    cout << ans << endl;
}

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

#define rep(i,n) for(int i;i<(int)(n);i++)
#define Rep(i,n) for(int i;i<=(int)(n);i++)
#define all(v) v.begin,v.end
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int MX = 1000005;

int main(){
    int n,a,cnt=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        if((i%2==0)&&(a%2==1))cnt++;
    } 
    cout<<cnt<<endl;
}

Measured memory_bytes: 3620
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v, yes="Yes", no="No"):
    print([yes, no][not v])


def main():
    """エントリーポイント"""
    N = input(int)
    S = input([str, N])
    count = dd(int)
    max_ = [0, {}]
    for s in S:
        count[s] += 1
        if max_[0] == count[s]:
            max_[1] |= {s}
        elif max_[0] < count[s]:
            max_[0] = count[s]
            max_[1] = {s}
    for ans in sorted(max_[1]):
        print(ans)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


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

sum_card=0
if A<K:
    sum_card=A
    K-=A
else:
    sum_card=K
    K-=K
if B<K:
    K-=B
else:
    K-=K
sum_card-=K

print(sum_card)

Measured memory_bytes: 61780
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>

using namespace std;

int main() {
	double pai = 3.141592653589793;
	double r;
	double s,l;
	
	cin >> r;
	
	s = pai * r * r;
	l = 2 * pai * r;
	
	cout << fixed << setprecision(6) <<  s << " " << l << endl;
	}



Measured memory_bytes: 3268
package main

import (
	"bufio"
	"fmt"
	"os"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	S, T := nextLine(), nextLine()
	ans := 0
	for i := 0; i < len(S); i++ {
		if S[i] == T[i] {
			ans++
		}
	}
	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 640
import std.algorithm;
import std.array;
import std.bigint;
import std.bitmanip;
import std.conv;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; }

T[] readToArray(T)() {
    return readln.split.to!(T[]);
}

void readInto(T...)(ref T ts) {
    auto ss = readln.split;
    foreach(ref t; ts) {
        t = ss.front.to!(typeof(t));
        ss.popFront;
    }
}

// 冪乗をmod取りつつ計算
pure ulong modPow(ulong a, ulong n, ulong m) {
    ulong r = 1;
    while (n > 0) {
        if(n % 2 != 0) r = r * a % m;
        a = a * a % m;
        n /= 2;
    }
    return r;
}

// フェルマーの小定理から乗法逆元を計算
// 定理の要請により法は素数
pure ulong modInv(ulong a, ulong m) {
    return modPow(a, m-2, m);
}

// mod取りつつ順列を計算
pure ulong modPerm(ulong n, ulong k, ulong m) {
    if (n < k) return 0;

    ulong r = 1;
    for (ulong i = n-k+1; i <= n; i++) {
        r *= i;
        r %= m;
    }
    return r;
}

// mod取りつつ順列を計算
pure ulong modFact(ulong n, ulong m) {
    return modPerm(n, n, m);
}

// mod取りつつ組み合わせを計算
// modInvを使っているので法は素数
pure ulong modComb(ulong n, ulong r, ulong m) {
    return modPerm(n, r, m)*modInv(modFact(r, m), m) % m;
}

immutable ulong MOD = 1000000007;

void main() {
    ulong n, k;
    readInto(n, k);
    for (ulong i = 1; i <= k; i++) {
        writeln(modComb(n-k+1, i, MOD)*modComb(k-1, i-1, MOD) % MOD);
    }
}


Measured memory_bytes: 256
n,k = map(int, input().split())
s = [1]*n
for i in range(k):  
    d = int(input())
    a = list(map(int, input().split()))
    for i in range(d):
        if s[a[i] - 1] == 1:s[a[i] - 1] = 0
print(sum(s))

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

double a[102];
int main() {
	double n,sum=0;
	cin>>n;
	for(ll i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	double p=sum/n;
	double sa=abs(p-a[0]);
	ll ans=0;
	for(ll i=1;i<n;i++){
		double now=abs(p-a[i]);
		if(now<sa){
			ans=i;
			sa=now;
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  
  bool bo = false;
  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j < s.size(); j++) {
      if (s.at((i + j) % s.size()) != t.at(j)) {
        break;
      }
      else if (j == s.size() - 1) {
        bo = true;
      }
    }
    if (bo) {
      break;
    }
  }
  if (bo) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
   char S[3],T[3];
   int i,cou=0;
   scanf("%s",S);
   scanf("%s",T);
   for(i=0;i<3;i++){
      if(S[i]==T[i]){
         cou++;
      }
   }
   printf("%d",cou);
   return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

#define MAX 100000



typedef struct{
  int parent;
  int left;
  int right;
  int degree;
}node;

int getdepth(int);
int getsibling(int);
int getheight(int);

node T[MAX];

int main(){
  int i, j, sib, deg, id, k, n, depth;

  scanf("%d",&n);

  for(i=0;i<n;i++) T[i].parent = T[i].left = T[i].right = -1;

  for(i=0 ; i<n ; i++){

    scanf("%d",&id);
    scanf("%d%d",&T[id].left,&T[id].right);
    if(T[id].left != -1){
      T[T[id].left].parent = id;
      T[id].degree++;
    }
    if(T[id].right != -1){
      T[T[id].right].parent = id;
      T[id].degree++;
    }
/*
    for(j=0 ; j<k ; j++){

      scanf("%d",&deg);

      if(j==0) T[id].left = deg;

      else T[sib].right = deg;

      sib = deg;
      T[deg].parent = id;
    }*/
  }

  for(i=0 ; i<n ; i++){

    depth = getdepth(i);
    //printf("here\n");
    if(depth==0) printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, root\n", i, T[i].parent, getsibling(i), T[i].degree, depth, getheight(i));

    else if(T[i].left==-1 && T[i].right==-1) printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, leaf\n", i, T[i].parent, getsibling(i), T[i].degree, depth, getheight(i));

    else printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, internal node\n", i, T[i].parent, getsibling(i), T[i].degree, depth, getheight(i));
    /*
    //printf("here\n");
    printf("[");

    if(T[i].left != -1){
      id = T[i].left;
      printf("%d",id);

      while(id != -1){
        id = T[id].right;

        if(id != -1) printf(", %d",id);
      }
    }

    printf("]\n");
*/
  }
  return 0;
}

int getdepth(int i){//printf("in\n");
  int id = T[i].parent;
  int cnt = 0;

  while(id != -1){
    id = T[id].parent;
    cnt++;
    //printf("while\n");
  }

  return cnt;
}

int getsibling(int i){
  if(T[i].parent == -1) return -1;
  else if(T[T[i].parent].left == i) return T[T[i].parent].right;
  else return T[T[i].parent].left;
}

int getheight(int i){
  int l, r;
  if(i==-1) return -1;

  l = getheight(T[i].left);
  r = getheight(T[i].right);

  if(l>r) return l+1;
  else return r+1;

}



Measured memory_bytes: 2056
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1e+9 + 7;

//マクロ
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

struct Edge
{
  ll to, id;
};

vector<vector<Edge>> g;
vector<int> ans;

void dfs(ll v, ll c = -1, ll p = -1)
{
  int k = 1;
  rep(i, g[v].size())
  {
    ll u = g[v][i].to;
    ll ei = g[v][i].id;
    // 親以外の辺
    if (u == p)
      continue;
    // 親の数字ならインクリメント
    if (k == c)
      k++;
    ans[ei] = k;
    k++;
    // 自身が親になる
    dfs(u, ans[ei], v);
  }
}

int main()
{
  int n;
  cin >> n;
  g.resize(n);
  ans = vector<int>(n - 1);
  rep(i, n - 1)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back((Edge){b, i});
    g[b].push_back((Edge){a, i});
  }
  dfs(0);
  int mx = 0;
  rep(i, n) mx = max(mx, int(g[i].size()));
  cout << mx << endl;
  rep(i, n - 1)
  {
    cout << ans[i] << endl;
  }
  return 0;
}

// int main()
// {
//   ll n;
//   cin >> n;
//   vector<vector<ll>> e(n);
//   map<ll, ll> mp;
//   ll maxColor = 0;
//   rep(i, n - 1)
//   {
//     ll a, b;
//     cin >> a >> b;
//     a--;
//     b--;
//     e[a].push_back(i);
//     e[b].push_back(i);
//   }
//   ll ma = 0;
//   rep(i, n)
//   {
//     ll cannotUse = 0;
//     ll now = 1;
//     for (const auto &e : e[i])
//     {
//       // すでに存在
//       if (mp.count(e) != 0)
//       {
//         cannotUse = e;
//       }
//       else
//       {
//         if (now == cannotUse)
//         {
//           now++;
//         }
//         mp[e] = now;
//         if (ma < now)
//         {
//           ma = now;
//         }
//         now++;
//       }
//     }
//   }
//   cout << ma << "\n";
//   auto begin = mp.begin(), end = mp.end();
//   for (auto iter = begin; iter != end; iter++)
//   {
//     cout << iter->second << "\n";
//   }
//   return 0;
// }

Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
// 写経ver
using P = complex<double>;

const double eps = 1e-7;

double cross(const P &a,const P &b) {
    return a.real() * b.imag() - a.imag() * b.real();
}

template <class iter>
std::pair<P, double> min_ball(iter left, iter right, int seed = 1333) {
    const int n = right - left;

    assert(n >= 1);
    if (n == 1) {
        return {*left, double(0)};
    }

    std::mt19937 mt(seed);
    std::shuffle(left, right, mt);
    // std::random_shuffle(left, right); // simple but deprecated

    iter ps = left;
    using circle = std::pair<P, double>;

    auto make_circle_3 = [](const P &a, const P &b, const P &c) -> circle {
        double A = std::norm(b - c), B = std::norm(c - a), C = std::norm(a - b),
           S = cross(b - a, c - a);
        P p = (A * (B + C - A) * a + B * (C + A - B) * b + C * (A + B - C) * c) / (4 * S * S);
        double r2 = std::norm(p - a);
        return {p, r2};
    };

    auto make_circle_2 = [](const P &a, const P &b) -> circle {
        P c = (a + b) / (double)2;
        double r2 = std::norm(a - c);
        return {c, r2};
    };

    auto in_circle = [](const P &a, const circle &c) -> bool {
        return std::norm(a - c.first) <= c.second + eps;
    };

    circle c = make_circle_2(ps[0], ps[1]);

    // MiniDisc
    for (int i = 2; i < n; ++i) {
        if (!in_circle(ps[i], c)) {
            // MiniDiscWithPoint
            c = make_circle_2(ps[0], ps[i]);
            for (int j = 1; j < i; ++j) {
                if (!in_circle(ps[j], c)) {
                    // MiniDiscWith2Points
                    c = make_circle_2(ps[i], ps[j]);
                    for (int k = 0; k < j; ++k) {
                        if (!in_circle(ps[k], c)) {
                            c = make_circle_3(ps[i], ps[j], ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}

int main(void)
{
    IOS
    int n; cin >> n;
    vector<P> v;
    REP(i,n) {
        double x,y;
        cin >> x >> y;
        v.push_back(P(x,y));
    }

    auto ans = min_ball(ALL(v));
    
    cout << fixed << setprecision(10) << sqrt(ans.second) << '\n';

    return 0;
}

Measured memory_bytes: 384