akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(100000)

def dfs(v, tm):
    dts[v] = est[v] = tm + 1
    child = 0

    for i in adj[v]:
        if est[i] == float('inf'):
            child += 1
            parents[i] = v
            dfs(i, tm + 1)
            est[v] = min(est[v], est[i])

            if est[i] > dts[v]: 
                bridges.append((v, i)) if v < i else bridges.append((i, v))

        elif parents[v] != i:
            est[v] = min(est[v], dts[i])

nv, ne = map(int, input().split(' '))
adj = [[] for _ in range(nv)]
est = [float('inf')] * nv
parents = [None] * nv
dts = [0] * nv
bridges = []

for _ in range(ne):
    s, t = map(int, input().split(' '))
    adj[s].append(t)
    adj[t].append(s)

dfs(0, 0)
bridges.sort(key=lambda tup: (tup[0], tup[1]))
[print(str(bridge[0]) + ' ' + str(bridge[1])) for bridge in bridges]

Measured memory_bytes: 20344
gets.to_i.times{
	array=gets.chomp.split("0").map{|e|e.to_i}
	array.delete 0
	strInfo=[]

	array.length.times{|t|
		strInfo.push [array[t].to_s[0].to_i,array[t].to_s.length]
	}

	str=""
	strInfo.each{|e|
		if e[0]==1
			str.concat "." if e[1]%5==1
			str.concat "," if e[1]%5==2
			str.concat "!" if e[1]%5==3
			str.concat "?" if e[1]%5==4
			str.concat " " if e[1]%5==0
		elsif e[0]==2
			str.concat "a" if e[1]%3==1
			str.concat "b" if e[1]%3==2
			str.concat "c" if e[1]%3==0
		elsif e[0]==3
			str.concat "d" if e[1]%3==1
			str.concat "e" if e[1]%3==2
			str.concat "f" if e[1]%3==0
		elsif e[0]==4
			str.concat "g" if e[1]%3==1
			str.concat "h" if e[1]%3==2
			str.concat "i" if e[1]%3==0
		elsif e[0]==5
			str.concat "j" if e[1]%3==1
			str.concat "k" if e[1]%3==2
			str.concat "l" if e[1]%3==0
		elsif e[0]==6
			str.concat "m" if e[1]%3==1
			str.concat "n" if e[1]%3==2
			str.concat "o" if e[1]%3==0
		elsif e[0]==7
			str.concat "p" if e[1]%4==1
			str.concat "q" if e[1]%4==2
			str.concat "r" if e[1]%4==3
			str.concat "s" if e[1]%4==0
		elsif e[0]==8
			str.concat "t" if e[1]%3==1
			str.concat "u" if e[1]%3==2
			str.concat "v" if e[1]%3==0
		elsif e[0]==9
			str.concat "w" if e[1]%4==1
			str.concat "x" if e[1]%4==2
			str.concat "y" if e[1]%4==3
			str.concat "z" if e[1]%4==0
		end





	}

	puts str
}

Measured memory_bytes: 6164
#include <iostream>
#include <utility>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cctype>
#include <map>
// #include <bits/stdc++.h>
#define PI 3.141592653589793238
typedef unsigned long long ull;
typedef unsigned long ul;
typedef long long ll;
//typedef pair<ul, ul> P;
//typedef pair<P, ul> P2;
//typedef pair<P2, ul> P3;
using namespace std;

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	int x,a = 0,z;
	cin >> x;
	z = x;
	while (x > 0) {
		a += x % 10;
		x /= 10;
	}
	if (z%a) {
		cout << "No" << "\n";
	}
	else {
		cout << "Yes" << "\n";
	}

	return 0;
}

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

