akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rep1(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define repU(i,bottom,ceiling) for(auto (i) = (bottom); (i) <= (ceiling); ++(i))
#define repD(i,ceiling,bottom) for(auto (i) = (ceiling); (i) >= (bottom); --(i))
#define repS(s,n) for(int (s) = 0; s < 1 << (n); ++(s))
#define repV(i,v) for(auto (i) = begin(v); (i) < end(v); ++(i))
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define divceil(n,d) ((n)/(d) + ((n)%(d) > 0))
#define parity(a,b) (((a) & 1LL)^((b) & 1LL)^1LL)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF = -1 + (1 << 30);
const int MOD = (int)1e9 + 7;

ull next_subset(ull subset){
	ull tem = subset + (subset & -subset);
	ull btm = (~tem & subset) / (subset & -subset) >> 1;
	return btm | tem;
}


int N,a[200005],b[200005];

void solve(){
	
	int p = 1 << 29, res = 0;
	int l1,l2,r1,r2;
	
	repD(e,28,0){
	
		int cur = 0;
	
		rep(i,N){ a[i] %= p; b[i] %= p; }
		sort(a,a + N,greater<int>());
		sort(b,b + N);
		p >>= 1;
		l1 = 0,r1 = 0,l2 = 0,r2 = N;
	
		rep(i,N){
			while(l1 < N && a[i] + b[l1] < p) ++l1;
			while(r1 < N && a[i] + b[r1] < p * 2) ++r1;
			while(l2 < N && a[i] + b[l2] < p * 3) ++l2;
			cur ^= (r1 - l1) & 1;
			cur ^= (r2 - l2) & 1;
		}
		
		res += cur << e;

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

void input(){
	
	cin>>N;
	rep(i,N) cin>>a[i];
	rep(i,N) cin>>b[i];
	
	return;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	input();
	solve();
	
	return 0;
}





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

using namespace std;

#define MXN 100005

int a[MXN];

int main() { 
    int n, res = 0;
    while (cin >> n) {
        memset(a, 0, sizeof(a));
        for (int i = 1; i <= n; ++i) {
            cin >> a[i];
            res += abs(a[i]-a[i-1]);
        }
        res += abs(a[n]);
        for (int i = 1; i <= n; ++i) {
            cout << res-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]) << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 1664
import java.util.Scanner;
public class Main{
public static void main(String[]args){
    try(Scanner sc = new Scanner(System.in)){
        String line = sc.nextLine();
        String answer = "";
        int length = line.length();
        for(int i = 0;i<length;i++){
            char ch = line.charAt(i);
            if(Character.isLowerCase(ch)){
                ch=Character.toUpperCase(ch);
            }else{
                ch=Character.toLowerCase(ch);
            }
            answer += String.valueOf(ch);
        }
        System.out.println(answer);
    
        }
    }
}


Measured memory_bytes: 31636
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

int main() {
    auto grid = make_vec_nd((ll)0, 3, 3);
    rep(y,0,3) {
        rep(x,0,3) {
            cin >> grid[x][y];
        }
    }
    unordered_set<ll> numbers;
    ll N;
    cin >> N;
    rep(i,0,N) {
        ll b;
        cin >> b;
        numbers.insert(b);
    }
    auto ok = [&numbers, &grid](ll x, ll y) -> bool {
        return numbers.find(grid[x][y]) != numbers.end();
    };
    rep(i,0,3) {
        if (ok(i, 0) && ok(i, 1) && ok(i, 2)) {
            cout << "Yes" << endl;
            return 0;
        }
        if (ok(0, i) && ok(1, i) && ok(2, i)) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    if (ok(0,0) && ok(1,1) && ok(2,2)) {
        cout << "Yes" << endl;
        return 0;
    }
    if (ok(0,2) && ok(1,1) && ok(2,0)) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}



Measured memory_bytes: 888
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=list(input())
ans=0

for i in range(n):
  if i<k:
    if t[i]=="r":
      ans+=p
    elif t[i]=="s":
      ans+=r
    elif t[i]=="p":
      ans+=s
  else:
    if t[i]=="r" and t[i-k]!=t[i]:
      ans+=p
    elif t[i]=="s" and t[i-k]!=t[i]:
      ans+=r
    elif t[i]=="p" and t[i-k]!=t[i]:
      ans+=s
    else:
      t[i]="X"
    
print(ans)

Measured memory_bytes: 4084
S = input()
kuro1 = 0
siro1 = 0
kuro2 = 0
siro2 = 0

for i in range(len(S)):
    if i % 2:
        if S[i] == '0':
            kuro1 += 1
        else:
            siro1 += 1
    else:
        if S[i] == '0':
            kuro2 += 1
        else:
            siro2 += 1

print(min(siro2+kuro1, kuro2+siro1))


Measured memory_bytes: 3188
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"
int main()
{
	int n,k;
	cin>>n>>k;
	vi a(n);
	for0(i,n) cin>>a[i];
	sort(a.rbegin(),a.rend());
	ll s=0;
	for0(i,k) s+= a[i];
	cout<<s<<nw;
	return 0;
}

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;

LL isPrime(LL p){
	if(p<=1) return 0;
	if(p==2 || p==3 || p==5 || p==7) return 1;
	if(p==4 || p==6 || p==8 || p==9) return 0;

	LL i;
	int ret = 1;
	for(i=2; i*i<=p; i++){
		if(p%i==0 && i!=p){
			ret = 0;
			break;
		}
	}
	return ret;
}

map<long long, int> mp;

int ecount(int e){
	if(e == 1) return 1;
	else if(e == 2) return 1;
	else{
		int ret = 1;
		while(true){
			if( ret*(ret+1) > (2*e)) break;
			ret++;
		}
		ret--;
		return ret;
	}
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long N;
	cin >> N;

	if(N == 1){
		cout << "0" << endl;
		return 0;
	}
	if(isPrime(N)){
		cout << "1" << endl;
		return 0;
	}

	long long i = 2;
	int sqN = (int)sqrt(N) + 1;
	long long n = N;
	for(i = 2; n != 1 && i < (N/2) + 1; i++){
		if((n % i)==0){
			if(isPrime(i)){
				int e = 0;
				long long u = n;
				while((u % i)==0){
					e++;
					u = u / i;
					n = u;
				}
				mp[i] = e;
				if(isPrime(n)){
					mp[n] = 1;
					break;
				}
			}
		}
	}

	if(mp.size()==0){
		mp[N] = 1;
		cout << "1" << endl;
		return 0;
	}

	long long ans = 0;
	for(auto itr = mp.begin(); itr != mp.end(); itr++){
		ans += ecount(itr->second);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <functional>
#include <cmath>
#include <utility>
#include <tuple>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<vector<int,int>> vii;
#define rep(i,n) for (int i=0;i<n;i++);

ll mod = 1e9+7;


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

int main(){
    double a,b,x,deg;
    cin >> a >> b >> x;
    double s = x/a;
    if (a*b/2.0<=s){
        double h = (a*b-s)*2.0/a;
        deg = atan2(h,a)/(M_PI*2)*360;
    } else {
        double w = s*2.0/b;
        deg = atan2(b,w)/(M_PI*2)*360;
    }
    printf("%.10f\n",deg);
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <complex>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <thread>
#include <tuple>
#include <type_traits>
#include <vector>

#include <stdio.h>

using ll = long long;
using namespace std;

vector<vector<bool>> v;

int main() {
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> c(m);
    for (int i = 0; i < m; i++) {
        cin >> c[i];
    }

    vector<int> dp(50001, INT_MAX);
    dp[0] = 0;

    for (int i = 0; i < dp.size() - 1; i++) {
        for (int j = 0; j < m; j++) {
            if (i + c[j] < dp.size()) {
                dp[i + c[j]] = min(dp[i + c[j]], dp[i] + 1);
            }
        }
    }

    cout << dp[n] << endl;

    return 0;
}



Measured memory_bytes: 3156
#include<iostream>
#include<map>
typedef long long int ll;
using namespace std;
map<int,int> mym;
ll res[100005];
int main(){
  int N;
  cin>>N;
  ll sum=0;
  for(int i=0; i<N; i++){
    int t;
    cin>>t;
    sum+=t;
    mym[t]++;
  }
  int Q;
  cin>>Q;
  for(int i=0; i<Q; i++){
    ll b,c;
    cin>>b>>c;
    sum-=mym[b]*b;
    sum+=mym[b]*c;
    mym[c]+=mym[b];
    mym[b]=0;
    res[i]=sum;
  }
  for(int i=0; i<Q; i++) cout<<res[i]<<endl;
  return 0;
}


Measured memory_bytes: 8396
import java.util.*;
import java.io.*;

public class Main {

  void solve(InputReader in, PrintWriter out) {
    int a = in.nextInt();
    int b = in.nextInt();

    if (a <= b) {
      for (int i = 0; i < b; ++i)
        out.print(a);
    } else {
      for (int i = 0; i < a; ++i)
        out.print(b);
      
    }
  }

  public static void main(String[] args) throws Exception {
    InputReader in = new InputReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    Main solver = new Main();
    solver.solve(in, out);
    out.close();
  }

  static class InputReader {
    BufferedReader in;
    StringTokenizer st;

    public InputReader(InputStream is) {
      in = new BufferedReader(new InputStreamReader(is));
    }

    public String next() {
      try {
        while (st == null || !st.hasMoreTokens()) {
          st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }
  }
}


Measured memory_bytes: 21204
#include <iostream>
using namespace std;
int n, m, a[102], b[102];
long long d[102][100005];
int main() {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> a[i] >> b[i];
    for (int i = 1; i <= n; i++)
        for (int j = 0; j <= m; j++) {
            if (j >= a[i]) d[i][j] = max(d[i - 1][j], d[i - 1][j - a[i]] + b[i]);
            else d[i][j] = d[i - 1][j];
        }
    cout << d[n][m] << '\n';
}


Measured memory_bytes: 78336
// Problem : B - 1%
// Contest : AtCoder - AtCoder Beginner Contest 165
// URL : https://atcoder.jp/contests/abc165/tasks/abc165_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

#define FIO ios_base::sync_with_stdio(0); cin.tie(0);
#define T() int tt; cin >> tt; rep1(qq,1,tt)
#define rep(i,start,lim) for(int i=start;i<lim;i++)
#define rep1(i,start,lim) for(int i=start; i<=lim; ++i)
#define repd(i,start,lim) for(int i=start;i>=lim;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define br cout<<"\n"
#define MOD (1000000007LL)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define eps (1e-6)
#define what_is(x) cerr << #x << " is " << x << "\n";
#define int long long int
#define infll 9e18
#define inf 1e12

#define lnode (2 * node + 1)
#define rnode (2 * node + 2)

using namespace std;

typedef pair<int, int> pii;

const int N = 3 * 1e6 + 2;

int n, k;

int32_t main(){

  FIO
  cout << fixed << setprecision(18);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  long double p = 100.0;
  long double m = 1.01;
  int x; cin >> x;
  for(int i = 1; ; ++i){
    int t = i;
    long double val = p;
    while(t--){
      val *= m;
      val = floor(val);
    }
    if((int)val >= x){
      cout << i << '\n';
      break;
    }
  }


	return 0;
}






Measured memory_bytes: 3652
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Double a, b;
  cin>>a>>b;

  Int ans = a * b + EPS;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3748
fun main(args : Array<String>) {
    val times = Array(5,{readLine()!!.toInt()})
    
    var sum = 0;
    var min = 10;
    for (time in times){
       val e = time % 10;
       if(e != 0)
       {
         sum += time + (10 - e);
         if (min > e){min = e;}
       }else{
         sum += time;
       }
    }
    if(min != 10){
      sum = sum - 10 + min;
    }
    
    println(sum)
}

Measured memory_bytes: 33784
import sys


def main():

    input = sys.stdin.readline

    N,M = map(int,input().split())

    AB = [list(map(int,input().split())) for _ in range(M)]

    UF = UnionFind(N)

    for i in range(M):
        A,B = AB[i]

        A = A - 1
        B = B - 1

        UF.union(A,B)


    ans = 1
    for i in range(N):
        ans = max(ans,UF.size(i))

    print(ans)

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())

if __name__ == "__main__":
    main()

Measured memory_bytes: 49940
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

const int INF =  10000000;

struct edge {int to, cap, rev;};

vector<edge> G[202];
bool used[202];

void add_edge(int from, int to, int cap){
    G[from].push_back((edge{to, cap, (int)G[to].size()}));
    G[to].push_back((edge{from, 0, (int)G[from].size()-1}));
}

int dfs(int v, int t, int f, vector<edge> G[]){
    if(v == t) return f;
    used[v] = true;
    for(int i = 0; i < G[v].size(); i++){
        edge &e = G[v][i];
        if(!used[e.to] && e.cap > 0){
            int d = dfs(e.to, t, min(f, e.cap), G);
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int main(){
    int H, W;
    cin >> H >> W;
    int s = H+W;
    int t = H+W+1;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            char a;
            cin >> a;
            if(a == 'o') {
                add_edge(i, j+H, 1);
                add_edge(j+H, i, 1);
            }
            if(a == 'S') {
                //add_edge(i, j+H, INF);
                //add_edge(j+H, i, INF);
                add_edge(i, s, INF);
                add_edge(s, i, INF);
                add_edge(j+H, s, INF);
                add_edge(s, j+H, INF);
            }
            if(a == 'T') {
                //add_edge(i, j+H, INF);
                //add_edge(j+H, i, INF);
                add_edge(i, t, INF);
                add_edge(t, i, INF);
                add_edge(j+H, t, INF);
                add_edge(t, j+H, INF);
            }
        }
    }
    
    int flow = 0;

    while(true){
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF, G);
        if(f == 0){
            break;
        }
        flow += f;
    }
    if(flow >= INF){
        cout << -1 << endl;
    }else{
        cout << flow << endl;
    }
}

Measured memory_bytes: 896
#include <iostream>
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int n;
  long num;
  long max, min;
  long sum = 0;
  std::cin >> n;
  for (int i = 0; i < n; i++) {
    std::cin >> num;
    if (i == 0) {
      max = num;
      min = num;
    }
    if (max < num){
      max = num;
    }
    if (min > num) {
      min = num;
    }
    sum += num;
  }
  printf("%ld %ld %ld\n",min , max, sum);
  return 0;
}

Measured memory_bytes: 3192
package main

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

var digits []int

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	var str string
	fmt.Sscanf(scanner.Text(), "%s", &str)
	ds := strings.Split(str, "")

	digits = make([]int, len(ds))
	for i, d := range ds {
		digits[i], _ = strconv.Atoi(d)
	}

	ans := 0
	for i := 0; i < len(digits); i++ {
		var r int
		if i == 0 {
			r = rec(i, false, false, false, true)
		} else {
			r = rec(i, false, false, false, false)
		}
		ans = ans + r
	}
	fmt.Println(ans)
}

func rec(index int, thr, fiv, sev bool, strict bool) int {
	if index == len(digits) {
		if thr && fiv && sev {
			return 1
		} else {
			return 0
		}
	}

	ret := 0
	if strict {
		if digits[index] > 7 {
			ret = ret +
				rec(index+1, true, fiv, sev, false) +
				rec(index+1, thr, true, sev, false) +
				rec(index+1, thr, fiv, true, false)
		} else if digits[index] == 7 {
			ret = ret +
				rec(index+1, true, fiv, sev, false) +
				rec(index+1, thr, true, sev, false) +
				rec(index+1, thr, fiv, true, true)
		} else if digits[index] > 5 {
			ret = ret +
				rec(index+1, true, fiv, sev, false) +
				rec(index+1, thr, true, sev, false)
		} else if digits[index] == 5 {
			ret = ret +
				rec(index+1, true, fiv, sev, false) +
				rec(index+1, thr, true, sev, true)
		} else if digits[index] > 3 {
			ret = ret +
				rec(index+1, true, fiv, sev, false)
		} else if digits[index] == 3 {
			ret = ret +
				rec(index+1, true, fiv, sev, true)
		}
	} else {
		ret = ret +
			rec(index+1, true, fiv, sev, false) +
			rec(index+1, thr, true, sev, false) +
			rec(index+1, thr, fiv, true, false)
	}

	return ret
}


Measured memory_bytes: 640
#include <iostream>
#include <math.h>
#include <vector>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;

int main()
{
  int n,d,ans=0;
  long long rex,rey,red;
  cin >> n >> d;
  red=pow(d,2);
  vector<int> x(n);
  vector<int> y(n);
  rep(i,n) cin >> x[i] >> y[i];
  rep(i,n){
    rex=pow(x[i],2);
    rey=pow(y[i],2);
    if(rex+rey <= red) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4788
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

int main() {
#ifdef LOCAL
  freopen("d.in", "r", stdin);
  freopen("d.out", "w", stdout);
#endif

  int n;
  while (scanf("%d", &n) == 1) {
    int a, b;
    scanf("%d%d", &a, &b);
    ++n;
    vector<int> p(n);
    for (int i = 1; i < n; i++) {
      scanf("%d", &p[i]);
    }

    vector<int> ps = p;
    sort(ps.begin(), ps.end());

    vector<ll> dp(n, 1LL << 60);
    dp[0] = a * 1LL * (n - 1);

    for (int i = 0; i < n; i++) {
      int from = find(ps.begin(), ps.end(), p[i]) - ps.begin();
      ps.erase(ps.begin() + from);
      for (int j = from; j < (int)ps.size(); j++) {
        int v = ps[j];
        assert(v > p[i]);
        dp[v] = min(dp[v], dp[p[i]] - a + (b - a) * 1LL * (j - from));
      }
    }

    printf("%lld\n", *min_element(dp.begin(), dp.end()));
  }

  return 0;
}


Measured memory_bytes: 384
/**
 *   @FileName	f.cpp
 *   @Author	kanpurin
 *   @Created	2020.09.19 21:52:53
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int n,q;cin >> n >> q;
    vector<int> h(n,-1),w(n,-1);
    int h_min = n-1,w_min = n-1;
    ll ans = (ll)(n-2) * (n-2);
    while(q--) {
        int t,x;cin >> t >> x;
        x--;
        if (t == 1) {
            if (x < w_min) {
                ans -= max(0,h_min-1);
                for(int i = x; i < w_min;i++) {
                    w[i] = h_min;
                }
                w_min = x;
            }
            else {
                ans -= max(0,w[x]-1);
            }
        }
        else {
            if (x < h_min) {
                ans -= max(0,w_min-1);
                for(int i = x; i < h_min;i++) {
                    h[i] = w_min;
                }
                h_min = x;
            }
            else {
                ans -= max(0,h[x]-1);
            }
        }
        
        
        
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4764
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define ll long long 
#define pb(a) push_back(a)
#define fi first
#define se second
#define rep(a,b,c) for(int a = b ;a<=c;a++)
#define repn(a,b,c) for(int a = b ; a>=c ; a--)
#define FOR(a,b,c) for(int a = b ; a<c ;a++)
#define mem(a,b) memset(a,b , sizeof(a))
#define ll long long
#define mp make_pair
#define fi first
#define se second
#define size(a) ((int)a.size())
#define ii int
#define umap unordered_map
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a * b / gcd(a,b)
const int INF=0x3f3f3f3f;
const int maxn=5e5+10;
#define  max(a,b) (a > b) ? a : b;
#define  min(a,b) (a > b) ? b : a;
#define  st(a) setprecision(a)
#define fix_ std::fixed

void input(){
	freopen("in.txt", "r",stdin);
	freopen("out.txt", "w",stdout);
}
void fast(){

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	 cout.tie(NULL);
}



void solve(){

	ll a,b,c;

	cin>>a>>b>>c;

	cout<<c<<" "<<a<<" "<<b<<endl;
		
}


int main(){
	 solve();
	 exit(0);
}



Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <vector>
#include <string>
#include <cstdio>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ls x<<1
#define rs x<<1|1
#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define fun function
#define vi vector<int>
#define lowbit(x) x&(-x)
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);

using namespace std;

const int INF = 0x3f3f3f3f;

int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}; 

int main() {
	IOS;
#ifdef xiaofan
	freopen("1.in","r",stdin);
	freopen("1.out","w",stdout);
#endif
	int n;
	cin>>n;
	cout<<a[n-1];





	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int h,w,n;
  int dx[] = {0,1};
  int dy[] = {1,0};

  while(cin>>h>>w>>n,h||w||n) {
    bool ba[w][h];
    REP(y,h) REP(x,w)
      cin >> ba[x][y];
    int dp[w][h];               // dp[i][j] : n ñUàµÄ(j,i) ÉÚ®·éñ
    memset(dp,0,sizeof(dp));
    dp[0][0] = n;
    REP(y, h) {
      REP(x, w) {
        bool d;
        if (dp[x][y]%2) {
          d = ba[x][y];
        } else {
          d = !ba[x][y];
        }
        if (d) {
          if (x<w-1)
            dp[x+1][y] += (dp[x][y] + 1) / 2;
          if (y<h-1)
            dp[x][y+1] += dp[x][y] / 2;
        } else {
          if (x<w-1)
            dp[x+1][y] += dp[x][y] / 2;
          if (y<h-1)
            dp[x][y+1] += (dp[x][y] + 1) / 2;
        }
      }
    }
    // REP(y,h){
    //   REP(x,w) {
    //     cout<<dp[x][y]<<" ";
    //   }cout << endl;
    // }
    int x=0,y=0;
    while(x<w&&y<h) {
//      cout << x << " " << y << endl;
      bool d;
      if (dp[x][y]%2) {
        d = ba[x][y];
      } else {
        d = !ba[x][y];
      }

      x += dx[d];
      y += dy[d];
    }
    cout << y+1 << " " << x+1 << endl;
  }
}

Measured memory_bytes: 5744
using System;

namespace _1_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var a = ab[0];
            var b = ab[1];
            Console.WriteLine("{0} {1}", a * b, 2 * a + 2 * b);
        }
    }
}



Measured memory_bytes: 15796
from collections import deque
from collections import defaultdict

n,x,y = map(int,input().split())

count_dict = {key:0 for key in range(1,n)}

for s in range(1,n):
    for e in range(s+1,n+1):
        count_dict[min(e-s, abs(x-s)+1+abs(y-e),abs(y-s)+1+abs(x-e))] += 1


for i in range(1,n):
    print(count_dict[i])


#for s in range(1,n):
#    for e in range(s+1,n+1):
#        if s <= x <= e:
#            count_dict[min(e-s, x-s+1+abs(y-e))] += 1
#            if min(e-s, x-s+1+abs(y-e)) == 3:
#                print(s,e)
#        elif s <= y <= e:
#            count_dict[min(e-s, s-x+1+abs(y-e))] += 1
#            if min(e-s, s-x+1+abs(y-e)) == 3:
#                print(s,e)
#        else:
#            count_dict[e-s] += 1
#            if e-s == 3:
#                print(s,e)


#def bfs(s):
#    que = deque()
#    que.append([s,1,0])
#
#    while que:
#        i = que.popleft()
#        #特殊例の探索
#        if i[0] == x:
#            #yへの移動ルートも計算する
#            if checked_dict[y] == 0:
#                checked_dict[y] = 1
#                que.append([y,i[1],i[2]+1])
#                counter_dict[i[2]+1] += 1
#                #checked_dict[x] = 1
#                #counter_dict[i[2]] += 1
#        elif i[0] == y:
#            #i-1への移動ルートも計算する。
#            if checked_dict[i[0]-1] == 0:
#                checked_dict[i[0]-1] = 1
#                que.append([i[0]-1,-1,i[2]+1])
#                counter_dict[i[2]+1] += 1
#                #checked_dict[y] = 1
#                #counter_dict[i[2]] += 1
#
#        #通常例の探索
#        if i[0]!=n and checked_dict[i[0]+i[1]] == 0:
#            checked_dict[i[0]+i[1]] = 1
#            que.append([i[0]+i[1],i[1],i[2]+1])
#            counter_dict[i[2]+1] += 1
#            #checked_dict[i[0]] = 1
#            #counter_dict[i[2]] += 1
#
#
#
#
#
#
#
#
#
#n,x,y = map(int,input().split())
#
#checked_dict = {key:0 for key in range(0,n+1)}
#
#counter_dict = {key:0 for key in range(1,n)}
#
#result_dict = {key:0 for key in range(1,n)}
#
#
#for s in range(1,n):
#    checked_dict = {key:0 for key in range(0,n+1)}
#    counter_dict = {key:0 for key in range(1,n)}
#    checked_dict[s] = 1
#    bfs(s)
#    for j in range(1,n):
#        result_dict[j] += counter_dict[j]
#
#
#print(counter_dict)
#
#"""
#for i in range(1,n):
#    print(counter_dict[i])
#"""
#
#
##for j in range(1,n):
##    for k in range(1,j+1): # 1~jまで
##        result_dict[k] += 1*counter_dict[j]
##
##print(result_dict)
#	


Measured memory_bytes: 48220
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front

using ll = long long;
using namespace std;

ll M = 1000000007;
typedef pair<int, int> P;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<vector<int>> pla(10);
    vector<bool> used(n, false);
    rep(i, n)
    {
        int num=s[i]-'0';
        rep(j, 10)
        {
            if (num ==  j)
            {
                pla[num].push_back(i);
                used[j] = true;
                //cout<<j<<endl;
            }
        }
    }
    int cnt = 0;
    rep(i, 10)
    {
        if (pla[i].size()>=1)
        {
            int fc = pla[i][0];
            rep(j, 10)
            {

                if (pla[j].size()>=1)
                {
                    int site = upper_bound(all(pla[j]), fc) - pla[j].begin();
                    if (site < pla[j].size() && 0 <= site)
                    {
                        int sc = pla[j][site];
                        rep(k, 10)
                        {
                            if (pla[k].size()>0)
                            {
                                int tite = upper_bound(all(pla[k]), sc) - pla[k].begin();
                                if (tite < pla[k].size() && 0 <= tite)
                                {
                                    if(pla[k][tite]>sc)
                                    cnt++;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    string S;
    cin >> S;
    int stock=0,ans=0;
    REP(i,0,S.size()){
        if(stock>0){
            stock--;
            if(S[i]=='g') ans++;
        }else{
            stock++;
            if(S[i]=='p') ans--;
        }
    }
    P(ans);
}

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

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()
#define pi                  3.14159265359
ll INF=1e18+10;
ll MOD=1000000007;

int main()
{
    string s;cin>>s;
    int ans=0;
    for(int i=0;i<4;i++)
        ans= ans +(s[i]=='+' ? 1 : -1);
    cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

int main(){
    int K;cin>>K;
    string s;cin>>s;
    if(s.length()<=K){
        cout << s << endl;
    }else{
        string str = s.substr(0,K);
        cout << str  << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    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

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;


int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   long int n;
   cin>>n;

  	map<long int,long int> m;
  	vector<long int> v(n);

  	for(long int i = 0; i < n; i++)
  		cin>>v[i];

  	long int ans = 0;
  	for(long int i = n - 1; i >= 0; i--){
  		long int val = i + 1 + v[i];
  		ans += m[val];
  		m[i + 1 - v[i]]++;
  	}

  	cout<<ans;

   return 0;
}

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

int main(){
	int a,b,c,x,y,z,s,t;
	cin >> a >> b >> c;
	x=min({a,b,c});
	z=max({a,b,c});
	y=a+b+c-x-z;
	s=z-x;
	t=z-y;
	if((s%2==0)&&(t%2==0)){
		cout <<(s/2+t/2) <<endl;
	}
	else if((s%2==1)&&(t%2==1)){
		cout <<(s/2+t/2+1) <<endl;
	}
	else{
		cout <<(s/2+t/2+2) <<endl;
	}
	return 0;
}

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

int main(){
  int N; cin >> N;
  vector<int> v(N);
  for (int i=0;i<N;i++){
    cin >> v.at(i);
  }
  priority_queue<int> pq;
  for (int i=0;i<N;i++){
    pq.push(v.at(i));
  }
  int max=pq.top();
  pq.pop();  
  int secmax=pq.top();
  if (max==secmax){
    for (int i=0;i<N;i++)
      cout << max << endl;
  }
  else{
    for (int i=0;i<N;i++){
      if (v.at(i)==max)
        cout << secmax << endl;
      else
        cout << max <<endl;
    }
  }
}


Measured memory_bytes: 3316
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    c = readline().strip()

    if c in 'aeiou':
        print('vowel')
    else:
        print('consonant')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9008
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T>
// using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define sfind(i) (*find_by_order(i))
// #define ord(i) order_of_key(i)
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
using cd = complex<double>;
const double pi = acos(-1);
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define vi vector<int>
#define vl vector<ll>
#define _max(vec) (*max_element(all(vec)))
#define _min(vec) (*min_element(all(vec)))
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) (n>=r?((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod):0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'  //....????
#define int ll
vector<ll> ft(1, 1LL);

/*======================================================================*/
class Dsu {
    public :
    vector<int> drr;
    vector<int> size_arr;
    Dsu (int n) {
        rep(i, 0, n+1)drr.pb(i), size_arr.pb(1);
    }
    int f_p (int a) {return drr[a] == a ? a : f_p(drr[a]);}
    ll size (int a) {return (ll)size_arr[f_p(a)];}
    void uni(int a, int b) {
        int ap = f_p(a);
        int bp = f_p(b);
        if(ap == bp)return;
        if(size_arr[ap] <= size_arr[bp])swap(ap,bp);
        drr[bp] = ap;
        size_arr[ap] += size_arr[bp];
    }
};

void solve(){
    int n, m;
    cin >> n >> m;
    Dsu d(n+2);
    rep(i, 0, m){
        int a, b;
        cin >> a >> b;
        d.uni(a, b);
    }
    vi v(n+1, 0);
    int ans = 0;
    for(int i = 1; i <= n; i++){
        int par = d.f_p(i);
        if(v[par] == 0){
            ans++;
            v[par] = 1;
        }
    }
    cout << ans-1 << endl;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 5936
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    s = str(input().rstrip('\n'))
    k = int(input().rstrip('\n'))
    ls = []
    for i in range(n):
        if s[i] != s[k-1]:
            ls.append("*")
        else:
            ls.append(s[i])
    print("".join(ls))


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<stack>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
const ll mod = (1e+9) + 7;

int main() {
	int N, ans = 0;
	cin >> N;
	for (int i = 10; i <= N * 10; i *= 100) {
		if (N >= i) ans = ans * 100 + 9;
		else {
			if (i / 10 <= N) ans += N - (i / 10) + 1;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

struct UnionFind
{
	int n;
	std::vector<int> par,size;
	UnionFind(int sz) : n(sz), par(sz,0), size(sz,1) {
		std::iota(par.begin(),par.end(),0);
	}
	int find(int x) {
		if(par[x]==x) return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x=find(x);y=find(y);
		if(x==y) return;
		if(size[x]<size[y]) std::swap(x,y);
		size[x]+=size[y];
		par[y]=x;
	}
};


int main() {
	lnt m,k;
	std::cin >> m >> k;
	std::vector<lnt> p(m),c(m);
	rep(i,m) std::cin >> p[i];
	rep(i,m) std::cin >> c[i];
	lnt max=-3e18;
	std::map<lnt,lnt> map;
	UnionFind uf(m);
	rep(i,m) {
		uf.unite(i,p[i]-1);
	}
	rep(ii,m) {
		if(map[uf.find(ii)]) continue;
		map[uf.find(ii)]=1;
		lnt n=uf.size[uf.find(ii)];
		std::vector<lnt> dp(n+1,0);
		{
			int i=ii;
			rep(j,n) {
				dp[j+1]=dp[j]+c[i];
				i=p[i]-1;
			}
		}
		rep(i,n) {
			for(int j=i;j<n;j++) {
				if(j-i+1<=k) max=std::max(max,dp[j+1]-dp[i]);
				if(n-i+j+1<=k) {
					max=std::max(max,dp[n]-dp[i]+dp[j+1]);
					max=std::max(max,dp[n]-dp[i]+dp[j+1]+dp[n]*((k-(n-i+j+1))/n));
				}
				if(n-j+i+1<=k) {
					max=std::max(max,dp[n]-dp[j]+dp[i+1]);
					max=std::max(max,dp[n]-dp[j]+dp[i+1]+dp[n]*((k-(n-j+i+1))/n));
				}
			}
		}
	}
	print(max);
}


Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
int n,a[100000],sum;
map<int,int>freq;
int main(){
cin>>n;
for(int i=0;i<n;++i)
{
	cin>>a[i];
	freq[a[i]]++;
}
for (auto t:freq){
	if(t.second%2!=0)sum++;
}
	cout<<sum<<endl;
	return 0;
}

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

using namespace std;
#define taskname "TEST"
#define pb	push_back
typedef long double ld;
typedef long long ll;
const int maxn = 4e5 + 5;

int bit[maxn] , n , k;
ll a[maxn];
vector<ll> b;
void update(int x)
{
    for( ; x < maxn ; x += x & -x)
        bit[x]++;
}

int query(int x)
{
    int res = 0;
    for( ; x > 0 ; x &= x - 1)
        res += bit[x];
    return res;
}

void enter()
{
    cin >> n >> k;
    b.reserve(n);
    for(int i = 1 ; i <= n ; ++i){
        cin >> a[i];
        a[i] -= k;
        a[i] += a[i - 1];
        b.pb(a[i]);
    }
    b.pb(0);
    sort(b.begin(),b.end());
    b.erase(unique(b.begin(),b.end()),b.end());
}

void solve()
{
    ll res = 0;
    update(lower_bound(b.begin(),b.end(),0) - b.begin() + 1);
    for(int i = 1 ; i <= n ; ++i)
    {
        res += query(lower_bound(b.begin(),b.end(),a[i]) - b.begin() + 1);
        update(lower_bound(b.begin(),b.end(),a[i]) - b.begin() + 1);
    }
    cout << res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	if(fopen(taskname".INP","r"))
        freopen(taskname".INP", "r",stdin) ,
        freopen(taskname".OUT", "w",stdout);
    enter();
    solve();
}


Measured memory_bytes: 8448
def LI(): return [int(x) for x in input().split(" ")]
def LS(): return [str(x) for x in input().split(" ")]
def ItoS(L): return [str(x) for x in L]
def StoI(L): return [int(c) for c in L]


def solve():
    a, b = LI()
    if a*b % 2:
        print("Odd")
    else:
        print("Even")


solve()

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 100010, mod = 1e9 + 7;

int sx, sy, tx, ty;
string res;

int main()
{
    cin >> sx >> sy >> tx >> ty;

    int x = tx - sx, y = ty - sy;
    for(int i = 0; i < y; i++) res += 'U';
    for(int i = 0; i < x; i++) res += 'R';
    for(int i = 0; i < y; i++) res += 'D';
    for(int i = 0; i < x; i++) res += 'L';

    res += 'L';
    for(int i = 0; i < y + 1; i++) res += 'U';
    for(int i = 0; i < x + 1; i++) res += 'R';
    res += 'D';
    res += 'R';
    for(int i = 0; i < y + 1; i++) res += 'D';
    for(int i = 0; i < x + 1; i++) res += 'L';
    res += 'U';

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


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

using namespace std;

int A, B;
string S;

int main(int argc, char* argv[]) {
  cin >> A >> B >> S;

  for (int i = 0; i < S.size(); i++) {
    if (i == A && S[i] != '-') {
      cout << "No" << endl;
      return 0;
    }

    if (i != A && S[i] < '0' || '9' < S[i]) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x, y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x, y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;
ll mode=pow(10,9)+7;
bool cmp(pair<long double ,int > x, pair<long double , int> y){ return x.F<y.F && x.S<y.S; }
const ll maxn=1e4+10;
ll __lcm(ll a, ll b){ return (a*b)/__gcd(a,b); }
int main(){ 
    
//    #ifndef ONLINE_JUDGE
//  		freopen("input.txt", "r", stdin);
//    #endif
    
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    string s;
    cin>>s;
    for (int i=0;i<s.size();i++) s[i]='x';
    cout<<s<<endl;
    
	return 0;
}


Measured memory_bytes: 256