akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
    using namespace std; 
    #define pb          push_back
    #define pf          push_front
    #define eb          emplace_back
    #define mp          make_pair
    #define ff          first
    #define ss          second
    #define popf()      pop_front()
    #define popb()      pop_back()
    #define ll          int64_t
    #define lli         long long int
    #define ld          long double
    #define mod         1000000007
    #define inf         1000000000000007
    #define ninf        -1000000000000007
    #define minf        1000000000000000007
    #define nl          cout<<"\n"
    #define dbg         cout<<"debug\n"
    #define all(v)      v.begin(),v.end()
    #define iter(it,v)  for(auto it=v.begin();it!=v.end();++it)
    #define riter(it,v) for(auto it=v.rbegin();it!=v.rend();++it)
    #define forn(i,a,b) for(int64_t i=int64_t(a);i<int64_t(b);++i)
    #define forb(i,a,b) for(int64_t i=int64_t(a);i>=int64_t(b);--i)
    #define fastio()    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); 

    //-------------------------------L_I_Erq34-------------------------------

    const ll MAXN=107,MAXL=100007;
    ll dp[MAXN][MAXL];
    vector<pair<ll,ll>> v;

    bool comparell(pair<ll,ll> a,pair<ll,ll> b)
    {
        if(a.ff==b.ff)
            return a.ss>b.ss;
        return a.ff<b.ff;
    }

    int main()
    {
        ll n,t,i,w,a,b,j,k,z,m;
        cin>>n>>w;
        k=0;
        forn(i,0,n)
        {
            cin>>a>>b;
            v.pb(mp(a,b));
            k+=b;
        }
        forn(i,0,n+1)
            forn(j,0,k+7)
                dp[i][j]=inf;
        sort(all(v),comparell);
        m=0;
        dp[0][0]=0;
        forn(i,1,n+1)
        {
            forn(j,v[i-1].ss,k+7)
                dp[i][j]=min(dp[i][j],dp[i-1][j-v[i-1].ss]+v[i-1].ff);
            forn(j,0,MAXL)
                dp[i+1][j]=dp[i][j];
        }
        forn(i,0,n+1)
            forn(j,0,k+7)
            {
                //cout<<i<<" "<<j<<" "<<dp[i][j]<<"\n";
                if(dp[i][j]<=w)
                    m=max(j,m);
            }
        cout<<m<<"\n";
        return 0;
    }

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll N, K;
  scanf("%lld %lld", &N, &K);

  vector<ll> a_list;
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);
    a_list.emplace_back(v);
  }

  for (ll i = K; i < N; i++) {
    ll p = a_list[i - K];
    ll c = a_list[i];

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


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

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

void Main(){
  ll N, x; cin >> N >> x;
  vector<ll> a(N);
  rep(i, 0, N) cin >> a[i];
  vector<ll> s(N);
  s[0] = a[0];
  rep(i, 1, N) s[i] = a[i - 1] + a[i];
  ll res = 0;
  rep(i, 0, N){
    if(s[i] > x){
      ll tmp = s[i] - x;
      res += tmp;
      s[i] -= tmp;
      if(i < N - 1) s[i + 1] -= tmp;
    }
  }
  cout << res << endl;
}

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

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

  Main();
}


Measured memory_bytes: 1792
def solve():
    x = int(input())
    if x < 4:
        return 1
    elif x < 8:
        return 4
    elif x < 9:
        return 8
    l = [i**j for i in range(1,x+1) for j in range(2,int(x**0.5)) if i**j<=x]
    return max(l)
        
if __name__ == '__main__':
    print(solve())

Measured memory_bytes: 3060
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;

#define SIZE 400000
#define SIZE0 200000
#define INF 1000000000
#define mod 1000000009

typedef long long ll;

vector<pair<int,pair<long double, ll> > > G[SIZE];

ll power(ll k, ll n, int M){
  if(n==0) return 1;
  if(n==1) return k % M;

  ll res = power(k, n/2, M);

  res = res * res % M;

  if(n % 2)
    res = k % M * res % M;

  return res;
}

bool visited[SIZE];
long double memo[SIZE];
long long memo2[SIZE];

bool dfs(int now, int back = -1, long double sum = 0, ll modsum = 1) {

  if (visited[now]) return false;
  visited[now] = true;
  memo[now] = sum;
  memo2[now] = modsum;

  for(auto p : G[now]) {
    int to = p.first;
    long double v = p.second.first;
    ll x = p.second.second;

    if (to == back) continue;

    if (visited[to]) {
      //cerr << to << endl;
      //cerr << abs(sum - memo[to] + v) << endl;
      if (abs(sum - memo[to] + v) > 1) {
        //cerr << abs(sum - memo[to] + v) << endl;
        return true;
      } else {
        //cerr << abs(sum - memo[to] + v) << endl;
        if(modsum * x % mod != memo2[to]) return true;
      }
    } else {
      if(dfs(to, now, sum + v, modsum * x % mod)) {
        return true;
      }
    }
  }

  return false;
}

int main(){
  int N, M;

  scanf("%d%d", &N, &M);

  for(int i=0; i<M; i++) {
    int a, b, x;

    scanf("%d%d%d", &a, &b, &x);
    long double v = logl(x);
    a--; b--;

    G[a].push_back({b, {v, x} });
    G[b].push_back({a, {-v, power(x, mod-2, mod)}});
  }


  for(int i=0; i<N; i++) {
    bool ok = dfs(i);

    if (ok) {
      puts("No");
      return 0;
    }
  }

  puts("Yes");
  return 0;
}



