akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 

#define INF INT_MAX/2
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;

vector<int>Par,Rank;

void init(int n){
   Par.resize(n);
   for(int i=0;i<n;i++)Par[i]=i;
   Rank.resize(n,0);
}

int root(int x){
   if(Par[x]==x)return x;
   else return root(Par[x]);
}

bool is_uni(int x,int y){
   return (root(x) == root(y));
}

void uni(int x,int y){
   x=root(x);
   y=root(y);
   if(x==y)return;
   if(Rank[x]<Rank[y]){
      Par[x]=y;
   }
   else{
      Par[y]=x;
      if(Rank[x]==Rank[y])Rank[x]++;
   }
}


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

   int N,M;
   cin>>N>>M;
   vector<int>p(N),x(M),y(M);
   for(int i=0;i<N;i++)cin>>p[i];
   for(int i=0;i<M;i++)cin>>x[i]>>y[i];
   init(N+1);
   for(int i=0;i<M;i++){
      uni(x[i],y[i]);
   }
   ll ans = 0;
   for(int i=0;i<N;i++){
      if(is_uni(i+1,p[i]))ans++;
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 2176
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

typedef struct{
    int value[105];
    int top;
}stack;

void getValue(stack *, int *, int *);
int isEmpty(stack *);
void push(stack *, int);
int pop(stack *);

int main(){
    char s[100];
    stack polish = { .top = 0 };
    int a, b, res;
    while(scanf("%s", s) != EOF){
        if (s[0] == '+'){
            getValue(&polish, &a, &b);
            res = a + b;
            push(&polish, res);
        } 
        else if (s[0] == '-'){
            getValue(&polish, &a, &b);
            res = a - b;
            push(&polish, res);
        }
        else if (s[0] == '*'){
            getValue(&polish, &a, &b);
            res = a * b;
            push(&polish, res);
        } 
        else {
            int x = atoi(s);
            push(&polish, x);
        }
    }
    int result = pop(&polish);
    printf("%d\n", result);
    return 0;
}

void getValue(stack *source, int *bottom, int *top){
    *top = pop(source);
    *bottom = pop(source);
}

int isEmpty(stack *check) {
    if (check->top == 0) return 1;
    return 0;
}

void push(stack *pushTo, int source) {
    pushTo->value[++pushTo->top] = source;
}

int pop(stack *popFrom) {
    if (isEmpty(popFrom)) exit(-1);
    return popFrom->value[popFrom->top--];
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }

int main() {
  string s; cin >>s;
  for (int i=0; i<s.size(); i++) cout <<"x";
  cout <<endl;
}

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

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N, T;
vector<int> apples;
int get_max_profit() {
  int min_price = apples[0];
  int max_profit = 0;
  for (int i = 1; i < N; i++) {
    max_profit = max(max_profit, apples[i] - min_price);
    min_price = min(min_price, apples[i]);
  }
  return max_profit;
}

int main() {
  cin >> N >> T;
  apples.resize(N);
  for (auto &val : apples) {
    cin >> val;
  }
  int max_profit = get_max_profit();
  map<int, int> deg;
  map<int, pii> res;
  for (int &val : apples){
    deg[val]++;
    // cout << "val = " << val << " " << max_profit << endl;
    if (deg.count(val - max_profit) > 0){
      // cout << val << " " << max_profit << endl;
      res[val].first = deg[val - max_profit];
      res[val].second =  deg[val];
    }
  }
  int ans = 0;
  for (auto &val : res){
    ans += min(val.second.first, val.second.second);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8448
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
typedef long long int ll;
int main(){
	int N, a;
	map<int, int> mpa;
	cin >> N;
	for(int i = 1; i <= N; i++){
		cin >> a;
		mpa[a]++;
	}
	map<int, int>::iterator itr;
	ll ans = 0;
	for(itr = mpa.begin(); itr != mpa.end(); itr++){
		if(itr->first <= itr->second) ans += itr->second - itr->first;
		else ans += itr->second;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4864
import sys
input = sys.stdin.readline

N,Q = map(int,input().split())

adj = [list() for _ in range(N)]
for _ in range(N-1):
    a,b = map(int,input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)

memo = [0]*N
for _ in range(Q):
    p,x = map(int,input().split())
    memo[p-1] += x

stack = [(None,0)]
while stack:
    p,v = stack.pop()
    for u in adj[v]:
        if u != p:
            memo[u] += memo[v]
            stack.append((v,u))

print(*memo)


Measured memory_bytes: 128208
let input = readLine()!.split(separator: " ").map { Int($0)! }
let N = input[0]
let K = input[1]
let A = readLine()!.split(separator: " ").map { Int($0)! }

let mostSignificantBit = String(1_000_000_000_000, radix: 2).count
var dp = [true: Optional<Int>.none, false: Optional<Int>.none]
dp[false] = 0

for i in stride(from: 0, to: mostSignificantBit, by: 1) {
    let mask = 1 << (mostSignificantBit - i - 1)

    var numberOfSetBit = 0
    for j in stride(from: 0, to: N, by: 1) {
        if A[j] & mask == mask {
            numberOfSetBit += 1
        }
    }

    let scoreWhen0 = mask * numberOfSetBit
    let scoreWhen1 = mask * (N - numberOfSetBit)

    var newDP = [true: Optional<Int>.none, false: Optional<Int>.none]

    [0, 1].forEach { digit in
        for isLessThanK in [false, true] {
            guard let previousValue = dp[isLessThanK]! else { continue }

            let nextIsLessThanK = isLessThanK || (K & mask > digit << (mostSignificantBit - i - 1))

            switch (isLessThanK, nextIsLessThanK) {
            case (true, true):
                newDP[nextIsLessThanK] = max(
                    newDP[nextIsLessThanK]! ?? 0,
                    previousValue + max(scoreWhen0, scoreWhen1)
                )
            case (false, true):
                guard digit == 0 else { continue } // この桁で初めてKを下回る、つまり1を選択することはない
                newDP[nextIsLessThanK] = max(
                    newDP[nextIsLessThanK]! ?? 0,
                    previousValue + scoreWhen0
                )
            case (false, false):
                guard K & mask == digit << (mostSignificantBit - i - 1) else { continue } // Kと同じ数字を選択する
                newDP[nextIsLessThanK] = max(
                    newDP[nextIsLessThanK]! ?? 0,
                    previousValue + (digit == 1 ? scoreWhen1 : scoreWhen0)
                )
            default:
                break
            }
        }
    }
    dp = newDP
}

print(max(dp[true]! ?? 0, dp[false]! ?? 0))


Measured memory_bytes: 15044
S = input()
n = len(S) + 1
num = [0] * n
for i in range(n-1):
    if S[i] == '<':
        num[i + 1] = max(num[i] + 1, num[i + 1])
for i in range(n - 2, -1, -1):
    if S[i] == '>':
        num[i] = max(num[i + 1] + 1, num[i])
print(sum(num))

Measured memory_bytes: 23348
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
struct edge{ll to; ll cost;};
struct graph{
    ll N;
    vector<vector<edge> > G;
    vector<bool> used;
    vector<ll> depth;
    ll maxd=-1;
    ll dnode;

    graph(ll n): N(n), G(N), used(N,false), depth(N,-1) {}

    void add_edge(ll s, ll t, ll cost=1){
        G[s].emplace_back((edge){t,cost});
        G[t].emplace_back((edge){s,cost}); //無向ならON
    }

    void dfs(ll v=0, ll d=0){
        used[v]=true;
        depth[v]=d;
        if(maxi(maxd,d)) dnode=v; //一番深いノードを更新
        for(auto E : G[v]){
            if(!used[E.to]){
                dfs(E.to, d+E.cost);
            }
        }
    }

    ll delimiter(){
        dfs();
        rep(i,N) used[i]=false;
        dfs(dnode);
        return maxd;
    }
};
//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    graph g(N);
    rep(i,N-1){
        ll a,b; cin>>a>>b;
        g.add_edge(--a,--b);
    }
    ll x=g.delimiter();
    cout<< ( x%3!=1 ? "First" : "Second" )<<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 21504
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, K;
	cin >> N >> K;

	vector<vector<Int>> ab(N, vector<Int>(2, 0));
	for (Int i = 0; i < N; i++) {
		cin >> ab[i][0] >> ab[i][1];
	}

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

	Int count = 0;
	Int num = 0;

	while (count < K) {
		count += ab[num][1];
		num++;
	}

	cout << ab[num - 1][0] << "\n";
}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#define endl "\n"
using namespace std;

int sz;

vector<int> dp;


/*  Using Memoization */

int costOfJumpMemo(int arr[], int n)
{

    if (dp[n] != -1)
        return dp[n];

    if (n == 0)
        return 0;

    /* work without this also */

    if (n < 0)
        return INT_MAX;

    int right = abs(arr[n] - arr[n - 1]) + costOfJumpMemo(arr, n - 1);

    int left = INT_MAX;

    if (n - 2 >= 0)
        left = abs(arr[n] - arr[n - 2]) + costOfJumpMemo(arr, n - 2);

    return dp[n] = min(right, left);
}

int main()
{

    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif

    int n;

    cin >> n;

    int arr[n];
  
   dp.resize(n,-1);

    for (int i = 0; i < n; ++i)
        cin >> arr[i];

    sz = sizeof(arr) / sizeof(arr[0]);

    /* Recurison bottom to top */

    //cout << costOfJump(arr, 0) << endl;

    //cout << costOfJump2(arr, sz - 1);

    /*  Using Memoization */

    cout << costOfJumpMemo(arr, sz - 1);

    return 0;
}

Measured memory_bytes: 7296
#include <stdio.h>

int main(void)
{
	int n,j;
	int min,max;
	long int sum;
	int a[10000];

	scanf("%d",&n);

	for (j = 0; j < n; j++)
	{
		scanf("%d",&a[j]);
	}

	min = a[0];

	for (j = 0; j < n; j++)
	{
		if (min > a[j])
		{
			min = a[j];
		}
	}

	max = a[0];

	for (j = 0; j < n; j++)
	{
		if (max < a[j])
		{
			max = a[j];
		}
	}

	sum = 0;

	for (j = 0; j < n; j++)
	{
		sum += a[j];
	}

	printf("%d %d %ld\n",min,max,sum );

	return 0;
}

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

#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) ; 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 sp system("pause")
#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 INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
bool isPrime(int a)
{
    if(a < 2) return 0;
    if(a % 2 == 0 && a != 2) return 0;
    FOR(i, 2, sqrt(a)) if(a % i == 0) return 0;
    return 1;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int x;
    cin >> x;
    while(!isPrime(x)) x++;
    cout << x;
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
td = [list(map(int, input().split())) for _ in range(n)]

td.sort(key = lambda x:x[1], reverse=True)
cand = []
memo = [0 for i in range(n+1)]

ans = 0
duplicate = []
unique = []
num = 0
i = 0

for t, d in td:
    i += 1
    if i <= k:
        ans += d
        if memo[t]:
            duplicate.append(d)
        else:
            memo[t] = 1
            num += 1
    else:
        if not memo[t]:
            unique.append(d)
            memo[t] = 1

tmp = ans
ans += num * num

# print(tmp, ans)

for d, u in zip(reversed(duplicate), unique):
    tmp += u - d
    num += 1
    ans = max(ans, tmp + num * num)

print(ans)


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

int main(int argc, char *argv[])
{
    int n;
    cin >> n;

    vector<int> a(n);
    for(int& x : a) cin >> x;

    int res = 0;
    int amount = 1;
    for(int i = 1; i < a.size(); ++i) {
        if(a[i - 1] == a[i]) amount++;
        else
        {
            res += amount / 2;
            amount = 1;
        }
    }

    res += amount / 2;

    cout << res << endl;
}


Measured memory_bytes: 256
/******************************************
* nils sjoberg never died  *
* He hibernated *
* So did dinesh easwar *
******************************************/
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <cstdlib>
#include <iomanip>
 
using namespace std;
typedef vector< long long > vec;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
#define pb push_back
#define PB pop_back()
#define sqr(a) (((a) * (a)))
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define umap unordered_map
#define all(c) (c).begin(),(c).end()
#define newl "\n"
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,a,b) for(ll i=a; i>=b; i--)
#define forn(i, n) for (ll i = 0; i < n; i++)
#define sz(a) int((a).size())
#define frev(n) for(ll i=n-1; i>=0, i--)
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define vecpresent(container, element) (find(all(container), element) != container.end())
#define N 1000000007
#define PI 3.1415926535897932384
#define F first
#define S second
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll binpow(ll a, ll b, ll m){
	a %= m;
	ll res = 1;
	while(b>0){
	if(b&1)
		res = res * a % m;
	a = a * a % m;
	b >>= 1;
	}
	return res;
}

ll binmul(ll a, ll b, ll m){
	b %= m;
	ll res = 0;
	while(a>0){
		if(a&1)
			res = res + b % m;
		b = b + b % m;
		a >>= 1;
	}
	return res;
}

ll gcd(ll a, ll b){
	while(b){
		a %= b;
		swap(a, b);
	}
	return a;
}

pii fib(int n){
	if(n==0)
		return {0, 1};
	auto p = fib(n >> 1);
	int c = p.first * (2*p.second - p.first);
	int d = p.first*p.first + p.second*p.second;
	if(n&1)
		return {d, c+d};
	else
		return {c, d};
}


 
void solve(){
	ll n, count=0, a;
	cin >> n;
	forn(i, n){
		cin >> a;
		if(i%2==0 && a%2==1) count++;
	}
	cout << count;

	
}



int main()
{
 	FAST
	ll test;
	test=1;
	//cin>>test;
	while(test--)
	{
		solve();
	}
	return 0;
}



Measured memory_bytes: 3588
#include <stdio.h>

int main(void) 
{
	long long i, j, k, n, m, l, a, b, c;
	long long A[101][101] = { 0 };
	long long B[101][101] = { 0 };
	long long C[101][101] = { 0 };

	scanf("%lld %lld %lld", &n, &m, &l);

	for (j = 0; j < n; j++) {
		for (i = 0; i < m; i++) {

			scanf("%lld", &a);
			A[j][i] = a;

		}
	}

	for (j = 0; j < m; j++){
		for (i = 0; i < l; i++){
			scanf("%lld", &b);
			B[j][i] = b;
		}
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < l; j++){
			C[i][j] = 0;
			for (k = 0; k < m; k++) {
				C[i][j] += A[i][k] * B[k][j];				
			}			
		}
	}


	for (i = 0; i < n; i++) {
		for (j = 0; j < l; j++) {
			printf("%lld", C[i][j]);
			if (j != l - 1) {
				printf(" ");
			}
		}
		printf("\n");
	}

	return 0;

}


Measured memory_bytes: 2112
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int n;
    int num[100010];
    vector<int> odd, even;
    int oddbuck[100010] = {0};
    int evenbuck[100010] = {0};
    int maxo = 0, o1, o2;
    int maxe = 0, e1, e2;
    int ans1 = 0, ans2 = 0;

    cin >> n;

    for (int i = 0; i < n; i++) cin >> num[i];

    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            odd.push_back(num[i]);
        }
        else {
            even.push_back(num[i]);
        }
    }

    for (int i = 0; i < (int)odd.size(); i++) {
        oddbuck[odd[i]]++;
        evenbuck[even[i]]++;
    }

    for (int i = 0; i < 100010; i++) {
        if (maxo < oddbuck[i]) {
            maxo = oddbuck[i];
            o1 = i;
        }
        if (maxe < evenbuck[i]) {
            maxe = evenbuck[i];
            e1 = i;
        }
    }

    oddbuck[o1] = 0;
    evenbuck[e1] = 0;
    maxo = 0;
    maxe = 0;

    for (int i = 0; i < 100010; i++) {
        if (maxo < oddbuck[i]) {
            maxo = oddbuck[i];
            o2 = i;
        }
        if (maxe < evenbuck[i]) {
            maxe = evenbuck[i];
            e2 = i;
        }
    }

    if (e1 == o1) {
        for (int i = 0; i < (int)odd.size(); i++) {
            if (odd[i] != o1) {
                ans1++;
            }
            if (even[i] != e2) {
                ans1++;
            }
            if (odd[i] != o2) {
                ans2++;
            }
            if (even[i] != e1) {
                ans2++;
            }
        }

        cout << (ans1 < ans2 ? ans1 : ans2) << endl;
    }
    else {
        for (int i = 0; i < (int)odd.size(); i++) {
            if (odd[i] != o1) {
                ans1++;
            }
            if (even[i] != e1) {
                ans1++;
            }
        }

        cout << ans1 << endl;
    }

    return (0);
}


