akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main()
{
  int N,H,ans=0;
  cin>>N>>H;
  vector <int> a(N),b(N);
  for(int i=0;i<N;i++){
    cin>>a[i]>>b[i];
  }
  sort(b.rbegin(),b.rend());
  sort(a.rbegin(),a.rend());

  for(int i=0;i<N;i++){
    if(H<=0 || b[i]<a[0])break;
    H-=b[i];
    ans++;
  }

  if(H>0){
    ans+=(H+a[0]-1)/a[0];
  }

  cout<<ans<<endl;

}


Measured memory_bytes: 1024
use std::cmp::{min, max};


fn main() {
    let (a, b, c, x, y) = {
        let tmp = read_vec::<i64>();
        (tmp[0], tmp[1], tmp[2], tmp[3], tmp[4])
    };

    let mut ans = i64::max_value();
    for c_count in 0..(2 * max(x, y) + 1) {
        if c_count % 2 != 0 {
            continue;
        }

        ans = min(ans, a * max(0, x - c_count / 2) + b * max(0, y - c_count / 2) + c * c_count);
    }

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define maxn 2333
using namespace std;
int a[maxn * 3];
int dp[maxn][maxn];
int DP[maxn][maxn];
int MaxR[maxn], MaxC[maxn];

bool has[maxn]; 
int main() {
//	freopen("F.in", "r", stdin);
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= 3 * n; ++i) {
		scanf("%d", a + i);
	}
	if(n == 1) {
		printf("%d\n", a[1] == a[2] && a[2] == a[3]);
	} else {
		int Max = 0;
		memset(dp, 0x80, sizeof dp);
		memset(DP, 0x80, sizeof DP);
		memset(MaxR, 0x80, sizeof MaxR);
		memset(MaxC, 0x80, sizeof MaxC);
		dp[a[1]][a[2]] = dp[a[2]][a[1]] = 0;
		has[a[1]] = has[a[2]] = true;
		int tot = 0;
		for(int _ = 1; _ < n; ++_) {
			int id = _ * 3, x, y, z;
			x = a[id], y = a[id + 1], z = a[id + 2];
			if(x == y && y == z) {
				++tot;
				continue;
			}
			for(int i = 1; i <= n; ++i) {
				if(has[i]) DP[x][i] = DP[i][x] = DP[y][i] = DP[i][y] = DP[z][i] = DP[i][z] = 0; // availability 
			}
			has[x] = has[y] = has[z] = true;
			DP[z][x] = DP[x][z] = max(Max, dp[y][y] + 1); // drop 1 card from x, y, z
			DP[x][y] = DP[y][x] = max(Max, dp[z][z] + 1);
			DP[y][z] = DP[z][y] = max(Max, dp[x][x] + 1);
			for(int i = 1; i <= n; ++i) { // drop j, y, z, left i, x
				DP[i][x] = DP[x][i] = max(DP[i][x], max(MaxR[i], MaxC[i]));
				DP[i][y] = DP[y][i] = max(DP[i][y], max(MaxR[i], MaxC[i]));
				DP[i][z] = DP[z][i] = max(DP[i][z], max(MaxR[i], MaxC[i]));
			}
			for(int i = 1; i <= n; ++i) { // drop 2 card from x, y, z
				DP[x][x] = max(DP[x][x], dp[i][x] + (i == y && y == z));
				DP[i][y] = DP[y][i] = max(DP[i][y], dp[i][x] + (x == z));
				DP[i][z] = DP[z][i] = max(DP[i][z], dp[i][x] + (x == y));
			}
			for(int i = 1; i <= n; ++i) {
				DP[y][y] = max(DP[y][y], dp[i][y] + (i == x && x == z));
				DP[i][x] = DP[x][i] = max(DP[i][x], dp[i][y] + (y == z));
				DP[i][z] = DP[z][i] = max(DP[i][z], dp[i][y] + (y == x));
			}
			for(int i = 1; i <= n; ++i) {
				DP[z][z] = max(DP[z][z], dp[i][z] + (i == x && x == y));
				DP[i][x] = DP[x][i] = max(DP[i][x], dp[i][z] + (z == y));
				DP[i][y] = DP[y][i] = max(DP[i][y], dp[i][z] + (z == x));
			}
			for(int i = 1; i <= n; ++i) {
				Max = max(Max, DP[i][x]);
				Max = max(Max, DP[i][y]);
				Max = max(Max, DP[i][z]);
				MaxR[i] = max(MaxR[i], max(DP[i][x], max(DP[i][y], DP[i][z])));
				MaxC[x] = max(MaxC[x], DP[x][i]); 
				MaxC[y] = max(MaxC[y], DP[y][i]); 
				MaxC[z] = max(MaxC[z], DP[z][i]);
				dp[i][x] = dp[x][i] = DP[i][x];
				dp[i][y] = dp[y][i] = DP[i][y];
				dp[i][z] = dp[z][i] = DP[i][z];
			}
			for(int i = 1; i <= n; ++i) DP[i][x] = DP[x][i] = DP[i][y] = DP[y][i] = DP[i][z] = DP[z][i] = 0x80808080;
//			for(int i = 1; i <= n; ++i) 
//				for(int j = 1; j <= n; ++j)
//					assert(dp[i][j] == dp[j][i]);
//			cerr << _ << endl; 
		}
		int Ans = 0;
		for(int i = 1; i <= n; ++i) {
			for(int j = 1; j <= n; ++j) {
				Ans = max(Ans, dp[i][j] + (i == j && j == a[3 * n]));
			}
		}
		Ans += tot;
		printf("%d\n", Ans);
	}
	return 0;
}