Measured memory_bytes: 37936
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  int n;
  cin >> n;
  double ans = 0;


  for(int i = 0; i < n; i++){
    double x;
    string str;
    cin >> x >> str;

    if(str == "JPY"){
      ans += x;
    } else {
      ans += x*380000.0;
    }
  }


  cout << setprecision(6) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int mypow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x;
		}
		x = x * x;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), moder - 2, moder) % moder * mod_pow(kai(y), moder - 2, moder) % moder;
}
int mystoi(string x) {
	int res = 0;
	rep(i, x.size()) {
		res = res * 10 + x[i] - '0';
	}
	return res;
}
/*--------Library Zone!--------*/

signed main() {
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	if (e - a <= k)cout << "Yay!" << endl;
	else cout << ":(" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL long long
#define MOD 100000
#define inf 1999999999
#define ALL(x) (x).begin(), (x).end()
#define LBi(x, n) lower_bound(ALL(x), n) - (x).begin()
#define ZIP(x) (x).erase(unique(ALL(x)), (x).end())
#define Pi pair<int, int>
#define Vi vector<int>

#define rep(n) for(int i = 0; i < n; i++)

string s, t;
char ch[10];
int n, a, b, c, d, x, m[5];

int main() {
	cin >> s >> t;
	if (s == t)cout << "=" << endl;
	else cout << (s < t ? "<" : ">") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#define rep(i,m,n) for(int i=m; i<(n); i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
typedef long long ll;
using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    if(x==3 || x==5 || x==7) cout << "YES";
    else cout << "NO";
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>
#include<iomanip>
#include<tuple>
#include<bitset>


using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define printfloat(x) cout << fixed << setprecision(7) << (x) << endl;
#define printbit(x) cout << bitset<15>(x) << endl;
using ll = long long int;



long double pi = 3.14159265359;

int n;
int x[200000],y[200000];
int d;
int ans;
int main(){
    cin >> n >> d;
    rep(i,n){
        cin >> x[i] >> y[i];
    }
    rep(i,n){
        if(d >= sqrt((ll)x[i]*x[i]+(ll)y[i]*y[i])){
            ans ++;
        }
    }
    cout << ans <<endl;

return 0;
}

Measured memory_bytes: 5128
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[600][600];

ll convert(string str){
  ll ans = 0;
  rep(i,0,str.sz)ans += (str[i] - '0') * pow(10,str.sz-i-1);
  return ans;
}

int main(){
  cin >> s;
  vll vec;
  rep(i,0,1 << (s.sz - 1)){
    t = "";
    rep(j,0,s.sz){
      t += s[j];
      if(i >> j & 1){
        vec.pb(convert(t));
        t = "";
      }
    }
    if(t != "")vec.pb(convert(t));
  }
  n = 0;
  rep(i,0,vec.sz)n += vec[i];
  print(n);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    long N,K,keep,cnt=0;
    cin >> N >> K;
    vector<long>A(N,0),d(K);
    for(int i=0;i<K;i++){
        cin >> d[i];
        for(int j=0;j<d[i];j++){
            cin >> keep;
            A[keep-1]++;
        }
    }
    for(int i=0;i<N;i++){
        if(A[i]==0){
            cnt++;
        }
    }
    cout << cnt;
}

Measured memory_bytes: 3632
package main

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

func main() {
	N := readInt()

	All := ParseAllNum(getAllNum(getIArray(N)...))
	P, Q, Pr, Qr := 0, 0, -1, -1

	Loop(0, N, func(i int) {
		P += readInt() * Pow(10, N-i) / 10
	})
	Loop(0, N, func(i int) {
		Q += readInt() * Pow(10, N-i) / 10
	})

	sort.Ints(All)

	for i, v := range All {
		if v == P {
			Pr = i + 1
		}
		if v == Q {
			Qr = i + 1
		}
		if Pr != -1 && Qr != -1 {
			break
		}
	}
	fmt.Println(abs(Pr - Qr))
}

func ParseAllNum(in [][]int) []int {
	Result := make([]int, len(in))
	for i, v := range in {
		R := 0
		Loop(0, len(v), func(i int) {
			R += v[i] * Pow(10, len(v)-i) / 10
		})
		Result[i] = R
	}
	return Result
}

func getIArray(l int) []int {
	Result := make([]int, l)
	Loop(0, l, func(i int) {
		Result[i] = i + 1
	})
	return Result
}

func getAllNum(source ...int) [][]int {
	Result := make([][]int, 0, len(source))
	for _, v := range source {
		excluded := exclude(source, v)
		if len(excluded) == 1 {
			Result = append(Result, []int{v, excluded[0]})
		} else {
			a := getAllNum(excluded...)
			for _, av := range a {
				o := make([]int, len(av)+1)
				o[0] = v
				for avi, avv := range av {
					o[avi+1] = avv
				}
				Result = append(Result, o)
			}
		}
	}

	return Result
}

func exclude(i []int, t int) []int {
	Result := make([]int, len(i)-1)
	index := 0
	for _, c := range i {
		if c != t {
			Result[index] = c
			index++
		}
	}
	return Result
}

/////////////////////////////////////////
var scanner = bufio.NewScanner(os.Stdin)

func init() {
	scanner.Split(bufio.ScanWords)
	//scanner.Split(bufio.ScanLines)
}

func readInt() int {
	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())
	return t
}

func Loop(start, end int, f func(i int)) {
	for i := start; i < end; i++ {
		f(i)
	}
}

func Pow(a, b int) int {
	result := a
	Loop(0, b-1, func(i int) {
		result = result * a
	})

	return result
}

func abs(i int) int {
	if i >= 0 {
		return i
	} else {
		return i * -1
	}
}

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

int main() {
    string S; cin >> S;
    for (int i = 0; i < 26; i++) {
        bool ismatched = false;
        char alphabet = i + 'a';
        for (int j = 0; j < S.size(); j++) {
            if (S[j] == alphabet) {
                ismatched = true;
            }
        }
        if (!ismatched) {
            cout << alphabet << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}


Measured memory_bytes: 3700
def main():
    N = int(input())

    a = [0]
    a += map(int, input().split())

    b = [0] * (N + 1)

    x = N
    k = 1
    while x > 0:
        while x * (k + 1) > N:
            t = 0
            for j in range(2, k + 1):
                t ^= b[x * j]
            b[x] = a[x] ^ t
            x -= 1
        k += 1

    ans = [i for i, x in enumerate(b) if x == 1]
    print(len(ans))
    print(*ans, sep='\n')


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int n, q;
string s;
char vq[MAX][2];

int solve(int i){
    rep(j,q){
        if(s[i]!=vq[j][0]) continue;
        if(vq[j][1]=='L') i--;
        else i++;
        if(i<0||i>=n) return i;
    }
    return i;
}

int main(){
    cin>>n>>q>>s;
    rep(i, q) cin>>vq[i][0]>>vq[i][1];

    int ok=-1, ng=n;
    while(ng-ok>1){
        int mid=(ok+ng)/2;
        if(solve(mid)<0) ok=mid;
        else ng=mid;
    }
    int ans=ok+1;

    ng=-1, ok=n;
    while(ok-ng>1){
        int mid=(ok+ng)/2;
        if(solve(mid)>=n) ok=mid;
        else ng=mid;
    }
    ans+=n-ok;
    out(n-ans);
}


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

#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,lessl<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define int long long
#define double long double

#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()

#define ff first
#define ss second
#define mp make_pair

#define pb push_back
#define endl "\n"

#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)

#define bp __builtin_popcountll
#define inf 1e18

const int N=1e5+5;
const int M=1e9+7;
void solve()
{
	 int n;
	 cin>>n;
	 int a[n];
	 for(int i=0;i<n;i++)
	 	cin>>a[i];
	 int ans=0;
	 map<int,int> m1,m2;
	 vector<pair<int,int>> v1,v2;
	 for(int i=0;i<n;i++)
	 {	
	 	if(i%2==0)
	 	{
	 		m1[a[i]]++;
	 	}
	 	else
	 	{
	 		m2[a[i]]++;
	 	}
	 }
	 for(auto X:m1)
	 {
	 	v1.pb({X.ss,X.ff});
	 }
	 for(auto X:m2)
	 {
	 	v2.pb({X.ss,X.ff});
	 }
	 sort(all(v1));
	 reverse(all(v1));
	 sort(all(v2));
	 reverse(all(v2));
	 if(v1[0].ss!=v2[0].ss)
	 {
	 	cout<<n-v1[0].ff-v2[0].ff<<endl;
	 }
	 else
	 {
	 	ans=min(n-v1[0].ff,n-v2[0].ff);
	 	if(v2.size()>1)
	 	ans=min(ans,n-v1[0].ff-v2[1].ff);
	 	if(v1.size()>1)
	 	ans=min(ans,n-v1[1].ff-v2[0].ff);
	 	cout<<ans<<endl;
	 }

	 
}

signed main()
{
	FAST
	
	#ifndef ONLINE_JUDGE
	freopen("input_sublime.txt", "r", stdin);
	freopen("output_sublime.txt", "w", stdout);
	#endif
	
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
    	// cout<<"Case #"<<tc<<": ";
    	solve();
    }
    
    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
	#endif
}


Measured memory_bytes: 12532
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define	foreach( gg,itit )	for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define	mp make_pair
#define	pb push_back
#define sz(a) int((a).size())
#define all(a)  a.begin(), a.end()
#define	debug(ccc)	cout << #ccc << " = " << ccc << endl;
#define present(c,x) ((c).find(x) != (c).end())
const double eps = 1e-8;
#define EQ(a,b) (fabs((a)-(b))<eps)
inline int max(int a,int b){return a<b?b:a;}
inline int min(int a,int b){return a>b?b:a;}
inline ll max(ll a,ll b){return a<b?b:a;}
inline ll min(ll a,ll b){return a>b?b:a;}
const int mod = 1e9+7;
const int N = 1e6+10;
const ll inf = 1e18;

ll power(ll a,ll n){
	if(n==0){
		return 1;
	}
	ll b = power(a,n/2);
	b = b*b%mod;
	if(n%2) b= b*a%mod;
	return b;
}

int add(int a,int b){ return (a+b)%mod;}
int mul(int a,int b){ return (ll)a*b%mod;}



int main(){
 // 	freopen("nice.in","r",stdin);
 // freopen("nice.out","w",stdout);
	ll x; scanf("%lld",&x);
	ll ans = 0;;
	if(x>=11){
		ans+= (x/11)*2; x%=11;
	}
	if(x==0);
	else if(x<=6) ans++;
	else ans+=2;
	printf("%lld\n",ans);
	return 0;
}




Measured memory_bytes: 256
#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)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};

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

    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];

    rep(i, h){
        rep(j, w){
            if(s[i][j] == '#') cout << '#';
            else{
                int cnt = 0;
                rep(dir, 8){
                    int di = i + dy[dir];
                    int dj = j + dx[dir];
                    if(di<0 || di>=h || dj<0 || dj>=w) continue;
                    
                    if(s[di][dj] == '#') ++cnt;
                }
                cout << cnt;
            }
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 2010
#define M 100010
#define int long long
int pr[N],ct,n,a[M],ans,v1[M],v2[M];
map<int,int>vi,c;
void si(){
	for(int i=2;i<N;i++){
		if(!vi[i])pr[++ct]=i;
		for(int j=1;j<=ct&&pr[j]*i<N;j++){
			vi[pr[j]*i]=1;
			if(i%pr[j]==0)break;
		}
	}
}
void init(){
	for(int i=1;i<=n;i++){
		int x=1,y=1;
		for(int j=1;j<=ct;j++)
			if(!(a[i]%pr[j])){
				int c=0;
				while(a[i]%pr[j]==0){
					a[i]/=pr[j];
					c++;
				}
				c%=3;
				if(!c)continue;
				for(int k=1;k<=c;k++)
					x=x*pr[j];
				for(int k=c+1;k<=3;k++)
					y=y*pr[j];
			}
		int r=sqrt(a[i]);
		if(r*r==a[i]){
			x=x*r*r;
			y=y*r;
		}
		else{
			x=x*a[i];
			y=y*a[i]*a[i];
		}
		v1[i]=x;
		v2[i]=y;
		if(!c.count(x))c[x]=1;
		else c[x]++;
	}
}
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	si();
	vi.clear();
	init();
	for(int i=1;i<=n;i++){
		if(vi[v1[i]]||vi[v2[i]])continue;
		int x;
		if(c[v1[i]]>c[v2[i]])x=v1[i];
		else x=v2[i];
		vi[x]=1;
		if(x==1)ans+=1;
		else ans+=c[x];
	}
	cout<<ans;
}

Measured memory_bytes: 27648
def insertionSort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v

    return cnt


def shellSort(A, n):
    cnt = 0

    G = []
    G.append(1)
    for i in range(n):
        tmp = 3 * G[-1] + 1
        if tmp > n:
            break
        else:
            G.append(tmp)
    G.reverse()
    m = len(G)

    print(m)
    print(*G)

    for i in range(m):
        cnt = insertionSort(A, n, G[i], cnt)

    print(cnt)


def main():
    n = int(input())
    a = []
    for i in range(n):
        a.append(int(input()))

    shellSort(a, n)

    for i in range(n):
        print(a[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 45520
use std::cmp::*;
use std::io::*;
fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();

    let h: usize = itr.next().unwrap().parse().unwrap();
    let w: usize = itr.next().unwrap().parse().unwrap();
    let g: Vec<Vec<char>> = (0..h)
        .map(|_| itr.next().unwrap().chars().collect())
        .collect();

    let dx: Vec<isize> = [0, -1, 0, 1, -1, 1, -1, 1].to_vec();
    let dy: Vec<isize> = [1, 0, -1, 0, -1, 1, 1, -1].to_vec();
    let mut ans = 0;
    for i in 0..h {
        for j in 0..w {
            if g[i][j] == '.' {
                let mut q = std::collections::VecDeque::new();
                q.push_back((i, j));
                let mut dist = vec![vec![99; w]; h];
                dist[i][j] = 0;
                while let Some((y, x)) = q.pop_front() {
                    for i in 0..4 {
                        let nx = x as isize + dx[i];
                        let ny = y as isize + dy[i];
                        if 0 <= nx
                            && nx < w as isize
                            && 0 <= ny
                            && ny < h as isize
                            && g[ny as usize][nx as usize] == '.'
                            && dist[ny as usize][nx as usize] == 99
                        {
                            dist[ny as usize][nx as usize] = dist[y][x] + 1;
                            q.push_back((ny as usize, nx as usize));
                        }
                    }
                }
                for k in 0..h {
                    for l in 0..w {
                        if dist[k][l] != 99 {
                            ans = max(ans, dist[k][l]);
                        }
                    }
                }
            }
        }
    }
    println!("{}", ans);
}


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

#define EQ(a,b) (abs((a)-(b)) < EPS)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define sz size()
#define all(a) (a).begin(),(a).end()

using namespace std;
typedef long double D;
typedef complex<D> P;
typedef pair<P,P> L;
typedef vector<P> Poly;

const D EPS = 1e-8;
const D PI = acos(-1);

inline D dot(P x, P y){return real(conj(x)*y);}
inline D cross(P x, P y){return imag(conj(x)*y);}

inline P unit(P p){return p/abs(p);}
inline pair<P,P> norm(P p){return make_pair(p*P(0,1),p*P(0,-1));}

//for line(segment)
inline int ccw(P a,P b,P c){
  b -= a;c -= a;
  if (cross(b,c)>EPS) return 1;   //counter clockwise
  if (cross(b,c)<-EPS) return -1; //clockwise
  if (dot(b, c)<-EPS) return 2;   //c--a--b on line
  if (abs(b)+EPS<abs(c)) return -2;   //a--b--c on line
  return 0;                       //on segment
}

inline P line_cp(L a,L b){
  return a.fs+(a.sc-a.fs)*cross(b.sc-b.fs,b.fs-a.fs)/cross(b.sc-b.fs,a.sc-a.fs);
}

//vertexes are in the counter-clockwise order.
inline Poly convex_cut(Poly p,L l){
  Poly res;
  rep(i,p.sz){
    int nxt = (i+1)%p.sz;
    if(ccw(l.fs,l.sc,p[i]) != -1)res.pb(p[i]);
    if(ccw(l.fs,l.sc,p[i]) * ccw(l.fs,l.sc,p[nxt]) < 0){
      res.pb( line_cp(l, L(p[i],p[nxt]) ) );
    }
  }
  return res;
}

bool check(D dis, const Poly &p){
  Poly U(4);
  U[0] = P(-1e6, -1e6);
  U[1] = P(+1e6, -1e6);
  U[2] = P(+1e6, +1e6);
  U[3] = P(-1e6, +1e6);

  int n = p.size();
  for(int i=0;i<n;i++){
    L l = L(p[i],p[(i+1)%n]);
    P vec = norm(l.sc-l.fs).fs, move = dis*unit(vec);
    l.fs += move; l.sc += move;
    U = convex_cut(U,l);
  }
  return !U.empty();
}

int main(){
  int n;
  while(cin >> n,n){
    Poly p(n);
    for(int i=0;i<n;i++){
      D x,y;
      cin >> x >> y;
      p[i] = P(x,y);
    }

    D l = 0, r = 1e6;
    for(int i=0;i<100;i++){
      D mid = (l+r)/2;
      if(check(mid,p))l = mid;
      else r = mid;
    }
    cout << fixed << setprecision(10) << l << endl;
  }
}

Measured memory_bytes: 1336
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int sum = 0, t = 1;
	vector<int> ans;
	while (sum < n) {
		ans.push_back(t);
		sum += t;
		t++;
	}
	for (auto &p : ans) {
		if(p == sum - n) continue;
		cout << p << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  int N;
  cin >> N;
  vector<int> t(N + 1), x(N + 1), y(N + 1);
  t[0] = x[0] = y[0] = 0;
  for (int i = 1; i <= N; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }
 
  for (int i = 0; i < N; i++) {
    int l1_dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    int intarval = t[i + 1] - t[i];
    if (l1_dist > intarval || (intarval - l1_dist) % 2 != 0) {
      cout << "No" << endl;
      return 0;
    }
  }
 
  cout << "Yes" << endl;
 
  return 0;
}

Measured memory_bytes: 1408
let () =
  print_endline @@
  Scanf.scanf "%s" @@ fun s ->
  let s = Array.init (String.length s) (fun i -> s.[i]) in
  Array.sort compare s;
  if s.(0) = s.(1) && s.(1) <> s.(2) && s.(2) = s.(3) then "Yes" else "No"


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M;
vector <int> Graph[int(1e5+5)], Rev[int(1e5+5)];
int ans[int(1e5+5)];
bool visited[int(1e5+5)];

int DFS(int before, int now){

  for (int i = 0; i < Rev[now].size(); i++){
    int next = Rev[now][i];
    if (!visited[next]) return 0;
  }

  visited[now] = true;
  ans[now] = before;

  for (int i = 0; i < Graph[now].size(); i++){
    int next = Graph[now][i];
    if (!visited[next]) DFS(now, next);
  }

  return 0;
}

int main(){
  cin >> N >> M;
  for (int i = 0; i < N + M - 1; i++){
    int A, B; cin >> A >> B;
    Graph[A].push_back(B);
    Rev[B].push_back(A);
  }

  for (int i = 1; i <= N; i++){
    if (Rev[i].size() == 0){
      DFS(0, i);
    }
  }

  for (int i = 1; i <= N; i++) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 19716
using System;

public class Test
{
	public static void Main()
	{
		// your code goes here
		Console.ReadLine();
		string[] s = Console.ReadLine().Split(' ');
		long[] n = new long[s.Length];
		for(int i = 0; i < s.Length; i++) {
			n[i] = long.Parse(s[i]);
		}
		
		Array.Sort(n);
		long sum = 0;
		foreach(var num in n) {
			sum += num;
		}
		
		Console.WriteLine( "{0} {1} {2}", n[0], n[n.Length - 1], sum );
		
	}
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

struct Seg{
  int n;
  vector<ll>node,lazy;
  vector<bool>lazyFlag;

  Seg(vector<ll>v){
    n=1;
    while(n<v.size())n*=2;
    node.resize(2*n-1,INF);
    lazy.resize(2*n-1,INF);
    lazyFlag.resize(2*n-1,false);
    for(int i=0;i<v.size();i++)node[n-1+i]=v[i];
    for(int i=n-2;i>=0;i--){
      node[i]=min(node[2*i+1],node[2*i+2]);
    }
  }
  ll operator[](int index){
    return node[n-1+index];
  }
  void eval(int k,int l,int r){
    if(lazyFlag[k]){
      node[k]=lazy[k];
      if(r-l>1){
        lazy[2*k+1]=lazy[2*k+2]=lazy[k];
        lazyFlag[2*k+1]=lazyFlag[2*k+2]=true;
      }
      lazyFlag[k]=false;
    }
  }
  ll getmin(int a,int b,int k=0,int l=0,int r=-1){
    if(r<0)r=n;
    eval(k,l,r);
    if(r<=a||b<=l)return INF;
    if(a<=l&&r<=b)return node[k];
    ll vl=getmin(a,b,2*k+1,l,(r+l)/2);
    ll vr=getmin(a,b,2*k+2,(r+l)/2,r);
    return min(vl,vr);
  }
  void add(int a,int b,ll x,int k=0,int l=0,int r=-1){
    if(r<0)r=n;
    eval(k,l,r);
    if(b<=l||r<=a)return;
    if(a<=l&&r<=b){
      lazy[k]=x;
      lazyFlag[k]=true;
      eval(k,l,r);
    }
    else{
      add(a,b,x,2*k+1,l,(l+r)/2);
      add(a,b,x,2*k+2,(l+r)/2,r);
      node[k]=min(node[2*k+1],node[2*k+2]);
    }
  }
};

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

  int N,Q;
  cin>>N>>Q;
  vector<ll>S(N),T(N),X(N),D(Q);
  for(int i=0;i<N;i++)cin>>S[i]>>T[i]>>X[i]; for(int i=0;i<Q;i++)cin>>D[i];
  Seg seg(vector<ll>(Q,INF));
  vector<tuple<ll,ll,ll>>memo;
  for(int i=0;i<N;i++){
    int r=Q;
    int l=-1;
    int m;
    while(r-l>1){
      m=(r+l)/2;
      if(S[i]-X[i]>D[m])l=m;
      else r=m;
    }
    int r2=Q;
    int l2=r-1;
    int m2;
    while(r2-l2>1){
      m2=(r2+l2)/2;
      if(T[i]-X[i]-1>=D[m2])l2=m2;
      else r2=m2;
    }
    tuple<ll,ll,ll>a(X[i],r,r2);
    memo.push_back(a);
  }
  sort(rng(memo));
  reverse(rng(memo));
  for(auto it:memo)seg.add(get<1>(it),get<2>(it),get<0>(it));
  for(int i=0;i<Q;i++){
    ll res=seg.getmin(i,i+1);
    if(res==INF)cout<<-1<<endl;
    else cout<<res<<endl;
  }
  return 0;
}


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

int main(){
    int min=10,sum=0;
    vector<int>c(100000000);
    vector<int>d(100000000);
    for(int i=0;i<5;i++){
        cin>>c[i];
        sum+=((c[i]+9)/10)*10;
        if(min>c[i]%10&&c[i]%10!=0){
            min=c[i]%10;
        }

    }
    
    cout<<sum-10+min;
}

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

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    if (a > k) {
        cout << k << endl;
    } else {
        int restbc;
        restbc = k - a;
        if (restbc < b) {
            cout << a << endl;
        } else {
            int restc;
            restc = k - a - b;
            cout << a - restc << endl;
        }
        
    }

    return 0;
}

Measured memory_bytes: 3544
import std.algorithm, std.array, std.container, std.range, std.bitmanip;
import std.numeric, std.math, std.bigint, std.random, core.bitop;
import std.string, std.conv, std.stdio, std.typecons;

void main()
{
  while (true) {
    auto rd = readln.split.map!(to!int);
    auto h = rd[0], w = rd[1];

    if (h == 0 && w == 0) break;

    foreach (i; 0..h) {
      foreach (j; 0..w)
        write(i == 0 || i == h - 1 || j == 0 || j == w - 1 ? '#' : '.');
      writeln;
    }

    writeln;
  }
}

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

int main(){
    LL a, b, c;
    while(scanf("%lld%lld%lld", &a, &b, &c) != EOF){
        LL ans = min(a * b * (c & 1), min(a * c * (b & 1), b * c * (a & 1)));
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

#define L 100
#define Gard NULL

struct Tree{
  int nodekey;
  struct Tree *parent;
  struct Tree *leftch;
  struct Tree *rightch;
};

typedef struct Tree  *Search;
Search road;

void Insert(int );
void Pre(Search );
void In(Search );
Search Find(int ,Search);

int main(){
  int loop,numnode;
  char order[L];
  int i;
    
  scanf("%d",&loop);
  
  for(i=0;i<loop;i++){
    scanf("%s",order);
   
    if(order[0]=='i'){
      scanf("%d",&numnode);
      Insert(numnode);
    }
    
    else if(order[0]=='p'){
      In(road);
      printf("\n");
      Pre(road);
      printf("\n");
    }
    
    else if(order[0]=='f'){
      scanf("%d",&numnode);
    
      if(Find(numnode,road)!=Gard){
	printf("yes\n");
      }

      else{
	printf("no\n");
      }
    }
    
  }
  
  return 0;
}

void Insert(int numnode){
  Search xnode,ynode,znode;
  
  xnode=road;
  ynode=Gard;
  znode=(struct Tree *)malloc(sizeof(struct Tree));
  znode->nodekey=numnode;
  znode->leftch=Gard;
  znode->rightch=Gard;
  
  while(1){
    if(xnode==Gard)break;
    ynode=xnode;
    
    if(znode->nodekey<xnode->nodekey){
      xnode=xnode->leftch;
    }
    
    else{
      xnode=xnode->rightch;
    }
  }
  
  znode->parent=ynode;
  
  if(ynode==Gard){
    road=znode;
  }
  
  else if(znode->nodekey<ynode->nodekey){
    ynode->leftch=znode;
  }
  
  else{
    ynode->rightch=znode;
  }
  
}

void Pre(Search road){
  
  if(road==Gard){
    return;
  }
  
  printf(" %d",road->nodekey);
  
  Pre(road->leftch);
  Pre(road->rightch);
  
}

void In(Search road){
  
  if(road==Gard){
    return;
  }
  
  In(road->leftch);
  
  printf(" %d",road->nodekey);
  
  In(road->rightch);
}

Search Find(int numnode, Search road){
  
  if((road==Gard) || (numnode==road->nodekey)){
    return road;
  }
  
  else if(numnode<road->nodekey){
    return Find(numnode,road->leftch);
  }
  
  else{
    return Find(numnode,road->rightch);
  }
}



Measured memory_bytes: 20432
#ifndef Local
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
#endif

#include <bits/stdc++.h>

using namespace std;

#define popCnt(x) (__builtin_popcountll(x))
#define sz(x) ((int)(x.size()))
#define all(v) begin(v), end(v)
#define rall(v) rbegin(v), rend(v)
typedef long long Long;
typedef double Double;

template <class U, class V>
istream& operator>>(istream& is, pair<U, V>& p) {
  is >> p.first >> p.second;
  return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& x : v) {
    is >> x;
  }
  return is;
}

template <class T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (auto& x : v) {
    os << x << " ";
  }
  return os;
}

const int MOD = round(1e9 + 7);

int power(int base, int p) {
  if (p == 0) return 1;
  int res = power(base, p / 2);
  res = 1LL * res * res % MOD;
  if (p & 1) {
    res = 1LL * res * base % MOD;
  }
  return res;
}

int modInverse(int x) { return power(x, MOD - 2); }

const int FN = 2e6 + 5;
int fact[FN];
int inv_fact[FN];

void buildFactorial() {
  fact[0] = 1;
  inv_fact[0] = 1;
  for (int i = 1; i < FN; ++i) {
    fact[i] = 1LL * i * fact[i - 1] % MOD;
    inv_fact[i] = modInverse(fact[i]);
  }
}

int nCr(int n, int r) {
  if (r > n) return 0;
  int res = fact[n];
  res = 1LL * res * inv_fact[r] % MOD;
  res = 1LL * res * inv_fact[n - r] % MOD;
  return res;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif

  buildFactorial();
  int k;
  string s;
  cin >> k >> s;

  int res = 0;
  for (int i = 0; i <= k; ++i) {
    int tmp = power(26, i);
    tmp = 1LL * tmp * power(25, k - i) % MOD;
    tmp = 1LL * tmp * nCr(k - i + sz(s) - 1, k - i) % MOD;
    res = (res + tmp) % MOD;
  }
  cout << res << endl;

  return 0;
}

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

string t = "RGB";

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<vector<ll>> v(3, vector<ll>(n,0));
	vector<map<int,int>> mp(3);
	rep(i,n){
		rep(j,3){
			if(s[i] == t[j]){
				v[j][i]++;
				mp[j][i]++;
			}
		}
	}
	rep(i,3){
		rep(j,n){
			if(j>0) v[i][j] += v[i][j-1];
		}
	}
	
	ll ans = 0;
	
	for (int i = 0; i < n; ++i) {
		for (int j = i+1; j < n; ++j) {
			if(s[i] == s[j]) continue;
			int id;
			rep(k,3){
				if(t[k] != s[i] && t[k] != s[j]) id = k;
			}
			ans += v[id][n-1] - v[id][j];
			if(2*j-i<n && mp[id][2*j-i] != 0) ans--;
		}
	}
	cout << ans << endl;
    return 0;
}



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

struct UnionFind {
    vector<ll> par;  // par[i]: parent of i
    vector<ll> siz;

    UnionFind(ll N) : par(N + 1), siz(N + 1, 1ll) {  // initialize by making every node a root node
        for (int i = 0; i <= N; i++) par[i] = i;
    }

    ll root(ll x) {  // find the root of a given node
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return;
        if (siz[rx] < siz[ry]) swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
        return;
    }

    bool issame(ll x, ll y) {  // return true if x and y belong to the same tree
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    UnionFind uft(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        uft.unite(a, b);
    }

    set<int> ss;
    for (int i = 0; i < n; ++i) {
        ss.insert(uft.root(i));
    }
    cout << ss.size() - 1 << endl;
}


Measured memory_bytes: 8480
N=int(input())
lst=[list(map(int,input().split())) for _ in range(N)]
ans=[[0,0,0] for _ in range(N+1)]
for i in range(1,N+1):
    ans[i][0]=max(ans[i-1][1]+lst[i-1][0],ans[i-1][2]+lst[i-1][0])
    ans[i][1]=max(ans[i-1][0]+lst[i-1][1],ans[i-1][2]+lst[i-1][1])
    ans[i][2]=max(ans[i-1][0]+lst[i-1][2],ans[i-1][1]+lst[i-1][2])
print(max(ans[-1][0],ans[-1][1],ans[-1][2]))

Measured memory_bytes: 47360
import math

def main():

    Q = int(input())
    query = []
    max_r = 0
    for _ in range(Q):
        l, r = map(int, input().split())
        query.append([l, r])
        max_r = max(max_r, r)

    primes = set()
    for i in range(2, max_r+1):
        if isprime(i):
            primes.add(i)

    # print(primes)
    count = [0]
    for i in range(1, max_r+1):
        if i % 2 == 1 and i in primes and (i+1) // 2 in primes:
            count.append(count[-1] + 1)
        else:
            count.append(count[-1])

    # print(count)
    for l, r in query:
        print(count[r] - count[l-1])


def isprime(n):
    if n == 1: return False
    for i in range(2, int(math.sqrt(n))+1):
        if n % i == 0:
            return False
    return True


if __name__ == '__main__':
    main()


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if ((A + B) > (C + D)) {
    cout << "Left" << endl;
  }

  else if ((A + B) == (C + D)) {
    cout << "Balanced" << endl;
  }

  else {
    cout << "Right" << endl;
  }
}


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

using namespace std;

typedef long int lint;
typedef long long int llint;

#define INF 1073741824
#define LINF 4611686018000000000
#define MOD 1000000007

int win(char c) {
    if (c == 'r') return 2;
    if (c == 's') return 0;
    return 1;
}

int main() {
    int n, k;
    cin >> n >> k;
    int rsp[3];
    for (int i = 0; i < 3; i++) cin >> rsp[i];
    string t;
    cin >> t;
    int ans = 0;
    int prev;
    for (int i = 0; i < k; i++) {
        prev = -1;
        for (int j = i; j < n; j += k) {
            int tmp = win(t[j]);
            if (prev != tmp) {
                prev = tmp;
                ans += rsp[prev];
            } else {
                prev = -1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

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

void init(int par[], int V){
  for(int i = 0; i < V; ++i)
    par[i] = i;
}

int find(int x, int par[]){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x], par);
  }
}

void unite(int x, int y, int par[], int rank[]){
  x = find(x, par);
  y = find(y, par);

  if(x == y)
    return;

  if(rank[x] > rank[y]){
    par[y] = x;
  }else{
    par[x] = y;
    if(rank[x] == rank[y])
      rank[y]++;
  }
}

int same(int x, int y, int par[]){
  return find(x, par) == find(y, par);
}

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

llong kruskal(int V, int E, vector<edge> es){
  sort(ALL(es), comp);
  int *par, *rank;

  par = new int[V];
  rank = new int[V];

  init(par, V);
  REP(i,V){
    rank[i] = 0;
  }

  llong res = 0;
  REP(i,E){
    edge e = es[i];
    if(!same(e.u, e.v, par)){
      unite(e.u, e.v, par, rank);
      res += e.cost;
    }
  }
  
  delete[] par;
  delete[] rank;

  return res;
}

int main(){

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

  vector<pii> x, y;
  REP(i,n){
    int tx, ty;
    scanf("%d %d", &tx, &ty);
    x.push_back({tx, i});
    y.push_back({ty, i});
  }

  SORTV(x); SORTV(y);

  vector<edge> v;
  REP(i,n - 1){
    v.push_back({x[i].second, x[i + 1].second, x[i + 1].first - x[i].first});
    v.push_back({y[i].second, y[i + 1].second, y[i + 1].first - y[i].first});
  }

  printf("%lld\n", kruskal(n, (int)v.size(), v));

  return 0;
}



Measured memory_bytes: 9700
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,b,c,d,x,y;
   cin>>a>>b>>c>>d;
   x=a+b;
   y=c+d;
   if(x>y)
   {
       cout<<"Left";
   }
   else if(x==y)
   {
       cout<<"Balanced";
   }
   else if(x<y)
   {
       cout<<"Right";
   }


    return 0;
}


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

using namespace std;
vector<int> V;

int bin_search(int n){
    int ini = 0;
    int fim = V.size();

    while(ini<=fim){
        int meio = (ini+fim)/2;
        if (V[meio] == n) return meio;
        else if (V[meio] > n) {
            fim = meio-1;
        } else {
            ini = meio+1;
        }
    }

    return -1;
}

int main(){

    int x;
    cin >> x;
    int n;
    cin >> n;

    for (int i=0; i<n; i++){ 
        int num;
        cin >> num;
        V.push_back(num);
    }

    sort(V.begin(), V.end());

    if (n==0){
        cout << x << endl;
        return 0;
    }

    for (int i=0; i<=1000; i++){
        if (bin_search(x-i) == -1){
            cout << x-i << endl;
            break;
        } else if (bin_search(x+i) == -1){
            cout << x+i << endl;
            break;
        }
    }

    return 0;

}

Measured memory_bytes: 3648
package main
 
import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)
 
func run() {
	n := nextInt()
	k := nextInt()

	h := make([]int, 0)
	
	h = readIntArray(n)

	count := 0
	for _, v := range h {
		if (v >= k){
			count++
		}
	}
	Println(count)

}

// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695
 
var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
 
// Caution: You will get unexpected result if a single token is larger than this size.
const BufferSize = 64 * 1024 * 1024
 
func Print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}
 
func Printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}
 

func readIntArray(n int) ([]int) {
	v := make([]int, 0)
	for i := 0; i < n; i++ {
		v = append(v, nextInt())
	}
	return v
}
 
func Println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}
 
func next() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	a, err := strconv.Atoi(next())
	if err != nil {
		log.Fatal(err)
	}
	return a
}
 
func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}

 
func main() {
	sc.Buffer(make([]byte, 0, BufferSize), BufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}


Measured memory_bytes: 7168
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

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

    vector<int> X(N,0);
    for(auto &x:X){
        cin >> x;
    }

    int ans=MOD;
    for(int i=1; i<=100; i++){
        int tmp=0;
        for(int j=0; j<N; j++){
            tmp+=(X[j]-i)*(X[j]-i);
        }
        ans=min(ans,tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256