Measured memory_bytes: 2044
from collections import Counter
n, *a = map(int, open(0).read().split())
C = Counter(a)
ans = 0
for x in sorted(a)[::-1]:
	if not C[x]:
		continue
	y = 1 << x.bit_length()
	C[x] -= 1
	if C[y - x]:
		ans += 1
		C[y - x] -= 1
print(ans)

Measured memory_bytes: 33712
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int cnt[100005];
signed main()  {
    int N,K;
    cin >> N >> K;
    int ans = 0;
    vector<int>cnt(N+1);
    for(int i = 1; i <= N; i++) {
        cnt[i] = cnt[i-1]+i;
    }
    // 0 1 3 6
    for(int i = K; i <= N; i++) {
        ans+=(cnt[N]-cnt[N-i]-cnt[i-1]+1)%INF;
    }
    cout << (ans+1)%INF << endl;
}


Measured memory_bytes: 4684
n=int(input())
x_list=[]
y_list=[]
for i in range(n):
    x,y=map(int,input().split())
    x_list.append(x)
    y_list.append(y)
ans=n
for i in range(n):
    for j in range(i+1,n):
        temp=n
        x_d=x_list[j]-x_list[i]
        y_d=y_list[j]-y_list[i]
        for l in range(n):
            for m in range(l+1,n):
                if (x_list[m]-x_list[l]==x_d and y_list[m]-y_list[l]==y_d) or (x_list[m]-x_list[l]==-x_d and y_list[m]-y_list[l]==-y_d):
                    temp=temp-1
        ans=min(ans,temp)
