akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

vector<int> bitconversion(int i, int n, int N){
    int x = 1;
    rep(j,N){
        x *= n;
    }
    vector<int> vec(N);
    rep(j,N){
        x /= n;
        vec[j] = i / x;
        i -= x * vec[j];
    }
    return vec;
}

int main(){
    int H,W,K;
    cin >> H >> W >> K;
    vector<string> S(H);
    rep(i,H){
        cin >> S[i];
    }
    int ans_min = 200000;
    int num = 1;
    rep(i,H - 1) num *= 2;
    rep(k,num){
        vector<int> bi = bitconversion(k, 2, H - 1);
        vector<bool> iscut(H, false);
        rep(i,H - 1){
            if (bi[i] == 1) iscut[i] = true;
        }
        iscut[H - 1] = true;
        vector<vector<int> > sum(H, vector<int> (W + 1));
        rep(i,H){
            sum[i][0] = 0;
            rep(j,W){
                if (S[i][j] == '0') sum[i][j + 1] = 0;
                if (S[i][j] == '1') sum[i][j + 1] = 1;
            }
        }
        rep(i,H){
            rep(j,W){
                sum[i][j + 1] += sum[i][j];
            }
        }
        rep(j,W + 1){
            rep(i,H - 1){
                if (!iscut[i]) sum[i + 1][j] += sum[i][j];
            }
        }
        int prev = 0;
        int times = 0;
        int now = 0;
        bool possible = true;
        while(true){
            bool cut = false;
            if (now == W + 1){
                break;
            }
            else if (!possible){
                break;
            }
            else{
                rep(i,H){
                    if (iscut[i]){
                        if (sum[i][now] - sum[i][prev] > K){
                            cut = true;
                            if (now - prev == 1) possible = false;
                        }
                    }
                }
                if (cut){
                    prev = now - 1;
                    times++;
                }
                else{
                    now++;
                }
            }
        }
        int ans_sub = 0;
        rep(i,H - 1){
            if (iscut[i]) ans_sub++;
        }
        ans_sub += times;
        if (possible){
            ans_min = min(ans_min, ans_sub);
        }
    }
    cout << ans_min << endl;
}

Measured memory_bytes: 3684
#include <stdio.h>

int main(void)
{
	int a, b;
	
	scanf("%d %d", &a, &b);
	
	if( a == b ){
		printf("a == b\n");
	}
	else{
		printf("a %c b\n", (a > b) ? '>' : '<');
	}
	
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cout <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cout <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);

using namespace std;

char s[105][105];
int dp[105][105];
int n, m;

int f(int a, int b) {
	if ( a > n-1 || b > m-1) return 1e9;
	return dp[a][b];
}

int main() {
	read2(n, m);
	FOR(i,0,n) scanf("%s", s[i]);
	dp[n-1][m-1] = (s[n-1][m-1]=='.') ? 0 : 1;
	FORD(i,n-1,0) FORD(j,m-1,0) {
		if (i==n-1 && j==m-1) continue;
		if (s[i][j] == '.') {
			dp[i][j] = min(f(i+1,j), f(i,j+1));
		} else {
			dp[i][j] = 1e9;
			if (i+1<n) {
				if (s[i+1][j] == '.') dp[i][j] = min(dp[i][j], 1 + dp[i+1][j]);
				else dp[i][j] = min(dp[i][j], dp[i+1][j]);
			}
			if (j+1<m) {
				if (s[i][j+1] == '.') dp[i][j] = min(dp[i][j], 1 + dp[i][j+1]);
				else dp[i][j] = min(dp[i][j], dp[i][j+1]);
			}
		}
	}
	printf("%d\n", dp[0][0]);
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<tuple<string, int, int>> r(N);
  for (int i = 0; i < N; i++) {
    string s;
    int p;
    cin >> s >> p;
    r.at(i) = make_tuple(s, p * (-1), i+1);
  }
 
  sort(r.begin(), r.end());
  
  for (int i = 0; i < N; i++) {
    int a, p;
    string s;
    tie(s, p, a) = r.at(i);  
    cout << a << endl;
  }
}

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

int main(){
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int ans = min(k, a) - max(0, min(k-a-b, c));
  cout << ans << endl;
  return 0;
}
  

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

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

ll dp[200001][5];

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n+1);
    for(int i=1;i<=n;++i) cin >> a[i];

    for(int i=1;i<=n;++i) {
        ll min_prev = (1LL << 50);
        for(int j=0;j<5;++j) {
            min_prev = min(min_prev, dp[i-1][j]);
            if(j == 0 || j == 4) {
                dp[i][j] = min_prev + a[i];
            } else if(j == 1 || j == 3){
                dp[i][j] = min_prev + (a[i]==0?2:(a[i]%2));
            } else {
                dp[i][j] = min_prev + 1 - (a[i]%2);
            }
        }
    }

    cout << *min_element(dp[n], dp[n]+5) << endl;
}


Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
using namespace std;

class xx{
public:
  int num, id;
  bool operator<(const xx& another) const{
    return num < another.num;
  };
};

void solve(){
  int n; cin >> n;
  vector<xx> x(n);
  for(int i = 0; i < n; i++){
    cin >> x[i].num;
    x[i].id = i;
  }
  sort(x.begin(), x.end());
  //for(int i = 0; i < n; i++) cout << x[i].num << " " << x[i].id << endl;
  int ans1 = x[n / 2 - 1].num, ans2 = x[n / 2].num;
  vector<int> ans(n);
  for(int i = 0; i < n; i++){
    if(i <= n / 2 - 1) ans[x[i].id] = ans2;
    else ans[x[i].id] = ans1;
  }
  for(int i = 0; i < n; i++) cout << ans[i] << endl;
  return;
}

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


