akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(){
  int N; scanf("%d", &N); // N ha saikoro no men no kazu
  int K; scanf("%d", &K); // K ha tokuten no judge you no suuji
  int count;
  int score = 0;
  double prov = 0;
  double prov_tmp = 1;
  int i, j, l;
  
  for(i = 1; i <= N; i++){
    count = 0;
    score = i;
    if(score < K){
      for(j = 1; score < K; j++){
	score *= 2;
	count++;
      }
    }
    if(count != 0){
      for(l = 1; l <= count; l++){
	prov_tmp /= 2.0;
      }
    }
    prov += prov_tmp;
    
    prov_tmp = 1;
  }

  printf("%.12lf", prov / (double)(N));
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int n;
	double x, ans=0;
	string u;
	cin >> n;
	cout << fixed;
	cout << setprecision(8) <<endl;
	for(int i=0; i<n; i++){
		cin >> x >> u;
		if(u[0]=='J'){
			ans+=x;
		} else {
			ans+=x*380000;
		}
	}
cout << ans << endl;

	return 0;
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (int)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}


int main()
{
    ll n,cntf=0,cntb=0;
    cin >> n;
    
    vll a(n),fro(n),bac(n);
    rep(i,n)cin >> a[i];
    
    rep(i,n){
        cntf += a[i];
        fro[i] = cntf;
    }

    repr(i,n){
        cntb += a[i];
        bac[i] = cntb;
    }

    //rep(i,n)cout << fro[i] << " " << bac[i] << endl;

    
    ll min=M;
    rep(i,n-1){
        ll dif = abs(fro[i]-bac[i+1]);
        if(dif < min)min = dif;
    }

    cout << min << endl;
    return 0;
}

Measured memory_bytes: 4992
import java.io.IOException;
import java.util.Scanner;

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

		int n = sc.nextInt();
		int min = 1_000_000_000;
		int max = 1;

		for (int i = 0; i < n; i++) {
			int tmp = sc.nextInt();
			if (tmp < min)
				min = tmp;
			if (tmp > max)
				max = tmp;
		}

		System.out.println(max - min);

		sc.close();
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int A,B;
int main(){
    cin >> A >> B;
    if(A + B < 10) cout << A + B << '\n';
    else cout << "error" << '\n';
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

int main()
{
	int i, j, h[10], buf;
	
	for(i=0; i<10; i++) {
		scanf("%d", &h[i]);
	}

	for(j=0; j<9; j++){
		for(i=9; i>j; i--){
			if(h[i-1] > h[i]){
				buf = h[i-1];
				h[i-1] = h[i];
				h[i] = buf;
			}
		}
	}
	printf("%d\n%d\n%d\n", h[9], h[8], h[7]);
	return 0;

}

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

int main()
{
  int N, ans = 0;
  vector<int> a(100);
  vector<int> b(100);
  vector<int> sum_a(100);
  vector<int> sum_b(100);

  cin >> N;
  for (int i = 0; i < N; i++)
    cin >> a[i];
  for (int i = 0; i < N; i++)
    cin >> b[i];
  sum_a[0] = a[0];
  sum_b[0] = b[N - 1];
  for (int i = 1; i < N; i++)
  {
    sum_a[i] = sum_a[i - 1] + a[i];
    sum_b[i] = sum_b[i - 1] + b[N - 1 - i];
  }
  for (int i = 0; i < N; i++)
    ans = max(ans, sum_a[i] + sum_b[N - 1 - i]);
  cout << ans << endl;
}

Measured memory_bytes: 256
#define _DEBUG
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const ll INF=1e+18;
const int MOD=1e+9+7;

//デバッグ
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug1(x1) cout<<#x1<<": "<<x1<<endl
#define debug2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug5,debug4,debug3,debug2,debug1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif

//REPマクロ
#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 REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//省略
using vi  = vector<int>;
using vii = vector<vector<int>>;
using vl  = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

// xのn乗%modを計算
ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}

