akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1e6;

int main() {
    int n;
    cin >> n;

    vector<int> dp(n+1, INF);  // dp[i] : i円引き出すのに必要な操作回数の最小値

    dp[0] = 0;
    for(int i = 1; i <= n; i++) {

        int a = 1;
        while(a <= i) {
            dp[i] = min(dp[i], dp[i-a] + 1);
            a *= 6;
        }
        
        int b = 1;
        while(b <= i) {
            dp[i] = min(dp[i], dp[i-b] + 1);
            b *= 9;
        }
    }

    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 640
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a;
    string s;
    cin >>a >>s;
    if(a < 3200)
        cout <<"red";
    else 
        cout <<s;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> b(n);
	for(int i=0;i<n;i++){
		cin >> b[i];
	}
	vector<double> x(n);
	x[0]=b[0];
	for(int i=1;i<n;i++){
		x[i]=b[i];
		for(int j=0;j<i;j++){
			x[i]=max(x[i],x[j]+2.0*sqrt(b[i]*b[j]));
		}
	}
	double res=0;
	for(int i=0;i<n;i++){
		res=max(res,x[i]+b[i]);
	}
	printf("%.9f\n",res);
}



Measured memory_bytes: 3244
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int N,M;
int p[100001];
vector<int> G[100001];
int visited[100001];
int ans=0,c=1;
void dfs(int v){
  visited[v]=c;
  for(int i=0;i<G[v].size();i++){
    int u=G[v][i];
    if(visited[u]==0)dfs(u);
  }
}
int main(){
  cin >> N >> M;
  for(int i=0;i<N;i++){
    cin >> p[i];
    p[i]--;
  }
  for(int i=0;i<M;i++){
    int x,y;
    cin >> x >> y;
    x--;y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  for(int i=0;i<N;i++){
    if(visited[i]==0){
      dfs(i);
      c++;
    }
  }
  for(int i=0;i<N;i++){
    if(visited[i]==visited[p[i]])ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8576
import java.util.*;

public class Main {
    int n, m;
    ArrayList<Integer>[] es;

    public static void main(String[] args) {
        Main m = new Main();
        m.read();
        m.solve();
    }

    void read() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        es = new ArrayList[n];
        for (int i = 0; i < n; i++)
            es[i] = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            es[a].add(b);
            es[b].add(a);
        }
    }

    void solve() {
        int[] log = new int[n];
        Arrays.fill(log, Integer.MAX_VALUE);
        PriorityQueue<Node> queue = new PriorityQueue<>(Comparator.comparing(Node::getCost));
        queue.add(new Node(0, 0));
        log[0] = 0;
        while (!queue.isEmpty()) {
            Node a = queue.poll();
            if (log[a.current] < a.cost) continue;
            log[a.current] = a.cost;
            for (int e: es[a.current]) {
                if (log[a.current] + 1  <= 2)
                    queue.add(new Node(e, log[a.current]+1));
            }
        }
        if (log[n-1] <= 2)
            System.out.println("POSSIBLE");
        else
            System.out.println("IMPOSSIBLE");
    }

    private class Node {
        int current;
        int cost;
        Node (int curr, int c) {
            current = curr;
            cost = c;
        }

        public int getCost() {
            return cost;
        }
    }
}


Measured memory_bytes: 145320
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int X;

  cin >> X;

  int fhun = 0;
  int five = 0;
  int amari;

  fhun = X / 500;
  amari = X % 500;
  five = amari / 5;

  int ure;

  ure = fhun * 1000 + five * 5;

  cout << ure << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

int main() {
    string s;
    cin >> s;
    int mon = (s[5]-'0')*10 + (s[6]-'0');
    int day = (s[8]-'0')*10 + (s[9]-'0');
    if (mon > 4) cout << "TBD" << endl;
    else cout << "Heisei" << endl;
    return 0;
}

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

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;}
template<class T> inline T gcd(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T lcm(T a,T b){return a*b/gcd(a,b);}

const int INF=1e9;
const double eps=0.0000000001;

int main(){
  int n;
  cin >> n;
  string s;
  int ketua=0;
  int atamab=0;
  int ab=0,v=0;
  FOR(j,n){
    cin >> s;
    if(s[0]=='B' && s[s.size()-1]=='A')v++;
    FOR(i,s.size()){
      if(i==0 && s[i]=='B')atamab++;
      if(i==s.size()-1 && s[i]=='A')ketua++;

      if(i==s.size()-1)break;
      if(s[i]=='A' && s[i+1]=='B')ab++;

    }
  }
  if(atamab+ketua==v*2 && v!=0)ab--;
  cout << ab+min(ketua,atamab) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int n, m, cnt[305], y[5], ta;
char x[105];
 
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf("%s", x);
		for (int j = 0; j < m; j++) {
			cnt[x[j]]++;
			if (i < n - 1 - i)
				ta = 2;
			else if (i == n - 1 - i)
				ta = 1;
			else
				ta = 0;
			if (j > m - 1 - j)
				ta = 0;
			else if (j < m - 1 - j)
				ta *= 2;
			// printf("%d\n", ta);
			y[ta]++;
		}
	}
	// printf("%d %d %d\n", y[1], y[2], y[4]);
	for (int i = 'a'; i <= 'z'; i++)
		if (cnt[i] % 2)
			cnt[i]--, y[1]--;
	if (y[1] > 0 && y[1] % 2 == 0) {
		y[2] += y[1] / 2;
		y[1] = 0;
	}
	for (int i = 'a'; i <= 'z'; i++)
		if (cnt[i] % 4 == 2)
			cnt[i] -= 2, y[2]--;
	if (y[2] > 0 && y[2] % 2 == 0) {
		y[4] += y[2] / 2;
		y[2] = 0;
	}
	for (int i = 'a'; i <= 'z'; i++)
		y[4] -= cnt[i] / 4;
	// printf("%d %d %d\n", y[1], y[2], y[4]);
	printf(y[1] == 0 && y[2] == 0 && y[4] == 0 ? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define out(st) cout << st << endl;

#define ll long long
#define ull unsigned long long

ll gcd(ll a, ll b) {
    if (a < b) return gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

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

    if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) {
        Yes;
    } else {
        No;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    int ans = 0;
    
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }

    vector<int> B(N);
    for (int i = 0; i < N; i++) {
        cin >> B.at(i);
    }

    vector<int> C(N-1);
    for (int i = 0; i < N-1; i++) {
        cin >> C.at(i);
    }
    // cout << endl;
    // cout << C.at(0) << endl;
    // cout << C.at(1) << endl;

    for(int i =0;i<N-1;i++){
        if(A.at(i) +1 == A.at(i+1)){
            ans += C.at(A.at(i)-1);
           // cout << "in" << C.at(i) << endl;
        }
    }

    for(int i=0;i<N;i++){
        ans += B.at(i);
    }
    cout << ans << endl;
    


}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
C = [0]

for i in range(1, len(H)):
  if H[i-1] < H[i]:
    C.append(i)
C.append(N)
    
D = [C[j+1] - C[j] - 1 for j in range(len(C)-1)]

print(max(D))

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

int main() {
  string s;
  cin >> s;
  rep(i,0,s.size()){
    if(s[i] == '?') cout << 'D';
    else cout << s[i];
  }
  cout << "" << endl;
}

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

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  string s;
  cin >> s;
  int len = s.length();
  vector<char> left((len-1)/2), right((len-1)/2);
  rep(i,(len-1)/2+1) {
    left[i] = s[i];
    right[i] = s[i + (len-1)/2+1];
  }
  bool ok = true;
  if (left != right) ok = false;
  reverse(all(right));
  if (left != right) ok = false;
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(void){
    int n,k,all=0;
    scanf("%d%d",&n,&k);
    int a[n];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<n-1;j++){
            if(a[j]<a[j+1]){
                int u=a[j];
                a[j]=a[j+1];
                a[j+1]=u;
            }
        }
    }

    for(int i=0;i<k;i++){
        all=all+a[i];
    }

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

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

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