print(ans)


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

using namespace std;

int main() {
    char x[4];
    cin >> x[0] >> x[1] >> x[2] >> x[3];

    for (int bits = 0; bits < (1 << 3); ++bits) {
        int result = x[0] - '0';
        for (int i = 0; i < 3; ++i) {
            if ((bits >> i) & 1)
                result = result + (x[i + 1] - '0');
            else
                result = result - (x[i + 1] - '0');
        }
        if (result == 7) {
            cout << x[0];
            for (int i = 0; i < 3; ++i) {
                if ((bits >> i) & 1)
                    cout << '+' << x[i + 1];
                else
                    cout << '-' << x[i + 1];
            }
            cout << "=7" << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
        int a,b,c,d;

        scanf("%d%d%d%d",&a,&b,&c,&d);

        if ((a<=b)&&(c<=d))
                printf("%d\n",a+c);
        else if  ((a<=b)&&(c>=d))
                printf("%d\n",a+d);
        else if ((a>=b)&&(c>=d))
                printf("%d\n",b+d);
        else
                printf("%d\n",b+c);

        return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 998244353; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

inline int binpow (int a, int n) {
    int ans = 1;
    for (; n; n >>= 1) {
        if (n & 1) ans = ((ll)ans * a) % MOD;
        a = ((ll)a * a) % MOD;
    }
    return ans;
}
vector <int> f, fi;
inline void precalc (int n) {
    f.resize(n);
    fi.resize(n);
    f[0] = 1;
    for (int i = 1; i < n; i++) {
        f[i] = ((ll)f[i - 1] * i) % MOD;
    }
    fi[n - 1] = binpow(f[n - 1], MOD - 2);
    for (int i = n - 2; i >= 0; i--) {
        fi[i] = ((ll)fi[i + 1] * (i + 1)) % MOD;
    }
}
inline int  C (int n, int k) {
    return ((ll)(((ll)f[n] * fi[k]) % MOD) * fi[n - k]) % MOD;
}
inline int mul (int a, int b) {
    return ((ll)a * b) % MOD;
}

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    precalc(n + 1);
    int ans = 0;
    for (int i = 0; i <= k; i++) {
        ans = (ans + mul(mul(m, binpow(m - 1, n - i - 1)), C(n - 1, i))) % MOD;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 4792
ret = []
while True:
   cnt = 0
   n, x = map(int, raw_input().split())
   num_arr = [i for i in range(1, n + 1)]

   if (n, x) == (0, 0):
       break

   for i in range(n, 0, -1):
       for j in range(i -1, 0, -1):
           if 0 < x - i - j < j:
               cnt += 1
   ret += [cnt]
for i in ret:
    print i

Measured memory_bytes: 6456
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;

#define all(v) (v).begin(),(v).end()
using ll = long long;
constexpr ll INF = 1e18;

int main(void) {
    ll N;
    cin >> N;
    ll c = 0;
    vector<ll> d1(N);
    vector<ll> d2(N);
    for (int i = 0; i < N; i++) {
        cin >> d1[i] >> d2[i];
    }
    for (int i = 0; i < N; i++) {
        if (d1[i] == d2[i]) c++;
        else c = 0;
        if (c == 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }

    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
    
    
  int main(){
    lint c[3][3];
    rep(i,3){
        rep(j,3){
            cin>>c[i][j];
        }
    }
    bool x[3][3];
        rep(i,3){
        rep(j,3){
            x[i][j]=false;
        }
    }
    lint N;
    cin >>N; lint A[N];
    rep(i,N){cin >> A[i];
        rep(j,3){
        rep(k,3){
            if(c[j][k]==A[i])x[j][k]=true;
        }
    }
    }
    bool f=false;
    rep(i,3){
        if(x[0][i]&&x[1][i]&&x[2][i])f=true;
        if(x[i][0]&&x[i][1]&&x[i][2])f=true;
    }
    if(x[0][0]&&x[1][1]&&x[2][2])f=true;
    if(x[0][2]&&x[1][1]&&x[2][0])f=true;
    if(f)cout<<"Yes";
    else cout<<"No";
  }
     
  


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.PriorityQueue;
import java.util.StringTokenizer;





 class Main{
	
	

	public static void main(String[] args) throws IOException {
		
		
		FastScanner sc=new FastScanner();
		int n = sc.nextInt();
		int w = sc.nextInt();
		
		int[] we = new int[n];
		int[] val = new int[n];
		int sum = 0;
		for(int i = 0; i < n; i++)
		{
			we[i] = sc.nextInt();
			val[i] = sc.nextInt();
			sum += val[i];
		}
		long ans = 0;
		int max = sum + 10;
		long[][] dp = new long[n + 1][sum + 1];
		for(int i = 0; i <= n; i++)
		{
			Arrays.fill(dp[i], Integer.MAX_VALUE);
			dp[i][0] = 0;
		}
		
		
		for(int i = 1; i <= n; i++)
		{
			for(int j = 1; j <= sum; j++)
			{
				dp[i][j] = Math.min(dp[i - 1][Math.max(0, j - val[i - 1])] + we[i - 1], dp[i - 1][j]);
				if(dp[i][j] <= w) ans = Math.max(ans, j);
			}
		}
		System.out.println(ans);
		
		
	}
	
	
	
	static long dp[][];
	
 
	private static long solve(long[] wights, long[] value, int n, long capacity) {
		if(n == 0 || capacity==0)
			return 0;
		if(dp[n][(int) capacity] != -1)
			return dp[n][(int) capacity];
		if(wights[n-1] <= capacity) {
			return dp[n][(int) capacity] = Math.max(solve(wights, value, n-1, (int) (capacity-wights[n-1])) 
					+ value[n-1],
					solve(wights, value, n-1, capacity));
		}
		else {
			return dp[n][(int) capacity] =  solve(wights, value, n-1, capacity);
		}
		
	}





	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long[] readArrayLong(int n) {
        	long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
        }
		long nextLong() {
			return Long.parseLong(next());
		}
		String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
	}
}


Measured memory_bytes: 136992
N = int(input())
S = input()
count = 0
flag = 0
while flag == 0:
    flag = 1
    dep = 0
    for i in S:
        if i == ")":
            dep += 1
        else:
            dep -= 1
        if dep > 0:
            break
    if dep > 0:
        S = "("*dep + S
        flag = 0
    elif dep < 0:
        S = S + ")"*(-dep)
        flag = 0
    #print(S)
print(S)
    

Measured memory_bytes: 38768
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;
        static void Main(string[] args)
        {
            var AB = Sarray();
            var A = AB[0];
            var B = AB[1];
            var g = gcd(A, B);
            var div = primefactorize(g);
            WriteLine(div.Count + 1);
        }
        static long gcd(long x, long y) => y == 0 ? x : gcd(y, x % y);

        static Dictionary<long,long> primefactorize(long n)
        {
            var primes = new Dictionary<long, long>();
            for (long i = 2; i * i <= n; ++i)
            {
                while (n % i == 0)
                {
                    if (primes.ContainsKey(i))
                        ++primes[i];
                    else
                        primes[i] = 1;
                    n /= i;
                }
            }
            if (n != 1) primes[n] = 1;
            return primes;
        }
    }
}

Measured memory_bytes: 13396
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

vector<lint> eratosthenes_sieve(lint n) {
    vector<lint> ps(n + 1);
    iota(ps.begin() + 2, ps.end(), 2);
    for (lint i = 2; i * i <= n; ++i)
        if (ps[i])
            for (lint j = i * i; j <= n; j += i) ps[j] = 0;
    return ps;
}

vector<lint> make_primes(lint n) {
    vector<lint> ps = eratosthenes_sieve(n);
    ps.erase(remove(ps.begin(), ps.end(), 0), ps.end());
    return ps;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    lint q, l, r;
    scanf("%lld", &q);
    vector<lint> ps = make_primes(100000);
    set<lint> prime;
    for (auto n : ps){
        prime.insert(n);
    }
    vector<lint> ans(100001, 0);
    for (int i=3; i<=100000; i+=2){
        if(prime.count(i) == 1 && prime.count((i + 1) / 2) == 1){
            ans[i] = ans[i - 2] + 1;
            ans[i + 1] = ans [i];
        }
        else {
            ans[i] = ans[i - 2];
            ans[i + 1] = ans[i];
        }
    }
    for (lint i = 0; i < q; ++i){
        scanf("%lld %lld", &l, &r);
        lint q_ans = ans[r] - ans[l - 1];
        printf("%lld\n", q_ans);
    }
    return 0;
}

Measured memory_bytes: 2688
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
ll N,M,K,ans,X;
string S,T;
ll C[200005];
ll R[200005];
ll INF = 998244353;
vector<ll> fac(300001);
vector<ll> ifac(300001);
ll mpow(ll x, ll n){
    ll a = 1;
    while(n != 0){
        if(n&1) a = a*x % INF;
        x = x*x % INF;
        n = n >> 1;
    }
    return a;
}
ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % INF;
    return tmp * fac[a] % INF;
}

bool found = true;
int main(){
    cin >> N >> M >> K;
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % INF;
        ifac[i+1] = ifac[i]*mpow(i+1, INF-2) % INF;
    }
    X = mpow(M-1,N-K-1);
    X = (X*M)%INF;
    C[0] = 1;
    R[0] = X;
    for(ll i=1;i<=K;i++){
        C[i] = comb(N-1,i);
        R[i] = (R[i-1]*(M-1))%INF;
    }
    for(ll i=0;i<=K;i++){
        ans = (ans + (C[i]*R[K-i])%INF)%INF;
    }
    cout << ans << endl;
    
}




Measured memory_bytes: 11080
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

    long double tmp = a*b;
    ll ans = tmp;

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

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

int main() {
    int n,x,y,i,j;
    cin>>n>>x>>y;
    int a[2005]={0};
    for(i=1; i<n; i++) {
        for(j=i; j<=n; j++) {
            a[min(j-i,abs(x-i)+abs(j-y)+1)]++;
        }
    }
    for(i=1;i<n;i++)
        printf("%d\n",a[i]);
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N;
  cin >> N;
 
  vector<int> a(N);
  long double ans = 0;
  rep(i, N) {
    cin >> a.at(i);
    ans += 1.0 / a.at(i);
  }

  cout << fixed << setprecision(10);
  cout << 1.0 / ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
int n;
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>n;
	cout<<(n<1000?"ABC":"ABD");
	re 0;
}

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

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

	int AC=0,WA=0,TLE=0,RE=0;
	for(int i=0;i<N;i++){
		if(S.at(i) == "AC"){
			AC++;
		}else if(S.at(i) == "WA"){
			WA++;
		}else if(S.at(i) == "TLE"){
			TLE++;
		}else{
			RE++;
		}
	}

	cout << "AC x " << AC << endl;
	cout << "WA x " << WA << endl;
	cout << "TLE x " << TLE << endl;
	cout << "RE x " << RE << endl;

}