int main(){
    ll N,X,M;
    cin>>N>>X>>M;
    ll cnt=1;
    vl deta(M,0);
    deta[X]++;
    ll ans=X;

    vl mdpow(M,0);
    REP(i,M){
        mdpow[i]=mod_pow(i,2,M);
    }

    while(true){
        X = mdpow[X];
        ans+=X;
        cnt++;

        if(cnt==N){
            cout<<ans<<endl;
            return 0;    
        }

        if(deta[X]!=0){
            break;
        }else{
            deta[X]++;
        }
    }
    ll one_loop=0;

    ll tmp=X;
    ll loop_sum=0;
    ll loop_size=0;

    do{
        X = mdpow[X];
        loop_sum+=X;
        loop_size++;
    }while(X!=tmp);

    ll loop_cnt=(N-cnt)/loop_size;

    cnt+=loop_cnt*loop_size;
    ans+=(loop_sum*loop_cnt);
    
    X = tmp;

    while(cnt<N){
        X = mdpow[X];
        ans+= X;
        cnt++;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 4772
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int[] data = new int[5];
		for(int i = 0;i < 5;i++){
			data[i] = sc.nextInt();
		}
		
		int index = 0;
		int min = 10;
		for(int i = 0;i < 5;i++){
			int sub = data[i] % 10;
			
			if(sub < min && sub != 0){
				index = i;
				min = sub;
			}
			
		}
		
		int ans = 0;
		for(int i = 0;i < 5;i++){
			if(i != index){
				while(data[i] % 10 != 0){
					data[i] = data[i] + 1;
				}
			}
			ans += data[i];
		}
		System.out.print(ans );
		

	}
	


}


class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}




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

using namespace std;

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