int main(){

	int a, n, q, v, h;
	int w[1000001] = {0};
	
	cin >> n >> q;
	
	h = 0;
	for(int i=0; i<q; i++){
		cin >> a >> v;
		w[a] += v;
		if(a == h && v < 0){
			h = 0;
			for(int j=0; j<=n; j++){
				if(w[h] <= w[j]){
					if(w[h] != w[j] || h > j){
						h = j;
					}
				}
			}
		}
		else{
			if(w[h] <= w[a]){
				if(w[h] != w[a] || h > a){
					h = a;
				}
			}
		}
		
		cout << h << " " << w[h] << endl;
	}

	return 0;

}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end()))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int H, W, K;
string c[110000];
vvint dp;
signed main() {
    int x1, y1, x2, y2;
    cin >> H >> W >> K;
    cin >> y1 >> x1 >> y2 >> x2;
    x1--, y1--, x2--, y2--;
    rep(i, H) { cin >> c[i]; }
    dp.resize(H);
    fill(all(dp), vint(W));
    rep(i, H)rep(j, W) { dp[i][j] = LLONG_MAX; }
    dp[y1][x1] = 0;
    queue<pint> q;
    q.push({y1, x1});
    while (!q.empty()) {
        pint cur = q.front();
        int yc = cur.first, xc = cur.second;
        q.pop();
        rep(i, 4) {
            reps(j, K) {
                int yn = yc + DY[i] * j, xn = xc + DX[i] * j;
                if (yn < 0 || yn >= H || xn < 0 || xn >= W || c[yn][xn] == '@' || dp[yn][xn] <= dp[yc][xc]) {
                    break;
                }
                if(dp[yn][xn]==LLONG_MAX)q.push({yn, xn});
                chmin(dp[yn][xn], dp[yc][xc] + 1);
            }
        }
    }
    if (dp[y2][x2] != LLONG_MAX) { cout << dp[y2][x2] << endl; }
    else { cout << -1 << endl; }

}


Measured memory_bytes: 23508
#include <stdio.h>
#include <string.h>

int main() {
  int N;
  char Ws[100][11];

  int i, j;

  scanf("%d", &N);
  scanf("%s", Ws[0]);

  for (i = 1; i < N; i++) {
    scanf("%s", Ws[i]);
    if (Ws[i - 1][strlen(Ws[i - 1]) - 1] != Ws[i][0]) {
      printf("No\n");
      return 0;
    } else {
      for (j = 0; j < i; j++) {
        if (strcmp(Ws[i], Ws[j]) == 0) {
          printf("No\n");
          return 0;
        }
      }
    }
  }

  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 128
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    s = input()
    if len(set(s)) == 2 and s.count(list(set(s))[0]) == 2 and s.count(list(set(s))[1]) == 2:
        print('Yes')
    else:
        print('No')
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 8932
# -*- coding: utf-8 -*-
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, A, B, C, D = map(int, input().split())


def check(m):
    return C*(N-1-m)-D*m <= B-A <= -C*m+(N-1-m)*D


for m in range(N):
    if check(m):
        print("YES")
        break
else:
    print("NO")


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

int main(){
  string s,t;
  cin >> s;
  cin >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end(),greater<char>());
  if(s<t) cout << "Yes" <<endl;
  else cout <<"No" << endl;
  return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 1000000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
int n,k,ans;
signed main(){
	double d,t,s;
	cin>>d>>t>>s;
	if(d/s>t)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}


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

int main(){
  int n, k, q, a;
  cin >> n >> k >> q;
  vector<int> vn(n,0);
  for(int i=0; i<q; ++i){
    cin >> a;
    --a;
    ++vn[a];
  }
  for(int i=0; i<n; ++i){
    if(k-q+vn[i] > 0) printf("Yes\n");
    else printf("No\n");
  }
}

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

using namespace std;

int main() {
    
    int num;
    int *arr;

    cin >> num;
    arr = new int[num];
    for(int i = 0; i < num; i++)
        cin >> arr[i];
        
    for(int k = 0; k < num; k++) {
            if(k > 0)
                cout << " ";
            cout << arr[k];
    }
    cout << endl;

    for(int i = 1, j = i - 1; i < num; i++) {
        while(j >= 0 && arr[j] > arr[j+1]) {
            swap(arr[j], arr[j+1]);
            j--;
        }
        
        j = i;
        for(int k = 0; k < num; k++) {
            if(k > 0)
                cout << " ";
            cout << arr[k];
        }
        cout << endl;
    }

    delete [] arr;
    
    return 0;
}


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

using namespace std;

int h, w;
int n;

int main() {
    cin >> h;
    cin >> w;
    cin >> n;
    int a[n];
    int seq[h * w];
    int si = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        for (int h = 0; h < a[i]; h++) {
            seq[si++] = i;
        }
    }
    int map[h][w];
    int i, j;
    si = 0;
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            map[i][j] = seq[si++];
        }
        if (i < h) {
            i++;
            for (--j; j >= 0; j--) {
                map[i][j] = seq[si++];
            }
        }
    }
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            printf("%d ", map[i][j]);
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 384
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

K, S = map(int, input().split())