Measured memory_bytes: 6372
from heapq import*
I=lambda:list(map(int,input().split()))[::-1]
k,n=I()
q=[]
v=i=T=A=0
l=[0]*-~n
for b,a in sorted(eval('I(),'*n))[::-1]:
 if i<k:
  if l[a]:heappush(q,b)
  else:T+=v*2+1;v+=1
  T+=b
 elif l[a]^1and q:T+=b+v*2+1-heappop(q);v+=1
 A=max(A,T);i+=1;l[a]=1
print(A)

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

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

  map<string, int> mp;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;

    if (mp.count(s) == 0) {
      mp.insert(make_pair(s, 1));
    } else {
      mp[s]++;
    }
  }

  int M;
  cin >> M;

  for (int i = 0; i < M; i++) {
    string s;
    cin >> s;

    if (mp.count(s) == 0) {
      mp.insert(make_pair(s, -1));
    } else {
      mp[s]--;
    }
  }

  int ans = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    int n = itr->second;
    if (n > ans) {
      ans = n;
    }
  }

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

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>

using namespace std;

#define NMAX 200010

int a[NMAX];
int imos[NMAX];

void reset(int n) {
    for(int i = 0; i < n; i++) imos[i] = 0;
}

int max(int a, int b) {
    if(a > b) return a;
    else return b;
}