int main()
{
  string n;
  cin >> n;
  for (int i = 0; i <= int(n.size()) / 2; i++){
    if (n[i] != n[int(n.size()) - 1 - i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio() ios_base::sync_with_stdio(false);
#define rmod(x, y) ((((x)%(y))+(y))%(y))
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
template<typename T, typename R = null_type, typename C = less<T>>
tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update> ordered_set(){
	return tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update>();
}

const int maxn = 2e5+5;
int n, k, a[maxn];
int main(){
	scanf("%d %d", &k, &n);
	for(int i = 0; i<n; i++) scanf("%d", &a[i]);
	a[n] = k+a[0];
	ll sum = 0, mx = 0;
	for(int i = 0; i<n; i++)
		sum+= ll(a[i+1]-a[i]), mx = max(ll(a[i+1]-a[i]), mx);
	sum-= mx;
	printf("%lld\n", sum);

	return 0;
}


Measured memory_bytes: 1152
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

struct State {
  int from;
  int to;
  State(int f,int t)
    : from(f),to(t) {}
};

void matrix_pow(const bool A[101][101],const bool B[101][101],
                bool C[101][101],int length){
  bool tmp[101][101] = {};
  for(int i = 0; i < length; i++){
    for(int j = 0; j < length; j++){
      bool sum = false;
      for(int k = 0; k < length; k++){
        sum |= (A[i][k] && B[k][j]);
      }
      tmp[i][j] = sum;
    }
  }
  memcpy(C,tmp,sizeof(bool)*101*101);
}

void fast_pow(int n,int length,bool A[101][101],bool C[101][101]) {
  for(int i = 0; i < length; i++){
    C[i][i] = 1;
  }
  while(n > 0) {
    if (n & 1){
      matrix_pow(C,A,C,length);
    }
    matrix_pow(A,A,A,length);
    n >>= 1;
  }
}

int main(){
  int total_stations;
  int total_sections;
  int total_steps;
  while(~scanf("%d %d %d",
               &total_stations,
               &total_sections,
               &total_steps)){
    if(total_stations == 0 && total_sections == 0 && total_steps == 0) break;
    vector<int> edge[101];
    for(int section_i = 0; section_i < total_sections; section_i++){
      int src,dst;
      scanf("%d %d",&src,&dst);
      src--; dst--;
      edge[src].push_back(dst);
      edge[dst].push_back(src);
    }

    vector<State> states;
    states.push_back(State(-1,0));
    for(int from = 0; from < total_stations; from++){
      for(int i = 0; i < edge[from].size(); i++){
        int to = edge[from][i];
        states.push_back(State(from,to));
      }
    }

    bool init_matrix[101][101] = {};
    for(int y = 0; y < states.size(); y++){
      for(int x = 0; x < states.size(); x++){
        if(states[y].to == states[x].from
           && states[y].from != states[x].to){
          init_matrix[y][x] = true;
        }
      }
    }

    bool result_matrix[101][101] = {};
    fast_pow(total_steps,states.size(),init_matrix,result_matrix);

    bool isok = false;
    for(int i = 0; i < states.size(); i++){
      if(states[i].to == total_stations - 1 && result_matrix[0][i]){
        isok = true;
        break;
      }
    }
    printf("%s\n",isok ? "yes" : "no");
  }
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
//---------------------------------------------------------------------------------------------------
typedef pair<int,int> P;

int main(void){
    // Your code here!
    int x; cin >> x;
    ll ans = 0;
    while (x - 500 >= 0) {
        x-=500;
        ans+= 1000;
    }
    while( x - 5 >= 0) {
        x-=5;
        ans += 5;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3600
#include<iomanip>
#include <string>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
#define nin(n) int n; cin >> n;
#define kin(k) int k; cin >> k;
const int INF = 1001001001;
int main(){
   int n; cin >> n;vector<string> s(n);
  for(int i=0;i<n;i++){
    cin >> s[i];
    sort(s[i].begin(),s[i].end());
  }
  sort(s.begin(),s.end());
 long long int ans=0;
  int count=0;
  for(int i=0;i<n-1;i++){
    if(s[i]==s[i+1]){
      count++;
      ans+=count;
    }
    else{
      count=0;
    }
  }
  cout << ans;
}

Measured memory_bytes: 7296
#include <algorithm>
#include <cassert>
#include <iostream>
#include <limits>
#include <queue>
#include <vector>

#ifdef _DEBUG
#define ASSERT(x) cassert(x)
#define DLOG(x) cout << #x " " << x << endl;
#else
#define ASSERT(x)
#define DLOG(x)
#endif

using namespace std;

bool canCompose(const vector<int>& nums, int q, vector<bool>& buf) {
  buf.resize(q);
  buf.assign(q, false);
  buf[0] = true;
  for (auto n : nums) {
    for (int i = buf.size() - 1; i >= 0; --i) {
      if (buf[i]) {
        if (i + n == buf.size()) {
          return true;
        } else if (i + n < buf.size()) {
          buf[i + n] = true;
        }
      }
    }
  }
  return false;
}

int main() {
  int n;
  cin >> n;
  vector<int> nums;
  nums.reserve(n);
  for (int i = 0; i < n ; ++i) {
    int t;
    cin >> t;
    nums.push_back(t);
  }
  int q;
  sort(nums.begin(), nums.end(), greater<int>());
  cin >> q;
  vector<bool> buf;
  for (int i = 0; i < q; ++i) {
    int t;
    cin >> t;
    cout << (canCompose(nums, t, buf) ? "yes" : "no") << endl;
  }
}



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

int n;

bool is_true(int mm, int yy){
	return mm>=1 && mm<=12;
}

int main(){
	cin >> n;
	int yy = n%100;
	int mm = n/100;
	if(is_true(mm,yy) && is_true(yy,mm)){
		cout << "AMBIGUOUS\n";
	} else if(is_true(mm,yy)){
		cout << "MMYY\n";
	} else if(is_true(yy,mm)){
		cout << "YYMM\n";
	} else {
		cout << "NA\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
    
int main(){
    long long k;
    cin >> k;
    long long cur = 7;
    int cnt = 1;
    int ans = -1;
    bool ok = false;
    rep(i,k+3){
        cur = cur % k;
        if(cur == 0){
            ok = true;
            ans = cnt;
            break;
        }
        cur = cur * 10 + 7;
        cnt ++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3584
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

#define INF (int)1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

template <typename T> using Vec = vector<T>; // c++11
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

Vec<bool> elatos (int m) {
    Vec<bool> prime(m + 1, true);
    for (int i = 2; i < m + 1; i++) {
        if (prime[i] == true) {
            int j = 2;
            while (i * j < m + 1) {
                prime[i * j] = false;
                j++;
            }
        }
    }
    return prime;
}

int main(void) {
    while (1) {
        int m;
        int a;
        int b;
        cin >> m >> a >> b;
        if (b == 0) {
            break;
        }

        int product = 0;
        int ans_p;
        int ans_q;

        Vec<bool> prime = elatos(m);

        for (int p = 1; p * p <= m; p++) {
            for (int q = p; p * q <= m; q++) {
                double first = (double)a / (double)b;
                double second = (double)p / (double)q;
                if (first <= second && p * q > product && prime[p] == 1 && prime[q] == 1) {
                    product = p * q;
                    ans_p = p;
                    ans_q = q;
                }
            }
        }
        cout << ans_p << " " << ans_q << endl;
    }
    return 0;
}

Measured memory_bytes: 2976
n = input()
red = []
for i in range(n):
    red.append(raw_input())
k = input()
blue = []
for j in range(k):
    blue.append(raw_input())
ans = 0
for r in red:
    counterR = 0
    counterB = 0
    for word in red:
        if word == r:
            counterR += 1
    for word in blue:
        if word == r:
            counterB += 1
    if ans < counterR - counterB:
        ans = counterR - counterB
print ans

Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N; cin >> N;
    string S; cin >> S;
    lint ans = 0;
    range(i, 0, N - 2) {
        if (S.substr(i, 3) == "ABC") ans += 1;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
//gauravsinghh
#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 ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define MAXI (1<<32)
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100005
#define SIZ 1000005
#define SIZE 200005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define ffo(i, a, b) for(int i = a; i >= b; i--)
#define MAX 100005
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

bool comp(const pair<ll,ll>&a,const pair<ll,ll>&b){
	return a.ss < b.ss;
}

//ll p[20000005]={0};
//vector<ll>ans;
/*void sieve(){
    ll i,j;
    p[0]=p[1]=1;
    for(i=2;i*i<=20000005;i++){
        if(!p[i]){
            for(j=2*i;j<20000005;j+=i){
                p[j]=1;
            }
        }
    }
    fo(i,2,20000005){
        if(!p[i]){
            ans.pb(i);
        }
    }
}*/


signed main(){ 
    IOS
    //io_set();
    ll n;
    cin >> n;
    cout << 24 - n + 24 << endl;
    return 0;
}



Measured memory_bytes: 256
class UnionFind:
    def __init__(self, node):
        self.parent = [-1 for _ in range(node)]

    def find(self, target):
        if self.parent[target] < 0:
            return target
        else:
            self.parent[target] = self.find(self.parent[target])
            return self.parent[target]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def union(self, x, y):
        root_x = self.find(x)
        root_y = self.find(y)
        if root_x == root_y:
            return
        if self.parent[root_x] > self.parent[root_y]:
            root_x, root_y = root_y, root_x
        self.parent[root_x] += self.parent[root_y]
        self.parent[root_y] = root_x

    def get_size(self, x):
        return -self.parent[self.find(x)]

    def get_root(self):
        return [i for i, root in enumerate(self.parent) if root < 0]


def main():
    n, m = map(int, input().split())
    uf = UnionFind(n)
    for _ in range(m):
        x, y, _ = map(lambda x: int(x) - 1, input().split())
        uf.union(x, y)
    print(len(uf.get_root()))


if __name__ == '__main__':
    main()


Measured memory_bytes: 13460
#include<bits/stdc++.h>
using namespace std;
#define lli long long int 
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define vi vector<lli> 
#define pb push_back
#define NA(i,s,n) for(lli i=s; i<n; ++i)

const lli N = 1e5 + 3;
vi gp[N];
lli n, m;

void dfs(lli nd, lli par, vi &vis) {
    vis[nd] = 1;
    for(lli i:gp[nd]) if(i!=par && vis[i]!=1) {
        dfs(i, nd, vis);
    }
    return;
}

void solve(){
    cin >> n >> m;
    lli a, b;
    NA(i,0,m) {
        cin >> a >> b;
        gp[a].pb(b), gp[b].pb(a);
    }
    lli ct = 0;
    vi vis(n+1, 0);
    NA(i,1,n+1) {
        if(!vis[i]) dfs(i, -1, vis), ++ct;
    }
    cout << (ct - 1);
    return;
}

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

Measured memory_bytes: 11100
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <queue>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <sstream>
#include <cassert>
#include <functional>
#include <cfloat>
#include <climits>
#include <cstring>
#include <stack>
#include <time.h>
#include <complex>
using namespace std;

int main()
{
    int X,t;
    cin>>X>>t;
    if(t>=X)
    cout<<"0";
    else cout<<X-t; 
    return 0;
}


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

using namespace std;
typedef long long ll;
ll N,A; vector<ll> x;

ll dp[60][6000];

ll dfs(ll a, ll b){
  
  if( dp[a][b] != -1){ return dp[a][b];}
  if( b < 0 || b > 6000|| a < 0){ return 0;}
  else{
    ll res = dfs( a - 1, b) + dfs( a - 1, b - x[a]);
    
    return dp[a][b] = res;}
}


int main(){
 cin >> N >> A; x.resize(N);
  
 for(ll i = 0; i < N; i++){ cin >> x[i] ;  x[i]  -=A;}
                                                                
  
  for(ll i = 0; i < 60; i++){
    for(ll j = 0; j < 6000; j++){
      dp[i][j] = -1;
      if( i == 0){ dp[i][j] = 0;}
 }}
  
   dp[0][x[0] + 3000] +=  1; //initialize; 
   dp[0][3000] += 1; // select nothing
  
  
      
  
  cout << dfs(N-1, 3000) - 1 << endl; return 0;}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;
int main(){

  ll a,b,c,d,i;
  cin >> a >> b ;

  c=max(a,b);
  d=min(a,b);
  for(i=c;i<=a*b;i+=c){
    if(i%a==0 && i%b==0){
      cout << i << endl;
      return 0;
    }
  }

  cout << a*b << endl;

}


Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
 
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> p;

#define INF (1<<29)
#define INFL (1ll<<60)
#define EPS (1e-10)
#define PI (acos(-1))
const ll MOD = 1000000007ll;


ll mod_pow(ll x, ll n) {
	if (n == 0) return 1;
	ll res = mod_pow(x * x % MOD, n / 2);
	if (n & 1) res = res * x % MOD;
	return res;
}

ll n;
ll x[112345];
ll fact[112345];

int main() {
	cin >> n;
	REP(i, n) scanf("%lld", x + i);
	
	fact[0] = 1;
	FOR(i, 1, 112345) fact[i] = fact[i - 1] * i % MOD;
	
	ll ans = 1, cnt = 0;
	FOR(i, 1, n) {
		if (x[i] < (i - cnt) * 2 + 1) {
			ans = ans * (i + 1 - cnt) % MOD;
			cnt++;
		}
	}
	ans = ans * fact[n - cnt] % MOD;
	
	cout << ans << endl;
	return 0;
}


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

#define PB push_back
#define F first
#define S second
#define MP make_pair
#define LL long long
#define ULL unsigned long long
#define LB lower_bound
#define MOD1 1000000007
#define MOD2 1000000009
#define INF LONG_MAX
#define pr(i, x, n)                    \
    for (int ii = i; ii < n + i; ii++) \
    {                                  \
        cout << x[ii] << " ";          \
    }                                  \
    cout << endl;
#define ip(i, x, n)                    \
    for (int ii = i; ii < n + i; ii++) \
    {                                  \
        cin >> x[ii];                  \
    };
#define db(x, y) cout << x << " " << y << endl;
#define LD long double
#define PR pair<LD, LL>

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main()
{
    static const int _ = []() {
        ios::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        return 0;
    }();
    int n,m;
  cin >> n >> m;
  if(n == m)
    cout << "Yes";
  else
    cout << "No";
   

    return 0;
}

Measured memory_bytes: 256
count = 0
n = int(input())
p = list(map(int,input().split()))

for i in range(n-2):
    if p[i] < p[i+1] < p[i+2]:
        count += 1
    elif p[i] > p[i+1] > p[i+2]:
        count += 1
print(count)

Measured memory_bytes: 3060
s = input()

dir = [0 for i in range(4)]
for i in range(len(s)):
    if s[i] == "N":
        dir[0] += 1
    elif s[i] == "W":
        dir[1] += 1
    elif s[i] == "S":
        dir[2] += 1
    elif s[i] == "E":
        dir[3] += 1

if 0 not in dir:
    print("Yes")
elif dir.count(0) == 3:
    print("No")
elif dir[0] == 0 and dir[2] == 0 or dir[1] == 0 and dir[3] == 0:
    print("Yes")
else:
    print("No") 

Measured memory_bytes: 3064
#include <iostream>
#include <string.h>
using namespace std;
int main(void){
    int num[13]={0,1,3,1,2,1,2,1,1,2,1,2,1};
    int x,y;
    cin>>x>>y;
    if(num[x]==num[y]) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, bool>> data(N, {1, false});
    data[0].second = true;

    rep(i, M){
        int x, y;
        cin >> x >> y;
        int numx = data[x - 1].first;
        bool bx = data[x - 1].second;
        int numy = data[y - 1].first;
        bool by = data[y - 1].second;
        
        if(numx == 1){
            data[x - 1] = make_pair(0, false);
            data[y - 1] = make_pair(numy + 1, by || bx);
        } else {
            data[x - 1] = make_pair(numx - 1, bx);
            data[y - 1] = make_pair(numy + 1, by || bx);
        }
    }

    int ans = 0;

    for(pair<int, bool> p: data){
        if(p.second){
            ans++;
        }
    }
    cout << ans << endl;
    
    return 0;
}


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

using namespace std;
const int MAX = 305;

double p[MAX][MAX][MAX], ev[MAX][MAX][MAX];
int cnt[4];

int main()
{
    int n;

    cin >> n;

    for(int i = 1; i <= n; ++i)
    {
        int a;

        cin >> a;

        ++cnt[a];
    }

    p[cnt[1]][cnt[2]][cnt[3]] = 1;

    for(int c = n; c >= 0; --c)
        for(int b = n; b >= 0; --b)
            for(int a = n; a >= 0; --a)
            {
                if(a + b + c == 0)
                    continue;

                if(a + b + c > n)
                    continue;

                double pWaste = (double)(n - (a + b + c)) / n;
                double evWaste = pWaste / (1 - pWaste) + 1;

                ev[a][b][c] += evWaste * p[a][b][c];

                if(a != 0)
                {
                    double currP = (double)a / (a + b + c);
                    p[a - 1][b][c] += p[a][b][c] * currP;
                    ev[a - 1][b][c] += ev[a][b][c] * currP;
                }
                if(b != 0)
                {
                    double currP = (double)b / (a + b + c);
                    p[a + 1][b - 1][c] += p[a][b][c] * currP;
                    ev[a + 1][b - 1][c] += ev[a][b][c] * currP;

                }
                if(c != 0)
                {
                    double currP = (double)c / (a + b + c);
                    p[a][b + 1][c - 1] += p[a][b][c] * currP;
                    ev[a][b + 1][c - 1] += ev[a][b][c] * currP;
                }
            }

    cout << setprecision(10);
    cout << ev[0][0][0];

    return 0;
}


Measured memory_bytes: 221320
import Data.List

main = do
  s <- getLine
  t <- getLine
  print $ compute s t

compute :: String -> String -> Int
compute s t = minimum $ map (dist t) $ tails s

dist (t:ts) (s:ss) = dist ts ss + if t == s then 0 else 1
dist [] _ = 0
dist _ [] = 9999


Measured memory_bytes: 3920
import java.util.*;

public class Main {
    final static int MOD = 1000000007;
    
    public static void main(String[] args) {
        MyScanner in = new MyScanner();
        int a = in.nextInt();
        int b = in.nextInt();
        int ans = -1;
        
        if (0 < a && a < 10 && 0 < b && b < 10) {
            System.out.println(a * b);
        } else {
            System.out.println(ans);
        }
        
    }
    
    static class MyScanner {
        static Scanner sc = new Scanner(System.in);
        
        String next() {
            return sc.next();
        }
        
        String nextLine() {
            return sc.nextLine();
        }
        
        int nextInt() {
            return Integer.parseInt(sc.next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        int[] nextIntArray(int n) {
            int[] array = new int[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextInt();
            }
            return array;
        }
        
        double[] nextDoubleArray(int n) {
            double[] array = new double[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextDouble();
            }
            return array;
        }
        
        long[] nextLongArray(int n) {
            long[] array = new long[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextLong();
            }
            return array;
        }
        
        String[] nextLineArray(int n) {
            String[] array = new String[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextLine();
            }
            return array;
        }
        
        int[][] nextIntMatrix(int n, int m) {
            int[][] matrix = new int[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    matrix[i][j] = nextInt();
                }
            }
            return matrix;
        }
        
        double[][] nextDoubleMatrix(int n, int m) {
            double[][] matrix = new double[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    matrix[i][j] = nextDouble();
                }
            }
            return matrix;
        }
        
        long[][] nextLongMatrix(int n, int m) {
            long[][] matrix = new long[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    matrix[i][j] = nextLong();
                }
            }
            return matrix;
        }
    }
}

Measured memory_bytes: 23764
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};



int N;

int main () {
  cin >> N;

  if (N % 2 == 1) {
    int sum = (N * N - N - (N - 1)) / 2;
    cout << sum << "\n";

    for (int i=1;i<=N;++i) {
      for (int j=1;j<=N;++j) {
        if (i >= j) continue;
        if (i + j == N) continue;

        cout << i << " " << j << "\n";
      } 
    }
  } else {
    int sum = (N * N - N - N) / 2;
    cout << sum << "\n";


    for (int i=1;i<=N;++i) {
      for (int j=1;j<=N;++j) {
        if (i >= j) continue;
        if (i + j == (N + 1)) continue;

        cout << i << " " << j << "\n";
      } 
    }
  }
}

Measured memory_bytes: 256
class Dice 
    attr_reader :nums
    def initialize(nums)
        @nums = [nil] + nums
    end
    def top
        @nums[1]
    end
    def front
        @nums[2]
    end
    def right
        @nums[3]
    end
    def rollx
        @nums[1], @nums[2], @nums[6], @nums[5] = @nums[5], @nums[1], @nums[2], @nums[6]
        self
    end
    def rolly
        @nums[1], @nums[3], @nums[6], @nums[4] = @nums[4], @nums[1], @nums[3], @nums[6]
        self
    end
    def rollz
        @nums[2], @nums[3], @nums[5], @nums[4] = @nums[4], @nums[2], @nums[3], @nums[5]
        self
    end
    def moveN
        rollx.rollx.rollx
    end
    def moveS
        rollx
    end
    def moveE
        rolly
    end
    def moveW
        rolly.rolly.rolly
    end
    def move(m)
        case m
        when 'N' then moveN
        when 'S' then moveS
        when 'E' then moveE
        when 'W' then moveW
        end
    end
    def move_all
        moves = [
            # top:1 front:2
            :y, :rollz, :y, :rollz, :y, :rollz, :y, :rollz, :moveN,
            # top:2 front:6
            :y, :rollz, :y, :rollz, :y, :rollz, :y, :rollz, :moveW,
            # top:3 front:6
            :y, :rollz, :y, :rollz, :y, :rollz, :y, :rollz, :moveW,
            # top:5 front:6
            :y, :rollz, :y, :rollz, :y, :rollz, :y, :rollz, :moveW,
            # top:4 front:6
            :y, :rollz, :y, :rollz, :y, :rollz, :y, :rollz, :moveN,
            # top:6 front:3
            :y, :rollz, :y, :rollz, :y, :rollz, :y, :rollz,
        ]
        moves.each do |m|
            if m == :y
                yield self
            else
                self.send(m)
            end
        end
    end
end

nums = STDIN.gets.split.map(&:to_i)
n = STDIN.gets.to_i

dice = Dice.new(nums)

n.times do |i|
    t, f = STDIN.gets.split.map(&:to_i)
    dice.move_all do |d|
        if d.top == t && d.front == f
            puts d.right
        end
    end
end

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

using namespace std;

long long f(long long x, long long m) {
    return x % m;
}

int main() {
    long long n, x, m;
    cin >> n >> x >> m;

    vector<long long> results(1, x);
    long long a = x;
    long long preCount = 0;
    long long preSum = x;
    long long setCount = 0;
    long long setSum = 0;
    for (int i = 1; i < n; i++) {
        a = f(a * a, m);
        preSum += a;
        for (int j = results.size() - 1; j >= 0; j--) {
            if (results[j] == a) {
                setCount = i - j;
                preCount = i;
                for (int k = 0; k < setCount; k++) {
                    setSum += results[j + k];
                }
                break;
            }
        }
        if (setCount) {
            break;
        }
        results.push_back(a);
    }
    if (!setCount) {
        cout << preSum << endl;
        return 0;
    }

    long long setTime = (n - preCount - 1) / setCount;
    long long remain = (n - preCount - 1) % setCount;
    long long subSum = 0;
    for (int i = 0; i < remain; i++) {
        a = f(a * a, m);
        subSum += a;
    }

    cout << preSum + setTime * setSum + subSum << endl;
    return 0;
}

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

using namespace std;

struct edge {
    int u, v, cost;
};

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

bool comp(const edge &e1, const edge &e2)
{
    return e1.cost < e2.cost;
}

const int MAX_M = (100 - 1) * 50 + 1;
int N, M;
edge es[MAX_M];

void Kruskal()
{
    sort(es, es + M, comp);
    UnionFind uf(N);
    int res = 0;
    int cnt = 0;

    for (int i = 0; i < M; i++) {
        edge e = es[i];
        if (!uf.findSet(e.u, e.v)) {
            uf.unionSet(e.u, e.v);
            res += e.cost;
            cnt++;
        }
    }

    cout << res << endl;
}

int main()
{
    while (cin >> N >> M, N || M) {
        for (int i = 0; i < M; ++i)
            cin >> es[i].u >> es[i].v >> es[i].cost;
        Kruskal();
    }

    return 0;
}

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

const int N = 100000;

int a[N], len[N], cnt[N], rnk[N];

int main()
{
  int n, m, q;
  while (scanf("%d%d%d", &n, &m, &q) == 3) {
    for (int i = 0; i < q; ++ i) {
      scanf("%d", a + i);
      a[i] --;
    }
    memset(len, 0, sizeof(*len) * n);
    memset(cnt, 0, sizeof(*cnt) * m);
    memset(rnk, -1, sizeof(*rnk) * m);
    std::vector<int> seq;
    for (int i = q - 1; i >= 0; -- i) {
      if (rnk[a[i]] == -1) {
        rnk[a[i]] = seq.size();
        seq.push_back(a[i]);
      }
      if (cnt[a[i]] < n && len[cnt[a[i]]] == rnk[a[i]]) {
        len[cnt[a[i]]] ++;
        cnt[a[i]] ++;
      }
    }
    int o = 0;
    while (o < m && ~rnk[o]) {
      o ++;
    }
    int min_len = seq.size();
    while (min_len && seq[min_len - 1] < o) {
      o = seq[-- min_len];
    }
    bool ok = true;
    for (int i = 0; i < n; ++ i) {
      ok &= len[i] >= min_len;
    }
    puts(ok ? "Yes" : "No");
  }
}


Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin>>n;
    string s;
    while(n){
        if(n%2){
            s+='1';
            n--;
        }else{
            s+='0';
        }
        n/=(-2);
    }
    reverse(s.begin(),s.end());
    if(s=="")cout<<0<<endl;
    else cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	double data;
	while(scanf("%lf",&data)!=EOF){
		if(data>91.00) printf("heavy\n");
		else if(data>81.00) printf("light heavy\n");
		else if(data>75.00) printf("middle\n");
		else if(data>69.00) printf("light middle\n");
		else if(data>64.00) printf("welter\n");
		else if(data>60.00) printf("light welter\n");
		else if(data>57.00) printf("light\n");
		else if(data>54.00) printf("feather\n");
		else if(data>51.00) printf("bantam\n");
		else if(data>48.00) printf("fly\n");
		else 				printf("light fly\n");
	}
	return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using ll = long long;
using namespace std;

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

  bool c = false;
  for(int i=0;i<N.length();i++){
    if(N.at(i) == '7'){
      c = true;
      break;
    } 
  }

  if(c){  
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }


  return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
struct UnionFind{
  int n;
  vector<int> r,p;
  UnionFind(){}
  UnionFind(int sz):n(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
  int find(int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }
  int size(int x){
    return r[find(x)];
  }
};
//END CUT HERE

struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE

signed DSL_1_A(){
  int n,q;
  cin>>n>>q;
  UnionFind uf(n);
  for(int i=0;i<q;i++){
    int c,x,y;
    cin>>c>>x>>y;
    if(c) cout<<uf.same(x,y)<<"\n";
    else uf.unite(x,y);
  }
  cout<<flush;
  return 0;
}
/*
  verified on 2019/03/03
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_A&lang=jp
*/

signed ABC120_D(){
  int n,m;
  cin>>n>>m;
  vector<int> a(m),b(m);
  for(int i=0;i<m;i++) cin>>a[i]>>b[i];

  UnionFind uf(n);
  vector<Int> ans(m+1,0);
  ans[m]=(Int)n*(n-1)/2;
  for(int i=m-1;i>=0;i--){
    a[i]--;b[i]--;
    ans[i]=ans[i+1];
    if(uf.same(a[i],b[i])) continue;
    
    Int x=uf.size(a[i]),y=uf.size(b[i]);
    ans[i]-=x*y;
    
    uf.unite(a[i],b[i]);
  }
  ans.erase(ans.begin());
  for(Int x:ans) cout<<x<<"\n";
  cout<<flush;
  return 0;
}

/*
  verified on 2019/03/03
  https://atcoder.jp/contests/abc120/tasks/abc120_d
*/

signed main(){
  //DSL_1_A();
  ABC120_D();
  return 0; 
}


Measured memory_bytes: 3712
#include <stdio.h>
int main() {
	int n, ans = 0;
	char a[101], b[101], c[101];
	scanf("%d%s%s%s", &n, a, b, c);
	for (int i = 0; i < n; i++) {
		if (a[i] == b[i] && b[i] == c[i]) {
			ans += 0;
		} else if (a[i] == b[i] || b[i] == c[i] || c[i] == a[i]) {
			ans += 1;
		} else {
			ans += 2;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
from math import log2

n, k = map(int, input().split())
ans = 0
for i in range(n):
    x = log2((k / (i + 1)))
    if x < 0:
        x = 0
    else:
        if x != int(x):
            x = int(x) + 1
    ans += (1 / n) * (0.5**x)
print('{:.12f}'.format(ans))

Measured memory_bytes: 3060
N = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))

total = 0
for i in range(N):
    b = b_list[i]

    defeated = min(a_list[i], b)
    a_list[i] -= defeated
    b -= defeated
    total += defeated

    defeated = min(a_list[i + 1], b)
    a_list[i + 1] -= defeated
    total += defeated
print(total)


Measured memory_bytes: 19116