using namespace std;


int main() {
    int n;
    cin >> n;
    int temp, temp1;
    vector< pair<int, int> > v;
    pair<int, int>  temp2;
    rep(i, n) {
        cin >> temp >> temp1;
        temp2.first = temp1;
        temp2.second = temp;
        v.push_back(temp2);
    }

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

    

    /*rep(i, n) {
        cout << v[0][i] << " ";
        cout << v[1][i] << endl;
    }*/

    int time = 0;

    for (int i = 0; i < n; i++) {
        time += v[i].second;
        if (time > v[i].first) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";

    

    return 0;
}

Measured memory_bytes: 2420
#include <stdio.h>  /*入出力*/
#include <stdlib.h> /*標準ライブラリ*/
#include <string.h> /*文字列*/
#include <math.h>   /*計算*/
#include <assert.h> /*確認*/
#include <ctype.h>  /*文字操作*/
#include <stdbool.h>/*bool型*/
#include <limits.h>/*限界*/
//---------------------------------------------------
#define rep(i, n) for(int  i = 0; i < (n); i++)
#define ABS(a) (((a)>(0))?a:-(a))
#define LL long long
#define MOD 1000000007//10^9+7(素数)
//---------------------------------------------------
LL max(LL a, LL b){
  if (a > b) {
    return a;
  }else return b;
}

int main(void)
{
  LL a;
  LL b;
  LL x;
  scanf("%lld", &x);
  for (LL i = -6000; i < 6000; i++) {
    for (LL j = -6000; j < 6000; j++) {
      a = (((i*i)*i)*i)*i;
      b = (((j*j)*j)*j)*j;
      if ( x ==  (a-b) ) {
        printf("%lld %lld\n", i, j);
        return 0;
      }
    }
  }

}


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

using namespace std;

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


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int n, i;
    int a[100];
    scanf("%d", &n);

    for (i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
    }
    for (i = n; i >= 2; i--)
    {
        printf("%d ", a[i]);
    }
    printf("%d\n", a[1]);
    return 0;
}


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

