akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define s second
#define f first
long long const mod = 1000000007; 
#define inf 1000000000000000000
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod)+mod)%mod;}
inline ll mul(ll a, ll b){ return (((a%mod)*(b%mod))%mod+mod)%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

ll power(ll x,ll y,ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
}

ll modInv(ll x)
{
    return power(x,mod-2,mod)%mod;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n,k;
    cin>>n>>k;
    
    ll h[n];
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    sort(h,h+n,greater<ll>());
    for(int i=k;i<n;i++)
    {
        sum=sum+h[i];
    }
    
    cout<<sum<<endl;
    
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int n,be[120000],x[120000],y[120000],d[120000],et,tot,con[120000];
struct edg{
	int y,ne;
};
edg e[220000];
inline void add_edge(int x,int y){
	e[++et].y=y;
	e[et].ne=be[x];
	be[x]=et;
}
int q[120000],he,ta;
int main(){
	scanf("%d",&n);
	fo(i,2,n){
		scanf("%d%d",&x[i],&y[i]);
		add_edge(x[i],y[i]);
		add_edge(y[i],x[i]);
		d[x[i]]++;
		d[y[i]]++;
	}
	fo(i,1,n)
		if (d[i]==1) q[++ta]=i;
	he=1;
	while (he<=ta){
		int &x=q[he];
		int i=be[x],y;
		while (i){
			if (d[e[i].y]){
				y=e[i].y;
				break;
			}
			i=e[i].ne;
		}
		if (d[y]==2){
			//printf("cut%d %d\n",x,y);
			d[y]-=2;
			i=be[y];
			while (i){
				if (d[e[i].y]){//!!!!!!!
					d[e[i].y]--;
					if (d[e[i].y]==1) q[++ta]=e[i].y;
					if (d[e[i].y]==2&&con[e[i].y]) q[++ta]=con[e[i].y];		
				}
				i=e[i].ne;
			}
		}
		else{
			if (con[y]&&con[y]!=x){//!!!!!! forgot con[y]!=x
				printf("First\n");
				return 0;
			}
			con[y]=x;
		}
		he++;
	}
	bool du=0;
	fo(i,1,n) if (d[i]){
		du=1;
		break;
	}
	if (!du){
		printf("First\n");
		return 0;
	}
	fo(x,1,n){
		tot=0;
		int i=be[x];
		while (i){
			if (d[e[i].y]==1) tot++;
			i=e[i].ne;
		}
		if (tot>=2){
			printf("First\n");
			return 0;
		}
	}
	printf("Second\n");
	return 0;
}

Measured memory_bytes: 4352
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

using namespace std;
using namespace __gnu_pbds;

template < typename T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

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

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef pair < int, int > pii;
typedef vector < ll > vll;
typedef vector < int > vi;
typedef gp_hash_table < int, int > fast;

#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, base = 1e9, MOD = 1e9 + 7, N = 1e5 + 5, M = 1e3 + 5, LG = 20;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

void test();

int main() {
    fast_io();
    cout << fixed << setprecision(15);
    test();
    return 0;
}

void test() {
    ll n, m;
    cin >> n >> m;
    pll p[n + 1];
    multiset < ll > st;
    for (int i = 1; i <= n; ++i) {
        cin >> p[i].F >> p[i].S;
    }
    sort(p + 1, p + n + 1);
    ll ans = 0;
    int j = 1;
    for (int i = 1; i <= m; ++i) {
        while (j <= n and p[j].F == i) {
            st.emplace(p[j].S);
            ++j;
        }
        if (st.size()) {
            ll cur = *st.rbegin();
            ans += cur;
            st.erase(st.find(cur));
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 6528
#include<stdio.h>
#define MAX 100000
#define MIN -1

struct Node{ int parent, left, right;};
struct Node T[MAX];

int getDepth(int);
void print(int);
int  D[MAX];
int main(){
  int i,j,n,x,y,c,l,a;
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    T[i].parent = T[i].left = T[i].right = MIN;
  }
  
  for ( i = 0; i < n; i++ ){
    scanf("%d%d",&x,&y);
    for ( j = 0; j < y; j++ ){
      scanf("%d", &c);
      if ( j == 0 ) T[x].left = c;
      else T[l].right = c;
      l = c;
      T[c].parent =x;
    }
  }
  
  a=0;
  for ( i = 0; i < n; i++ ){
    D[i] = getDepth(i);
    if ( D[i] > a ){
      a = D[i];
    }
  }

  for ( i = 0; i < n; i++ ){
    print(i);
  }
  
  return 0;
}


int getDepth(int u){
  int d=0;
  while(T[u].parent!=MIN){
    u=T[u].parent;
    d++;
  }
  return d;
}


void print(int u){
  int i, c;
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("depth = %d, ", D[u]);

  if ( T[u].parent == MIN) printf("root, [");
  else if ( T[u].left == MIN) printf("leaf, [");
  else printf("internal node, [");

  for(i = 0, c = T[u].left; c != MIN; i++, c = T[c].right){
    if (i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
}




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


int main(){
    #ifdef LOCAL_MACHINE
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif
    
    int n,w;
    scanf("%d %d",&n,&w);

    int weight[n+2];
    int value[n+2];

    long long dp[w+2]={};
    for(int i=0;i<n;i++){
        int wt,vl;
        scanf("%d %d",&wt,&vl);    

        for(int j=w;j>=wt;j--){
            dp[j]=max(dp[j],dp[j-1]);
            dp[j]=max(dp[j],dp[j-wt]+vl);
        }
    }
    printf("%lld\n",dp[w]);
    
    return 0;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
    const char *First = "First";
    const char *Second = "Second";

    char S[100001];

    if (scanf("%s", S) < 1) return 0;

    int len = strlen(S);

    printf("%s\n"
        , (len % 2 == 0) ^ (S[0] == S[len - 1]) ? Second : First);
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) = println(run {
    val s = readLine()!!
    val n = s.length
    if (s.isPalindrome() &&
            s.take((n-1)/2).isPalindrome() &&
            s.takeLast((n-1)/2).isPalindrome()
    ) "Yes" else "No"
})

fun String.isPalindrome() = this == this.reversed()

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

#define UF_NUM 505050

int main() {
    li a, b, c;
    cin >> a >> b >> c;
    cout << ((a == b && b == c) ? "Yes" : "No") << endl;


    return 0;
}

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

bool hate[10];

bool check(int num) {
  while (num > 0) {
    int tmp = num % 10;
    if (hate[tmp]) return false;
    num /= 10;
  }
  return true;
}

int main() {
  int N, K;
  cin >> N >> K;
  for (int i = 0; i < K; i++) {
    int D;
    cin >> D;
    hate[D] = true;
  }

  int ans = 0;
  while (1) {
    if (check(N)) {
      ans = N;
      break;
    }
    N++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
K, N = map(int, input().strip().split())
As = list(map(int, input().strip().split()))

max_interval = 0
index = None
distance = 0
for i in range(N):
    if i == N-1:
        interval = K - As[i] + As[0]
    else:
        interval = abs(As[i+1] - As[i])
    if interval > max_interval:
        max_interval = interval
        index = i
        
if index == N-1:
    distance = As[index] - As[0]
else:
    distance = As[index] + K - As[index+1]
print(distance)

Measured memory_bytes: 26444
N,A,B,C,D=map(int,input().split())
if A>B:
    A,B=B,A
N-=1
if N%2==1:
    m=[[A+C,A+D],[A-D,A-C]]
    N-=1
else:
    m=[[A,A]]
    
flag=0
e=D-C

for MIN,MAX in m:
    if MIN<=B<=MAX:
        flag=1
        break
    if MIN>B:
        MAX,MIN=MIN,MAX
    MAX=abs(MAX-MIN)
    b=abs(B-MIN)
    MIN=0
    n=N//2
    p=[b-n*e,b+n*e]
    for i in range(n+1):
        if p[1]<MIN:
            break
        elif MAX<p[0]:
            MIN+=2*C
            MAX+=2*D
            p[0]+=e
            p[1]-=e
        else:
            flag=1
            break

print(["NO","YES"][flag])

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <algorithm>

int main() {
	int answer = 0;
	std::array<int, 3>arr;
	for (int i = 0; i < 3;i++) {
		std::cin >> arr[i];
	}
	std::sort(arr.begin(),arr.end());
	answer = arr[2] * 10 + arr[1] + arr[0];
	std::cout << answer << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7;
ll GCD(ll x, ll y) {if (x % y == 0) return y;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x * y / GCD(x, y);}

int main(){
  ll n,k; cin>>n>>k;
  ll ans=pow(n/k,3);
  if(k%2==0){
   if(k/2<=n%k) ans+=pow(/*(n-k/2)/k +1*/n/k+ 1,3);
 else ans+=pow(n/k,3);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
n = int(input())
x = list(map(int, input().split()))

sum_list = []
start = min(x)
stop = max(x)
for i in range(1, 100):
    sum = 0
    for j in x:
        sum += (i - j) ** 2
    sum_list.append(sum)

print(min(sum_list))


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

int main(){
	int a,b,c;
	int x;
	int count=0;
	cin>>a>>b>>c;
		for(x = a; x <= b;x++){
			if(c%x==0){
				count++;
			}
		}
	cout<<count<<endl;
	
return 0;
}


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

using namespace std;

long long inf=1000000007;
int cnt=0;

void merge(vector<int> &A,int left,int mid,int right){
	int n1=mid-left;
	int n2=right-mid;
	vector<int> L,R;
	for(int i=0;i<n1;i++){
		L.push_back(A.at(left+i));
	}

	for(int i=0;i<n2;i++){
		R.push_back(A.at(mid+i));
	}
	L.push_back(inf);
	R.push_back(inf);

	int i=0;
	int j=0;

	for(int k=left;k<right;k++){
		if(L.at(i)<=R.at(j)){
			A.at(k)=L.at(i);
			i++;
		}else{
			A.at(k)=R.at(j);
			j++;
		}

		cnt++;
	}
}

void mergeSort(vector<int> &A,int left,int right){
	if(left+1<right){
		int mid=(left+right)/2;
		mergeSort(A,left,mid);
		mergeSort(A,mid,right);
		merge(A,left,mid,right);
	}
}

int main(){
	int n;
	cin>>n;
	vector<int> A(n);
	for(int i=0;i<n;i++) cin>>A.at(i);

	mergeSort(A,0,n);

	for(int i=0;i<n;i++){
		cout<<A.at(i);
		if(i<n-1) cout<<" ";
		else cout<<endl<<cnt<<endl;
	}

	return 0;
}



Measured memory_bytes: 7372
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

/* Union-Find-Tree */
class Union_Find {
public:
  vector<long long> par;
  vector<long long> rnk;

  Union_Find (long long n) {
    par.resize(n), rnk.resize(n);
    for (int i = 0; i < n; ++i) {
      par[i] = i;
      rnk[i] = 0;
    }
  }

  // 木の根を求める
  int find(int x) {
    if (par[x] == x)
    return x;
    else
    return par[x] = find(par[x]);
  }

  // xとyの属する集合を併合
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (rnk[x] < rnk[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if (rnk[x] == rnk[y]) rnk[x]++;
    }
  }

  // xとyが同じ集合に属するか否か
  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

int main() {
  ll n, k, l; scanf("%lld %lld %lld", &n, &k, &l);
  Union_Find road(n), train(n);

  rep(i,k) {
    int t,s; scanf("%d %d", &t, &s);
    t--, s--;
    if (!road.same(t,s)) road.unite(t,s);
  }

  rep(i,l) {
    int t,s; scanf("%d %d", &t, &s);
    t--, s--;
    if (!train.same(t,s)) train.unite(t,s);
  }

  vector<pair<int, int> > com(n);
  map<pair<int, int>, int> s;
  rep(i,n) {
    com[i].first = road.find(i);
    com[i].second = train.find(i);
    s[com[i]]++;
  }

  rep(i,n) {
    printf("%d ",s[com[i]]);
  }
  END;
}


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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int>vec(M,0);
  for(int i=0; i<N; i++){
    int K;
    cin >> K;
    for(int i=0; i<K; i++){
      int A;
      cin >> A;
      vec[A-1] += 1;
    }
  }
  int ans=0;
  for(int i=0; i<M; i++){
    if(vec[i] == N){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3656
#include<iostream>
using namespace std;
 
int gcd(int a,int b)
{
  int tmp;
  if(a>b){
    tmp = a;
    a = b;
    b = tmp;
  }
  if(a == 0){return b;}
  else{return gcd(b%a,a);}
}

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

int main()
{
  int a,b;

  while(cin >> a >> b){
    cout << gcd(a,b) << " " << lcm(a,b) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define nl '\n'

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int , int> pi;

void solve()
{
	ll n;
	cin>>n;
	ll answer = 0;
	for(ll i=0; i<n; i++)
		answer += (i+1)*(n-i);
	for(ll i=0; i<n-1; i++)
	{
		ll x, y;
		cin>>x>>y;
		if(x > y) swap(x, y);
		answer  -= x*(n-y+1);
	}
	cout<<answer<<nl;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	//cin>>t;
	t = 1;
	while(t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int N; cin >> N;
  int h[N]; rep(i,N) cin >> h[i];
  int retval = 0, l=0;

  while (l<N){
    if (h[l]==0) {
      l++;
      continue;
    }
    int i=l;
    while (i<N && h[i]>0){
      h[i]--;
      i++;
    }

    retval++;
  }
  cout << retval << endl;
  
  // cout << fixed << setprecision(10);
  
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>

using namespace std;


int main(){
  int n,AUTO,total,home;
  string op;

  scanf("%d",&n);
  for(int i=0;i<n;i++){
    AUTO=0;
    total=0;
    home=0;
    while(true){
      if(AUTO == 3)break;
      cin >> op;
      if(op == "HIT"){
	home = (home<<1)+1;
	if(home>>3){
	  total++;
	  home = home & ~(1<<3);
	}
       
      }
      else if(op == "HOMERUN"){
	for(int i=0;i<3;i++){
	  if(home>>i & 1)total++;
	}
	total++;
	home=0;
      }
      else if(op == "OUT")AUTO++;
    }
    printf("%d\n",total);
  }
  return 0;
}

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

int main(void){
    int a[3],n;
    cin >> a[0] >> a[1] >> a[2] >> n;
    sort(a,a+3,greater<int>());
    for(int i = 0;i < n;i++)a[0] *= 2;
    cout << a[0]+a[1]+a[2];
}

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

#include <algorithm>
#include <cassert>
#include <vector>

namespace atcoder {

// Implement (union by size) + (path compression)
// Reference:
// Zvi Galil and Giuseppe F. Italiano,
// Data structures and algorithms for disjoint set union problems
struct dsu {
  public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};

}  // namespace atcoder

using namespace atcoder;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000000000000

long long get(int h,int m,vector<int> x){
	vector<string> S(h,string(7,'0'));
	rep(i,7*h){
		if(binary_search(x.begin(),x.end(),i%m)){
			S[i/7][i%7]='1';
		}
	}
	dsu D(h*7);
	
	rep(i,h){
		rep(j,7){
			if(i!=h-1){
				if(S[i][j]=='0'&&S[i+1][j]=='0'){
					D.merge(i*7+j,(i+1)*7+j);
				}
			}
			if(j!=6){
				if(S[i][j]=='0'&&S[i][j+1]=='0'){
					D.merge(i*7+j,i*7+j+1);
				}
			}
		}
	}
	long long ret = 0LL;
	rep(i,h){
		rep(j,7){
			if(S[i][j]=='1')continue;
			if(D.leader(i*7+j)==i*7+j)ret++;
		}
	}
	return ret;
	
}

int main(){
	
	long long n,m,q;
	cin>>n>>m>>q;
	vector<int> a(q);
	rep(i,q)cin>>a[i];
	
	long long ans = 0LL;
	if(n<=m){
		ans = get(n,m,a);
	}
	else{
		ans = get(m,m,a);
		n -= m;
		ans += n/m * (get(2*m,m,a)-get(m,m,a));
		n %= m;
		ans += get(m+n,m,a) - get(m,m,a);
	}
	cout<<ans<<endl;
	
    return 0;
}



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

void bubbleSort(int A[],int N){
    int flag,count,tmp;
    count =0;
    flag =1;
    while(flag==1){
        flag=0;
        for(int j=N-1; 0<j; j-- ){
            if(A[j]<A[j-1]){
                tmp=A[j];
                A[j] = A[j-1];
                A[j-1]= tmp;
                flag =1;
                count++;
            }
        }
    
    }
    for(int i =0;i<N;i++) {
        if(i>0) cout << " ";
        cout << A[i];
    }
    cout << endl << count << endl;
}
    

int main(){
    int A[100],N;
    cin >> N;
    for(int i=0; i<N;i++) cin >>A[i];
    bubbleSort(A,N);



}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n;
  cin >> n;
  vector<string> s(n);
  ll ans = 0;
  rep(i, n) {
    cin >> s[i];
    if (s[i] == "E869120") ans++;
  }

  cout << ans << endl;
}



Measured memory_bytes: 3320
loop do
  l = (1..8).map{gets.chomp}.join
  puts "A" if l.include?("1100000011")
  puts "B" if l.include?("1000000010000000100000001")
  puts "C" if l.include?("1111")
  puts "D" if l.include?("1000000110000001")
  puts "E" if l.include?("11000000011")
  puts "F" if l.include?("100000001100000001")
  puts "G" if l.include?("110000011")
  break unless gets
end

Measured memory_bytes: 8596
import copy

N = int(input())
A = sorted(list(map(int, input().split())))


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def calc(B):
    lo, hi = 1, 10 ** 9 + 1
    while abs(hi - lo) > 1:
        X = copy.deepcopy(B)
        m = (hi + lo) // 2

        skipped = False
        while len(X) > 1:
            a, b = X.pop(), X.pop()
            GCD = gcd(a, b)
            if GCD < m:
                if skipped is False:
                    skipped = True
                    X.append(a)
                    continue
                else:
                    hi = m
                    break
            X.append(GCD)
        else:
            if X[0] >= m:
                lo = m
            else:
                hi = m
    return lo


ans1 = calc(A)
ans2 = calc(A[::-1])

print(max(ans1, ans2))


Measured memory_bytes: 123116
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
#define ALL(x) (x).begin(), (x).end()
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された

    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }

    return true;
}

int main(void){
    int N = 0, K = 0, sum = 1;
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        if ((sum + K) < (sum * 2)) sum += K;
        else sum *= 2;
    }
    cout<<sum<<endl;
    return 0;
}


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

class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	try {
	    String st;
	    while((st=sc.readLine())!=null){
		int n = Integer.valueOf(st);
		System.out.println(n*(n+1)/2+1);
	    }
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 8968
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

/* define */
#define Yes(X) puts ( X ? "Yes" : "No")
#define YES(X) puts ( X ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = a; i < b ; i++)
#define REP(i, n) for ( int i = 0; i < n ; i++)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = (int)1e9 + 7;

/* alias */
typedef long long ll;
typedef unsigned  u;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0) return Lgcd(b, a % b); 
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / Lgcd(a, b) * b;
}

/* main */
int main() {
	int n, a, b, ma = 0, mb;
	scanf("%d", &n);
	REP(i, n) {
		scanf("%d%d", &a, &b);
		if (ma < a) {
			ma = a;
			mb = b;
		}
	}
	printf("%d", ma + mb);
	return 0;
}

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

// nCr mod p(n<p)をキビキビ計算する
// 構築:O(n), クエリ:O(1)
struct combination_mod {
    using lint = long long int;
    int sz;
    lint mod;
    vector<lint> fac;
    vector<lint> finv;
    combination_mod(int _sz, lint _mod) : sz(_sz), mod(_mod) {
        fac.assign(sz + 1, 1);
        finv.assign(sz + 1, 1);
        vector<lint> inv(sz + 1, 1);
        for (int i = 2; i <= sz; i++) {
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
    lint query(int n, int r) {
        return fac[n] * (finv[r] * finv[n - r] % mod) % mod;
    }
};

lint mod = 1e+9 + 7;
lint n, k;

int main() {
    cin >> n >> k;
    combination_mod comb(2 * n, mod);
    if (k >= n - 1) {
        cout << comb.query(2 * n - 1, n) << endl;
        return 0;
    }
    if (k == 1) {
        cout << n * (n - 1) % mod << endl;
        return 0;
    }
    lint ans = (1 + n * (n - 1)) % mod;
    for (int i = 1; i < k; i++) {
        lint ta = comb.query(n, i + 1);
        ta *= comb.query(n - 1, i + 1);
        ta %= mod;
        ans = (ans + ta) % mod;
    }
    cout << ans << endl;
}

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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second

#define TRACE

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

const int N = 405;
const int M = 100005;

bool present[N];

int x[M], y[M];
int g[M];
bool never[N];
bitset<N> store[M][4];

int main(){
	int n, m; sd(n); sd(m);
	int ans = 0;
	for(int i = 1; i <= m; i++) sd(x[i]), sd(y[i]);
	for(int i = 1; i <= n; i++){
		memset(present, 0, sizeof present);
		bitset<N> ok; ok.reset();
		present[i] = 1;
		for(int j = 1; j < i; j++) ok[j] = !never[j];
		for(int j = m; j >= 1; j--){
			if(present[x[j]]){
				if(!present[y[j]]){
					g[j] = 2;
					ok &= ~store[j][3 - g[j]];
					store[j][2].set(i);
					present[y[j]] = 1;
				} else{
					never[i] = 1;
					break;
				}
			} else{
				if(present[y[j]]){
					g[j] = 1;
					ok &= ~store[j][3 - g[j]];
					store[j][1].set(i);
					present[x[j]] = 1;	
				}
			}
		}
		if(!never[i]) ans += ok.count();
	}
	cout << ans;
}

Measured memory_bytes: 21760
N, T = map(int, input().split())

tList = list(map(int, input().split()))

sumTime = 0

for i in range(N-1):
    dt = tList[i+1] - tList[i]
    if dt < T:
        sumTime += dt
    else:
        sumTime += T

sumTime += T

print(sumTime)

Measured memory_bytes: 25196
N=int(input())

sqrt_N = N**0.5

list_D=[]
list_A=[]

i=1
while(i<sqrt_N):
    if N%i == 0:
        list_D.append(i)
    i+=1

for d in list_D:
    list_A.append(N//d-1)
    
if N==1 or N==2:
    print(0)
else:
    if N%list_A[-1] == 0:
        list_A.pop(-1)
    print(sum(list_A))


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

int main() {
  int n;
  cin >> n;
  int p1000 = n / 1000, p100 = n % 1000 / 100, 
      p10 = n % 1100 / 10, p1 = n % 1110 / 1;

  if (n == 1000 || n == 1100) {
    cout << "Yes" << endl;
  } 
  else if ((p1000 == p100 && p100 == p10) || (p100 == p10 && p10 == p1)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

  int p[100001];
  int sz[100001];

int root(int x)
{
  if (p[x]==x) return x;
  return root(p[x]);
}

bool same(int x, int y)
{
  return root(x) == root(y);
}

void unite(int x, int y)
{
  x=root(x);y=root(y);
  if(x==y) return;
  if (sz[x] > sz[y]) swap(x,y);
  p[x] = y;
  sz[y] += sz[x];
  
  return;
}



int main()
{
  int N, M, K;
  cin >> N >> M >> K;  
    
  int minus[N+1];
  
  for(int i=0;i<N+1;i++)
  {
    p[i]=i;
    sz[i]=1;
    minus[i]=0;
  }

  for(int i=0;i<M;i++)
  {
    int k,j;
    cin >> k >> j;
    unite(k,j);
    minus[k]++;
    minus[j]++;
  }

  for(int i=0;i<K;i++)
  {
    int k,j;
    cin >> k >> j;
    
    if (same(k,j))
    {
      minus[k]++;
      minus[j]++;
    }
  }

  for(int i=1;i<N+1;i++)
  {
    if(i!=1) cout << " ";
    //printf("i: %d, root: %d, sz: %d, minus: %d\n",i,root(i),sz[root(i)],minus[i]);
    cout << sz[root(i)] - minus[i] - 1;
  }
  
  cout << endl;
  
    return 0;
}




Measured memory_bytes: 2048
/*Lower_Rating*/
/*Ex*/
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stack>
#include<vector>
#include<queue>
#include<bitset>
#include<set>
using namespace std;

#define LL long long
#define DB double
#define MOD 1000000007
#define Pr pair<int,int>
#define X first
#define Y second
#define MAXN 100000
#define eps 1e-10
#define INF 10000000000
#define mem(x,p) memset(x,p,sizeof(x))

LL read(){
  LL x=0,F=1;char c=getchar();
  while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
  while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
  return x*F;
}
int add(int a,int b){return (a+b>=MOD)?a+b-MOD:a+b;}
int dec(int a,int b){return (a-b<0)?a-b+MOD:a-b;}
int mul(LL a,int b){return a*b%MOD;}

int n;LL x;
LL D,ans,sum[MAXN+5];
struct node{
    LL b,l,r,h;
}p[MAXN+5];
bool cmp(node s1,node s2){
    return s1.h>s2.h;
}

LL calc(int i,LL pv){
    if(pv<=p[i].b)return pv*p[i].l;
    return p[i].b*p[i].l+(pv-p[i].b)*p[i].r;
}

bool check(LL v){
    LL res=0,rm=v%x,cnt=v/x;
    if(cnt>=n)return sum[n];
    for(int i=1;i<=n;i++){
        if(i<=cnt)res=max(res,calc(i,rm)+sum[cnt+1]-p[i].h);
        else res=max(res,calc(i,rm)+sum[cnt]);
    }
    return res>=D;
}

int main(){
    //freopen("homework.in","r",stdin);
    //freopen("homework.out","w",stdout);
    n=read(),x=read();
    for(int i=1;i<=n;i++){
        p[i]=(node){read(),read(),read(),0};
        p[i].h=p[i].b*p[i].l+(x-p[i].b)*p[i].r;
        D+=p[i].b*p[i].l;
    }
    sort(p+1,p+n+1,cmp);
    for(int i=1;i<=n;i++)sum[i]=sum[i-1]+p[i].h;
    LL l=0,r=INF;
    while(l<=r){
        LL mid=(l+r)>>1;
        if(check(mid))r=mid-1,ans=mid;
        else l=mid+1;
    }
    printf("%lld",ans);
}


Measured memory_bytes: 4096
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n,k;
int main(){
	in(n);in(k);
	if(k==1)puts("0");
	else printf("%d\n",n-k);
	return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define int         ll int
#define float       double
#define	endl		'\n'
#define maxpq       priority_queue<ll>
#define minpq       priority_queue<ll, vector<ll>, greater<ll> >
#define mii         map<int,int>
#define msi         map<string,int>
#define mis         map< int, string>
#define mpi         map<pair< int, int>, int>
#define pii         pair< int, int>
#define vi          vector< int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define EPS         1e-9
#define INF         1e18
#define PI          3.14159265358979323846
#define MAXI        1000000
#define what_is(x)  cerr << #x << " is " << x << endl;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
#define N 100005
int modexp(int x,int n,int mod){
	x%=mod;
	int res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n/=2;
	}
	return res;
}
int modInverse(int n, int p)
{ 
    return modexp(n, p - 2, p); 
} 
int nCr(int n,int r, int p) 
{ 
    if (r == 0) 
        return 1; 
    int fac[n + 1]; 
    fac[0] = 1; 
    for (int i = 1; i <= n; i++) 
        fac[i] = (fac[i - 1] * i) % p; 
  
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; 
} 
float dis(int x,int y)
{
	return sqrt(x*x+y*y);
}
signed main()
{
	fast;
	int t=1;
	//cin>>t;
	while(t--)
	{
		int n,d;
		cin>>n>>d;
		int i,j,k;
		int num=0;
		for(i=0;i<=n-1;i++)
		{
			int x,y;
			cin>>x>>y;
			if(dis(x,y)<=d*1.0) num++;
		}
		cout<<num<<endl;
   }
   return 0;
}

Measured memory_bytes: 3672
import java.util.*;
public class Main{

    void run(){
        Scanner sc = new Scanner(System.in);
        int[][] dp = new int[5][4001];
        dp[0][0] = 1;
        for(int i = 1; i < 5; i++){
            for(int ii = 0; ii <= 1000 * i; ii++){
                for(int iii = Math.max(0,ii-1000); iii <= ii; iii++){
                    dp[i][ii] += dp[i-1][iii];
                }
            }
        }
        while(sc.hasNext()){
            System.out.println(dp[4][sc.nextInt()]);
        }
    }
    public static void main(String[] args){
        new Main().run();
    }
}
        

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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  
  for(int i=0; i<N; i++){
  	int l,r;
    cin >> l >> r; 
    if(l == r){
      sum++;
      continue;
    }
    sum += r - l + 1;
    
  }
  cout << sum << endl;
  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define nl cout<<"\n"
#define db(x) cout<<x<<" "
#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define fk(a,b) for(int k=a;k<b;k++)
#define F first
#define S second
#define UM unordered_map<int,int>
#define MP map<int,int>
#define mxsize (int)1e6
void fun(){
    int  n,x,t;
    cin>>n>>x>>t;
    n=ceil(1.0*n/x);
    n*=t;
    cout<<n<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("/ATOM/input.txt", "r", stdin);
        freopen("/ATOM/output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t--){
        fun();
    }
}

Measured memory_bytes: 3556
#include"bits/stdc++.h"
using namespace std;
#define rep(i, N) for(int i=0; i<N; ++i)
using ul = unsigned long;
using ll = long long;

ul euclidean_gcd(ul a, ul b) {
  if(a < b) return euclidean_gcd(b, a);
  ul r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
    ul a, b;
    cin >> a >> b;
    ul c = euclidean_gcd(a, b);
    cout << (a * b / c) << endl;
}


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

template <typename T>
class BinarySearchTree {

  struct Node {
    T key;
    Node *par, *lhs, *rhs;
    Node(T k, Node *p, Node *l = 0, Node *r = 0) : key(k), par(p), lhs(l), rhs(r) {}
  };

  Node *root;

  // 入力：現在のノード curr, 中間順巡回のノードの順番を保存した配列 order
  // 出力：なし
  void inorder_dfs(Node *curr, std::vector<int> &order) {
    if (!curr) return;
    inorder_dfs(curr->lhs, order);
    order.push_back(curr->key);
    inorder_dfs(curr->rhs, order);
  }

  // 入力：現在のノード curr, 中間順巡回のノードの順番を保存した配列 order
  // 出力：なし
  void preorder_dfs(Node *curr, std::vector<int> &order) {
    if (!curr) return;
    order.push_back(curr->key);
    preorder_dfs(curr->lhs, order);
    preorder_dfs(curr->rhs, order);
  }

public:

  BinarySearchTree() : root(0) {}

  // 入力：なし
  // 出力：中間順巡回のノードの順番を保存した配列
  std::vector<int> inorder() {
    std::vector<int> res;
    inorder_dfs(root, res);
    return res;
  }

  // 入力：なし
  // 出力：先行順巡回のノードの順番を保存した配列
  std::vector<int> preorder() {
    std::vector<int> res;
    preorder_dfs(root, res);
    return res;
  }

  // 入力：値 x
  // 出力：なし
  void insert(const T &x) {
    Node *curr = root, *prev = 0;
    while (curr) {
      prev = curr;
      if (curr->key > x) curr = curr->lhs;
      else if (curr->key < x) curr = curr->rhs;
      else return;
    }
    (!prev ? root : (prev->key > x) ? prev->lhs : prev->rhs) = new Node(x, prev);
  }

  // 入力：値 x
  // 出力：キーに x を持つノードのポインタ (存在しない場合は 0)
  Node *find(const T &x) {
    Node *curr = root;
    while (curr) {
      if (curr->key == x) return curr;
      curr = (curr->key > x ? curr->lhs : curr->rhs);
    }
    return 0;
  }

};

void insert(BinarySearchTree<int> &BST) {
  int x;
  std::cin >> x;
  BST.insert(x);
}

void find(BinarySearchTree<int> &BST) {
  int x;
  std::cin >> x;
  std::cout << (BST.find(x) ? "yes" : "no") << std::endl;
}

void print(BinarySearchTree<int> &BST) {
  std::vector<int> inorder = BST.inorder();
  std::vector<int> preorder = BST.preorder();
  for (size_t i = 0; i < inorder.size(); i++) {
    std::cout << " " << inorder[i];
  }
  std::cout << std::endl;
  for (size_t i = 0; i < preorder.size(); i++) {
    std::cout << " " << preorder[i];
  }
  std::cout << std::endl;
}

void ALDS1_8_A() {
  BinarySearchTree<int> BST;
  size_t N;
  std::cin >> N;
  for (size_t i = 0; i < N; i++) {
    std::string s;
    std::cin >> s;
    if (s == "insert") insert(BST);
    else print(BST);
  }
}

void ALDS1_8_B() {
  BinarySearchTree<int> BST;
  size_t N;
  std::cin >> N;
  for (size_t i = 0; i < N; i++) {
    std::string s;
    std::cin >> s;
    if (s == "insert") insert(BST);
    else if (s == "find") find(BST);
    else print(BST);
  }
}

int main() {

  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  // ALDS1_8_A();
  ALDS1_8_B();

}


Measured memory_bytes: 26180
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
#define REP(i,x,n) for(int i=x; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()

int main(){
  bool ans=0;
  int n,cnt=0;
  cin >> n;
  vi p(n),q(n);
  rep(i,n){
    cin >> p[i];
    q[i]= p[i];
  }

  sort(all(q));
  
  if(q==p)
    ans=1;

  rep(i,n)
    if(q[i] != p[i])
      cnt++;

  if(cnt==2)
    ans=1;
  
  if(ans)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 256
def f(n)
  ret = 0
  while n.even? do
    n /= 2
    ret += 1
  end
  ret
end

N = gets.to_i

ans = 1
max_count = 0
for i in 1..N do
  count = f(i)
  if count > max_count
    max_count = count
    ans = i
  end
end

puts ans

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define inf 1000000000
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(i) cout<<i<<endl;
const int mod=1e9 +7;
int main(){
IOS;
int n,k,i,j;
cin>>n>>k;
int dp[k+1];
memset(dp,0,sizeof(dp));
int a[n];
for(i=0;i<n;i++){
    cin>>a[i];
}
for(i=0;i<=k;i++){
    for(j=0;j<n;j++){
        if(!dp[i]){
            if(i+a[j]<=k)
                dp[i+a[j]]=1;
        }
    }
}
if(dp[k])
    cout<<"First"<<endl;
else cout<<"Second"<<endl;
}



Measured memory_bytes: 640
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
def do():
    boin = ('a','e','u','i','o')
    c = STR()
    if c in boin:
        print('vowel')
    else:
        print('consonant')
if __name__ == '__main__':
    do()

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

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int vectorgcd(std::vector<int> a){
    int ans = a.at(0);
    for(int i = 1; i < a.size(); i++){
        ans = euclidean_gcd(ans, a.at(i));
    }
}


int main(void){
    int n;
    std::cin >> n;

    std::vector<int> a(n);
    for(int i = 0; i < n; i++){
        std::cin >> a.at(i);
    }

    int ans = vectorgcd(a);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;

template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}

#define P (1'000'000'007)

signed main() {
    capi(n);

    vi va;
    rep(i, n) {
        capi(a);
        va.push_back(a);
    }

    vi vl, vr;
    vl.push_back(va[0]);
    rep (i, n - 1) {
        vl.push_back(gcd(vl[i], va[i + 1]));
    }
    reverse(all(va));
    vr.push_back(va[0]);
    rep (i, n - 1) {
        vr.push_back(gcd(vr[i], va[i + 1]));
    }
    reverse(all(vr));

    int ans = 0;

    rep(i, n) {
        chmax(ans, gcd((i == 0 ? vr[i + 1] : vl[i - 1]), (i == n - 1 ? vl[i - 1] : vr[i + 1])));
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 5912
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	ll n;
	cin>>n;
	ll a[n];
	set<ll> s;
	for(ll i=0;i<n;i++){
		cin>>a[i];
		s.insert(a[i]);
	}
	if(s.size()==n){
		cout<<"YES";
	}
	else
		cout<<"NO";
}

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

using namespace std;

using ll = long long;

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

    int n, t;
    cin >> n >> t;

    vector<int> a(n);
    for (auto &&x : a) cin >> x;

    vector<int> max_a(n);
    for (int i = n - 2; 0 <= i; --i)
        max_a[i] = max(max_a[i + 1], a[i + 1]);

    int d = 0;
    for (int i = 0; i < n - 1; ++i)
        if (a[i] < max_a[i]) d = max(d, abs(a[i] - max_a[i]));

    int cnt = 0;
    for (int i = 0; i < n - 1; ++i)
        if (a[i] < max_a[i] && abs(a[i] - max_a[i]) == d) ++cnt;

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long llint;
const llint MOD = 1'000'000'007;

int main() {

    llint M, N;
    cin >> M >> N;
    for(int i = 0; i < N; i++) {
        int a;
        cin >> a;
        M -= a;
    }
    if(M < 0)
        M = -1;
    cout << M;
}

Measured memory_bytes: 3604
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B, C);

// ===

fn main() {
    let (a, b, k): (i32, i32, i32) = read();
    let mut ans = vec![];
    for i in a..a+k {
        if a <= i && i <= b {
            ans.push(i);
        }
    }
    for i in (b-k+1)..b+1 {
        if a <= i && i <= b {
            ans.push(i);
        }
    }
    ans.sort();
    ans.dedup();

    for a in ans {
        println!("{}", a);
    }
}


Measured memory_bytes: 4352