akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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;
}



int main(){
    ll n,m;
    cin >> n >> m;
    ll s[m],c[m];
    REP(i,m){
        cin >> s[i] >> c[i];
    }
    ll x[n];
    REP(i,n){
        x[i] = 0;
    }

    REP(i,m){
        x[n- s[i]] = c[i];
    }

    ll ans = 0;

    if(n!=1){
        if(x[n-1] == 0){
            x[n-1] = 1;
        }
    }

    REP(i,n){
        ans += pow(10,i) * x[i];
    }
    
    REP(i,m){
        if(x[n-s[i]] != c[i]){
            ans = -1;
        }
    }
    if(n>1 and x[n-1]==0){
        ans = -1;
    }
    

    cout << ans << endl;

}

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

int main()
{
    while (true)
    {
        string deck;
        cin >> deck;
        if (deck=="-")
        {
            break;
        }
        int len=deck.size();
        int m;
        cin >> m;
        for (int i=0; i<m; i++)
        {
            int h;
            cin >> h;
            deck = deck.substr(h,len-h) + deck.substr(0, h);
        }
        cout << deck << endl;
    }
}


Measured memory_bytes: 3204
a = [list(map(int,input().split())) for _ in range(3)]
n=int(input())
b=[int(input()) for _ in range(n)]


for i in range(len(b)):
    for j in range(len(a)):
        for k in range(3):
            if b[i]==a[j][k]:
                a[j][k]='o'
ans=0
for i in range(3):
    if a[i][0]=='o' and a[i][1]=='o' and a[i][2]=='o':
        ans+=1
    if a[0][i]=='o' and a[1][i]=='o' and a[2][i]=='o':
        ans+=1
if a[0][0]=='o' and a[1][1]=='o' and a[2][2]=='o':
    ans+=1
if a[0][2]=='o' and a[1][1]=='o' and a[2][0]=='o':
    ans+=1
if ans>=1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3188
package main

import (
	"fmt"
)

// main is ...
func main() {
	var x int
	fmt.Scan(&x)

	var jTmp int
	for i := x; ; i++ {
		// fmt.Println("i")
		for j := 2; j <= i; j++ {
			// fmt.Println("j")
			jTmp = j
			if i%j == 0 {
				// fmt.Println("break")
				break
			}
		}
		// fmt.Println("ij", i, jTmp)
		if i == jTmp {
			fmt.Print(i)
			return

		}
	}

}


Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll x;cin>>x;
  ll k=100;
  while(x>k){
    k+=k/100;
    res++;
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 3656
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(X: int):

    def isOK(m):
        return X <= m*(m+1)/2

    ng = -1
    ok = X

    while abs(ok - ng) > 1:
        mid = (ok + ng)//2
        if isOK(mid):
            ok = mid
        else:
            ng = mid
    print(ok)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
/*
author: Apoorv Singh
*/

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

typedef vector <long long> vi;
typedef pair <long long, long long> pii;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define FOR(i, a, b) for (long long i = a; i < b; ++i)
#define FORR(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX
#define endl "\n"
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

template <class X>
void printarr(X arr[], int n)
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    cout << endl;
}
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){ for (X a : v) x << a << ' '; return x;} 
template <typename X, typename Y> ostream& operator << (ostream& x, const vector< pair<X, Y> >& v) {for (pair <X, Y> it : v) x << it.first << ' ' << it.second << endl; return x;} 
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (pair <T, S> it : v) os << it.first << " => " << it.second << endl; return os; }

double pi = 3.14159265358979323846264338327950288419716939937510582097494459230;
int modulo = 1e9 + 7;

int fpow(int a, int n)
{
    int ans = 1;
    while (n)
    {
        if (n&1)
            ans = (ans * a)%modulo;
        a = (a*a)%modulo;
        n = n >> 1;
    }
    return ans;
}

/*
const int M = 1e6 + 10;
int composite[M] = {0};

void sieve()
{
    FOR(i,2,M)
    {
        if (!composite[i])
        {
            for (int j = 2*i; j < M; j += i)
                composite[j] = max(composite[j], i);
        }
    }
}
*/

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k; cin >> n >> k;
    if (k == 1) 
    {
        cout << 0;
        return 0;
    }
    int a = n-k+1, b = 1;
    cout << a-b;
    return 0;
}

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