cnt = 0
for x in range(K + 1):
    for y in range(K + 1):
        z = S - x - y
        if 0 <= z <= K:
            cnt += 1

print(cnt)

Measured memory_bytes: 40684
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  ll N;
  ci(N);
  ll a = 0;
  repi(i, 1, N + 1){
    if(i % 3 != 0 && i % 5 != 0){
      a += i;
    }
  }
  co(a);
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll a,b,c,k;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>a>>b>>c>>k;
    while(b<=a&&k>0)
    {
        k--;
        b*=2;
    }
    while(c<=b&&k>0)
    {
        k--;
        c*=2;
    }
    if(a<b&&b<c&&k>=0)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<pair<ll, int>> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i].first;
        A[i].second = i;
    }
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    vector<vector<ll>> dp(N+1, vector<ll>(N+1, 0));
    for (int i = 0; i < N; i++) {
        dp[0][i+1] = dp[0][i] + abs(N-1-i-A[i].second) * A[i].first;
        dp[i+1][0] = dp[i][0] + abs(A[i].second-i) * A[i].first;
        for (int j = 1; j <= i; j++) {
            dp[j][i+1-j] = max(dp[j-1][i+1-j] + abs(j-1-A[i].second) * A[i].first, dp[j][i-j] + abs(N-i-1+j - A[i].second) * A[i].first);
        }
    }
    ll ans = 0;
    for (int i = 0; i <= N; i++) ans = max(ans, dp[i][N-i]);
    cout << ans << endl;
    return 0;
}

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

const int N=2010;
int sump[N][N],sume1[N][N],sume2[N][N];
bool mp[N][N];

int main()
{
    static char s[N];
    int n,m,q;cin>>n>>m>>q;
    for(int i=1;i<=n;i++)
    {
        scanf("%s",s+1);
        for(int j=1;j<=m;j++)
            mp[i][j]=(s[j]=='1');
    }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        {
            sump[i][j]=sump[i-1][j]+sump[i][j-1]-sump[i-1][j-1]+mp[i][j];
            sume1[i][j]=sume1[i-1][j]+sume1[i][j-1]-sume1[i-1][j-1]+(mp[i][j]&&mp[i][j+1]);
            sume2[i][j]=sume2[i-1][j]+sume2[i][j-1]-sume2[i-1][j-1]+(mp[i][j]&&mp[i+1][j]);
        }
    while(q--)
    {
        int x1,y1,x2,y2;scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
        int n=sump[x2][y2]-sump[x1-1][y2]-sump[x2][y1-1]+sump[x1-1][y1-1];
        int m=sume1[x2][y2-1]-sume1[x2][y1-1]-sume1[x1-1][y2-1]+sume1[x1-1][y1-1];
        m+=sume2[x2-1][y2]-sume2[x2-1][y1-1]-sume2[x1-1][y2]+sume2[x1-1][y1-1];
        printf("%d\n",n-m);
    }
    return 0;
}

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

typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
#define SP << " " <<
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

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

    int N; cin >>N;
    int X = N/1.08;

    for (int i = min(1,X-100); i < X+100; i++) {
        int n = i * 1.08;
        if (n == N) {
            cout << i << endl;
            return 0;
        }
    }

    cout << ":(" << endl;
}


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

int sqr(int u){
    return u * u;
}
double dis(int x1, int y1, int x2, int y2){
    double r = sqrt(sqr(x1 - x2) + sqr(y1 - y2));
    return r;
}

int gt(int u){
    if (u == 0 || u == 1) return 1;
    return u * gt(u - 1);
}
int main(){
    int n, x[10], y[10];
    double r = 0;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> x[i] >> y[i];
    }
    for (int i = 0; i < n - 1; i++){
        for (int j = i + 1; j < n; j++){
            r += dis(x[i], y[i], x[j], y[j]) * (n - 1) * gt(n - 2);
        }
    }
    cout << setprecision(10) << fixed << 2 * r / gt(n);
}


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