Measured memory_bytes: 46344
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
using namespace std;

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(int i=0;i<n;i++)
#define repf(i,f,n) for(int i=f;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())



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


int main() {

  char b;
  cin >> b;
  if(b=='A') cout << "T" << endl;
  if(b=='C') cout << "G" << endl;
  if(b=='G') cout << "C" << endl;
  if(b=='T') cout << "A" << endl;


}

















//


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

int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    for (int i = 0; i < N; i++) cin >> P[i];

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (P[i] == i + 1) {
            ans++;
            i++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
 
 
using namespace std;
 
 
const int MOD = 1e9 + 7;
const int N = 1e5;
const long long INF = 1e18L;
 
long long dp[N + 1];
 
int main() {
    int n, p;
    cin >> n >> p;
    int w[n], v[n];
    for (int i = 0; i < n; i++)
        cin >> w[i] >> v[i];
    fill(dp, dp + N + 1, INF);
    dp[0] = 0;
    int s = accumulate(v, v + n, 0);
    for (int i = 0; i < n; i++)
        for (int x = s - v[i]; x >= 0; x--)
            dp[x + v[i]] = min(dp[x + v[i]], dp[x] + w[i]);
    long long ans = 0;
    for (long long i = 0; i <= s; i++)
        if (dp[i] <= p)   
            ans = max(ans, i);
    cout << ans;
}


Measured memory_bytes: 1024
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal, ROUND_FLOOR

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = input().split()
A = Decimal(int(A))
B = Decimal(B)
C = A*B
print(C.quantize(Decimal("0"), rounding=ROUND_FLOOR))


Measured memory_bytes: 10664
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class T> inline T pow2_L(T a){
  return a*a;
}
int main(){
  int KL2GvlyY, Lj4PdHRW, N, Q5VJL1cS, res;
  rd(N);
  Lj4PdHRW = 0;
  KL2GvlyY = 35000;
  while(Lj4PdHRW < KL2GvlyY){
    if((Lj4PdHRW + KL2GvlyY)%2==0){
      Q5VJL1cS = (Lj4PdHRW + KL2GvlyY) / 2;
    }
    else{
      Q5VJL1cS = (Lj4PdHRW + KL2GvlyY + 1) / 2;
    }
    if(Q5VJL1cS*Q5VJL1cS <= N){
      Lj4PdHRW = Q5VJL1cS;
    }
    else{
      KL2GvlyY = Q5VJL1cS - 1;
    }
  }
  res =pow2_L((KL2GvlyY));
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190822-2

// --- original code ---
// {
//   int N, res;
//   rd(N);
//   res = (bsearch_max[int, x, 0, 35000](x*x <= N)) ** 2;
//   wt(res);
// }


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

int main()
{
    int a,b,m;
    cin >> a >> b >> m;
    
    int aa[a];
    int bb[b];
    int x[m], y[m], z[m];
    
    int mina = 100000;
    for(int i=0; i<a; i++){
        int tmp;
        cin >> tmp;
        aa[i] = tmp;
        if(tmp < mina) mina = tmp;
    }
    int minb = 100000;
    for(int i=0; i<b; i++){
        int tmp;
        cin >> tmp;
        bb[i] = tmp;
        if(tmp < minb) minb = tmp;
    }
    for(int i=0; i<m; i++){
        cin >> x[i] >> y[i] >> z[i];
        //cout << x[i] << y[i] << z[i] << endl;
    }
    /*
    int sum = 100000*2;
    for(int i=0; i<a; i++){
        for(int j=0; j<b; j++){
            int tmp = aa[i] + bb[j];
            //cout << aa[i] << "," << bb[j] << "," << tmp << endl;
            if(sum > tmp) sum = tmp;
        }
    }
    */
    
    int ans = mina + minb;
    for(int i=0; i<m; i++){
        //cout << aa[x[i]-1] << bb[y[i]-1] << z[i] << endl;
        int sum = aa[x[i]-1] + bb[y[i]-1] - z[i];
        if(sum < ans){
            ans = sum;
        }
    }
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
long long rui(long long n, long long k, long long p) {
	if (k == 0) {
		return 1;
	}
	else {
		long long a = rui(n, k / 2, p);
		if (k % 2 == 0) {
			return (a*a) % p;
		}
		return (((a*a) % p)*n) % p;
	}
}
int main(){
	int n, a, b, c;
	cin >> n >> a >> b >> c;
	cout << n - a - b + c << endl;
}


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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
std::vector<std::string> split(const std::string &str, const char delemiter) {std::vector<std::string> res;std::stringstream ss(str);std::string buffer; while( std::getline(ss, buffer, delemiter) ) res.push_back(buffer); return res;}
int msb(int x) {return x?31-__builtin_clz(x):-1;}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    ll N,K; cin >> N >> K;
    vector<ll> A(N);
    for(int i = 0; i < N; ++i) cin >> A[i];
    ll ng = 0, ok = 1e9, md;
    while(ok-ng>1){
        md = (ok+ng)/2;
        ll cnt = 0;
        for(int i = 0; i < N; ++i){
            cnt += (A[i]/md)-(A[i]%md==0?1:0); 
        }
        (cnt<=K?ok:ng)=md;
    }    
    cout << ok << endl;
    return 0;
}


Measured memory_bytes: 4764
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int n;
  scan(n);
  ll ans = 0;
  rep (i, n) {
    int l, r;
    scan(l, r);
    ans += (r - l + 1);
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define sz(a) (int)a.size()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int P = 1e9 + 7;
inline int add(int a, int b) {if((a += b) >= P) a -= P; return a;}
inline int sub(int a, int b) {if((a -= b) < 0) a += P; return a;}
inline int mul(int a, int b) {return 1ll * a * b % P;}
inline int kpow(int a, int b) {int r=1;for(;b;b>>=1,a=mul(a,a)) {if(b&1)r=mul(r,a);}return r;}
//----
const int N = 202020;
int n;
int a[N], b[N];
int main(){
	scanf("%d", &n);
	rep(i, 0, n) scanf("%d", a + i), b[i] = a[i];
	sort(b, b + n);
	int m = n / 2;
	rep(i, 0, n) {
		if(a[i] < b[m]) printf("%d\n", b[m]);
		else printf("%d\n", b[m - 1]);
	}
	return 0;
}


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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long res = a * c;
  res = max(a * d, res);
  res = max(b * d, res);
  res = max(b * c, res);
  cout << res << "\n";
}



Measured memory_bytes: 3216
data = input().split()
data.reverse()
stk = []

for i in range(len(data)):
    tmp = data.pop()
    if tmp == '+':
        tmp1 = stk.pop()
        tmp2 = stk.pop()
        stk.append(int(tmp2)+int(tmp1))
    elif tmp == '-':
        tmp1 = stk.pop()
        tmp2 = stk.pop()
        stk.append(int(tmp2)-int(tmp1))
    elif tmp == '*':
        tmp1 = stk.pop()
        tmp2 = stk.pop()
        stk.append(int(tmp2) * int(tmp1))
    else:
        stk.append(tmp)

print(stk.pop())

Measured memory_bytes: 7688
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int n;
    cin >> n;
    int a[n];
    int b[n];
    rep(i, 2) {
        rep(j, n) {
            if(i) cin >> b[j];
            else cin >> a[j];
        }
    }
    int ans = 0;
    rep(i, n) {
        int cou = 0;
        rep(j, i+1) {
            cou += a[j];
        }
        for (int j = i; j < n; j++) {
            cou += b[j];
        }
        ans = max(ans, cou);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
char s[10];
int main()
{
	scanf("%s",s);
	int len=strlen(s);
	for(int i=0;i<len;i++)
	  if(s[i]=='A'&&s[i+1]=='C') return printf("Yes"),0;
	puts("No");
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    long long n,m,l,p,g=1;
    cin>>n>>m;
    l=p=m/n;
    for(long long i = 1;i<p;i++){
        if(m%i==0){
            if(i<=l)g=max(g,i);
            if(i>=n)g=max(g,m/i);
        }
        p=m/i;
    }
    cout<<g<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  ll h,w,m;
  cin>>h>>w>>m;

  vector<pair<ll,int>>p(h);
  vector<pair<ll,int>>q(w);
  map<pair<int,int>,int> r;
  rep(i,h) p[i]={0,i};
  rep(i,w) q[i]={0,i};

  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    p[a].fi++;
    q[b].fi++;
    r[{a,b}]=1;
    }

  sort(all(p));
  reverse(all(p));
  sort(all(q));
  reverse(all(q));

  ll ans=0;
  rep(i,w){
    ll x=p[0].fi+q[i].fi;
    if(r.count({p[0].se,q[i].se})) x--;
    chmax(ans,x);
  }

  rep(i,h){
    ll x=p[i].fi+q[0].fi;
    if(r.count({p[i].se,q[0].se})) x--;
    chmax(ans,x);
  }

  cout << ans << endl;

}

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

using namespace std;


typedef int32_t h_int32;
typedef int64_t h_int64;
typedef uint32_t uh_int32;
typedef uint64_t uh_int64;
typedef h_int64 h_int;

#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 FOR( i, a, n ) for(int i = ( int )( a ); i < ( int )( n ); ++i )
#define FORR( i, a, n ) for(int i = ( int )( n ); i >= ( int )( a ); --i)

#define VINIT( v, type, n )vector<type> v; v.resize( n );
#define VINIT2( v, type, n, a )vector<type> v; v.resize( n, a );
#define VCIN( v, type, n ) VINIT( v, type, n ) REP( i, n ) cin >> v[i];

#define DOUT( x ) cerr << #x << " = " << x << "\n";
#define COUT( x ) cout << ( x ) << "\n";

#define INF 999999999



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

        int cnt = 0;
        while(n > 0)
        {
                n >>= 1;
                ++cnt;
        }
        COUT( 1 << ( cnt - 1 ) );
        return 0;
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  rep(i,s.size()-1){
    if( s[i] == s[i+1] ){
      cout << i+1 << " " << i+2 << endl;
      return 0;
    }
  }
  rep(i,s.size()-2){
    if(s[i] == s[i+2]){
      cout << i+1 << " " << i+3 << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << "\n";
  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>

int partition(int *, int, int);

int main(){

  int n,r,i,*A,p;

  scanf("%d",&n);

  A = malloc(sizeof(int)*n); 

  for(i = 0 ; i < n ; i++)
    scanf("%d",&A[i]);

  p = partition(A, 0, n-1);

  for(i = 0 ; i < n ; i++){
    if(i == p) printf("[%d] ",A[i]);
    else if(i == n-1) printf("%d\n",A[i]);
    else printf("%d ",A[i]);
  }

  return 0;

}


int partition(int *A, int p, int r){

  int x,i,j,tmp;

  x = A[r];
  i = p-1;

  for(j = p ; j <= r-1 ; j++){
    if(A[j] <= x){
      i++;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
    tmp = A[i+1];
    A[i+1] = A[r];
    A[r] = tmp;

    return i+1;

}

Measured memory_bytes: 988
x=int(input())
ans=-1
if(x>=400 and x<=599):
    ans=8
elif(x>=600 and x<=799):
    ans=7
elif(x>=800 and x<=999):
    ans=6
elif(x>=1000 and x<=1199):
    ans=5
elif(x>=1200 and x<=1399):
    ans=4
elif(x>=1400 and x<=1599):
    ans=3
elif(x>=1600 and x<=1799):
    ans=2
elif(x>=1800 and x<=1999):
    ans=1
print(ans)

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

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


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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int n, m, q;
vector<int> a, b, c, d;
lol result{0};

void dfs(vector<int> s)
{
    if(s.size()==n+1)
    {
        lol now = 0;
        REP(i, q)
        {
            if(s[b[i]]-s[a[i]]==c[i])
                now += d[i];
        }
        result = max(result, (lol)now);
        return;
    }
    s.push_back(s.back());
    while(s.back()<=m)
    {
        dfs(s);
        s.back()++;
    }
}

int main()
{
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    REP(i, q)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vector<int>(1, 1));
    
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_map>

template<typename T>
class cUnionFind{
private:
	struct cNode{
		T data;
		size_t parent;
		size_t rank;
		cNode(T data_,size_t parent_,size_t rank_)
			:data(data_),parent(parent_),rank(rank_){}
	};
private:
	std::vector<cNode> Buf;
	std::unordered_map<T,size_t> Hash;
public:
	cUnionFind(){}
private:
	bool link(T x_,T y_){
		auto x_itr=Hash.find(x_);
		auto y_itr=Hash.find(y_);

		if(x_itr==Hash.end() || y_itr==Hash.end())return true;

		size_t x_index=x_itr->second;
		size_t y_index=y_itr->second;

		if(Buf[x_index].rank>Buf[y_index].rank){
			Buf[y_index].parent=x_index;
		}
		else{
			Buf[x_index].parent=y_index;
			if(Buf[x_index].rank==Buf[y_index].rank){
				++Buf[y_index].rank;
			}
		}

		return false;
	}
	size_t find_set_helper(size_t index_){
		if(index_!=Buf[index_].parent){
			size_t ans_index=find_set_helper(Buf[index_].parent);
			Buf[index_].parent=ans_index;
		}

		return Buf[index_].parent;
	}
public:
	bool make_set(T data_){
		size_t index=Buf.size();
		Buf.emplace_back(cNode(data_,index,0));
		auto ans=Hash.insert(std::make_pair(data_,index));
		return !ans.second;
	}
	std::pair<T,bool> find_set(T x_){
		auto x_itr=Hash.find(x_);
		if(x_itr==Hash.end())return std::make_pair(x_,true);

		size_t index=x_itr->second;
		if(Buf[index].parent!=index){
			Buf[index].parent=find_set_helper(Buf[index].parent);
		}

		return std::make_pair(Buf[Buf[index].parent].data,false);
	}
	bool union_set(T x_,T y_){
		return link(find_set(x_).first,find_set(y_).first);
	}
};

using namespace std;

const double pi=4*atan(1.0);

int mod=1000000007;

int main() {
	int n,q;
	cin>>n>>q;
	cUnionFind<int> UnionFind;
	for(int i=0;i<n;++i){
		UnionFind.make_set(i);
	}

	vector<array<int,3>> Query(q);
	for(auto& val:Query){
		int query,x,y;
		cin>>query>>x>>y;
		val={query,x,y};
	}

	for(const auto& val:Query){
		int query,x,y;
		query=val[0];
		x=val[1];
		y=val[2];

		if(query==0){
			UnionFind.union_set(x,y);
		}
		else{
			if(UnionFind.find_set(x)==UnionFind.find_set(y)){
				cout<<1<<endl;
			}
			else{
				cout<<0<<endl;
			}
		}
	}

	//system("pause");
	return 0;
}

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



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    

    void calc()
    {
        cin = new Scanner();
        long n = cin.nextLong();
        long s = cin.nextLong();

        
        for (int b = 2; b <= 1000000; b++)
        {
            if(calc2(n, b) == s)
            {
                Console.WriteLine(b); return;
            }
        }
        
        long start = n / 1000000;
        for (long i = start; i >= 1; i--)
        {
            long amari = s - i;
            if (amari < 0) continue;
            long b = (n - amari) / i;
            if(b * i + amari == n && b > amari && b > i)
            {
                Console.WriteLine(b); return;
            }
        }

        if(n == s)
        {
            Console.WriteLine(n + 1);
            return;
        }

        Console.WriteLine(-1);
    }

    long calc2(long n, long b)
    {
        long ans = 0;
        while(n != 0)
        {
            ans += n % b;
            n /= b;
        }
        return ans;
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13140
//To compile : type "$     g++ test.cpp -std=c++14 -I .    "
#include <atcoder/lazysegtree>
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
using namespace atcoder;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;


template <unsigned long long mod > class modint{
public:
    ll x;
    constexpr modint(){x = 0;}
    constexpr modint(ll _x) : x((_x < 0 ? ((_x += (LLONG_MAX / mod) * mod) < 0 ? _x + (LLONG_MAX / mod) * mod : _x) : _x)%mod){}
    constexpr void set_raw(ll _x){
        //_x in [0, mod)
        x = _x;
    }
    constexpr modint operator-(){
        return x == 0 ? 0 : mod - x;
    }
    constexpr modint& operator+=(const modint& a){
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr modint operator+(const modint& a) const{
        return modint(*this) += a;
    }
    constexpr modint& operator-=(const modint& a){
        if((x -= a.x) < 0) x += mod;
        return *this;
    }
    constexpr modint operator-(const modint& a) const{
        return modint(*this) -= a;
    }
    constexpr modint& operator*=(const modint& a){
        (x *= a.x)%=mod;
        return *this;
    }
    constexpr modint operator*(const modint& a) const{
        return modint(*this) *= a;
    }
    constexpr modint pow(unsigned long long pw) const{
        modint res(1), comp(*this);
        while(pw){
            if(pw&1) res *= comp;
            comp *= comp;
            pw >>= 1;
        }
        return res;
    }
    //以下、modが素数のときのみ
    constexpr modint inv() const{
        return modint(*this).pow(mod - 2);
    }
    constexpr modint& operator/=(const modint &a){
        (x *= a.inv().x)%=mod;
        return *this;
    }
    constexpr modint operator/(const modint &a) const{
        return modint(*this) /= a;
    }
};
#define mod1 998244353
using mint = modint<mod1>;

ostream& operator<<(ostream& os, const mint& a){
    os << a.x;
    return os;
}
using vm = vector<mint>;

ll N,M,H,W,Q,K,A,B;
//string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

vm ten(400010);
vector<vm> one_to_nine(9, vm(400010));

struct S {
	ll sz;
	mint sum;
    S(ll _sz, mint a) : sz(_sz), sum(a){}
};

using F = int;

S op(S s, S t){
	return S(s.sz + t.sz, s.sum * ten[t.sz] + t.sum);
}

S e(){ return S(0, 0); }

S mapping(F f, S s){
	if(f == 0) return s;
	else return S(s.sz, one_to_nine[f - 1][s.sz]);
}

F composition(F f, F g){
	if(f == 0) return g;
	else return f;
}

F id(){ return 0; }

int main() {
	cin>>N>>Q;
	ten[0] = 1;
	rep(j, 9) one_to_nine[j][1] = j + 1;
	reps(i, 1, 400009){
		ten[i] = ten[i-1] * 10;
		rep(j, 9){
			one_to_nine[j][i+1] = one_to_nine[j][i] * 10 + j + 1;
		}
	}
	vector<S> for_init(N, S(1, 1));
	lazy_segtree<S, op, e, F, mapping, composition, id> seg(for_init);
	rep(_, Q){
		int l, r, d;
		cin>>l>>r>>d;
		--l;
		seg.apply(l, r, d);
		cout<<seg.all_prod().sum<<endl;
	}
}

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

int main() {
  int N=0,K=0;
  cin >> N >> K;

  // ここにプログラムを追記
  int Kekka=0,i=0;
  Kekka=1;
  for (int i=0; i<N; i++) {
    if (Kekka*2>Kekka+K) {
      Kekka+=K;
    } else {
      Kekka*=2;
    }
  }
  cout << Kekka << endl;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define repr(i, a, b) for (int i = a; i > b; i--)
#define all(A) A.begin(), A.end()
typedef long long ll;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

vector<pair<char, int> > run_length_encoding(string s){
    vector<pair<char, int> > res;
    s += '$';
    char c = s[0];
    int now = 1;
    for(int i = 1; i < s.size(); i++){
        if(s[i] != c){
            res.push_back(pair<char, int>(c, now));
            c = s[i]; now = 1;
        }else now++;
    }
    return res;
}

int main() {
    int N;
    string S;
    cin >> N >> S;
    auto r = run_length_encoding(S);
    int ans = r.size();
    cout << ans << endl;
}

Measured memory_bytes: 1656
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

signed main(){
    

    int R, G, B, N; cin >> R >> G >> B >> N;
    int ans = 0;
    for(int r = 0; r <= N; r++){
        for(int g = 0; g <= N; g++){
            if((N - r * R - g * G) >= 0 && (N - r * R - g * G) % B == 0){
                ans++;   
            }
        }
    }

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



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

int s[100000];

int main(){
	int n;
	cin >> n;
	for(int i = 1;i <= n;i++) cin >> s[i];
	sort(s + 1,s + n + 1);
	int m = s[n] - s[1];
	cout << m;
}

Measured memory_bytes: 256
#include <stdio.h>

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

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

int main() {
    string s;
    int ans;

    cin>>s;

    if (s=="SUN") ans=7;
    else if(s=="MON") ans=6;
    else if(s=="TUE") ans=5;
    else if(s=="WED") ans=4;
    else if(s=="THU") ans=3;
    else if(s=="FRI") ans=2;
    else ans=1;

    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
using namespace std;
typedef long long lli;
lli n,k,l;
template <typename T>
class union_find : public vector<pair<lli,lli> >{
public:
    union_find():vector<pair<lli,lli> >(){}
    union_find(lli n):vector<pair<lli,lli> >(n){
        for(lli i = 0;i < n;i++){
            (*this)[i].first = i;
            (*this)[i].second = 0;
        }
    }
    lli find(T x){
        if((*this)[x].first == x) return x;
        else return (*this)[x].first = find((*this)[x].first);
    }
    void unite(T x,T y){
        x = find(x);y = find(y);
        if(x == y) return;
        if((*this)[x].second < (*this)[y].second) (*this)[x].first = y;
        else {
            (*this)[y].first = x;
            if((*this)[x].second == (*this)[y].second) (*this)[x].second++;
        }
    }
    bool same(T x,T y){
        return find(x) == find(y);
    }
};

union_find<lli> ufr;
union_find<lli> uft;
map<pair<lli,lli>,lli > m;
vector<lli> ans;
int main(int argc, char const *argv[]) {
    cin >> n >> k >> l;
    ufr = union_find<lli>(n+1);
    uft = union_find<lli>(n+1);
    for(lli i = 0;i < k;i++){
        lli p,q;
        cin >> p >> q;
        ufr.unite(p,q);
    }
    for(lli i = 0;i < l;i++){
        lli r,s;
        cin >> r >> s;
        uft.unite(r,s);
    }
    for(lli i = 1;i <= n;i++){
        m[make_pair(ufr.find(i),uft.find(i))]++;
    }
    for(lli i = 1;i < n;i++){
        cout << m[make_pair(ufr.find(i),uft.find(i))] << " ";
    }
    cout << m[make_pair(ufr.find(n),uft.find(n))] << endl;

    return 0;
}


Measured memory_bytes: 18048
#!/usr/bin/env python3

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def main():
    a = input()
    n = len(a)
    di = {c: 0 for c in ABC}
    for c in a:
        di[c] += 1
    invdi = {c: n - di[c] for c in ABC}
    res = 0
    for c in ABC:
        res += di[c] * invdi[c]
    assert res % 2 == 0
    res //= 2
    res += 1
    print(res)


main()


Measured memory_bytes: 4008
#include<bits/stdc++.h>
#define N 101
using namespace std;
int dp[N][4][4],n,k,d[N];

int solve(int x,int d1,int d2){
   if(x==0) return 1;
   if(dp[x][d1][d2]>0) return dp[x][d1][d2];
  if(d[x]>0){
    if(d1!=d[x] || d2!=d[x]) dp[x][d1][d2]=(dp[x][d1][d2]+solve(x-1,d[x],d1))%10000;
  }
  else {
    for(int i=1;i<4;i++){
      if(d1==i && d2==i)continue;
      else dp[x][d1][d2]=(dp[x][d1][d2]+solve(x-1,i,d1))%10000;
    }
  }
  return dp[x][d1][d2];
}

int main(){
  cin>>n>>k;
  int a,b;
  for(int i=0;i<n;i++)
    for(int j=0;j<4;j++)
      for(int k=0;k<4;k++)dp[i][j][k]=0;

  for(int i=0;i<k;i++)cin>>a>>b,d[a]=b;
  cout<<solve(n,0,0)<<endl;
  return 0;
}

Measured memory_bytes: 1168
fn main() {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).unwrap();
  let mut iter = s.split_whitespace();

  let n: i32 = iter.next().unwrap().parse().unwrap();
  let d: i32 = iter.next().unwrap().parse().unwrap();

  let ans = (n + d * 2) / (d * 2 + 1);

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


Measured memory_bytes: 4352
N = int(input())
W_list = list(map(int, input().split()))

ans = 0

for i in range(N):
    ans += W_list[i]
    if sum(W_list)/2 < ans:
        if ans - sum(W_list)/2 >= sum(W_list)/2 - (ans - W_list[i]):
            print((sum(W_list) - (ans - W_list[i])) - (ans - W_list[i]))
            exit()
        else:
            print(ans - (sum(W_list) - ans))
            exit()

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

#define For(i,a,b) for(int (i) = (a);(i) < (b);i++)
#define Rep(i,n) For((i),0,(n))
#define All(a) (a).begin(),(a).end()
#define sp " "
#define INF 1e18
#define INT_INF 1e9
#define MAX 1000

typedef long long ll;
const ll MOD = 1000000007;
const ll MOD_9 = 998244353;

int main(){
    int n;
    cin >> n;
    vector<ll> A(n);
    int ans = 0;
    Rep(i,n){
        cin >> A[i];
    }
    sort(All(A));
    Rep(i,n-1){
        if(A[i] != A[i+1])ans++;
    }
    cout << ans+1 << endl;
    //cin >> n;
}


Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if(a > b){
    cout<< "a > b" << endl;
    }
    else if(a < b){
    cout<< "a < b" << endl;
    }
    else{
        cout<< "a == b" << endl;
    }
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
long long power(long long x, long long y, long long m) 
{ 
    if (y == 0) 
        return 1; 
    long long p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
} 
long long gcd(long long a,long long b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b%a, a); 
} 
long long modInv(long long a,long long m)
{
	return power(a,m-2,m);
}
int main()
{
	const long long Mod = 998244353;
	long long n,m,k;
	cin>>n>>m>>k;
	vector<long long> fac(n);
	fac[0]=1;
	for(int i = 1;i<n;i++)
		fac[i] = (i*fac[i-1])%Mod;
	long long ans = 0;
	for(int k1=0;k1<=k;k1++)
	{
		ans = ans + (((((fac[n-1]*modInv(fac[k1],Mod))%Mod)*modInv(fac[n-1-k1],Mod))%Mod)*((m*power(m-1,n-1-k1,Mod))%Mod))%Mod;
		ans%=Mod;
	}
	cout<<ans<<'\n';
}


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

using namespace std;

using ll = long long;

constexpr ll mod = 1e9 + 7;

ll dp[22][1 << 21];

inline int next_bit_perm(int v) {
  int t = v | (v - 1);
  return (t + 1) | (((~t & -~t) - 1) >> (__builtin_ctz(v) + 1));
}

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

  int n;
  cin >> n;

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

  for (int i = 1; i < n; ++i) {
    vector<int> a;
    for (int j = 0; j < n; ++j) {
      int tmp;
      cin >> tmp;
      if (tmp) {
        a.emplace_back(j);
      }
    }
    int mask = (1 << n) - 1;
    for (int j: a) {
      for (int s = (1 << i) - 1; s < (1 << n); s = next_bit_perm(s)) {
        dp[i + 1][s | (1 << j)] = (dp[i + 1][s | (1 << j)] + dp[i][s]) % mod;
      }
    }
  }

  cout << dp[n][(1 << n) - 1] << '\n';

  return 0;
}


Measured memory_bytes: 323840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
#define REP(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(ll (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define _GLIBCXX_DEBUG

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<1000000007>;

const double PI = 3.14159265358979323846;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main()
{	
    int a, b;
    cin >> a >> b;

    cout << a*b << endl;
}


Measured memory_bytes: 3632