namespace ABC065B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] a = new int[N + 1];

            for(int i=1; i <= N; i++)
            {
                a[i] = int.Parse(Console.ReadLine());
            }

            bool[] pushed = new bool[N + 1];

            int b = 1;
            int num = 0;
            while(true)
            {
                if(b == 2)
                {
                    Console.WriteLine(num);
                    break;
                }
                else if(pushed[b])
                {
                    Console.WriteLine(-1);
                    break;
                }
                pushed[b] = true;
                b = a[b];
                num++;
            }

        }
    }
}


Measured memory_bytes: 13408
#include <iostream>
#include <vector>
#include <string>

using namespace std;


int main(int argc, char const *argv[]) {
    string s;
    cin >> s;
    vector<int> ans(s.length(), 0);
    
    int head = 0;
    int i = 1;
    while (i < s.length()) {
        // cout << i << endl;
        // s[i-1] == 'R' && 
        if (s[i] == 'L') {
            int j = head;
            for(; j < s.length(); j++) {
                if (j > i && s[j] == 'R') {
                    i = j;
                    head = i;
                    break;
                }
                if ((i - j) % 2 == 0) {
                    ans[i] += 1;
                } else {
                    ans[i - 1] += 1;
                }
            }
            if (j == s.length()) {
                break;
            }
        } else {
            i++;
        }
    }
    for (auto v: ans) {
        cout << v << " ";
    }
    cout << endl;    
    return 0;
}


Measured memory_bytes: 1152
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int nxt() {int x;scanf("%d", &x);return x;}


int main(){
    int n = nxt();
    VI count(n);
    REP(i, n-1){
        count[nxt()-1]++;
    }
    REP(i, n) printf("%d ", count[i]);
    return 0;
}



Measured memory_bytes: 4056
#include <iostream>

using namespace std;

int main(){
    int sum = 0;
    int m = 0;
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        int L;
        cin >> L;
        sum += L;
        m = max(m, L);
    }
    if(m < sum - m) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define inf 1e16
#define M 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define mx 1000010