int min(int a, int b) {
    if(a > b) return b;
    else return a;
}

int get_int() {
    int res = 0;
    char c = getchar();
    while(c != EOF && c != ' ' && c != '\n') {
        res *= 10;
        res += c - '0';
        c = getchar();
    }
    return res;
}

void put_int(int n) {
    char c[30];
    int sz = 0;
    c[sz++] = (n % 10) + '0';
    n /= 10;
    while(n > 0) {
        c[sz++] = (n % 10) + '0';
        n /= 10;
    }
    for(int i = sz-1; i >= 0; i--) {
        putchar(c[i]);
    }
    putchar('\n');
}

int main(){

    int n, k;
    n = get_int();
    k = get_int();
    for(int i = 0; i < n; i++) a[i] = get_int();

    for(int itr = 0; itr < k; itr++) {
        int f = 0;
        reset(n+1);
        for(int i = 0; i < n; i++){
            f = (a[i] != n);
            imos[max(0, i - a[i])]++;
            imos[min(n, i + a[i] + 1)]--;
        }
        int acc = 0;
        for(int i = 0; i < n; i++){
            acc += imos[i];
            a[i] = acc;
        }
        if(!f) break;
    }

    for(int i = 0; i < n; i++) put_int(a[i]);
    return 0;
}