using namespace std;

typedef long long ll;

#define rep(i, n) for (int i = 0 ; i < (int)(n) ; ++i)
#define rep2(i, n, a) for (int i = a ; i < (int)(n) ; ++i)

#define per(i, n) for (int i = n ; i >= 0 ; --i)

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

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

  int highScore = 0;
  rep(i, S.length() - T.length() + 1) {
    int score = 0;

    rep(j, T.length()) {
      if (S[i + j] == T[j]) {
        ++score;
      }
    }

    highScore = max(highScore, score);
  }

  cout << (T.length() - highScore) << '\n';

  return 0;
}

Measured memory_bytes: 3644
#include <iostream>
using namespace std;
 
int main() {
	long long n, m, t[10000^5], sum=0;
scanf("%d\n",&n) ;
for( int i=1;i<=n;i++) {
scanf("%d",&t[i] ) ;
sum+=t[i] ;
} 
scanf("%d\n",&m) ;
for(int j=1;j<=m;j++) {
int a, b ;
scanf("%d %d\n",&a,&b) ;
printf("%d\n", sum-t[a]+b) ;
} 
 
 
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast","unroll-loops")
#pragma GCC push_options
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include <xmmintrin.h>
#include <immintrin.h>
using namespace::std;
__attribute__((constructor))void init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// typedef mp::number<mp::cpp_dec_float<0>> cdouble;
// typedef mp::cpp_int cint;
template<typename T>using pbds=__gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T>using pbds_map=__gnu_pbds::tree<T,T,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T,typename E>using hash_map=__gnu_pbds::gp_hash_table<T,E>;
template<typename T>using pqueue =__gnu_pbds::priority_queue<T, greater<T>,__gnu_pbds::rc_binomial_heap_tag>;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define MOD 1000000007LL
//#define MOD 998244353LL
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(lint i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(lint i=0;i<t.size();i++)output(t[i]);}
#define rep(i,n) for(lint i=0;i<lint(n);++i)
#define repi(i,a,b) for(lint i=lint(a);i<(lint)(b);++i)
#define rrep(i,n) for(lint i=lint(n)-1;i>=0;--i)
#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)
#define irep(i) for(lint i=0;;++i)
#define all(n) begin(n),end(n)
#define dist(a,b,c,d) sqrt(pow(a-c,2)+pow(b-d,2))
inline lint gcd(lint A,lint B){return B?gcd(B,A%B):A;}
inline lint lcm(lint A,lint B){return A/gcd(A,B)*B;}
// inline cint cgcd(cint A,cint B){return B?cgcd(B,A%B):A;}
// inline cint clcm(cint A,cint B){return A/cgcd(A,B)*B;}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
const vector<lint> dx={1,0,-1,0,1,1,-1,-1};
const vector<lint> dy={0,1,0,-1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
auto call=[&](auto f,auto... args){return f(f,args...);};

int main(){
    lint a,b,c;
    cin>>a>>b>>c;
    if(a+b+1>=c){
        cout<<b+c<<endl;
    }else{
        cout<<b+a+b+1<<endl;
    }
}

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

void shift(char *str, int n)
{
    int i, j;
    
    for (i = 0; i < strlen(str); i++) {
        if (str[i] == ' ' || str[i] == '.')
                continue;
        for (j = n; j > 0; j--) {
            if (str[i] == 'z') {
                str[i] = 'a';
            } else {
                str[i]++;
            }
        }
    }
}

int search(char *str, char *key)
{
    int i;
    
    while (*str != '\0') {
        for (i = 0; key[i] != '\0'; i++) {
            if (key[i] != str[i])
                break;
        }
        if (key[i] == '\0')
            return 1;
        str++;
    }
    return 0;
}

int main(void)
{
    int i;
    char str[80];
    
    while (scanf("%[^\n]%*c", str) != EOF) {
        for (i = 0; i <= 25; i++) {
            shift(str, 1);
            if (search(str, "the") == 1 || search(str, "this") == 1 || search(str, "that") == 1) {
                printf("%s\n", str);
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using G = vector<vector<int>>;
    
int main(){
    int n;
    cin >> n;
    vector<ll> l(n);
    rep(i,n) cin >> l[i];
    sort(l.begin(), l.end());
    int ans = 0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            for(int k=j+1; k<n; k++){
                if(l[k]<l[i]+l[j]) {
                    if(l[i]!=l[j] && l[j]!=l[k] && l[k]!=l[i]){
                    ans++;
                    }
                }
                
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()

using P = pair<int, int>;

struct UnionFind {
    vector<int> p;
    UnionFind(int n) : p(n, -1) {};
    bool unite(int u, int v) {
        if ((u = root(u)) == (v = root(v))) return false;
        if (p[u] > p[v]) swap(u, v);
        p[u] += p[v]; p[v] = u;
        return true;
    }
    bool find(int u, int v) { return root(u) == root(v); }
    int root(int u) { return p[u] < 0 ? u : p[u] = root(p[u]); }
    int size(int u) { return -p[root(u)]; }
};

struct edge {
    int from, to, cost;
    edge() {};
    edge(int _from, int _to, int _cost) {
        from = _from; to = _to; cost = _cost;
    };
    bool operator<(const edge& e) {
        if (cost != e.cost) return cost < e.cost;
        if (from != e.from) return from < e.from;
        if (to != e.to) return to < e.to;
        return false;
    }
};

int main() {
    int n;
    cin >> n;
    vector<P> px(n), py(n);
    rep(i, n) {
        int x, y; scanf("%d%d", &x, &y);
        x--; y--;
        px[i] = P(x, i);
        py[i] = P(y, i);
    }
    sort(ALL(px));
    sort(ALL(py));

    vector<edge> es;
    rep(i, n - 1) {
        int dx = abs(px[i + 1].first - px[i].first);
        int dy = abs(py[i + 1].first - py[i].first);
        es.push_back(edge(px[i].second, px[i + 1].second, dx));
        es.push_back(edge(py[i].second, py[i + 1].second, dy));
    }
    sort(ALL(es));

    ll ans = 0;
    UnionFind uf(n);
    for (edge& e : es) {
        int u = e.from, v = e.to;
        if (uf.unite(u, v)) {
            ans += e.cost;
        }
    }

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

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

int main() {
	int a,b,c,d,e;
	cin >>a;
	cin >>b;
	cin>>c;
	cin>>d;
	cin>>e;
	if(a>b){
		a=b;
	}
	if(a>c){
		a=c;
	}
	if(d>e){
		d=e;
	}
	cout << a+d-50<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;

int main(){
	int n;
	while( cin >> n, n ){
		map<int, ll> worker;
		queue<int> order;
		for( int i = 0; i < n; i++ ){
			int id;
			ll price, num;
			cin >> id >> price >> num;
			if( worker.find(id) == worker.end() ){
				order.push(id);
			}
			worker[id] += (price * num);
		}
		bool flag = true;
		while( !order.empty() ){
			if( worker[order.front()] >= 1000000 ){
				cout << order.front() << endl;
				flag = false;
			}
			order.pop();
		}
		if( flag ){
			cout << "NA" << endl;
		}
	}
}

Measured memory_bytes: 1288
import sys
input = sys.stdin.readline
inf = float('inf')
mod = 10**9+7


def INT_(n): return int(n)-1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [input() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    N = I()
    s = LI()

    """
    A+kC=N-1
    A=N-1-kC
    0,A     ,C, A+C       ,2C,A+2C      ,3C,A+3C      =N-1
    0,N-1-kC,C, N-1-(k-1)C,2C,N-1-(k-2)C,3C,N-1-(k-3)C=N-1
    """

    ans = 0
    for c in range(1, N):
        score = 0
        hass = set([0, N-1])

        for k in range(1, (N - 1) // c):
            if k * c in hass or N - 1 - (k * c) in hass or N - 1 - (k * c) == k * c:
                score = -inf
                break
            #print(N - 1 - (k * c), k*c)
            score += s[N - 1 - (k * c)] + s[k * c]
            hass.add(N - 1 - (k * c))
            hass.add(k * c)

            # print(score)
            ans = max(ans, score)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 97108
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cassert>
#define llong long long
using namespace std;

const int N = 400;
const int P = 998244353;
llong dp[N+3][N+3][N+3];
llong pw1[N+3],pw2[N+3];
llong fact[N+3],finv[N+3];
llong inv[N+3];
int a[N+3],b[N+3];
int n;

llong quickpow(llong x,llong y)
{
	llong cur = x,ret = 1ll;
	for(int i=0; y; i++)
	{
		if(y&(1ll<<i)) {y-=(1ll<<i); ret = ret*cur%P;}
		cur = cur*cur%P;
	}
	return ret;
}
llong comb(llong x,llong y) {return x<0||y<0||x<y ? 0ll : fact[x]*finv[y]%P*finv[x-y]%P;}

int main()
{
	inv[1] = 1; for(int i=2; i<=N; i++) inv[i] = (P-P/i)*inv[P%i]%P;
	fact[0] = 1ll; for(int i=1; i<=N; i++) fact[i] = fact[i-1]*i%P;
	finv[N] = quickpow(fact[N],P-2); for(int i=N-1; i>=0; i--) finv[i] = finv[i+1]*(i+1)%P;
	scanf("%d",&n); int sa = 0,sb = 0,ssa = 0;
	for(int i=1; i<=n; i++) scanf("%d%d",&a[i],&b[i]),ssa+=a[i];
	dp[0][0][0] = P-1ll;
	for(int i=1; i<=n; i++)
	{
		sa += a[i],sb += b[i];
		for(int j=0; j<=sa; j++)
		{
			for(int k=0; k<=sb-i; k++) {dp[i][j][k] = dp[i-1][j][k];}
			if(j>=a[i])
			{
				llong x = (j-a[i])*inv[j]%P;
				pw1[0] = 1ll; for(int k=1; k<=sb-i; k++) pw1[k] = pw1[k-1]*x%P;
				x = a[i]*inv[j]%P;
				pw2[0] = 1ll; for(int k=1; k<=sb-i; k++) pw2[k] = pw2[k-1]*x%P;
				for(int k=0; k<=sb-i; k++)
				{
					for(int kk=0; kk<=k && kk<b[i]; kk++)
					{
						llong tmp = dp[i-1][j-a[i]][k-kk]*comb(k,kk)%P*pw1[k-kk]%P*pw2[kk]%P;
						dp[i][j][k] = (dp[i][j][k]-tmp+P)%P;
					}
				}
			}
//			for(int k=0; k<=sb-i; k++) printf("dp[%d][%d][%d]=%lld\n",i,j,k,dp[i][j][k]);
		}
	}
	llong ans = 0ll;
	for(int i=1; i<=sa; i++) for(int j=0; j<=sb; j++)
	{
//		printf("dp[%d][%d][%d]=%lld\n",n,i,j,dp[n][i][j]);
		ans = (ans+dp[n][i][j]*sa%P*inv[i])%P;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 508160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll N;
    cin >> N;
    vector<ll> a(N);
    vector<ll> x(N);
    set<ll> s;
    for (ll i = 0; i < N; i++) {
        cin >> a[i]; a[i]--;
        x[a[i]] = i;
    }

    s.insert(-1);
    s.insert(N);
    ll p, q;
    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        s.insert(x[i]);
        auto itr = s.find(x[i]);
        itr--;
        p = *itr;
        itr++; itr++;
        q = *itr;
        ans += (x[i] - p) * (q - x[i]) * (i+1);
        // printf("%lld %lld %lld\n", p, x[i], q);
    }

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


}

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

#ifdef DEBUG
#include "../include/debug.hpp"
#else
#define debug(...) 42
#define rdfile(...) 42
#endif

bool is_square(long long x) {
    for (long long i=0; i*i<=x; i++) {
        if (i*i == x) {
            return true;
        }
    }
    return false;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // rdfile("_input.txt");

    int N, D;
    cin >> N >> D;

    vector<vector<int>> X(N, vector<int>(D));
    for (int i=0; i<N; ++i) {
        for (int j=0; j<D; ++j) {
            cin >> X[i][j];
        }
    }

    int cnt = 0;
    for (int i=0; i<N; ++i) {
        for (int j=i+1; j<N; ++j) {
            long long d2 = 0;
            for (int k=0; k<D; ++k) {
                d2 += (X[i][k]-X[j][k]) * (X[i][k]-X[j][k]);
            }
            if (is_square(d2)) {
                cnt ++;
            }
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back 
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int h, w;
	cin >> h >> w;
	int t;
	cin >> t;
	int x = max(h, w);
	cout << (t + x - 1) / x << '\n';

}

Measured memory_bytes: 256
"use strict";
function Main(input) {
    const N = input.split("\n")[0] - 0;
    let e = new Array(N + 1).fill(0);
    for (let i = 2; i <= N; i++) {
        let cur = i;
        for (let j = 2; j <= i; j++) {
            while (cur % j == 0) {
                e[j] += 1;
                cur /= j;
            }
        }
    }
    const num = (m) => e.reduce((ac, x) => ac + ((x >= m - 1) ? 1 : 0), 0);
    let l75 = num(75);
    let l25 = num(25);
    let l15 = num(15);
    let l5 = num(5);
    let l3 = num(3);
    let r5x5x3 = (l5 * (l5 - 1) * (l3 - 2)) / 2;
    let r15x5 = l15 * (l5 - 1);
    let r25x3 = l25 * (l3 - 1);
    let r75 = l75;
    console.log(r75 + r25x3 + r15x5 + r5x5x3);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
using ll = long long;

int main(){
    ll n, d, x; std::cin >> n >> d >> x;
    std::vector<ll> a;
    for(int i=0; i<n; i++){
        ll b; std::cin >> b; a.push_back(b);
    }

    std::vector<ll> ch(d+1,0);
    for(auto &ai : a){
        for(int i=0; i*ai+1<=d; i++){
            ch[i*ai+1]++;
        }
    }

    std::cout << x + std::accumulate(ch.begin(), ch.end(), 0LL);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

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 main() {
	init();

	ll N, M; cin >> N >> M;
	string s, t; cin >> s >> t;
	bool ok = true;
	int g = gcd(N, M);
	int a = N / g, b = M / g;
	int i = 0, j = 0;
	while (i < N && j < M) {
		if (s[i] != t[j])ok = false;
		i += a;
		j += b;
	}
	cout << (ok ? lcm(N, M) : -1) << "\n";

	return 0;
}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int FFTMOD = 119 << 23 | 1;
const int INF = (int) 1e9 + 23111992;
const ll LINF = (ll) 1e18 + 23111992;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ull isqrt(ull k) {ull r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
mt19937 mt(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int mrand() {return abs((int) mt());}
inline int mrand(int k) {return abs((int) mt()) % k;}
#define db(x) cerr << "[" << #x << ": " << (x) << "] ";
#define endln cerr << "\n";

void chemthan() {
    int a, v, b, w; cin >> a >> v >> b >> w;
    int t; cin >> t;
    int d = abs(a - b);
    if (d <= (long long) t * (v - w)) {
        cout << "YES\n";
    }
    else {
        cout << "NO\n";
    }
}

int main(int argc, char* argv[]) {
    ios_base::sync_with_stdio(0), cin.tie(0);
    if (argc > 1) {
        assert(freopen(argv[1], "r", stdin));
    }
    if (argc > 2) {
        assert(freopen(argv[2], "wb", stdout));
    }
    chemthan();
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 3580
#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 ve vector

int main(){
    ll n,k;
    cin >> n >> k;
    ve<ll> a(n);
    rep(i,n) cin >> a[i];
    ve<ve<ll>> dp(41,ve<ll>(2,-1));
    dp[0][0] = 0;
    rep(i,40){
        ll id = pow(2,(39-i));
        ll cnt = 0;
        rep(j,n){
            if(a[j] & id) cnt++;
        }
        if(k&id){
            dp[i+1][0] = dp[i][0] + id*(n-cnt);
            if(dp[i][1] == -1) dp[i+1][1] = dp[i][0] + id*cnt;
            else{
                dp[i+1][1] = dp[i][1] + id*max(cnt,n-cnt);
                dp[i+1][1] = max(dp[i+1][1], dp[i][0] + id*cnt);
            }
        }else{
            dp[i+1][0] = dp[i][0] + id*cnt;
            if(dp[i][1] == -1) dp[i+1][1] = -1;
            else dp[i+1][1] = dp[i][1] + id*max(cnt,n-cnt);
        }
    }
    cout << max(dp[40][0],dp[40][1]) << endl;
    return 0;
}

Measured memory_bytes: 4168
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s[k - 1] -= 'A' - 'a';
    cout << s << endl;
    return 0;
}


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

int main(){
    long long x; cin >> x;
    long long a,b;
    a=0;
    long long fiveb;
    while(true){
        fiveb = pow(a,5)-x;
        int flag = 0;
        b=a-1;
        long long tmp = abs(fiveb);
        while((fiveb>=0&&abs(fiveb)-abs(pow(b,5))<=0)or(fiveb<0&&abs(fiveb)-abs(pow(b,5))>=0)){
            if(fiveb==pow(b,5)){
                flag = 1;
                break;
            }
            --b;
        }
        if (flag == 1) {
          break;
        }
        a++;
    }
    cout << a << " " << b << endl;
}

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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int> res(n);
	map<int,int> exists;
	for (int i = 0, x, y; i < m; ++i) {
		cin >> x >> y;
		if (x == 1 && y == 0 && n > 1) {
			cout << -1 << endl;
			return 0;
		}
		if (exists.find(x) != exists.end() && exists[x] != y) {
			cout << -1 << endl;
			return 0;
		}
		exists[x] = y;
		res[x-1] = y;
	}
	if (!res[0] && n > 1) res[0] = 1;
	for (int x: res) cout << x;
	cout << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
template <typename T>void read(T &x){
	x = 0; int f(1); char c = getchar();
	for(;!isdigit(c);c = getchar()) if(c == '-') f = -1;
	for(;isdigit(c);c = getchar()) x = x*10+c-'0';
	x *= f;
}
const int maxn = 100005;
int n,v[3],tv[3];
int l[maxn],r[maxn];
char to[3] = {'A','B','C'};
int main(){
	read(n); for(int i(0);i < 3;++i)	read(v[i]),tv[i] = v[i];
	for(int i(1);i <= n;++i){
		string s; cin >> s;
		l[i] = s[0]-'A';
		r[i] = s[1]-'A';
		if(l[i] > r[i])	swap(l[i],r[i]);
	} int ok = 1;
	for(int i(1);i <= n;++i){
		if(tv[l[i]] > tv[r[i]]){
			--tv[l[i]],++tv[r[i]];
		}
		else if(tv[l[i]] < tv[r[i]]){
			++tv[l[i]]; --tv[r[i]];
		}
		else{
			if(tv[l[i]] == 0){ok = 0;break;}
			--tv[l[i]]; ++tv[r[i]];
			if((tv[l[i+1]] != tv[r[i+1]])||(tv[l[i+1]] != 0))	continue;
			tv[l[i]] += 2; tv[r[i]] -= 2;
			if((tv[l[i+1]] != tv[r[i+1]])||(tv[l[i+1]] != 0))	continue;
			ok = 0;break;
		}
	}
	if(!ok){puts("No");return 0;}
	puts("Yes");
	for(int i(1);i <= n;++i){
		if(v[l[i]] > v[r[i]]){
			--v[l[i]],++v[r[i]];
			printf("%c\n",to[r[i]]);
		}
		else if(v[l[i]] < v[r[i]]){
			++v[l[i]]; --v[r[i]];
			printf("%c\n",to[l[i]]);
		}
		else{
			--v[l[i]]; ++v[r[i]];
			if((v[l[i+1]] != v[r[i+1]])||(v[l[i+1]] != 0)){
				printf("%c\n",to[r[i]]);continue;
			}
			v[l[i]] += 2; v[r[i]] -= 2;
			printf("%c\n",to[l[i]]);
		}
	}
	return 0;
}

Measured memory_bytes: 4500
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			var inputs = Console.ReadLine().Split(' ').Select(input => int.Parse(input)).OrderByDescending(num => num).ToArray();
			Console.WriteLine($"{inputs[0] * 10 + inputs[1] + inputs[2]}");
		}
	}

}


Measured memory_bytes: 11348
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
#include <cstring>

using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;
VI G[2000];

int match[2010];
bool used[2010];
int N;

bool dfs(int v) {
	used[v] = true;
	REP(i, G[v].size()) {
		int u = G[v][i], w = match[u];
		if (w < 0 || (!used[w] && dfs(w))) {
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}

int solve() {
	int res = 0;
	memset(match, -1, sizeof(match));
	REP(v, N) {
		if (match[v] < 0) {
			memset(used, 0, sizeof(used));
			if (dfs(v))res++;
		}
	}

	return res;
}



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

	int X, Y, M; cin >> X >> Y >> M;
	REP(i, M) {
		int a, b; cin >> a >> b;
		b += X;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	N = X + Y;

	cout << solve() << endl;

	return 0;
}


Measured memory_bytes: 3320
n = int(input())
li = list(map(int,input().split()))
li.sort(reverse = True)
ki = 0
kifl = False
ans = 0
for a in li:
    if a%2 == 0:
        ans += a
    else:
        if(kifl == True):
            ans += ki+a
            kifl = False
        else:
            ki = a
            kifl = True
print(ans//2)



Measured memory_bytes: 5588
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;
const int mod998 = 998244353;

char b;
string s;
int main() {
	s = "ACTGACTG";
	cin >> b;
	for (int i = 0;; ++i) {
		if (s[i] == b) {
			cout << s[i + 2] << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main()
{
    jaldi
    ll h;
    cin>>h;
    int upto = log2(h);
    ll ans=0;
    ll i;
    for(i=0;i<=upto;i++) 
    {
        ans=ans+pow(2,i);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  char c;
  cin>>c;
  if(c=='A') cout<<"T"<<endl;
  if(c=='T') cout<<"A"<<endl;
  if(c=='G') cout<<"C"<<endl;
  if(c=='C') cout<<"G"<<endl;
}


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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

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

    vector<int> A(N), B(N), C(N-1);
    REP(i,N) cin >> A[i];
    REP(i,N) cin >> B[i];
    REP(i,N-1) cin >> C[i];

    int ans = 0;
    REP(i,N) ans += B[i];
    REP(i,N-1){
        if(A[i+1] - A[i] == 1) ans += C.at(A[i]-1);
    }
    cout << ans << endl;
}

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

using namespace std;

#define int long long

main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin >> s;
		
	int cnt = 0;
	int n_of_A = 0;
	
	for(int i = 0; i < s.size(); i++) {
		if(s.at(i) == 'A')
			n_of_A++;
		else
		{
			if(i + 1 < s.size() && s.at(i) == 'B' && s.at(i + 1) == 'C')
			{
				cnt += n_of_A;
				i++;
			}
			else
				n_of_A = 0;
		}
    }
	
	cout << cnt << endl;
}


Measured memory_bytes: 720
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();
	int c = sc.nextInt();
	int count=1;
    if (a!=b){
      count+=1;
    }
    if (a!=c && b!=c){
      count+=1;
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 21844
//
// Created by Myabu on 2020/01/23.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;


int main(void){
    long long N;
    cin>>N;

    long long ans = 1;

    for (int i = 1; i < N; ++i) {
        if(i*i <= N){
            ans = i*i;
        }else{
            break;
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*
fun main(args: Array<String>) {
    val reader = Scanner(System.`in`)

    val S = reader.next()
    val T = reader.next()
    var matchMax = 0

    var checkIndex = 0
    while(checkIndex <= S.length - T.length){
        var curMatch = 0
        for(count in checkIndex..checkIndex + T.length - 1){
            if(T[count - checkIndex] == S[count]){
                curMatch++
            }
        }
        if(curMatch > matchMax){
            matchMax = curMatch
        }
        checkIndex++
    }
    println(T.length - matchMax)
}

Measured memory_bytes: 36340
// https://atcoder.jp/contests/abc049/tasks/arc065_a

#include <iostream>
#include <string>

using namespace std;

bool trim_from_right(std::string& s, std::string target) {
    auto pos = s.rfind(target);
    if (pos != string::npos && pos + target.size() == s.size()) {
        s.erase(pos);
        return true;
    }
    return false;
}
int main() {
    string s{};
    cin >> s;

    bool cont = true;
    while(cont) {
        cont = false;
        cont = cont || trim_from_right(s, "dreamer");
        cont = cont || trim_from_right(s, "dream");
        cont = cont || trim_from_right(s, "eraser");
        cont = cont || trim_from_right(s, "erase");
    }
    if (s.empty()) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}


// end of Template

ll a[60],n,k;
ll decr(ll a, ll b){
    ll res = a-b;
    if(res<0)res = n+1+res;
    return res;
}
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>k; n = 50;
    for(int i=1;i<=n;i++)a[i]=i-1;

    if(k>0){
        for(int i=1;i<=n;i++){
            ll st,zone,m,res;
            st = decr(a[i],1);
            res = st;
            zone = k/n;
            if(k%n==0)zone--;

            m = k%n;
            if(m==0)m=n;
            //cout<<res<<" "<<decr(st,m-1)<<newl;
            st = decr(st,m-1);
            res = zone + st;
            a[i]=res;
            //cout<<st<<" "<<zone<<" "<<m<<" "<<res<<newl;
        }
    }
    cout<<n<<newl;
    for(int i=1;i<=n;i++){
        cout<<a[i];
        if(i<n)cout<<" ";
        else cout<<newl;
    }



}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int x,y,d,r;
double a,b,f;
scanf("%lf %lf",&a,&b);
x=a;
y=b;
d=a/b;
r=x%y;
f=a/b;
printf("%d %d %lf\n",d,r,f);

	return 0;
}

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

using namespace std;
long long s[100000];
int main() {
int h;
cin>>h;long sum=0,so=0;
for(int i=0;i<h;i++)
{
    cin>>s[i];
    
}
sort(s,s+h);
for(int i=0;i<h;i++)
{
while(s[i]==s[i+1])
    {sum++;i++;}
    if(sum%2==0)
    so++;
    sum=0;
}

cout<<so;
cout<<endl;    
    return 0;
}

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

#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define fst first
#define snd second

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    cout << n * n;
    return 0;
}

Measured memory_bytes: 256