akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int partition(vi &a, int p, int r) {
    int x = a[r];
    int i = p-1;
    for (int j = p; j < r; ++j) {
        if (a[j] <= x) {
            i++;
            swap(a[i], a[j]);
        }
    }
    swap(a[i+1], a[r]);
    return i+1;
}

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

    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int j = partition(a, 0, n-1);
    rep(i, n) {
        if (i == j) cout << '[' << a[i] << ']' << (i == n-1 ? '\n' : ' ');
        else cout << a[i] << (i == n-1 ? '\n' : ' ');
    }
}



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

using namespace std;

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

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

bool isp[10000000]={};


void makeEra(){
    for(int i=2;i<=10000;i++){
        if( isp[i] ){
            for(int j=2;i*j<10000000;j++){
                isp[i*j]=false;
            }
        }
    }
}


int main(){
    rep(i,10000000)isp[i]=true;
    isp[0]=isp[1]=false;
    makeEra();
    
    int n;
    while(cin>>n){
        if( n==0 )break;
        for(int i=n;;i--){
            if( isp[i] && isp[i-2] && isp[i-6] && isp[i-8] ){
                cout<<i<<endl;
                break;
            }
        }
    }
}

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

int main(){
    char a,b,temp;
    scanf("%c",&a);
    scanf("%c",&temp);
    scanf("%c",&b);

    int test = a-b;
    if(test==0)
        printf("H\n");
    else
        printf("D\n");

        return 0;
}

Measured memory_bytes: 256
float a,b,c,d,p=57.296;main(){for(;~scanf("%f%f%f%f",&a,&b,&c,&d);)a+1&&printf("%.0f\n",6378.1*acos(sin(a/p)*sin(c/p)+cos(a/p)*cos(c/p)*cos(b/p-d/p)));}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>
#include <string>

int main()
{
	int N;
	std::cin >> N;
	std::string C;
	std::cin >> C;
	int r = 0;
	for (char x : C)
	{

		if (x == 'R')r++;
	}
	int ans = 0;
	for (int i = 0; i < r; i++)
		if (C[i] == 'W')
			ans++;
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 3748
def main():
    n = int(input())
    print(find_next_prime(n))


def find_next_prime(n):
    return find_prime_in_range(n, 2*n)


def find_prime_in_range(a, b):
    for p in range(a, b):
        for i in range(2, p):
            if p % i == 0:
                break
        else:
            return p
    return None


if __name__ == '__main__':
    main()

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

#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
const lol Mod=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k,r;
int a[200010];
lol sum[200010];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>n;
  for(int i=0;i<n;i++) cin >>a[i];
  lol ans=0;
  for(int i=0;i<n;i++){
    if(a[i]+i<n){
      sum[a[i]+i]++;
    }
  }
  for(int i=0;i<n;i++){
    if(i-a[i]>=0){
      ans+=sum[i-a[i]];
    }
  }
  cout <<ans<<'\n';
  return (0);
}


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


using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 998244353;