Measured memory_bytes: 4480
# -*- coding: utf-8 -*-

from sys import stdin

n,x = [int(i) for i in stdin.readline().split()]
limit = int(x ** (1.0/n)) + 1

def devide_counter(x, p):
    count = 1
    x /= p
    while x % p == 0:
        count += 1
        x /= p
    return x, count

def factorize(x):
    ans = 1

    p = 2
    if x % p == 0:
        x, count = devide_counter(x, p)
        if count >= n:
            ans = ans * (p ** (count // n))

    for p in range(3, limit, 2):
        if x % p == 0:
            x, count = devide_counter(x, p)
            if count >= n:
                ans = ans * (p ** (count // n))
        if x < p * p:
            break
    return ans

if x == 1:
    print(1)
elif n == 1:
    print(x)
else:
    ans = factorize(x)
    print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
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 (a > b) { a = b; return 1; } return 0; }

const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll 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(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  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;
  }
};

vector<ll> v;

void decom(int n)
{
    // 割る数の初期値
    int a = 2;
    // √n ≧ a ( n ≧ a * a ) の間ループ処理
    while (n >= a * a) {
        // a で割り切れたら、a は素因数
        // そして、割られる数を a で割る
        // a で割り切れなかったら、 a を 1 増加させる
        if (n % a == 0) {
            v.PB(a);
            n /= a;
        } else {
            a++;
        }
    }
    // 最後に残った n は素因数
    v.PB(n);
}

int main() {
  int n; cin >> n;
  int a[n];
  mint ans = 0;
  FOR(i,0,n-1) {
    cin >> a[i];
    ans += (mint)1 / a[i];
  }

  map<int,int> m;

  FOR(i,0,n-1){
    v.clear();
    decom(a[i]);

    map<int,int> tmpm;

    for(auto x: v){
      ++tmpm[x];
    }
    for(auto x: tmpm){
      if(x.second > m[x.first]) m[x.first] = x.second;
    }
  }

  for(auto x: m){
    FOR(i,0,x.second-1) ans *= x.first;
  }

  cout << ans.x << endl;






}

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

int calc_gcd(int a, int b){
  int x = max(a, b), y = min(a, b);
  if(y == 0){
    return x;
  }
  return calc_gcd(y, x % y);
}

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

  string S, T;
  cin >> S;
  cin >> T;

  int gcd = calc_gcd(N, M);
  long long ans = static_cast<long long>(N) * M / gcd;

  bool valid = true;
  for(long long i = 0; i < N; i++){
    if(i * M % N == 0 && S[i] != T[i * M / N]){
      valid = false;
    }
  }

  if(valid){
    cout << ans << endl;
  }else{
    cout << -1 << endl;
  }
}


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

int main() {
	
	int a, b, c;
	
	cin >> a >> b >> c;
	
	if ( (a < b ) && (b < c) )
	{
		cout << "Yes" << endl;
	}else
	{
		cout << "No"  << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define next Next
#define y1 _y1
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=1000005,mod=998244353;
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
void Del(int &x,int y){
	if ((x-=y)<0)
		x+=mod;
}
int n;
int c[N],u[N];
int f[N];
int ans=0;
int main(){
	n=read();
	For(i,1,n)
		c[read()]++;
	n=1000000;
	For(i,1,n){
		For(j,1,n/i){
			Add(f[i],(LL)j*c[i*j]%mod);
		}
	}
	For(i,1,n)
		f[i]=(LL)f[i]*f[i]%mod;
	u[1]=1;
	For(i,1,n)
		for (int j=i+i;j<=n;j+=i)
			u[j]-=u[i];
	For(i,1,n)
		if (u[i]==-1)
			u[i]=mod-1;
	For(d,1,n)
		For(t,1,n/d)
			Add(ans,(LL)d*u[t]%mod*t%mod*t%mod*f[d*t]%mod);
//	outval(ans);
	For(i,1,n)
		Del(ans,(LL)c[i]*i%mod);
//	outval(ans);
	ans=(LL)ans*((mod+1)/2)%mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11904
#include  <bits/stdc++.h>
using namespace std;
vector<vector<int > >adj;


void dfs(vector<int> &vis, int node ) {
    if(vis[node]==1) return;
    vis[node]=1;
    for(int i=0;i<adj[node].size();i++) {
        if(vis[adj[node][i]]==0) dfs(vis, adj[node][i]);
    }
    return;
}

int main() {
    int m,n,a,b;
    cin>>n>>m;
    vector<int>add;
    for(int i=0;i<n+1;i++) {
        adj.push_back(add);
    }
    // for(int i=0;i<n+1;i++) adj[1].push_back()
    for(int i=0;i<m;i++) {
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    vector<int>visited(n+1,0);
    int cnt=-1;
    for(int i=1;i<n+1;i++) {
        if(visited[i]==0) {
            cnt++;
            dfs(visited, i);
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 10032
def solve(s):

    def expr(l):
        left, mid = term(l)
        return edum(mid, left)
    
    def edum(l, lval):
        if s[l] == '+':
            val, mid = term(l + 1)
            return edum(mid, lval + val)
        if s[l] == '-':
            val, mid = term(l + 1)
            return edum(mid, lval - val)
        else:
            return lval, l
    
    def term(l):
        left, mid = value(l)
        return tdum(mid, left)

    def tdum(l, lval):
        if s[l] == '*':
            l += 1
            val1, mid = value(l)
            return tdum(mid, lval * val1)
        if s[l] == '/':
            l += 1
            val1, mid = value(l)
            return tdum(mid, (abs(lval) // abs(val1)) * (-1 if (lval < 0) ^ (val1 < 0) else 1))
        else:
            return lval, l

    def value(l):
        if s[l] == '(':
            val1, mid = expr(l + 1)
            return val1, mid + 1
        else:
            val = 0
            fl =  s[l] == '-'
            if fl:
                l += 1
            while s[l].isdecimal():
                val *= 10
                val += int(s[l])
                l += 1
            if fl:
                val *= -1
            return val, l

    res = expr(0)[0]
    """
    gnd = eval(''.join(s[:-1]).replace('/', '//'))
    while res != gnd:
        pass
    """
    print(res)

def main():
    q = int(input())
    for _ in range(q):
        solve(list(input()))

if __name__ == '__main__':
    main()


Measured memory_bytes: 5624
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a;
    cin >> a;
    cout << dup(a,2)*(a/2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
  int main() {
  int n,count=0;
  int tab[22];
  scanf("%d",&n);
  for (int i = 0; i < n; i++) {
    scanf("%d",&tab[i]);
  }
  for (int i = 1; i <n-1; i++) {
    if ((tab[i]<tab[i-1]&&tab[i]>tab[i+1])||(tab[i]>tab[i-1]&&tab[i]<tab[i+1])) {
      count++;
    }
  }
  printf("%d\n",count );
    return 0;
  }


Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

/**
 * フィボナッチ数列
 * @author nobu
 * @see <a href="http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_A&lang=ja">ALDS1_10_A</a>
 */
public class Main {
	private static int dp[] = new int[50];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		Arrays.fill(dp, -1);
//		fibDp(n);
		fibRf(n);

		System.out.println(dp[n]);

		sc.close();
	}

	// 動的計画法
	private static int fibDp(int n) {
		if (n == 1 || n == 0) return 1;
		if (dp[n] != -1) return dp[n];
		return dp[n] = fibDp(n - 1) + fibDp(n - 2);
	}

	// 漸化式
	private static void fibRf(int n) {
		dp[0] = 1;
		dp[1] = 1;
		for (int i = 2; i <= n; i++) {
			dp[i] = dp[i - 1] + dp[i - 2];
		}
	}

}



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

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  
  int cont = 0;
  cont = x;
  x = y;
  y = cont;
  
  cont = x;
  x = z;
  z = cont;
  
  cout << x << " " << y << " " << z << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

constexpr ll MOD = 1e9 + 7;

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

    double t[1010];
    for (int i = 1; i <= 1000; i++)
    {
        double u = 0;
        for (int j = 1; j <= i; j++)
            u += (double)j / i;
        t[i] = u;
    }

    int n, k, p[212345];
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> p[i];

    double sum = 0;
    for (int i = 0; i < k; i++)
        sum += t[p[i]];
    double res = sum;
    for (int i = k; i < n; i++)
    {
        sum -= t[p[i - k]];
        sum += t[p[i]];
        res = max(res, sum);
    }

    cout << setprecision(20) << res << endl;

    return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int A, B;

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

    std::cin >> A >> B;

    int area = A * B - A - B + 1;
    std::cout << area << std::endl;
}


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

int main(void){
	int a[30];
	int w,n;
	cin >> w >> n;
	for(int i=0;i<w;i++){
		a[i]=i;
	}
	for(int i=0;i<n;i++){
		int x,y,tmp;
		scanf("%d,%d",&x,&y);
		tmp = a[x-1];
		a[x-1] = a[y-1];
		a[y-1] = tmp;
	}
	for(int i=0;i<w;i++) cout << a[i]+1 << "\n";
	return 0;
}

Measured memory_bytes: 0
<?php
list($n,$k)=explode(" ",trim(fgets(STDIN)));
$m0=(int)(floor($n/$k));
$ans=(int)(pow($m0,3));
if($k%2==0){
    $d=(int)(floor($n/($k/2)));
    $ans+=(int)(pow($d-$m0,3));
}
echo $ans;

Measured memory_bytes: 4728
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>

using namespace std;
#define DEBUG(x) cout<<#x<<": "<<x<<endl

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define INT(a) int((a)+1e-9)
int DX[4]={1,0,-1,0};
int DY[4]={0,1,0,-1};

typedef pair<int,int> Pii;


#define SUPnl 10002

int nl;
int p[SUPnl];

int init(){REP(ni,nl){p[ni]=-1;}}

int getRoot(int a){
	int ra=a;
	while(p[ra]!=-1){ra=p[ra];}
	if(ra!=a)p[a]=ra;
	return ra;
}

bool same(int a, int b){
	return getRoot(a) == getRoot(b);
}

void unite(int a, int b){
	a=getRoot(a);
	b=getRoot(b);
	if(a==b) return;
	p[b]=a;
}

int main(){
	int ol;
	cin>>nl>>ol;
	init();
	int ot,a,b;
	REP(oi,ol){
		cin>>ot>>a>>b;
		if(ot==0) unite(a,b);
		if(ot==1) cout<<same(a,b)<<endl;
	}
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int h,w;
    cin >> h >> w;
    
    vector<vector<char>> board(h,vector<char>(w));
    
    rep(i,h){
        rep(j,w){
            cin >> board[i][j];
        }
    }
    int i = 0;
    int j = 0;

    bool flag = true;
    
    while(true){
        bool next = false;
        if(i + 1 < h){
            if(board[i+1][j] == '#'){
                board[i][j] = '.';
                next = true;
                i++;
            }
            
        }
        
        if(j + 1 < w){
            if(board[i][j+1] == '#'){
                board[i][j] = '.';
                j++;
                next = true;
            }
        }
        
        if(!next) break;
        
        if(i == h - 1 and j == w - 1) {
            board[i][j] = '.';
            break;
        }
    }
    
    rep(i,h){
        rep(j,w){
            if(board[i][j]=='#') flag = false;
        }
    }
    
    if(flag) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <bitset>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <deque>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
const LL INF = 2e6;
const LL MOD = 1e9 + 7;
const LL _ = 1e10;

void solve() {
    LL n;
    LL dp[2005] = { 0 };
    dp[0] = 1;
    cin >> n;
    for (LL i = 0; i < n; i++) {
        for (LL j = i + 3; j <= n; j++) {
            dp[j] = (dp[j] + dp[i]) % MOD;
        }
    }
    cout << dp[n] << endl;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(20), cout.setf(ios::fixed);
    /*int t;
    cin >> t;
    while (t--) {
        solve();
    }*/
    solve();
}

Measured memory_bytes: 3640
#include <stdio.h>

#define BUF (60)
int N;
char S1[BUF];
char S2[BUF];

void input(void){
	scanf("%d",&N);
	scanf("%s",S1);
	scanf("%s",S2);
}

void show(void){
	printf("%d\n%s\n%s\n",N,S1,S2);
}

int main(void){
	input();

	unsigned int ans = 1;
	int prev = 0; //0: x 1:| 2:-
	for(int i=0;i<N;i++){
		if(S1[i] ==S2[i]){
			if(prev == 0){
				ans*=3;
			}else if(prev == 1){
				ans*=2;
			}else if(prev == 2){
			}
			prev = 1;
		}else{
			if(prev==0){
				ans*=6;
			}else if(prev==1){
				ans*=2;
			}else if(prev==2){
				ans*=3;
			}
			i++;
			prev = 2;
		}
		
		if( ans>=1000000007){
			ans%=1000000007;
		}

	//		printf("%d %u\n",i,ans);
	}

	printf("%u\n",ans);

	return 0;
}


Measured memory_bytes: 128
n = int(input())
dp = list(range(100010))
for i in range(n+1):
    pow6 = 1
    while pow6<=i:
        dp[i] = min(dp[i],dp[i-pow6]+1)
        pow6 *=6
    pow9 = 1
    while pow9<=i:
        dp[i] = min(dp[i],dp[i-pow9]+1)
        pow9 *=9
print(dp[n])

Measured memory_bytes: 6900
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const int N = 500, C = 30;

int n, c;
// Cost from x - > y, grid, cost to turn into C for each group
ll cost[C][C], grid[N][N], gCost[3][C];

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> c;
    // Convert all 1 indexed -> 0 indexed
    for (int i = 0; i < c; ++i) {
        for (int j = 0; j < c; ++j) {
            cin >> cost[i][j];
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> grid[i][j];
            --grid[i][j];

            for (int k = 0; k < c; ++k)
                gCost[(i + j) % 3][k] += cost[grid[i][j]][k];
        }
    }

    if (n == 1) {
        cout << 0;
        return 0;
    }
    
    ll ans = INF;
    for (int i = 0; i < c; ++i) {
        for (int j = 0; j < c; ++j) {
            if (j == i) continue;
            for (int k = 0; k < c; ++k) {
                if (k == i || k == j) continue;
                ans = min(ans, gCost[0][i] + gCost[1][j] + gCost[2][k]);
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 5552
#include <bits/stdc++.h>
using namespace std;
#define eni(x) template < class c > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
template < class c > struct rge { c b, e; };
template < class c > rge<c> range(c i, c j) { return rge<c>{i, j}; }
template < class c > auto dud(c* x) -> decltype(cerr << *x, 0);
template < class c > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; return * this; }
eni(==) return * this << range(begin(i), end(i)); }
template < class c, class b > debug & operator <<(pair < b, c > d) {
  return * this << "(" << d.first << ", " << d.second << ")";
}
template < class c > debug & operator <<(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  return * this << "]";
}
#else
template < class c > debug & operator <<(const c&) { return * this; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define mx 200005
mt19937 myrand(time(0));

struct SegmentTree{
    int tree[4*mx];

    void init(){
        memset(tree,0,sizeof tree);
    }

    void update(int pos, int l, int r, int idx, int value){
        if(l==r && l==idx){
            tree[pos]=value;
            return;
        }
        int mid=(l+r)>>1;
        if(idx>=l && idx<=mid) update(pos*2,l,mid,idx,value);
        if(idx>=(mid+1) && idx<=r) update(pos*2+1,mid+1,r,idx,value);
        tree[pos]=max(tree[pos*2],tree[pos*2+1]);
    }

    int query2(int pos, int l, int r, int idx){
        if(l==r) return tree[pos];
        int mid=(l+r)>>1;
        if(idx>=l && idx<=mid) return query2(pos*2,l,mid,idx);
        return query2(pos*2+1,mid+1,r,idx);
    }

    int query(int pos, int l, int r, int x){
        if(l==r) return l;
        int mid=(l+r)>>1;
        if(tree[pos*2]>=x) return query(pos*2,l,mid,x);
        return query(pos*2+1,mid+1,r,x);
    }
};

ll n,q;
SegmentTree s1,s2;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(),cout.tie();
    cin>>n>>q;
    s1.init(),s2.init();
    while(q--){
        int t,x;
        cin>>t>>x;
        if(t==1){
            if(s2.tree[1]<x) s1.update(1,1,n,x,n);
            else{
                int left=s2.query(1,1,n,x);
                s1.update(1,1,n,x,left-1);
            }
        }
        else{
            if(s1.tree[1]<x) s2.update(1,1,n,x,n);
            else{
                int down=s1.query(1,1,n,x);
                s2.update(1,1,n,x,down-1);
            }
        }
    }
    ll bad=0;
    for(int i=2;i<n;i++){
        int v=s1.query2(1,1,n,i);
        //debug()<<imie(i)imie(v);
        if(v==n) bad+=v-2;
        else if(v) bad+=v-1;
        v=s2.query2(1,1,n,i);
        //debug()<<imie(i)imie(v);
        if(v==n) bad+=v-2;
        else if(v) bad+=v-1;
    }
    ll ans=(n-2)*(n-2);
    ans-=bad;
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  
  int maxA = 0;
  int minB = 100000;
  
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    maxA = max(maxA, a);
    minB = min(minB, b);
  }
  cout << max(minB - maxA + 1, 0) << endl;
}

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

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

using namespace std;

int main() {

    ll a[3]; rep(i,3) cin >> a[i];
    if(a[0]%2 == 0 ||a[1]%2 == 0 ||a[2]%2 == 0 ) cout << 0;
    else {
        sort(a,a+3);
        cout << (a[0]*a[1]);
    }
    

    return 0;
}

Measured memory_bytes: 3612
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    string s;
    cin>>s;

    map<char,ll> mp;
    ll MOD = 998244353;
    ll ans = 1;
    FOR(i,0,3*n){
      vector<ll> v(3);
      v[0] = mp['R'];
      v[1] = mp['G'];
      v[2] = mp['B'];
      sortAlr(v);
      if(mp[s[i]] == v[0]){
        ans = ans*(n-mp[s[i]])%MOD;
      }
      else if(mp[s[i]] == v[1]){
        ans = ans*(v[0] - v[1])%MOD;
      }
      else{
        ans = ans*(v[1] - v[2])%MOD;
      }
      mp[s[i]]++;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
struct edge{
	int to,c,t,r;
	edge(int a,int b,int e,int d){to=a,c=b,t=e,r=d;}
};
int inf=1e9;
int N,M,H,K;
int b[256],d[256],dp[256];
int dis[25][100];
vector<edge> G[100];
void init(){
	rep(i,N) G[i].clear();
}
int main(){
	while(true){
		cin>>N>>M>>H>>K;
		if(N==0) break;
		init();
		rep(i,M){
			int a,b,c,h,r;
			cin>>a>>b>>c>>h>>r;
			a--,b--,r--;
			G[a].pb(edge(b,c,h,r));
			G[b].pb(edge(a,c,h,r));
		}
		int S,T;
		cin>>S>>T;
		S--,T--;
		int P;
		cin>>P;
		rep(i,P){
			int n;
			cin>>n>>d[i];
			int x=0;
			rep(j,n){
				int a;
				cin>>a;
				x|=(1<<(a-1));
			}
			b[i]=x;
		}
		rep(i,1<<K) dp[i]=inf;
		dp[0]=0;
		rep(i,1<<K){
			rep(j,P) chmin(dp[i|b[j]],dp[i]+d[j]);
		}
		int ans=inf;
		rep(bit,1<<K){
			rep(i,H+1) rep(j,N) dis[i][j]=inf;
			dis[0][S]=0;
			rep(i,H) rep(j,N){
				for(edge e:G[j]){
					if(i+e.t<=H) chmin(dis[i+e.t][e.to],dis[i][j]+( ( (bit>>e.r)&1 )?0:e.c  ) );
				}
			}
			int tmp=inf;
			rep(i,H+1) chmin(tmp,dis[i][T]);
			chmin(ans,tmp+dp[bit]);
		}
		if(ans>=inf) ans=-1;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1276
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

int main()
{
    string str;
    cin >> str;
    if (str == "Sunny")
        cout << "Cloudy";
    else if (str == "Cloudy")
        cout << "Rainy";
    else cout << "Sunny";
}

Measured memory_bytes: 3624
//y11-2
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807

int main(){
    while(true){

        int n;
        cin >> n;
        if(n == 0) return 0;

        int s[1000],p[1000],q[1000],r[1000];
        for(int i=0; i<n; i++){
            cin >> s[i] >> p[i] >> q[i] >> r[i];
        }
        int P,Q,R,C;
        cin >> P >> Q >> R >> C;

        int ans = 0;
        for(int i=0; i<n; i++){
            if(p[i] <= P && q[i] <= Q && r[i] <= R && 4*p[i]+9*q[i]+4*r[i] <= C){
                //if(ans != 0) cout << " ";
                //cout << s[i];
                cout << s[i] << endl;
                ans++;
            }
        }
        if(ans == 0) cout << "NA" << endl;
        //else cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <set>
#include <vector>

#define FOR(i, l, r) for (i = (l); i < r; i++ )

using namespace std;
typedef long long ll;
#define MAX_N (1010)
#define MAX_V (10010)

int n;
int A[MAX_N];
int g_min = MAX_V;		// global min
int B[MAX_N];			// sorted array
int T[MAX_V];			// index of sorted array
bool V[MAX_N];			// check whether it is already used.

int solve() {

    for ( int i = 0; i < n; i++ ) {
	V[i] = false;
	B[i] = A[i];
    }

    sort(B, B + n);

    for ( int i = 0; i < n; i++ ) {
	T[B[i]] = i;
    }

    int ret = 0;
    for ( int i = 0; i < n; i++ ) {
	if ( V[i] ) continue;
	// has not visited yet.
	int cur = i;
	int num = 0;
	int l_min = MAX_V;	// local min
	int sum_l = 0;
	while ( 1 ) {
	    V[cur] = true;
	    num++;
	    l_min = min(l_min, A[cur]);
	    sum_l += A[cur];
	    cur = T[A[cur]];
	    if ( V[cur] ) break; // 
	}

	int c0 = sum_l + (num - 2) * l_min;
	int c1 = sum_l + l_min + (num + 1) * g_min;
	ret += min(c0, c1);
    }
    return ret;
}

int main()
{
    scanf("%d", &n);
    
    for ( int i = 0; i < n; i++ ) {
	scanf("%d", &A[i]);
	g_min = min(g_min, A[i]);
    }

    int ans = solve();
    printf("%d\n", ans);

    return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   ll n,k;cin >>n>>k;
   vector<ll>a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    for (int i = 0; i <n-k; ++i) {
        if(a[i]>=a[i+k])puts("No");
        else puts("Yes");
    }
//    if(flg)puts("Yes");
//    else puts("No");
}


Measured memory_bytes: 4824
al=list(map(int,input().split()))+list(map(int,input().split()))+list(map(int,input().split()))
n=int(input())
bl=[int(input()) for _ in [0]*n]
for i in bl:
  for j in range(9):
    if al[j] == i:
      al[j] = 0
nobingo = (al[0]+al[1]+al[2])*(al[3]+al[4]+al[5])*(al[6]+al[7]+al[8])*(al[0]+al[3]+al[6])*(al[1]+al[4]+al[7])*(al[2]+al[5]+al[8])*(al[0]+al[4]+al[8])*(al[2]+al[4]+al[6])
if nobingo:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

string N;
int K;
ll dp[200][4][2];

int main(void){
	cin >> N >> K;
	int len = N.size();

	dp[0][0][0] = 1;
	for(int i = 0; i < len; i++){
		for(int j = 0; j <= K; j++){
			if(j <= K-1) dp[i+1][j+1][1] += dp[i][j][1] * 9;
			if(j <= K-1 and N[i] >= '1') dp[i+1][j+1][1] += (dp[i][j][0] * (N[i] - '0' - 1));
			if(j <= K-1 and N[i] >= '1') dp[i+1][j+1][0] += dp[i][j][0];
			
			if(N[i] == '0'){
				dp[i+1][j][0] += dp[i][j][0];
				dp[i+1][j][1] += dp[i][j][1];
			}else{
				dp[i+1][j][1] += dp[i][j][1] + dp[i][j][0];
			}
		}
	}

	cout << dp[len][K][0] + dp[len][K][1] << '\n';

	return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILL(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};


int main(){

  int n;
  cin >> n;
  long double d = 0;
  REP(i,n){
    long double x;cin >> x;
    d += (long double)(1/x);
  }
  cout << fixed << setprecision(15);
  cout << (long double)(1/d);

  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    int count = 0;
    for (int i = c; i < d; i++)
    {
        for (int j = a; j < b; j++)
        {
            if(i == j) count++;
        }
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 256
/* ex 9_1
   kohei_suzuki */

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

#define SIZE 100
 
//スタックの定義
typedef struct stack{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;

//スタックの初期化
void initialize_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}
 
//データの追加
void push(stack *stk, char elem){
    if(stk->count >= stk->size){
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }
    else{
        stk->top--;
        *(stk->top) = elem;
        stk->count++;
    }
}
 
//データの取り出し
char pop(stack *stk){
    char latest;
    if(stk->count <= 0){
        fprintf(stdout, "Error: stack underflow.\n");
        exit(1);
    }
    else{
        latest = *(stk->top);
        stk->top++;
        stk->count--;
        return latest;
    }
}

int main(void){
    char input[SIZE];
    stack stk;

    initialize_stack(&stk);//stkの初期化 

    scanf("%s", input);//入力受取

    for(int i=0; i<strlen(input); i++){
        //0,1が入力されたらスタックに追加
        if(input[i] == '0' || input[i] == '1'){
            push(&stk, input[i]);
        }
        //スタック内が空でなくBが入力されたらスタックから一つ取り出す
        else if(input[i] == 'B' && stk.count > 0){
            pop(&stk);
        }
    }

    //古いデータから出力
    for (int i=0; i<stk.count; i++){
        printf("%c", stk.data[SIZE-i-1]);
    }

}

Measured memory_bytes: 1660
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <vector>
#include <map>
#include <ctime>
#include <cmath>
#include <string.h>
#define inf 0x7fffffff
using namespace std;
struct P
{

    int x,y;

    bool operator<(const P &a)const{
       // if(y!=a.y)
       // return y>a.y;
       return x>a.x;
//        return z>a.z;
    }
};
vector<P> v[1010];

int a,b,c,o[2000000],i,k,d,n,m,e,dy[15]={0,0,-1,1,-1,1,-1,1},dx[15]={-1,1,0,0,1,1,-1,-1};
int l[3500005];

long long x,y,z[52],v1,v2;
//P u[100600];
int j[6000000];
queue<P> q,q1;
stack<int> s;
//queue<P> q;

//deque<int> d;
//'1'==49;
//'A'==65;
//'a'==97;
map<string, int > p;
string r,r1,r2;
//char r[1010];





//2147483647
int main()
{
    scanf("%d",&a);
    k=i=1;
    for(int t=1;t<=a;i*=3,t++)
        scanf("%d",&o[t]);
    for(int t=1;t<=a;t++)
        k*=(2-o[t]%2);
    printf("%d",i-k);

}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
//#pragma GCC optimize ("02")
#define ll long long
#define oo 1000000007
using namespace std;

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

	double l;
	cin >> l;

	double d = l/3;

	cout << fixed << setprecision(8) << d*d*d;

    return 0;
}


Measured memory_bytes: 256
#include	<iostream>
#include	<deque>
#include	<algorithm>
#include	<unordered_set>

using namespace std;

int main()
{
	int		n;
	cin >> n;
	deque<int>			dq;

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

	sort(begin(dq), end(dq));
	auto unq = unique(begin(dq), end(dq));
	dq.erase(unq, end(dq));

	int		q;
	cin >> q;
	unordered_set<int>		us;

	for (int i = 0; i < n; ++i)
	{
		int	temp;
		cin >> temp;
		us.insert(temp);
	}

	int		Cnt = 0;

	for (auto it : dq)
	{
		if (us.find(it) != us.end())
		{
			++Cnt;
		}
	}

	cout << Cnt << endl;

	return 0;
}

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

#ifdef _DEBUG
    #include "/home/v-o_o-v/deb.h"
    #define deb(x...)cerr << "[" << #x << "] = [";_print(x);
#else
    #define deb(x...)
#endif

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
   
    char c;
    cin >> c;
    if(isupper(c))puts("A");
    else puts("a");
    return 0;
}
// Write Here


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define CLEAR(a) memset(a,0,sizeof a)
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define fr freopen("input.txt", "r", stdin);
#define fw freopen("output.txt", "w", stdout);
#define int long long 
typedef long long LL;
typedef pair<int,int> pii;
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 5;
 
int x[MAX], y[MAX], r[MAX];
vector<pair<int, double> >g[MAX];
priority_queue<pair<double, int> , vector<pair<double, int> >, greater<pair<double, int> > > pq;
double ans[MAX];
 
double dist(int x1,int y1,int x2, int y2){
    double ret =sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
    return ret;
}
 
 main() {
    int sx, sy, ex, ey;
    cin >> sx >> sy >> ex >> ey;
 
    int n;
    cin >> n;
    REP(i,n){
        cin >> x[i] >> y[i] >> r[i];
    }
 
    REP(i,n){
        for(int j=i+1;j<n;j++){
            double d = dist(x[i],y[i], x[j], y[j]);
            d -= r[i]+r[j];
            if(d > 0) {
                g[i].pb(mp(j, d));
                g[j].pb(mp(i, d));
            }
            else{
                g[i].pb(mp(j, 0));
                g[j].pb(mp(i, 0));
            }
        }
    }
 
    REP(i, n){
        ans[i] = dist(sx, sy, x[i], y[i]) - r[i];
        if(ans[i] < 0) ans[i] = 0;
        pq.push(mp(ans[i], i));
    }
 
    while(!pq.empty()){
        int u = pq.top().S;
        pq.pop();
        for(int i=0;i<g[u].size();i++){
            int v = g[u][i].F;
            double w = g[u][i].S;
            if(ans[v] > ans[u] + w){
                ans[v] = ans[u] + w;
                pq.push(mp(ans[v], v));
            }
        }
    }
 
    double ret = 1e18;
    REP(i, n){
        double d = dist(ex, ey, x[i], y[i]) - r[i];
        if(d < 0) d =0;
        ret = min(ret, ans[i]+d);
    }
    ret = min(ret, dist(sx,sy,ex,ey));
    cout << fixed << setprecision(10) << ret;
    return 0;
}

Measured memory_bytes: 23060
//InTheNameOfGod
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(i,j,k) for(int i=j;i<k;++i)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define pb push_back
#define lb(i) i&(-i);
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int maxn =1e5+5;
int n,a[maxn],ad;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>n;
    rep(i,0,n)
    {
    	cin>>a[i];
    }
    sort(a,a+n);
    while(1)
    {
    	if(a[n-1]-ad==1)
    	{
    		int x=0;
    		while(n&&a[n-1]-ad==1)
    		{
    			x++;
    			n--;
    		}
    		if(x%2==0)cout<<"First";
    		else cout<<"Second";
    		return 0;
    	}
    	if(n==1)
    	{
    		a[0]-=ad;
    		if(a[0]%2==0)cout<<"First";
    		else cout<<"Second";
    		return 0;
    	}
    	if(n>=2&&a[n-2]-ad<=1)
        {
            int x=a[n-1]-ad-1;
            int y=0;
            n--;
            while(n&&a[n-1]-ad==1)
            {
                y++;
                n--;
            }
            if(x%2||y%2)
            {
                cout<<"First";
            }
            else cout<<"Second";
            return 0;
        }
    	n--;
    	ad++;
    }
    return 0;
}


Measured memory_bytes: 640
import sys
from collections import deque

input = sys.stdin.readline


def dfs(G, v, visited):
    visited[v] = True
    stack = deque([v])
    while stack:
        v = stack.pop()
        for u in G[v]:
            if visited[u]:
                continue
            visited[u] = True
            stack.append(u)


def main():
    N, M = map(int, input().split())
    G = [[] for _ in range(N)]
    a = [0] * M
    b = [0] * M
    for i in range(M):
        a[i], b[i] = map(int, input().split())
        a[i] -= 1
        b[i] -= 1
        G[a[i]].append(b[i])
        G[b[i]].append(a[i])

    ans = 0
    for i in range(M):
        G[a[i]].remove(b[i])
        G[b[i]].remove(a[i])

        visited = [False] * N
        dfs(G, 0, visited)

        if not all(visited):
            ans += 1

        G[a[i]].append(b[i])
        G[b[i]].append(a[i])

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N,A,B;

int main() {

	scanf("%d%d%d", &N,&A,&B);



	printf("%d\n", min(N * A, B));

	return 0;
}


Measured memory_bytes: 764
#include<cstdio>
#include<algorithm>
using namespace std;

bool arr[1005];
int hash_[1005];
const int MOD = 1e9+7;
void init(){
arr[1] = 1;
arr[2] = 1;
arr[3] = 1;
arr[5] = 1;
arr[7] = 1;
arr[11] = 1;
arr[13] = 1;
arr[17] = 1;
arr[19] = 1;
arr[23] = 1;
arr[29] = 1;
arr[31] = 1;
arr[37] = 1;
arr[41] = 1;
arr[43] = 1;
arr[47] = 1;
arr[53] = 1;
arr[59] = 1;
arr[61] = 1;
arr[67] = 1;
arr[71] = 1;
arr[73] = 1;
arr[79] = 1;
arr[83] = 1;
arr[89] = 1;
arr[97] = 1;
arr[101] = 1;
arr[103] = 1;
arr[107] = 1;
arr[109] = 1;
arr[113] = 1;
arr[127] = 1;
arr[131] = 1;
arr[137] = 1;
arr[139] = 1;
arr[149] = 1;
arr[151] = 1;
arr[157] = 1;
arr[163] = 1;
arr[167] = 1;
arr[173] = 1;
arr[179] = 1;
arr[181] = 1;
arr[191] = 1;
arr[193] = 1;
arr[197] = 1;
arr[199] = 1;
arr[211] = 1;
arr[223] = 1;
arr[227] = 1;
arr[229] = 1;
arr[233] = 1;
arr[239] = 1;
arr[241] = 1;
arr[251] = 1;
arr[257] = 1;
arr[263] = 1;
arr[269] = 1;
arr[271] = 1;
arr[277] = 1;
arr[281] = 1;
arr[283] = 1;
arr[293] = 1;
arr[307] = 1;
arr[311] = 1;
arr[313] = 1;
arr[317] = 1;
arr[331] = 1;
arr[337] = 1;
arr[347] = 1;
arr[349] = 1;
arr[353] = 1;
arr[359] = 1;
arr[367] = 1;
arr[373] = 1;
arr[379] = 1;
arr[383] = 1;
arr[389] = 1;
arr[397] = 1;
arr[401] = 1;
arr[409] = 1;
arr[419] = 1;
arr[421] = 1;
arr[431] = 1;
arr[433] = 1;
arr[439] = 1;
arr[443] = 1;
arr[449] = 1;
arr[457] = 1;
arr[461] = 1;
arr[463] = 1;
arr[467] = 1;
arr[479] = 1;
arr[487] = 1;
arr[491] = 1;
arr[499] = 1;
arr[503] = 1;
arr[509] = 1;
arr[521] = 1;
arr[523] = 1;
arr[541] = 1;
arr[547] = 1;
arr[557] = 1;
arr[563] = 1;
arr[569] = 1;
arr[571] = 1;
arr[577] = 1;
arr[587] = 1;
arr[593] = 1;
arr[599] = 1;
arr[601] = 1;
arr[607] = 1;
arr[613] = 1;
arr[617] = 1;
arr[619] = 1;
arr[631] = 1;
arr[641] = 1;
arr[643] = 1;
arr[647] = 1;
arr[653] = 1;
arr[659] = 1;
arr[661] = 1;
arr[673] = 1;
arr[677] = 1;
arr[683] = 1;
arr[691] = 1;
arr[701] = 1;
arr[709] = 1;
arr[719] = 1;
arr[727] = 1;
arr[733] = 1;
arr[739] = 1;
arr[743] = 1;
arr[751] = 1;
arr[757] = 1;
arr[761] = 1;
arr[769] = 1;
arr[773] = 1;
arr[787] = 1;
arr[797] = 1;
arr[809] = 1;
arr[811] = 1;
arr[821] = 1;
arr[823] = 1;
arr[827] = 1;
arr[829] = 1;
arr[839] = 1;
arr[853] = 1;
arr[857] = 1;
arr[859] = 1;
arr[863] = 1;
arr[877] = 1;
arr[881] = 1;
arr[883] = 1;
arr[887] = 1;
arr[907] = 1;
arr[911] = 1;
arr[919] = 1;
arr[929] = 1;
arr[937] = 1;
arr[941] = 1;
arr[947] = 1;
arr[953] = 1;
arr[967] = 1;
arr[971] = 1;
arr[977] = 1;
arr[983] = 1;
arr[991] = 1;
arr[997] = 1;
}

int main(){
    int n;
    scanf("%d",&n);
    init();
    long long ans = 1;// n = 1
    for(int i=2;i<=n;i++){
        if(arr[i])hash_[i]++;// 素数
        else for(int j=2,t=i;j<=t;j++){
            while(t%j==0){
                hash_[j]++;
                t/=j;
            }
        }
    }
    for(int i=1;i<=n;i++){
        if(hash_[i])
            ans = ans*(hash_[i]+1)%MOD;
    }

    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 128