Measured memory_bytes: 5160
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
        
        if(a.charAt(0)==b.charAt(0) && b.charAt(0) == c.charAt(0)){
            System.out.println("No");
        }else if(a.charAt(0) != b.charAt(0) && a.charAt(0) != c.charAt(0) && b.charAt(0) != c.charAt(0)){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 21716
//{{{
#include "bits/stdc++.h"
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const int MOD = 1e9+7;
//}}}

int parents[100001];
int p[100001];
int root(int x){
  if(parents[x] == x){
    return x;
  }else{
    return parents[x] = root(parents[x]);
  }
}

void unite(int x, int y){
  x = root(x);
  y = root(y);
  if(x == y) return;
  parents[x] = y;
}

int main(){
  int N, M;
  cin >> N >> M;
  rep(i, N) cin >> p[i];
  rep(i, 1, N){
    parents[i] = i;
  }

  rep(i, M){
    int x, y;
    cin >> x >> y;
    unite(x, y);
  }

  int ans = 0;
  rep(i, N){
    int id = i + 1;
    if(root(id) == root(p[i])){
      ans++;
    }
  }

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


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

int main(void) {
    string s;
    cin >> s;
    reverse(s.begin(),s.end());
    cout << s << endl;
    return 0;
}

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

 int main () {
 char str [222];
 scanf ("%s", str ) ;
 int n= strlen (str ) ;
 for (int i=n -2; i; i -=2) {
 if( strncmp (str , str +i/2 , i/2) ==0) {
 printf ("%d\n" ,i) ;
 return 0;
 }
 }
 return 0;
 }

Measured memory_bytes: 256
while n = gets.to_i
  break if n == 0
  l = gets.split.map(&:to_i)
  dif = l.zip(l[1..-1])[0...-1].map{ |v| v[1] - v[0] }
  dif << 2
  ret = []
  f = false

  n.times do |i|
    if dif[i] != 1
      if f
        ret[-1] = ret[-1].to_s+ "-"+ l[i].to_s
        f = false
      else
        ret << l[i].to_s
      end
    else
      if !f
        ret << l[i].to_s
        f = true
      end
    end
  end
  puts ret.join(" ")
end

Measured memory_bytes: 8780
#include <iostream>
#include <bitset>

int main() {
    std::bitset<64> a(0);

    int Q;
    std::cin >> Q;
    for (int q = 0; q < Q; ++q) {
        int t;
        std::cin >> t;
        int i;
        switch (t) {
            case 0:
                std::cin >> i;
                std::cout << a.test(i) << std::endl;
                break;

            case 1:
                std::cin >> i;
                a.set(i);
                break;

            case 2:
                std::cin >> i;
                a.reset(i);
                break;

            case 3:
                std::cin >> i;
                a.flip(i);
                break;

            case 4:
                std::cout << a.all() << std::endl;
                break;

            case 5:
                std::cout << a.any() << std::endl;
                break;

            case 6:
                std::cout << a.none() << std::endl;
                break;

            case 7:
                std::cout << a.count() << std::endl;
                break;

            default:
                std::cout << a.to_ullong() << std::endl;
                break;
        }
    }
    return 0;
}



Measured memory_bytes: 3088
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int count_ab(string s) {
	size_t pos = 0;
	int cnt = 0;
	while (true) {
		pos = s.find("AB", pos);
		if (pos == string::npos)
			break;
		cnt++, pos++;
	}

	return cnt;
}
int main() {
	int n;
	cin >> n;

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

	int cnt = 0;
	int leftb = 0, righta = 0, both = 0;
	for (int i = 0; i < n; i++) {
		cnt += count_ab(s[i]);
		if (s[i].front() == 'B' && s[i].back() == 'A')
			both++;
		else if (s[i].front() == 'B')
			leftb++;
		else if (s[i].back() == 'A')
			righta++;
	}

	if (both == 0) {
		cnt += min(leftb, righta);
	}
	else {
		cnt += both - 1;
		if (leftb > 0) {
			leftb--, cnt++;
		}
		if (righta > 0) {
			righta--, cnt++;
		}
		cnt += min(leftb, righta);
	}
	
	cout << cnt << endl;


	return 0;
}

Measured memory_bytes: 1144
#include<iostream>
#include<string>

using namespace std;

int main(){
  string str;
  cin >> str;

  int a = str.size();
  char swap;
  for(int i = 0; i < a/2; i++){
    swap = str[i];
    str[i] = str[a-i-1];
    str[a-i-1] = swap;
  }

  cout << str << endl;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<long long> A(N);
  bool flag = false;
  for(int i=0;i<N;i++)
    cin >> A.at(i);
  sort(A.begin(),A.end());
  for(int i=0;i<N-1;i++)
    {
    if(A.at(i)==A.at(i+1))
      {
       flag = true;
      }
       }
  if(flag==true)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
}



Measured memory_bytes: 1792