int main() {
	VI v = { 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 k;
	cin >> k;
	cout << v[k-1] << endl;


}




Measured memory_bytes: 256
#include<cstdio>
long long a,b,x,e,s;
int main()
{
    scanf("%lld%lld%lld",&a,&b,&x);
    if(a%x==0)s=a/x;
    else s=a/x+1;
    e=b/x;
    printf("%lld",e-s+1);
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n;
    cin>>n;
    Vec c(n);
    Vec s(n);
    Vec f(n);
    REP(i,1,n){
        cin>>c[i]>>s[i]>>f[i];
    }

    Vec ans;
    REP(i,1,n){
        //初期値
        Vec a(n);
        REP(j,i,n){
            ll t = max(a[j-1],s[j]);
            a[j] = (t-s[j]+f[j]-1) / f[j] * f[j] + s[j];
            a[j] += c[j];
        }
        ans.pb(a[n-1]);
    }
    ans.pb(0);
    rep(i,n){
        out(ans[i]);
    }
    return  0;
}


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

const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
    mint choose(int n, int a){
        mint x = 1 ,y = 1;
        for(int i = 0; i < a; ++i){
            x *= n-i;
            y *= i+1;
        }
        return x / y;
    }
    friend istream& operator>>(istream& is, mint& m){
        is >> m.x;
        return is;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

int n,k;
mint fanc[100010],ans;
vector<int>to[100010];

void dfs(int v, int p=-1, int d=0){
    if(to[v].size()==1&&d>0)return;
    if(d==0){
        if(k-1<to[v].size()){
            cout<<0<<endl;
            exit(0);
        }
        ans*=fanc[k-1]/fanc[k-1-to[v].size()];
        for(int u:to[v]){
            dfs(u,v,d+1);
        }
    }
    if(d>=1){
        if(k-2<(to[v].size()-1)){
            cout<<0<<endl;
            exit(0);
        }
        ans*=fanc[k-2]/fanc[k-2-(to[v].size()-1)];
        for(int u:to[v]){
            if(u==p)continue;
            dfs(u,v,d+1);
        }
    }
}

int main(){
    cin>>n>>k;
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    fanc[0]=1;
    for(int i=1; i<100010; ++i){
        fanc[i]=fanc[i-1]*i;
    }
    ans=k;
    dfs(0);
    cout<<ans<<endl;
}

Measured memory_bytes: 13288
#include<bits/stdc++.h>
using namespace std;
char a[16], b[16] = {'C', 'O', 'D', 'E', 'F', 'E', 'S', 'T', 'I', 'V', 'A', 'L', '2', '0', '1', '6'};
int ans;
int main()
{
    cin>>a;
    for(int i = 0; i < 16; i ++)
	{
        if(a[i] != b[i]) ans ++;
    }
    cout << ans << endl;
    return 0;
}

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

int N;

int sum_n(int n){
    int sum=0;
    while(n != 0){
      sum += n%10;
      n = n/10;
    }
    return sum;
}

int main() {
    cin >> N;
    string ans = "No";
    if(N%sum_n(N) == 0) ans = "Yes";

    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi(i,a,b) for(int i=a;i<=b;i++)
#define fid(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define pii pair<int,int>
#define TTT "Frog1"
#define maxn 100005
using namespace std;
int n, f[maxn], h[maxn];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen(TTT".inp", "r", stdin);
    freopen(TTT".out", "w", stdout);
    #endif // ONLINE_JUDGE
    cin >> n;
    fi(i, 1, n) cin >> h[i];
    f[0] = 1e9;
    f[1] = 0;
    fi(i, 2, n)
        f[i] = min(f[i - 1] + abs(h[i] - h[i - 1]), f[i - 2] + abs(h[i] - h[i - 2]));
    cout << f[n];
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int V[] = {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 K;
  cin >> K;
  --K;
  cout << V[K] << endl;
}




Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
num = 10**9+7
nots = [int(input()) for i in range(m)]
dp = [-1]*(n+1)
dp[0] = 1

for i in nots:
  dp[i] = 0

if dp[1] == -1:
  dp[1] = 1

if n == 1:
  print(1)
  exit()

for i in range(2,n+1):
  if dp[i] == -1:
    dp[i] = (dp[i-1] + dp[i-2]) % num
    
print(dp[n] % num)

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

using namespace std;

typedef long long ll;

const ll M = 50 * 50 + 1;

ll dp[M][M+M];

int main(){
    dp[0][M] = 1;
    int n, a;
    cin >> n >> a;
    vector<int> x(n);
    for (int i = 0; i < n; ++i) {
        int y;
        cin >> y;
        x[i] = y - a;
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < M + M; ++j) {
            dp[i+1][j] = dp[i][j];
            if (j - x[i] >= 0) dp[i+1][j] += dp[i][j-x[i]];
        }
    }

    cout << dp[n][M] - 1 << endl;
}

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

int main(){

    ll n,a,b;
    cin >> n >> a >> b;

    ll ans = a*(n/(a+b)) + min(a,n%(a+b));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;

int main() {
  ll Q,H,S,D,N; cin >> Q >> H >> S >> D >> N;
  ll L1 = min(Q*4,min(H*2,S));
  ll L2 = min(Q*8,min(H*4,min(S*2,D)));
  ll ans;
  if ( N % 2 == 0 ) {
    ans = (N/2)*L2;
  } else {
    ans = (N/2)*L2;
    ans += L1;
  }

  cout << ans << endl;
  return 0;
}


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

const int WH = 4900;

char board[WH];
string dp[WH];

bool comp(const string& a, const string& b){
	if(a.length() == b.length()){
		return a < b;
	}
	return a.length() < b.length();
}

int main(){
	int w, h, m;
	string r;
	while(cin >> w >> h, w){
		r = "";
		for(int i = 0;i < w * h;++i){
			cin >> board[i];
		}
		for(int i = 0;i < h;++i){
			for(int j = 0;j < w;++j){
				dp[i * w + j] = "";
				if(i - 1 >= 0 && dp[(i - 1) * w + j] != ""){
					dp[i * w + j] = dp[(i - 1) * w + j];
				}
				if(j - 1 >= 0 && dp[i * w + (j - 1)] != ""){
					dp[i * w + j] = max(dp[i * w + j], dp[i * w + (j - 1)], comp);
				}
				
				if('0' <= board[i * w + j] && board[i * w + j] <= '9'){
					if(dp[i * w + j] != "" || board[i * w + j] != '0'){
						dp[i * w + j] += board[i * w + j];
					}
				}
				else dp[i * w + j] = "";

				r = max(r, dp[i * w + j], comp);
			}
		}
		cout << r << endl;
	}
	return 0;
}

Measured memory_bytes: 1380
#include <iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
const ll MOD = 1000000007;

    ll N,C,M,K,temp,ans=0;
    ll Q,query[100010][3];
    vector<ll> T;
    bool fir=true,go=false;
    vector<int> g[100010];
    int flag[100010];
    int a[100010]={0};

void  dfs(int v,int dis,int color){
    if(flag[v]>=dis||dis<0)return;
    if(!a[v])a[v]=color;

    flag[v]=dis;
    for(auto x:g[v]){
            dfs(x,dis-1,color);
    }

}


int main() {
    ios_base::sync_with_stdio(false);
    for(int i = 0; i < 100010; i++) flag[i] = -10;
    cin>>N>>M;
    REP(i,M){
        cin>>C>>K;
        g[C].push_back(K);
        g[K].push_back(C);
    }
    cin>>Q;
    REP(i,Q){
        cin>>query[i][0]>>query[i][1]>>query[i][2];
    }
    for(int i=Q-1;i>=0;i--){
        dfs(query[i][0],query[i][1],query[i][2]);
    }
    EREP(i,N){
        cout<<a[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 9592
#include <bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define PB push_back

using namespace std;

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

void solve(){
	map<int,int> m;
	int a, b, c;
	cin >> a >> b >> c;
	m[a]++; m[b]++; m[c]++;
	if(m[a] == 2 || m[b] == 2 || m[c] == 2){
		if(m[a] == 1 || m[b] == 1 || m[c] == 1){
			cout << "Yes\n";
			return;
		}
	}
	cout << "No\n";
}

int main(){
	/*
	int t;
	cin >> t;
	while(t--)
		solve();
	*/
	
	solve();
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()	{
  int w, a, b;
  cin >> w >> a >> b;
  if (a < b)	{
    int temp = b - a - w;
    if (temp > 0) cout << temp << endl;
    else cout << 0 << endl;
  }
  else if (b < a)	{
    int temp = a - b - w;
    if (temp > 0) cout << temp << endl;
    else cout << 0 << endl;
  }
  else	{
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 3568
n,m=map(int,input().split())
py1=[]
for i in range(m):
    py1.append(list(map(int,input().split()))+[i+1])
py=sorted(py1)

number_list=[]
number_list.append([str(0)]*(6-(len(list(str(py[0][0])))))+list(str(py[0][0]))+[str(0)]*(6-(len(list(str(1)))))+list(str(1))+[str(py[0][-1])])
k=2
for j in range(1,m):
    if py[j][0]==py[j-1][0]:
        number_list.append([str(0)]*(6-(len(list(str(py[j][0])))))+list(str(py[j][0]))+[str(0)]*(6-(len(list(str(k)))))+list(str(k))+[str((py[j][-1]))])    
        k+=1
    else:
        k=1
        number_list.append([str(0)]*(6-(len(list(str(py[j][0])))))+list(str(py[j][0]))+[str(0)]*(6-(len(list(str(k)))))+list(str(k))+[str(py[j][-1])])
        k+=1
     
number_list_sort=sorted(number_list,key=lambda x:int(x[-1]))
for l in range(m):
    print(''.join(number_list_sort[l][:-1]))

Measured memory_bytes: 163700
#include <stdio.h>

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

Measured memory_bytes: 128
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


int main(int argc, char* argv[])
{
    int a,b,c,d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    if(d==b+1) {
        printf("0\n");
    }
    else {
        printf("1\n");
    }


    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
#define _rep(i, a, b) for (ll i = (a); i <= (b); ++i)
#define _rev(i, a, b) for (ll i = (a); i >= (b); --i)
#define _for(i, a, b) for (ll i = (a); i < (b); ++i)
#define _rof(i, a, b) for (ll i = (a); i > (b); --i)
#define oo 1e18
#define ll long long
#define db long double
#define eps 1e-9
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
#define pi acos(-1.0)
#define endl "\n"
#define lowbit(x) x &(-x)
const ll mod = 998244353;
const ll maxn = 1e5 + 10;
ll x, y;
vector<int> q, p, r;
signed main()
{
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    q.resize(a);
    p.resize(b);
    r.resize(c);
    _for(i, 0, a) cin >> q[i];
    _for(j, 0, b) cin >> p[j];
    _for(i, 0, c) cin >> r[i];
    sort(all(q), greater<int>());
    sort(all(p), greater<int>());
    sort(all(r), greater<int>());
    ll res = 0;

    priority_queue<int, vector<int>, greater<int>> aa, bb;
    _for(i, 0, x) {
        aa.push(q[i]);
    }
    _for(i, 0, y) {
        bb.push(p[i]);
    }
    int cc = 0;
    while (1) {
        int ta = aa.top();
        int tb = bb.top();
        if (cc >= c)break;
        if (min(ta, tb) < r[cc]) {
            if (ta < tb) {
                aa.pop();
                aa.push(r[cc++]);
            }
            else {
                bb.pop();
                bb.push(r[cc++]);
            }
        }
        else break;
    }
    while (!aa.empty()) {
        res += aa.top();
        aa.pop();
    }
    while (!bb.empty()) {
        res += bb.top();
        bb.pop();
    }
    cout << res << endl;
}

Measured memory_bytes: 2552
import math

N = int(input())

A = math.floor(N**0.5)
B = math.ceil(N**0.5)

while True:
    if N % A == 0:
        B = N // A
        break
    elif N % B == 0:
        A = N // B
        break
    else:
        A -= 1
        B += 1

print(A + B - 2)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
 
#define 	pi 				3.14159265358979
#define 	mod 			1000000007
#define 	ll  			long long int
#define 	rep(i, a, b) 	for(ll i = a ; i < b ; i++)
#define     repn(i, a, b)   for(ll i = a ; i > b ; i--)
#define 	mod1 			1000003
#define     mod2            998244353
#define     inf             2e18
#define 	hi   			"hello"
#define 	nl 				"\n"
#define 	ws 				" "
#define     sz              size()
#define     len             length()
#define 	F 				first
#define 	S 				second
#define 	pb				push_back
#define 	MP				make_pair
#define 	B 				begin()
#define     RB              rbegin()
#define 	E 				end()
#define     UB              upper_bound
#define     LB              lower_bound
#define     present(k, m)   (m.find(k)!=m.end())?1:0
#define 	all(v) 			v.begin(), v.end()
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define     pll             pair<ll, ll>
#define     vll             vector<ll>
#define     vpll            vector<pll>
#define 	vs 				vector<string>
#define     vc              vector<char>
#define     sqr(a)          ((a)*(a))
#define 	print1(a) 		for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	print2(a) 		for(auto i : a)cout<<i;cout<<"\n"
#define 	print3(a) 		for(auto i : a)cout<<i<<nl;
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

// ostringstream str1;
// str1 << n;
// string tmp = str1.str();
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }
 
bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }
 
double logn(double n, double r) { return (n > r - 1) ? 1 + logn(n / r, r) : 0; }
 
// vll pwx(32);
// void cal(ll x){ pwx[0] = 1; rep(i, 1, 32)pwx[i] = x*pwx[i-1]; }
 
/* ################################################################ */

#define space 200005

void solve(){
    ll n;
    cin >>n;
    if(n >= 30){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}

int main(){
    boost;
    // cal(3);

    // // For getting input from input.txt file 
    // freopen("input.txt", "r", stdin); 
  
    // // Printing the Output to output.txt file 
    // freopen("output.txt", "w", stdout);


    int t = 1, k = 1;
    // cin>>t;
    while(t--){
        // cout<<"Case #"<<k<<": ";
        solve();
        k++;
    }
}


Measured memory_bytes: 3664
use proconio::{fastout, input};
use std::collections::VecDeque;

#[derive(Debug, Clone, Default)]
struct Cell {
    wait: usize,
    cost: usize,
    neighbors: Vec<usize>,
}

#[fastout]
fn main() {
    input! {in_n: usize, in_ps: [usize; in_n * in_n]};

    let width = in_n + 2;
    let height = in_n + 2;
    let mut cells = Vec::new();

    for i in 0..(width * height) {
        let x = i % width;
        let y = i / width;
        let mut cell = Cell::default();

        if 0 < x && x < width - 1 && 0 < y && y < height - 1 {
            cell.wait = 1;
            cell.cost = *[x, width - x - 1, y, height - y - 1].iter().min().unwrap();
            cell.neighbors.push(i + 1);
            cell.neighbors.push(i - 1);
            cell.neighbors.push(i + width);
            cell.neighbors.push(i - width);
        }

        cells.push(cell);
    }

    let mut cost = 0;

    for in_p in in_ps {
        let x = (in_p - 1) % in_n + 1;
        let y = (in_p - 1) / in_n + 1;
        let i = x + y * width;

        cells[i].cost -= 1;
        cells[i].wait = 0;
        cost += cells[i].cost;

        let mut queue = VecDeque::new();

        queue.push_front(i);

        while !queue.is_empty() {
            let i = queue.pop_back().unwrap();

            for n in cells[i].neighbors.clone().iter() {
                let c = cells[i].cost + cells[*n].wait;

                if cells[*n].cost > c {
                    cells[*n].cost = c;
                    queue.push_front(*n);
                }
            }
        }
    }

    println!("{}", cost);
}


Measured memory_bytes: 27092
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	public static void main(String[] args) {
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		

		int ans=Math.max(a*10+b+c, Math.max(a+b*10+c,a+b+c*10));
		p(ans);
		
	}
	
	
	
	
	/*static boolean v(int i,long sum1,long sum2) {
		if(i==N) {
			long b=Math.abs(sum1-sum2);
			if(b==0) {
				if(sum1<=K) {
					return true;
				}else return false;
			}else if(b%D==0) {
				if(Math.max(sum1, sum2)<=K)return true;
				else return false;
			}
			else return false;
		}
		
		if(v(i+1,sum1,sum2+v[i]%D))return true;
		
		if(v(i+1,sum1+D-v[i]%D,sum2))return true;
		return false;
		
	}*/
	
	
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 22868
#include <stdio.h>

int main(void) {
    int X[11] = {0};
    int r, D, x_2000;

    scanf("%d %d %d", &r, &D, &x_2000);

    X[0] = x_2000;

    for (int i = 0; i < 10; ++i) {
        X[i + 1] = r * X[i] - D;
    }

    for (int j = 0; j < 10; ++j) {
        printf("%d\n", X[j + 1]);
    }

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
const int MOD = 1000000007;
using mint = Fp<MOD>;
const int MAX=400000;
mint fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i;
        inv[i] = (mint)MOD - inv[MOD%i] * (MOD / i);
        finv[i] = finv[i - 1] * inv[i];
    }
}

mint COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[k] * finv[n - k];
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    mint ans=1;
    int n;
    cin>>n;
    vec x(n);
    rep(i,n) cin>>x[i];
    rep(i,n) x[i]=2*i+1-x[i];
    ll now=0,a=0,b=0;
    while(a<n||b>0){
        while(x[a]<=now&&a<n) a++,b++;
        if(a<n) a++,b++;
        ans*=b;
        b--;
        now+=2;
    }
    cout<<ans;
}


Measured memory_bytes: 3968
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdlib>

using namespace std;

long long a[1000000];
long long n;

long long count(long long sum)	{
  long long changes = 0;
  for (int i = 1; i < n; i++)	{
    if (sum > 0)	{
      sum += a[i];
      if (sum >= 0)	{
        changes += abs(sum) + 1;
        sum = -1;
      }
    }
    else	{
      sum += a[i];
      if (sum <= 0)	{
        changes += abs(sum) + 1;
        sum = 1;
      }
    } 
  }
  return changes;
}



int main()	{
  cin >> n;
  long long sum = 0;
  long long changes = 1e18;
  for (int i = 0; i < n; i++)	{
    cin >> a[i];
  }
  if (a[0] == 0)	{
    changes = min(changes, count(-1) + 1);
    changes = min(changes, count(1) + 1);
  }
  else	{
    changes = min(changes, count(a[0]));
    if (a[0] > 0)	{
      changes = min(changes, count(-1) + abs(a[0]) + 1);
    }
    else	{
      changes = min(changes, count(1) + abs(a[0]) + 1);
    }
  }
  cout << changes << endl;
  return 0;
}

Measured memory_bytes: 4364
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};
    static long mod=1000000007;
    
    public static void main(String[] args) {        
        new Thread(null, new Main(), "", 200 * 1024 * 1024).start();        
    }

    public void run() {
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        
//        int n=sc.nextInt();
        int a=sc.nextInt(), b=sc.nextInt(), c=sc.nextInt(), d=sc.nextInt(), k=sc.nextInt();
        int x=a*60+b,y=60*c+d;
        out.println(y-x-k);
     	out.flush();
    }
    
    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }

    static void ret(long ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x,c;long s;
//	P(int  x, int c, long s) {
//	  this.x=x;
//	  this.c=c;
//	  this.s=s;
//	}
//}


class P implements Comparable<P>{
	int x,c;long s;
	P(int  x, int c, long s) {
	  this.x=x;
	  this.c=c;
	  this.s=s;
	}

    public int compareTo(P p){
        return Long.signum(s-p.s);
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString()
    {
        while( st==null || !st.hasMoreTokens() )
			try {
				st = new StringTokenizer(x.readLine());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        return st.nextToken();
    }
    public int nextInt()
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) {
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) {
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() {
        return this.nextString().toCharArray();
    }    
    public long nextLong()
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 33036
#include<bits/stdc++.h>
using namespace std;
int n,k;
string s;
int main()
{
	cin>>n>>s>>k;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!=s[k-1])
		{
			s[i]='*';
		}
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    Long N=scanner.nextLong();
    Long K=scanner.nextLong();
    

    if (K==1){
        System.out.println(0);
    }else if(K>N*2){
        System.out.println(N);
    }else{
        N=(N>K)?N%K:K%N;
        do{
            N=Math.abs(N-K);
        }while(N>Math.abs(N-K));
        /*while(N>Math.abs(N-K)){
            N=Math.abs(N-K);
            
        }*/
        System.out.println(N);
    }
  }

}

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

int main() {
  int n;
  cin>>n;
  bool ans=false;
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      int b;
      if(i*j==n)ans=true;
    }
  }
  if(ans)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N,T,ans;
  cin>>N>>T;
  vi A(N),MAX(N);
  rep(i,0,N) cin>>A[i];
  rep(i,1,N){
    int K=N-1-i;
    MAX[K]=max(MAX[K+1],A[K+1]);
  }
  map<int,int> X;
  rep(i,0,N-1){
    int R=MAX[i]-A[i];
    if(X.count(R))
      X.at(R)++;
    else
      X[R]=1;
    }
  for(auto a:X)
    ans=a.second;
  cout<<ans<<endl;
  }



Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
//const int MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const double pi = acos(-1.0);
const double EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

struct Union_Find_Tree{
    vector<int> par, rank, num;
    const int n;
    
    Union_Find_Tree(int n) : n(n){
        par.assign(n, -1), rank.assign(n, 0), num.assign(n, 1);
    }
    
    int root(int x){
        if(par[x] < 0 || par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    
    bool unite(int x, int y){
        x = root(x), y = root(y);
        if(x == y) return false;
        if(rank[x] < rank[y]) swap(x, y);
        if(rank[x] == rank[y]) rank[x]++;
        par[y] = x, num[x] += num[y];
        return true;
    }
    
    int size(int x) {return num[root(x)];}
    
    bool same(int x, int y) {return root(x) == root(y);}
    
    void clear(){
        fill(all(par), -1), fill(all(rank), 0), fill(all(num), 1);
    }
};

int main(){
    int N, Q;
    cin >> N >> Q;
    Union_Find_Tree uf(N);
    while(Q--){
        int q, u, v; cin >> q >> u >> v;
        if(q == 0) uf.unite(u, v);
        else cout << uf.same(u, v) << endl;
    }
}

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

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

vector< int > tree[SIZE];
vector< int > cost;
int ans[SIZE];

int bfs( P ncnt[] );

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    ++n;
    P ncnt[n];
    for( int i = 0; i <= n; ++i ) {
        ncnt[i].F = 0;
        ncnt[i].S = i;
        ans[i] = INF;

    }
    --n;

    for( int i = 0; i < n - 1; ++i ) {
        int a, b;
        cin >> a >> b;
        tree[a].pb( b );
        tree[b].pb( a );
        ncnt[a].F++;
        ncnt[b].F++;

    }
    sort( ncnt, ncnt + n + 1, greater<>() );

    for( int i = 0; i < n; ++i ) {
        int c;
        cin >> c;
        cost.pb( c );

    }
    sort( cost.begin(), cost.end() );

    cout << bfs( ncnt ) << endl;

    cout << ans[1];
    for( int i = 2; i <= n; ++i ) cout << " " << ans[i];
    cout << endl;

    return 0;
}

int bfs( P ncnt[] ) {
    queue< int > q;
    int res = 0;
    q.push( ncnt[0].S );
    ans[ncnt[0].S] = cost[cost.size() - 1];
    cost.pop_back();

    while( !q.empty() ) {
        int p = q.front(); q.pop();
        
        for( int i = 0; i < tree[p].size(); ++i ) {
            if( ans[tree[p][i]] == INF ) {
                ans[tree[p][i]] = cost[cost.size() - 1];
                res += min( ans[p], ans[tree[p][i]] );
                cost.pop_back();
                q.push( tree[p][i] );

            }
        }
    }
    return res;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define rep2(i,b) for(ll i=0;i<b;i++)
#define repl(i,a,b) for(ll i=a;i<=b;i++)
#define FastRead ios_base::sync_with_stdio(0);cin.tie(0)
int main()
{
    int n;
    cin>>n;
    vector<int>v;
    rep2(i,n)
    {
        int x;
        cin>>x;
        x--;
        v.pb(x);
    }
    int now=0,c=0;
    bool cnt=1;
    while(1)
    {
        if(now==1) break;
        else if (c>=n)
        {
            cnt=0;
            break;
        }
        else
        {
            now=v[now];
            c++;
        }
    }
    if(cnt)
        cout<<c<<endl;
    else cout<<"-1"<<endl;
    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
typedef vector<int> vi;
//const int MAX=;

int main(){
	lli K,A,B;
	cin>>K>>A>>B;
	if(B-A<=2){
		cout<<K+1;
		return 0;
	}
	if(K<=A-1){
		cout<<1+K;
		return 0;
	}
	K-=(A-1);
	lli x=K/2;
	lli y=K%2;
	cout<<A+x*(B-A)+y;
	
}

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

using namespace std;

int main()
{
	int alpha[26] = {0};
	char str[27];
	
	cin >> str;
	
	for (int i = 0; i < (int)strlen(str); i++) {
		if (alpha[str[i] - 'a'] > 0) {
			cout << "no" << endl;
			return (0);
		}
		alpha[str[i] - 'a']++;
	}
	
	cout << "yes" << endl;
	
	return (0);
}

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


int main() {
	string ATCG;

	cin >> ATCG;

	long long max = 0;
	long long count = 0;

	for (int i = 0; i < ATCG.size(); i++) {
		if ((ATCG[i] == 'A') || (ATCG[i] == 'T') || (ATCG[i] == 'C') || (ATCG[i] == 'G')) {
			count += 1;
		}
		else {
			count = 0;
		}
		if (max < count) {
			max = count;
		}
	}
	cout << max << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
int main(){
	string a;
	int l,r;
	cin>>a;
	for(int i=0;i<a.length();++i){
		if(a[i]=='A'){
			l=i;
			break;
		}
	}
	for(int i=a.length()-1;i>=0;--i){
		if(a[i]=='Z'){
			r=i;
			break;
		}
	}
	cout<<r-l+1;
}

Measured memory_bytes: 640
arr = "AIDUNYAN".split("")
h = Hash.new{|h, k| h[k] = []}
arr.permutation(8){|arr2| h[arr2[0] + arr2[1]] << arr2[2] + arr2[3] + arr2[4] + arr2[5] + arr2[6] + arr2[7]}
h.values.each{|arr2| arr2.uniq!}
str = "AIZUNYAN"
d = gets.chomp
i = 0
while i <= d.length - 8
    if h[d[i, 2]].include? d[i + 2, 6]
        d[i, 8] = str
        i += 8
    else
        i += 1
    end
end
puts d


Measured memory_bytes: 10704
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Solve(int A, int B)
        {
            return (A - 1) * (B - 1);
        }
        static void Main(string[] args)
        {
            int[] V = ReadInts();
            Console.WriteLine(Solve(V[0], V[1]));
        }
    }
}


Measured memory_bytes: 11092
S = input()

y = int(S[:4])
m = int(S[5:7])
d = int(S[8:])

flag = True
if y < 2019:
    flag = False
if y == 2019 and m < 5:
    flag = False

if flag:
    print('TBD')
else:
    print('Heisei')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)

using namespace std;
typedef long long ll;
using Graph =vector<int>;
typedef pair<int,int> P;
const ll MAX_N=131072;
vector<int> G[1000010];
int main(){
  int N,Q;cin>>N>>Q;
  vector<ll> a(N);
  rep(i,N) cin>>a[i];
  rep(i,Q){
    ll x;cin >>x;
    ll res=0;
    int right=0;
    ll sum=0;
    for(int left=0;left<N;++left){
      while(right<N &&sum+a[right]<=x){
        sum+=a[right];
        ++right;
      }
      res+=(right-left);
      if (right==left)++right;
      else sum-=a[left];
    }
  cout<<res<<endl;
  }
}



Measured memory_bytes: 27028
#include <iostream>
#include <algorithm>

#define MAX 100000

using namespace std;

int p[MAX];

int main() {

    int N,C,K;
    int b=0;
    cin>>N>>C>>K;
    for(int i=0;i<N;i++) {
        cin>>p[i];
    }
    sort(p,p+N,less<int>());
    int end,cap;
    for(int i=0;i<N;) {
        end=p[i]+K;
        cap=1;
        b++;
        while (i<N && cap <= C && p[i] <= end ) {
            cap++;
            i++;
        }
    }
    cout<<b<<endl;
    
    return 0;
}


Measured memory_bytes: 640