int main(){
    int N;
        cin >> N;
    
    if((N%10)==3){
        cout << "bon";
    }
    else if((N%10)==0||(N%10)==1||(N%10)==6||(N%10)==8){
        cout << "pon";
    }
    else{
        cout << "hon";
    }
}

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define dbg(var) {std::cout << #var << "  = " << var << nl;}
#define vi vector<int>
typedef long long ll;

using namespace std;

vector<vi> mul(const vector<vi> & a , const vector<vi> & b){
	vector<vi> res(3 , vi(3 , 0));
	rep(i , 3){
		rep(j , 3){
			rep(k , 3){
				res[i][j] += a[i][k] * b[k][j];
			}
		}
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 
	
	vector<vi> A = {
		{ 0 , 1 , 1 },
		{ 1 , 0 , 1 },
		{ 1 , 1 , 0 }
	};
	/*
	auto e = mul(A , A);
	rep(i , 3){
		rep(j , 3){
			cout << e[i][j] << " ";
		}
		cout << nl;
	}*/
	
	ll a , b , c , k;
	cin >> a >> b >> c >> k;
	cout << (b - a) * (k & 1LL ? 1 : -1) << nl;
	

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

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

    int n;
    int64_t k;
    cin >> n >> k;

    vector<pair<int, int>> ab(n);
    for (int i = 0; i < n; i++) {
        cin >> ab[i].first >> ab[i].second;
    }

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

    int64_t m = 0;
    for (int i = 0; i < n; i++) {
        m += ab[i].second;
        if (m >= k) {
            cout << ab[i].first << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1010;
typedef long long llong;
vector<llong> d; 
int x[maxN], y[maxN];
int n;

int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
char C[] = {'L', 'R', 'D', 'U'};

bool valid(llong x, llong y, int k) {
	return abs(x) + abs(y) <= (1ll<<k) - 1;
}

string get(int pos, llong x, llong y) {
	if (pos == -1) return "";
	for (int i = 0; i < 4; ++i) {
		llong nx = x + dx[i] * d[pos];
		llong ny = y + dy[i] * d[pos];
		int f = (x+y&1) != (nx+ny&1);
		if (d[pos] == f or (f == 0 and d[pos] != 1))	
		if (valid(nx, ny, pos)) {
			return get(pos-1, nx, ny) + C[i^1];
		}
	}
}

int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> x[i] >> y[i];
	for (int i = 1; i < n; ++i) {
		if ((x[i] + y[i]&1) != (x[i+1] + y[i+1]&1)) {
			puts("-1");
			return 0;
		}
	}
	for (int t = 0; t <= 30; ++t) {
		d.push_back(1ll<<t);
	}
	if (((x[1] + y[1])&1) == 0) d.push_back(1);
	cout << d.size() << endl;
	for (int e : d) cout << e << " "; cout << endl;
	for (int i = 1; i <= n; ++i) {
		cout << get((int)d.size() - 1, x[i], y[i]) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
s = list(map(int, input()))

def show(s, i):
  str_ = str(s[0])
  for j in range(3):
    if ((i >> (2-j)) & 1):
      str_ += '+' + str(s[j+1])
    else:
      str_ += '-' + str(s[j+1])
  str_ += '=7'
  print(str_)

for i in range(2 ** 3):
  t = bin(i)
  sum = s[0]
  for j in range(3):
    if ((i >> (2-j)) & 1):
      sum += s[j+1]
    else:
      sum -= s[j+1]
    
    if sum == 7:
      show(s, i)
      exit()

Measured memory_bytes: 3064
<?php
while ($n = rtrim(fgets(STDIN))){ 

    $temp_colc = [];
    for ($i=0; $i < strlen($n); $i++) {
        $temp_colc[] = intval(substr($n, $i ,1));
        // $temp_colc = $n[$i] + $n[$i + 1];
        // print_r($temp_colc);
    }

    while(count($temp_colc) > 1){
        // 一時的な配列
        $temp_colc2 = [];
        for ($i=0; $i < count($temp_colc) - 1; $i++) { 
            $temp_num = ($temp_colc[$i] + $temp_colc[$i + 1]) % 10;
            $temp_colc2[] = $temp_num;
        }
    // 配列に動きをつける。
        $temp_colc = $temp_colc2;
        // print_r($temp_colc);
    }
    print $temp_colc[0];
    print PHP_EOL;
}


Measured memory_bytes: 9256
#include<iostream>
#include<string>
#include<list>

using namespace std;

int main() {
	string s;
	cin >> s;
	for (int i = 0;; i++) {
		s.pop_back();
		if (s.size() % 2 == 0) {
			if (s.substr(0, s.size() / 2) == s.substr(s.size() / 2)) {
				cout << s.size() << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{

	int i;
	int arr[6];
	for(i=1; i<6; i++)
	{
		cin>>arr[i];
	}
	for(i=1; i<6; i++)
	{
		if(arr[i]==0) cout<<i;
	}

	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <map>

using namespace std;
using int64 = long long;

int main () {
    int n;
    cin >> n;
    map<int,int> mp;
    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        mp[a]++;
    }

    int64 ans = 0;
    for (auto p : mp) {
        if (p.first < p.second) ans += p.second - p.first;
        if (p.first > p.second) ans += p.second;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4736
n,q=[int(x) for x in input().split()]
s=input()
ruiwa=[0]*n
for i in range(n-1):
    if s[i]+s[i+1]=="AC":
        ruiwa[i+1]=ruiwa[i]+1
    else:
        ruiwa[i+1]=ruiwa[i]
for _ in [0]*q:
    l,r=[int(x) for x in input().split()]
    print(ruiwa[r-1]- ruiwa[l-1])

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

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var h     = int.Parse(spl[0]);
        var w     = int.Parse(spl[1]);

        var tbl = new int[h][];

        for(int i=0; i<h; i++) {
            tbl[i] = new int[w];
            var s = input.ReadLine();
            for (int j = 0; j < w; j++)
                tbl[i][j] = s[j];
        }

        var yoko = new Box[h][];
        var tate = new Box[h][];
        for(int i=0; i<h; i++) {
            yoko[i] = new Box[w];
            tate[i] = new Box[w];
        }
        
        Box box;

        for(int i=0; i<h; i++) {
            box = new Box();

            for(int j=0; j<w; j++) {
                var cell = tbl[i][j];
                if (box.c == 0)
                    box = new Box();

                if(cell == '.') {
                    box.c += 1;
                } else {
                    box = new Box();
                }

                yoko[i][j] = box;
            }
        }
        
        for(int j=0; j<w; j++) {
            box = new Box();

            for(int i=0; i<h; i++) {
                var cell = tbl[i][j];
                if (box.c == 0)
                    box = new Box();

                if(cell == '.') {
                    box.c += 1;
                } else {
                    box = new Box();
                }

                tate[i][j] = box;
            }
        }

        var max = 0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                max = Math.Max(tate[i][j].c + yoko[i][j].c-1, max);
            }
        }

        return max;
    }

    class Box
    {
        public int c = 0;
    }
}


Measured memory_bytes: 288828
num2alpha = lambda c: chr(c+65)
alpha2num = lambda c: ord(c) - ord('A')
N = int(input())
S = input()
new_S = str()
for i in range(len(S)):
    new_S = new_S + num2alpha((int(alpha2num(S[i]))+N)%26)
print(new_S)


Measured memory_bytes: 40812
a, b, c, x, y = map(int, input().split())
# ABピザ二枚がA,B一枚づつより高いなら普通に買えばいい
if a + b < c * 2:
    print(a * x + b * y)
else:
    # A,Bの多いほうに合わせてABを買う
    MAX = max(x, y)
    MIN = min(x, y)
    isXMAX = False
    if MAX == x:
        isXMAX = True
    AllAB = MAX * c * 2
    # A,Bの少ないほうに合わせて残りは普通に買う
    DivAB = MIN * c * 2
    if isXMAX:
        DivAB += (x - y) * a
    else:
        DivAB += (y - x) * b
    print(min(AllAB, DivAB))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
int arr[100005],dp[100005];
signed main()
{
    IOS
    int n; cin>>n;
    for(int i=1;i<=n;i++) cin>>arr[i];
    dp[1] = 0;
    dp[2] = fabs(arr[2] - arr[1]);
    for(int i = 3;i <= n;i++)
    {
      dp[i] = min(dp[i-1] + fabs(arr[i] - arr[i-1]) , dp[i-2] + fabs(arr[i] - arr[i-2]));
    }
    cout<<dp[n]<<endl;
    return 0;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,m;
string s;
vll f;
// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	ll a,b,c,k;
	cin >> a >> b >> c >> k;
	while(a >= b && k) b*=2,k--;
	while(b >= c && k) c*=2,k--;
	if(a<b && b<c) cout<<"Yes\n";
	else cout<<"No\n"; 
}

int main() {
	fastio;randomINT;
	//cin>>t;
	while(T--) {
		MAIN();
	}
	return 0;
}


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

ll ceil(ll a, ll b) {
    if (b < 0) {
        a *= -1;
        b *= -1;
    }
    if (a >= 0) {
        return (a + b - 1) / b;
    } else {
        return a / b;
    }
}

int main() {
    string S;
    cin >> S;
    int N = S.length();

    vector<int> ans(N, 0);
    for (int r = 0; r < N; r++) {
        if (S[r] == 'L')
            continue;

        int l = r;
        while (S[l] == 'R') {
            l++;
        }
        int a = l - 1;
        int b = l;
        while (l + 1 < N && S[l + 1] == 'L') {
            l++;
        }

        ans[a] += ceil(a - r + 1, 2);
        ans[b] += (a - r + 1) / 2;
        ans[b] += ceil(l - b + 1, 2);
        ans[a] += (l - b + 1) / 2;

        r = l;
    }

    for (int a : ans) {
        cout << a << " ";
    }
    cout << endl;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
    LL q,h,s,d,n;
    cin >> q >> h >> s >> d >> n;
    LL l = min(q*4,min(h*2,s));
    cout << min(n*l,n/2*d + (n % 2 == 1 ? l : 0)) << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    s = [list(input().split()) for i in range(n)]
    x = input()

    sl = 0
    res = 0
    for i in s:
        if i[0] == x:
            sl = 1
            continue
        if sl == 1:
            res += int(i[1])
            continue
    print(res)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#define print(n) std::cout << n << std::endl
#define print_no_indention(n) std::cout << n
using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    //n = 7;
    /*vector<int> d = {5,0,7,8,3,3,2};*/
    for (int i = 0; i < n; ++i) {
        cin >> d.at(i);
    }

    int sum = 0;

    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            if(i != j) sum += d.at(i) * d.at(j);
        }
    }

    print(sum);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int x = sc.nextInt();
		int a = 0;
		for (int i = 0; i <= x+1; i++) {
			a += i;
			if (x <= a) {
				System.out.println(i);
				break;
			}
		}
		sc.close();
	}
}


Measured memory_bytes: 21844
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=100005;
bool tr=0;int n;
struct sa{int x,y,t;}s[MAXN];
bool cmp(sa a,sa b)
{return a.t<b.t;}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&s[i].t,&s[i].x,&s[i].y);
		if(s[i].x+s[i].y>s[i].t)tr=1;
		if((s[i].x+s[i].y)%2!=s[i].t%2)tr=1;
	}sort(s+1,s+n+1,cmp);
	for(int j=n;j>1;j--)
		if(abs(s[j-1].x-s[j].x)+abs(s[j-1].y-s[j].y)>abs(s[j-1].t-s[j].t))
		{tr=1;break;}
	if(tr)printf("No\n");
	else printf("Yes\n");
}
/*
2
5 0 5
5 5 0
*/

Measured memory_bytes: 1280
#include<stdio.h>
 
int main() {
  int N;
  int a[N];
  int i, wa = 0;
 
  scanf("%d", &N);
  for(i = 0; i < N; i++) {
    scanf("%d", &a[i]);
  }
  for(i = 0; i < (N+1)/2; i++) {
    if( a[2*i]%2 == 1){ wa++; }
  }
  printf("%d", wa);

  return 0;  
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		ll n;
		cin>>n;
		vector<ll> height;
		vector<ll> dp(n,0);
		for(ll i=0; i<n; i++) {
			ll x;
			cin>>x;
			height.push_back(x);
		}

		dp[0] = 0;
		dp[1] = abs(height[1] - height[0]);

		for(ll i=2; i<n; i++) {

			ll cost1 = dp[i-1] + abs(height[i-1] - height[i]);
			ll cost2 = dp[i-2] + abs(height[i-2] - height[i]);

			dp[i] = min(cost1,cost2);
			
		}

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

		return 0;
	}


Measured memory_bytes: 2168
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%MOD;
        }
        x = (x*x)%MOD;
        n >>= 1;
    }
    return ret;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll n,q;
    cin >> n >> q;
    vector<ll> s(n),t(n),x(n);

    for(int i = 0; i < n; i++){
        cin >> s[i] >> t[i] >> x[i];
    }

    vector<ll> d(q);
    for(int i = 0; i < q; i++){
        cin >> d[i];
    }

    vector<tuple<ll,ll,ll>> z;
    for(int i = 0; i < n; i++){
        z.push_back(make_tuple(x[i],s[i]-x[i],t[i]-x[i]));
    }

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

    set<pair<ll,ll>> st;
    for(int i = 0; i < q; i++){
        st.insert({d[i],i});
    }

    vector<ll> ans(q,-1);
    for(int i = 0; i < n; i++){
        bool flag = true;
        while(flag){
            auto itr = st.lower_bound({get<1>(z[i]),0});
            if(itr == st.end()){
                flag = false;
            }else{
                if((*itr).first < get<2>(z[i])){
                    ans[(*itr).second] = get<0>(z[i]);
                    st.erase(itr);
                }else{
                    flag = false;
                }
            }
        }
    }

    for(int i = 0; i < q; i++){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 26860
#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>;

int main() {
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;
    if (A1 + A2 + A3 >= 22)
    {
        cout << "bust" << endl;
    } else
    {
        cout << "win" << endl;
    }
    
    
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iterator>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <sstream> 
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <functional>
#pragma GCC optimize("O3")
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define sp system("pause");
#define MOD 1e9+7;
#define mxN 2005
#define MXINT 1e9+5
void solve()
{
	ll n, k;

	cin >> n >> k;

	vector<ll> a(n);

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	vector<bool> dp(k+1,false);

	dp[0] = false;

	for (int i = 1; i <= k; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (i - a[j] >= 0)
			{
				if (dp[i - a[j]] == false)
				{
					dp[i] = true;
					break;
				}
			}
		}
	}
	cout << (dp[k] == true ? "First" : "Second");

}
int main()
{
	fast;
	solve();
	
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	for (int i = 1; i <= 9; i++)
	{
		for(int j=1;j<=9;j++)
			cout << i << "x" << j << "=" << i * j << endl;
	}

	return 0;
}



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

int main() {
    ll a,b,c;
    cin >> a >> b >> c;
    ll left = 4*a*b;
    ll d = (c-a-b);
    ll right = d*d;
    if(d>0&&left<right) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3632
#pragma region template
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n, q;
  cin >> n >> q;
  dsu uf(n);
  while(q--){
    int t, u, v;
    cin >> t >> u >> v;
    if(t == 0){
      uf.merge(u, v);
    }else{
      print(uf.same(u, v));
    }
  }
}


Measured memory_bytes: 3952
import sys
sys.setrecursionlimit(int(1e7))
from collections import deque
def inpl(): return list(map(int, input().split()))

def primes(N):
    sieve = [1]*(N+1)
    sieve[0], sieve[1] = 0, 0
    P = []
    for i in range(2, N+1):
        if sieve[i]:
            P.append(i)
            for j in range(2*i, N+1, i):
                sieve[j] = 0
    return P

N = int(input())
P = primes(10**6 + 10)

factors = [0]*len(P)
for i in range(len(P)):
    p = P[i]
    while N%p == 0:
        factors[i] += 1
        N = N//p

factors += [N!=1]
a = sum([f > 0 for f in factors])
b = 1
for i in range(len(P)+1):
    b *= factors[i] + 1

b -= 1

print(a, b)



Measured memory_bytes: 16808
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	int mi=s.size();
	for(int i=0;i<=s.size()-t.size();i++)
	{
		int cnt=0;
		for(int j=0;j<t.size();j++)
		{
			if(s[i+j]!=t[j])
				cnt++;
		}
		mi=min(mi,cnt);
	}
	cout<<mi;
}