int main(){
	IOS;
	ll n,k;cin>>n;
	ll a[n][3];rep(i,0,n)cin>>a[i][0]>>a[i][1]>>a[i][2];
	ll dp[n][3];
	rep(i,0,n)rep(j,0,3)dp[i][j]=-1;
	rep(i,0,3)dp[0][i]=a[0][i];
	rep(i,1,n){
		rep(j,0,3){
			dp[i][j]=max(dp[i][j],max(a[i][j]+dp[i-1][(j+1)%3],a[i][j]+dp[i-1][(j+2)%3]));
		}
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	return 0;
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll h,n;
	cin>>h>>n;
	vl a(n);
	rep(i,n)cin>>a[i];
	rep(i,n)h-=a[i];
	Yn(h<=0);
}


Measured memory_bytes: 1024
def add word
	val = hashF word
	@dic[val] << word
end

def hashF word
	word.gsub!("A", "1")
	word.gsub!("C", "2")
	word.gsub!("G", "3")
	word.gsub!("T", "4")
	return word.to_i(5) % @dic.length
end

def find word
	val = hashF word
    @dic[val].each{|v| return true if v == word}
    false
end

n = gets.to_i
@dic = Array.new(n){[]}
n.times{
	command, word = gets.chomp.split
	case command
	when "insert"
		add word
	else
		puts (find word) ? "yes" : "no"
	end
}

Measured memory_bytes: 211820
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LL_INF = 1e18 + 1;
const int MOD = 1e9 + 7;

int main() {

  ll N, K;
  cin >> N >> K;

  vector<ll> c(N);
  rep(i, N) { cin >> c[i]; }
  sort(c.begin(), c.end());

  ll l = -LL_INF;
  ll r = LL_INF;
  while (l + 1 < r) {
    // k個のときのペアの積の最大値を二分探索する
    ll x = (l + r) / 2;
    ll total = 0;

    rep(i, N) {
      // c[i] と組にしてXを超えないペアの数を二分探索で求める
      int ll = i, rr = N;
      if (c[i] > 0) {
        while (ll + 1 < rr) {
          int xx = (ll + rr) / 2;
          if (c[i] * c[xx] < x) {
            ll = xx;
          } else {
            rr = xx;
          }
        }
        total += ll - i;
        // printf("x: %d, c[i]:%lld ll:%d, total:%d\n", x, c[i], ll, total);
      } else {
        // c[i] が負の場合は、後ろから小さい数になる
        while (ll + 1 < rr) {
          int xx = (ll + rr) / 2;
          if (c[i] * c[xx] < x) {
            rr = xx;
          } else {
            ll = xx;
          }
        }
        total += N - rr;
        // printf("x: %d, c[i]:%lld ll:%d, total:%d\n", x, c[i], ll, total);
      }
    }

    if (total < K) {
      l = x;
    } else {
      r = x;
    }
  }

  cout << l << endl;
}

Measured memory_bytes: 1792
n,y = map(int,input().split())

for i in range(n+1):
    for j in range(n-i+1):
        if i*10000+j*5000+(n-i-j)*1000 ==y:
            print(i,j,n-i-j)
            exit()
        
print("-1 -1 -1")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n = 1e6;
vector<ll> v;
ll n;
void solve(){
  ll ans = 0;
  v[n] = 1e8;
  for(int i=0 ; i+1<=n ; i++){
    ll cnt = 0;
    while(v[i] == v[i+1]){
      cnt++;
      i++;
    }
    if(cnt%2 == 0)  ans++;
  }
  cout << ans << endl;
}
int main(){
  cin >> n;
  for(int i=0 ; i<n ; i++){
    ll x;
    cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  solve();
  return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int k;
	vector<int> num(3);
	cin >> num[0] >> num[1] >> num[2];
	cin >> k;
	vector<int>::iterator itr = max_element(num.begin(), num.end());
	size_t idx = distance(num.begin(), itr);
	int ans = 0;
	num[idx] *= pow(2, k);
	cout << num[0] + num[1] + num[2] << endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.*;

class Main{
	public static long gcd(long a,long b){
		return b==0?a:gcd(b,a%b);
	}

	public static void main(String[] $){
		var s=new Scanner(System.in);

		int n=s.nextInt();

		long r=0;
		for(int i=1;i<=n;++i){
			for(int j=1;j<=n;++j){
				var t=gcd(i,j);
				for(int k=1;k<=n;++k){
					r+=gcd(t,k);
				}
			}
		}
		System.out.println(r);
	}
}


Measured memory_bytes: 35764
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] d = new int[N];
		int ans = 0;
		
		for (int i=0; i<N; i++) {
			d[i] = sc.nextInt();
		}
		for (int i=0; i<N-1; i++) {
			for (int j=i+1; j<N; j++) {
				ans += d[i] * d[j];
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21972
s = input()
n = len(s)
S=[0 for i in range(n)]
for i in range(n):
    if s[i]=="R":
        S[i]=1


ANS =[0 for i in range(n)]
tame =[0,0]
k=0
for i in range(n):
    if S[i] == 1:
        tame[k]+=1
        k = (k+1)%2
    elif tame[0]>0:
        ANS[i-1] += tame[0]
        ANS[i] += tame[1]
        tame=[0,0]
        k=0
tame =[0,0]
k=0
for i in range(n-1,-1,-1):
    if S[i] == 0:
        tame[k]+=1
        k = (k+1)%2
    elif tame[0]>0:
        ANS[i+1] += tame[0]
        ANS[i] += tame[1]
        tame=[0,0]
        k=0
#print(ANS)
# ans=""
# for i in range(n):
#     ans += str(ANS[i])
#     ans += " "
# print(ans)
#print(n)

for i in range(n):
    ANS[i] = str(ANS[i])
ans = " ".join(ANS)
print(ans)

Measured memory_bytes: 48948
import math
import collections
import itertools
import copy

def YesNo(Bool):
    if(Bool):
        print("YES")
    else:
        print("NO")
    return

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def resolve():

    N,M=map(int,input().split())
    A=[0]*M
    B=[0]*M

    uf = UnionFind(N)
    for i in range(M):
        A[i],B[i]=map(int,input().split())
        uf.union(A[i]-1, B[i]-1)
        
    # for i in range(N):
    #     uf.find(i)

    cnt=uf.group_count()

    print(cnt-1)

resolve()


Measured memory_bytes: 19508
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;

map< ll, int > prime_factor(ll n) {
  map< ll, int > res;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n] = 1;
  return res;
}

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

  int cnt2 = 0, cnt5 = 0;

  ll d = 1e18;

  while (d % 2 == 0) {
    cnt2++;
    d /= 2;
  }

  while (d % 5 == 0) {
    cnt5++;
    d /= 5;
  }

  vector<vector<ll>> cnt(60, vector<ll>(60, 0));

  ll res = 0;

  rep(i,n) {
    ld a;
    cin >> a;
    ll tmp = round(a * 1e9);
    
    int x = 0, y = 0;

    while (tmp % 2 == 0) {
      x++;
      tmp /= 2;
    }

    while (tmp % 5 == 0) {
      y++;
      tmp /= 5;
    }


    for (int i = 0; i < 60; i++) {
      for (int j = 0; j < 60; j++) {
        if (x + i >= cnt2 && y + j >= cnt5) {
          res += cnt[i][j];
        }
      }
    }
    
    cnt[x][y]++;
  }

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

Measured memory_bytes: 3832
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	A := sc.nextIntSlice(N)
	cur := 1
	ans := 0
	for i := 0; i < N; i++ {
		if A[i] != cur {
			ans++
		} else {
			cur++
		}
	}

	if cur == 1 {
		fmt.Fprintln(wtr, -1)
	} else {
		fmt.Fprintln(wtr, ans)
	}
	wtr.Flush()
}


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

#define ll long long int
#define vi vector<int>
#define ii pair< int , int >
#define vii vector<ii>
#define FOR(i, n) for(ll i = 0; i < (ll)n; i++)
int MAX(int a, int b){return (a > b) ? a:b;}
int MIN(int a, int b){return (a < b) ? a:b;}
int ABS(int x){return (x > 0) ? x:-x;}
int left(int x){return (x<<1);}
int right(int x){return (x<<1)+1;}
int lsone(int x){return (x&(-x));}

const int maxn = 1e5 + 5;

int n, a[maxn][3];
int ans[maxn][4];
bool found[maxn][4];

int dp(int pos, int last){
	if(pos == n) return 0;
	if(found[pos][last]) return ans[pos][last];
	found[pos][last] = true;
	for(int i = 0; i < 3; i++){
		if(last != i){
			ans[pos][last] = max(ans[pos][last], dp(pos+1, i)+a[pos][i]);
		}
	}
	return ans[pos][last];
}

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d %d %d", &a[i][0], &a[i][1], &a[i][2]);
	}
	printf("%d\n", dp(0, 3));
}