Measured memory_bytes: 3544
use std::io;


fn main() {
    let (a, b) = {
        let i = read::<usize>();
        (i[0], i[1])
    };

    println!("{}", (a - 1) * (b - 1))
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int n;
    cin>>n;
    vector<ll>x(n);
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    
    vector<ll>sorted=x;
    sort(sorted.begin(),sorted.end());
    ll mid=sorted[n/2],mid2=sorted[n/2-1];
    
    for(int i=0;i<n;i++){
        if(x[i]<mid)cout<<mid<<endl;
        else cout<<mid2<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 6364
#include <bits/stdc++.h>
using namespace std;
#define rep(i, from, to) for (int i = from; i < to; i++)
#define sortv(x) sort(x.begin(), x.end())
#define revv(x) sort(x.begin(), x.end(), greater<int>())
#define dump(x) cerr << #x << " = " << x << endl
typedef vector<int> vi;
typedef long long ll;

int main()
{
  string s, t;
  cin >> s >> t;
  sortv(s);
  revv(t);
  dump(s);
  dump(t);
  if (s < t)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


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

int main() {
    ll n;
    cin >> n;
    vector<string>a(n);
    vector<ll>b(n);
    vector<ll>two(n), five(n);
    rep(i, n) cin >> a[i];
    rep(i, n) {
        bool start = false;
        rep(j, a[i].size()) {
            if (start) {
                two[i]--; five[i]--;
            }
            if (a[i][j] == '.') start = true;
            else b[i] = b[i] * 10 + (ll)(a[i][j] - '0');
        }
        while (b[i] % 2 == 0) {
            two[i]++; b[i] /= 2;
        }
        while (b[i] % 5 == 0) {
            five[i]++; b[i] /= 5;
        }
    }
    //rep(i, n) cout << two[i] << " " << five[i] << endl;
    ll zero = 50;
    vector<vector<ll>> vec(100, vector<ll>(100, 0));
    rep(i, n) vec[two[i] + zero][five[i] + zero]++;
    ll ans = 0;
    rep(i, 100) {
        rep(j, 100) {
            if (vec[i][j] == 0) continue;
            rep(k, 100) {
                rep(l, 100) {
                    if (vec[k][l] == 0) continue;
                    if (i + k >= 100 && j + l >= 100) {
                        if (i == k && j == l) {
                            ans += vec[i][j] * (vec[i][j] - 1);
                        }
                        else ans += vec[i][j] * vec[k][l];
                    }
                }
            }
        }
    }
    cout << ans / 2 << endl;
    return 0;
}


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

int main(){
    int K, S, cnt;
    cin >> K >> S;
    cnt = 0;
    for(int i = 0; i <= K; i++){
        for(int j = 0; j <= K; j++){
            if(S-(i+j) <= K && S-(i+j) >= 0){
                cnt++;
            }
        }
    }

    cout << cnt << endl;

}

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

signed main() {
	int n,h,w;
	std::cin >> n >> h >> w;
	print((n-h+1)*(n-w+1));
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

vector<string> split(const string &s, char delim)
{
    vector<string> elems;
    stringstream ss(s);
    string item;

    while (getline(ss, item, delim))
    {
        if (!item.empty())
        {
            elems.push_back(item);
        }
    }
    return elems;
}
int main()
{
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    cout << fixed << setprecision(7);

    string s;
    while (getline(cin, s))
    {
        vector<string> v = split(s, ' ');
        
        stack<long double> st;
        
        for(int i=0; i<(int)v.size(); ++i){
            long double val = 0;
            bool minus = false;
            string t = v[i];
            if(t.size()==1){
                if(t >= "0" && t <= "9"){
                    st.push((long double)t[0] - '0');
                }else if(t=="-"){
                    long double ab1 = st.top();
                    st.pop();
                    long double ab2 = st.top();
                    st.pop();
                    st.push(ab2-ab1);
                }else if(t=="+"){
                    long double ab1 = st.top();
                    st.pop();
                    long double ab2 = st.top();
                    st.pop();
                    st.push(ab2+ab1);
                }else if(t=="*"){
                    long double ab1 = st.top();
                    st.pop();
                    long double ab2 = st.top();
                    st.pop();
                    st.push(ab2*ab1);
                }else if(t=="/"){
                    long double ab1 = st.top();
                    st.pop();
                    long double ab2 = st.top();
                    st.pop();
                    st.push(ab2/ab1);
                }
            }else{
                for(int j=0; j<(int)t.size(); ++j){
                    if(t[j]=='-'){
                        minus = true;
                    }else{
                        val = val*10 + (t[j]-'0');
                    }
                }
                if(minus) val *= -1;
                st.push(val);
            }
            //cout << st.top() << endl;
        }
        cout << st.top() << endl;
    }
    return 0;
}


Measured memory_bytes: 3152
import numpy as np
n = int(input())
ab = []
for _ in range(n):
  ab.append( list(map(int, input().split())) )

nda = np.array(ab)
nda_sort = nda[np.argsort(nda[:, 1])]
# print(nda_sort)

time = 0
for i in range(n):
  time += nda_sort[i, 0]
  if time > nda_sort[i, 1]:
    print('No')
    exit()
print('Yes')

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

int main()
{
	int n, count = 0, ans = 0;
	cin >> n;
	for (int i = 0; (2 * i + 1) <= n; i++) {
		for (int j = 1; j <= (2 * i + 1); j++) {
			if ((2 * i + 1) % j == 0) {
				count++;
			}
		}
		if (count == 8) {
			ans++;
		}
		count = 0;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256