Measured memory_bytes: 11136
from itertools import combinations

n = int(input())
nums = list(map(int, input().split()))

def check(a,b,c):
    if a == b or b == c or c == a:
        return False

    if a + b > c and b +c > a and c + a > b:
        return True
    else:
        return False

ans = 0
for a, b, c in combinations(nums, 3):
    if check(a, b, c):
        ans += 1

print(ans)



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

using  namespace  std;

#define PI              acos(-1.0)
#define lcm(a,b)        (a * (b / __gcd(a,b)))
#define en '\n'

#define READ_IN freopen("Input.txt","r",stdin);
#define READ_OUT freopen("Output.txt","w",stdout);
#define Infi                0x3f3f3f3f

const int dx[] = {+1,-1,+0,+0};                         // 4 X directions
const int dy[] = {+0,+0,+1,-1};                         // 4 Y directions
const int dx8[] = {+0,+0,+1,-1,-1,+1,-1,+1};            // King X Moves
const int dy8[] = {-1,+1,+0,+0,+1,+1,-1,-1};            // King Y Moves
const int kx[] = {-2, -2, -1, -1,  1,  1,  2,  2};      // Knight X Moves
const int ky[] = {-1,  1, -2,  2, -2,  2, -1,  1};      // Knight Y Moves



int  Set    (int N,int pos) {return N=N | (1<<pos);}    /// turn a bit on
int  reset  (int N,int pos) {return N= N & ~(1<<pos);}  /// turn a bit off
bool check  (int N,int pos) {return (bool)(N & (1<<pos));} /// check, if a bit is on or not

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print( pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define trace(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define trace(x...)
#endif

typedef long long int           ll;
typedef unsigned long long int  llu;


int main(void){

   // READ_IN;
   double a;
   cin >> a;

   double ck = a/3.0;

   cout << fixed << setprecision(13) << ck*ck*ck << endl;


    return 0;
}




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

int main()
{
	int N, x;
	cin >> N >> x;
	vector<int> a(N);

	for (int i = 0; i < N; ++i) cin >> a[i];
	
	sort(a.begin(), a.end());

	int happy_cnt = 0;
	while (x > 0 && happy_cnt < a.size()) {
		x -= a[happy_cnt];
		if (x >= 0) ++happy_cnt;
	}
	if (x > 0) --happy_cnt;

	cout << happy_cnt << endl;

	return 0;
}

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

struct Ant{
    int num;
    char direc;
    Ant(){}
    Ant(int num, char direc):num(num),direc(direc){}
    bool operator<(const Ant& a) const{ return num < a.num; }
    bool operator>(const Ant& a) const{ return num > a.num; }
};

int main(){
    
    while(1){
        int n, l; cin >> n >> l;
        if(!n) break;
        vector<vector<set<Ant> > > tunnel(2, vector<set<Ant> > (l + 1));
    
        
        for(int i = 1; i <= n; i++){
            char d; cin >> d;
            int loc; cin >> loc;
            tunnel[0][loc].insert(Ant(i, d));
        }

        int t = 0;
        int now = 0;
        int next = 1;
        for(;;){

            /*de
            cout << endl;
            for(int i = 0; i <= l; i++){
                cout << i << ": ";
                for(auto ant : tunnel[now][i]){
                    cout << "(" << ant.num << ", " << ant.direc << ") ";
                }
                cout << endl;
            }*/


            int cnt_ant = 0;
            for(int i = 1; i < l; i++){
                cnt_ant += (int)tunnel[now][i].size();
            }
            if(cnt_ant == 0){
                if(tunnel[now][0].size() == 1){
                    for(auto ant : tunnel[now][0]){
                        cout << t << " " << ant.num << endl;
                    }
                }else{
                    for(auto ant : tunnel[now][l]){
                        cout << t << " " << ant.num << endl;
                    }
                }

                break;
            }

            for(int i = 1; i < l; i++){
                for(auto ant : tunnel[now][i]){
                    if(ant.direc == 'R'){
                        tunnel[next][i + 1].insert(ant);
                    }else{
                        tunnel[next][i - 1].insert(ant);
                    }
                }
            }

            for(int i = 1; i < l; i++){
                if(tunnel[next][i].size() == 2){
                    set<Ant> tmp;
                    for(auto ant : tunnel[next][i]){
                        if(ant.direc == 'L') ant.direc = 'R';
                        else ant.direc = 'L';
                        tmp.insert(ant);
                    }
                    tunnel[next][i] = tmp;
                }
            }

            t++;
            swap(now, next);
            for(int i = 0; i <= l; i++) tunnel[next][i].clear();
        }


    }
}


Measured memory_bytes: 3076
#include <iostream>
#include <vector>
using namespace std;
int linearSearch(int &T_i, vector<int> &S)
{
    for (vector<int>::iterator itr = S.begin(); itr != S.end(); itr++)
    {
        if (T_i == *itr)
        {
            return 1;
        }
    }
    return 0;
}
int main()
{
    int n, q, T_i, ans = 0;
    cin >> n;
    vector<int> S(n);
    for (int i = 0; i < n; i++)
    {
        cin >> S[i];
    }
    cin >> q;
    vector<int> T(q);
    for (int i = 0; i < q; i++)
    {
        cin >> T_i;
        ans += linearSearch(T_i, S);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3116
package main

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

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printansStr(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func printansInt(result bool, a, b int) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func main() {
	defer write.Flush()

	var a, p int
	fmt.Fscan(read, &a, &p)
	fmt.Fprintln(write, (a*3+p)/2)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define pb push_back
#define xx first
#define yy second
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define repp(i,k,n) for(int i=k;i<n;i++)
#define FAST ios::sync_with_stdio(0);cin.tie(0);
typedef long long ll;
typedef vector<int> iv;
typedef pair<int,int> iip;
typedef map<int,int> mii;
template <typename T>
void dbg(T t){cerr<<t<<endl ;}
template<typename T, typename... Args>
void dbg(T t, Args... args) {cerr << t <<" ";dbg(args...) ;}

bool check(int t,int a,int b,int x,int y){
    int d1 = abs(a - x);
    int d2 = abs(b - y);
    if(d1 + d2 > t) return false;
    t-= d1 + d2;
    return (t % 2 == 0);
}

int main() {
	FAST;
    int n,t,a,b,x = 0,y = 0,tt  = 0;
    cin >> n;
    rep(i,n){
        cin >> t >> a >> b;
        if(!check(t-tt,a,b,x,y)) return cout << "No",0;
        x = a;
        y = b;
        tt = t;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()

def kaibun(s, start, end):
  for i in range(start, end // 2):
    if s[i] != s[end - i - 1]:
      return "No"
  return "Yes"

a = kaibun(S, 0, len(S))
b = kaibun(S, 0, int((len(S) - 1) / 2))
c = kaibun(S, int((len(S) + 3) / 2), len(S))
if a == "Yes" and b == "Yes" and c == "Yes":
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
import java.io.*;

class Main {
    static char calc(String str, int index) {
        char answer = str.charAt(0);

        if (str.charAt(0) == '1') {
            int lastIndex = 0;
            for (int i = 1; i < str.length(); i++) {
                if (str.charAt(i) == '1') {
                    lastIndex = i;
                } else {
                    break;
                }
            }

            if (index - 1 <= lastIndex) {
                answer = '1';
            } else {
                answer = str.charAt(lastIndex + 1);
            }
        }

        return answer;
    }

    public static void main(String args[]) throws IOException {
        String S;
        int K;

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        S = br.readLine();
        String k_s = br.readLine();
        K = k_s.length() > 3 ? 101 : Integer.valueOf(k_s);

        System.out.println(calc(S, K));
    }
}


Measured memory_bytes: 21204
import java.io.*;
import java.util.*;
import java.util.function.IntToDoubleFunction;
import java.math.BigInteger;
public class Main {
	
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		double d=sc.nextDouble();
		double t=(double)sc.nextInt();
		double s=sc.nextDouble();
		double a=d/s;
		if(a<t+0.001)out.println("Yes");
		else out.println("No");
		out.flush();
    }
	
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;
		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}
		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		public boolean ready() throws IOException {
			return br.ready();
		}
		public int[] nextArr(int n) throws IOException{
			int arr[]=new int[n];
			for(int i=0;i<n;i++)arr[i]=nextInt();
			return arr;
		}
		public BigInteger BigInteger(String s) throws IOException{
			BigInteger a=new BigInteger(s);
			return a;
		}
	}
}


Measured memory_bytes: 25468
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  string L;
  cin >> L;
  int N = L.size();
  ll ans = 1;
  ll pwr = 1;
  vector<ll> A(N);
  A[N-1] = L[N-1] == '0' ? 1 : 3;
  for(int i=N-2; i>=0; i--) {
    if(L[i] == '1')
      A[i] += 2 * A[i+1] + 1 * pwr * 3;
    else
      A[i] += 1 * A[i+1];
    A[i] %= mod;
    pwr *= 3;
    pwr %= mod;
  }
  cout << A[0] % mod << endl;
  return 0;
}


Measured memory_bytes: 1280
package main
import "fmt"

func main() {
    N := scanNum()
    A0 := scanNum()
    A1 := scanNum()
    gcd_all := gcd(A0, A1)
    for i := 2; i < N; i++ {
        A := scanNum()
        gcd_all = gcd(gcd_all, A)
    }
    fmt.Println(gcd_all)
}

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

func scanNum() (num int) {
    fmt.Scan(&num)
    return
}

func scanString() (str string) {
    fmt.Scanf("%s", str)
    return
}

func scanNums(len int) (nums []int) {
    var num int
    for i := 0; i < len; i++ {
        fmt.Scan(&num)
        nums = append(nums, num)
    }
    return
}

func scanStrings(len int) (strings []string) {
    var str string
    for i := 0; i < len; i++ {
        fmt.Scanf("%s", str)
        strings = append(strings, str)
    }
    return
}

Measured memory_bytes: 5504
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

bool solve(int i, string& s) {
  for (int ii = s.size() - i - 1; ii < s.size(); ii++) {
    char c = s[ii];
    int fi0 = -1;
    int fi1 = 0;
    while (fi1 >= 0) {
      fi1 = s.find(c, fi0+1);
      if (fi1 - fi0 - 1 > i) break;
      if (fi1 == ii) return true;
      fi0 = fi1;
    }
  }
  return false;
}

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

  string s;
  cin >> s;

  int i = 0;
  while(!solve(i, s)) {
    i++;
  }
  cout << i << endl;
  return 0;
}



Measured memory_bytes: 256
a,b,k=map(int,input().split())
for i in range(k):
    if i%2==0:
        b=b+a//2
        a=a-(a+1)//2
        #print(a,b)
    else:
        a=a+b//2
        b=b-(b+1)//2
print(a,b)

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

int main( void ) {
    
    int n, m;
    cin >> n >> m;
    
    for( int i = 1; i <= n; i ++ ) {
        for( int j = 1; j <= m; j ++ ) {
            string str;
            cin >> str;
            
            if( str == "snuke" ) {
                cout << (char) (j - 1 + 'A') << i << endl;
                return 0;
            }
        }
    }
    
    return 0;
}

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

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  long long N;
  cin >> N, --N;
  string name;
  for (; N >= 0; --(N /= 26)) name += 'a' + N % 26;
  reverse(begin(name), end(name));
  cout << name << '\n';
}


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

int main() {
    int N=0;
    cin >> N;
    for(int i=N; i<=999; i++){
        int x = (i/100)%10;
        int y = (i/10)%10;
        int z = i%10;
        if(x==y && y==z ){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

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

int main()
{
	int a, b, c;
	cin >> a >> b;
	if ((0 <= a + b) && (a + b < 24)) {
		c = a + b;
	}
	else {
		c = a + b - 24;
	}
	cout << c << endl;
	return 0;
}

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

using namespace std;

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

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n;
pair<long double, long double> es[125];

int main(){
    scanf("%d",&n);
    REP(i,n){
        long double x,y;
        scanf("%Lf%Lf",&x,&y);
        es[i] = make_pair(x,y);
    }
    sort(es,es+n,[&](pii a, pii b){
        return atan2(a.second, a.first) < atan2(b.second, b.first);
    });
    long double ans = 0;
    REP(i,n){
        long double dx=0, dy=0;
        REP(j,n){
            dx += es[(i+j)%n].first;
            dy += es[(i+j)%n].second;
            CHMAX(ans, dx*dx + dy*dy);
        }
    }
    printf("%.20Lf\n",sqrtl(ans));
    return 0;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);
		String string = scanner.nextLine();

		if(string.equals("a") || string.equals("i") || string.equals("u") || string.equals("e") || string.equals("o")){
			System.out.println("vowel");
		}else{
			System.out.println("consonant");
		}
	}
}

Measured memory_bytes: 22100
#include <stdio.h>

void swap(int A[], int i, int j) {
	int t;
	t = A[i];
	A[i] = A[j];
	A[j] = t;
}

int partition(int A[], int p, int r) {
	int x,i,j,t;
	x = A[r];
	i=p;
	for(j=p;j<r;j++) {
		if(A[j] <= x) {
			swap(A, i, j);
			i++;
		}
	}
	
	swap(A, i, r);
	return i;
}

int A[100000+2];

int main(void) {
	int n,i,t;
	scanf("%d\n", &n);
	for(i=0;i<n;i++) {
		scanf("%d", &A[i]);
	}
	
	t = partition(A, 0, n-1);
	for(i=0;i<n;i++) {
		if(t == i) {
			printf("[%d]", A[i]);
		} else {
			printf("%d", A[i]);
		}
		
		if(i<n-1) {
			printf(" ");
		} else {
			printf("\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 992
#include<iostream>
const int X99 = 9;
const int Y99 = 9;
int main()
{
for(int x=1;x<=X99;x++){
for(int y=1;y<=Y99;y++){
std::cout << x << 'x' << y << '='<< x*y << '\n';
}
}
return 0;
}

Measured memory_bytes: 1112
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;




int main(){
    string S;
    cin >> S;
    int N;
    N = S.length() + 1;
    
    vector<int> v(N,-1);
    
    char prev = 's';
    rep(i,N-1){
        if (S[i] == '<' && (prev == '>'|| prev == 's')){
            v[i] = 0;
            prev = '<';
        }
        else if (S[i] == '<' && prev == '<') v[i] = v[i-1] + 1;
        else if (S[i] == '>' && (prev == '<'|| prev == 's')){
            v[i] = max(v[i],v[i-1]+1);
            prev = '>';
        }
    }
    if (S[N-2] == '<'){
        v[N-1] = v[N-2]+1;
    }
    
    //rep(i,N-1) cout << v[i] << S[i];
    //cout << v[N-1] << endl;
    
    
    prev = 's';
    rep(i,N-1){
        if (S[N-2-i] == '>' && (prev == '<'|| prev == 's')){
            v[N-1-i] = 0;
            prev = '>';
        }
        else if (S[N-2-i] == '>' && prev == '>') v[N-1-i] = v[N-1-i+1] + 1;
        else if (S[N-2-i] == '<' && (prev == '>'|| prev == 's')){
            v[N-1-i] = max(v[N-1-i],v[N-1-i+1]+1);
            
            prev = '<';
        }
    }
    if (S[0] == '>'){
        v[0] = v[1]+1;
    }
    if (S[N-2] == '<'){
        v[N-1] = v[N-2]+1;
    }
    //rep(i,N-1) cout << v[i] << S[i];
    //cout << v[N-1] << endl;
    ll ans = 0;
    rep(i,N) ans += v[i];
    cout << ans;
    rn 0;
}



Measured memory_bytes: 2820
#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, m;
  cin >> n >> m;
  vector<vector<int>> ss;
  vector<int> kv(m);
  
  rep(i,m){
    int k;
    cin >> k;
    kv[i]=k;
    vector<int> s1(k);
    rep(j,k){
      cin >> s1[j];
      s1[j]--;
    }
    ss.push_back(s1);
  }
  
  vector<int> p(m);
  rep(i,m) cin >> p[i];
  
  int count =0;
  
  rep(s,1<<n) {
    vector<int> d(n);
    rep(i,n) {
      if (s>>i&1) d[i] =1;
      else  d[i] =0;
    }
//    rep(i,n) cout << d[i]; cout << endl;
    bool condition=true;
    rep(i,m){
      int check=0;
      rep(j,kv[i]){
        check+=d[ss[i][j]];
//        cout << ss[i][j] << endl;
      }
//      cout << check%2 << ' ' << p[i] << endl;
      if(check%2 !=p[i] && condition==true){
        condition=false;
        break;
      }
    }
    if(condition) count +=1;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
ll modpow(ll a, ll b, ll m) {
    if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll h = modpow(a, b / 2, m);
        return h * h % m;
    } else {
        return a * modpow(a, b - 1, m) % m;
    }
}
ll comb(ll a, ll b, ll m) {
    if (b > a - b) {
        return comb(a, a - b, m);
    }
    ll c = 1, d = 1;
    REP(i, b) {
        c *= (a - i);
        d *= (b - i);
        c %= m;
        d %= m;
    }
    return c * modpow(d, m - 2, m) % m;
}

const int MAX_N = 50;
const int MOD = 1000000007;
ll dp[MAX_N + 1][MAX_N + 1][MAX_N * MAX_N];

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    dp[0][0][0] = 1;
    REP(i, N) {
        REP(j, i + 1) {
            REP(k, K + 1) {
                int nj;

                nj = j;
                dp[i + 1][nj][k + nj * 2] += dp[i][j][k];
                dp[i + 1][nj][k + nj * 2] %= MOD;

                nj = j + 1;
                dp[i + 1][nj][k + nj * 2] += dp[i][j][k];
                dp[i + 1][nj][k + nj * 2] %= MOD;

                nj = j;
                dp[i + 1][nj][k + nj * 2] += dp[i][j][k] * j * 2;
                dp[i + 1][nj][k + nj * 2] %= MOD;

                if (j >= 1) {
                    nj = j - 1;
                    dp[i + 1][nj][k + nj * 2] += dp[i][j][k] * j * j;
                    dp[i + 1][nj][k + nj * 2] %= MOD;
                }
            }
        }
    }
    cout << dp[N][0][K] << endl;
    return 0;
}


Measured memory_bytes: 49152
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

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 ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    ll k, t; cin >> k >> t;
    vector<ll> a;
    ll tmp;
    ll arr[10001]; INITA(arr, 0, 10000, 0);
    REP(i, t) {
        cin >> tmp;
        a.push_back(tmp);
    }
    sort(ALL(a), greater<ll>());

    // まず最多ケーキ (a[0]個) を配置して、その間に入れていく
    // 最多を配置した時点だと a[0]-1 ペアあり、他のを間に入れるごとに1削れる
    cout << max((ll) a[0]-1-(k-a[0]), (ll) 0) << endl;
    return 0;
}

Measured memory_bytes: 3588