akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#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>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

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

  int n;
  string s, t;
  cin >> n >> s >> t;

  int res = n * 2;
  rep(i,n) {
    if (s.substr(i, n-i) == t.substr(0, n-i)) res = min(res, n+i);
  }

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

typedef long long ll;

int main(void)
{
    int N;
    cin >> N;
    vector<int> l(N);
    REP(i, N)
    cin >> l[i];

    sort(l.begin(), l.end());
    ll ans = 0;

    REP(i, N)
    {
        rep(j, i + 1, N)
        {
            // b - a < c < a + b
            auto it = lower_bound(l.begin() + j + 1, l.end(), l[i] + l[j]);
            auto it2 = upper_bound(l.begin() + j + 1, l.end(), l[j] - l[i]);
            if (it2 == l.end())
                continue;
            /*
            if (it == l.end())
            
                it = l.end() - 1;
                */
            int dist = distance(it2, it);
            // cout << i << " " << j << " ";
            // cout << *it2 << " " << *it << endl;
            ans += dist;
        }
    }
    cout << ans << endl;
}

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

typedef long long ll;

int N;
ll A[200005];

int main() {
  std::cin >> N;
  for (int i = 0; i < N; ++i)
    std::cin >> A[i];
  std::sort(A, A+N, std::greater<int>());

  ll sum = -A[0];
  for (int i = 0; i < N; ++i)
    sum += A[i/2];

  std::cout << sum << "\n";

  return 0;
}


Measured memory_bytes: 5208
import java.util.*;
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String ans = "Yes";
		for(int i=1;i<=S.length();i++){
			if((i%2)==1){
				if((S.charAt(i-1)=='R')||(S.charAt(i-1)=='U') ||(S.charAt(i-1)=='D')){
				}
				else{
				ans="No";
				}
			}
			else{
				if((S.charAt(i-1)=='L')||(S.charAt(i-1)=='U') ||(S.charAt(i-1)=='D')){
				}
				else{
				ans="No";
				}
			}
		}
		System.out.println(ans);
    }
}

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

vector<vector<int>> v(111111);
bool used[111111];

ll dfs(int p){
    ll ret = 0;
    used[p] = 1;
    vector<int> e;
    for(auto i:v[p]){
        if(!used[i]){
            ll t = dfs(i);
            e.push_back(t);
        }
    }
    sort(e.begin(),e.end(),greater<int>());
    for(ll i=0;i<e.size();i++){
        ret = max(ret, e[i] + i + 1);
    }
    return ret;
}

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

   int n;
   cin>>n;
   for(int i=2;i<=n;i++){
       int a;
       cin>>a;
       v[a].push_back(i);
       //v[i].push_back(a);
   }
   ll ans = dfs(1);
   //ans--;
   cout<<ans<<endl;
   
}

Measured memory_bytes: 13952
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;

 
int main() {
	long long n, ans = 0;
	cin >> n;
	map<long long, pair<long long, long long> > m;
	vector<long long> a(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		m[a[i]].first++;
		ans -= m[a[i]].second;
		if(m[a[i]].first == 2) m[a[i]].second = 1;
		else if(m[a[i]].first > 2) m[a[i]].second = m[a[i]].second * m[a[i]].first / (m[a[i]].first - 2);
		ans += m[a[i]].second;  
	}
	for(int i = 0; i < n; ++i){
		long long ans1 = ans - m[a[i]].second;
		if(m[a[i]].second > 2) ans1 += m[a[i]].second * (m[a[i]].first - 2) / m[a[i]].first;
		cout << ans1 << "\n";
	}
}


Measured memory_bytes: 11136
INF = 100 ** 7


def main():
    n, m = map(int, input().split())
    c_list = list(map(int, input().split()))

    dp = [INF] * (n + 1)
    dp[0] = 0
    for c in c_list:
        for i in range(len(dp)):
            if dp[i] != INF and i + c < len(dp):
                dp[i + c] = min(dp[i + c], dp[i] + 1)
    print(dp[n])


if __name__ == '__main__':
    main()

Measured memory_bytes: 9528
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <list>
#include <cmath>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <set>
using ll = long long;
using namespace std;
#define INF 999999999

int main()
{
    int X, T;
    cin >> T >> X;
    cout << T / (double)X << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import decimal # 10進法に変換，正確な計算

def input():
    return sys.stdin.readline().strip()

def main():
    a, b, k = map(int, input().split())
    if k <= a:
        print(a-k, b)
        return
    elif k <= a + b:
        print(0, b-k+a)
        return
    print(0, 0)

    
    
main()

Measured memory_bytes: 5076
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

using namespace std;

const int mod = 998244353;

int bp(int x, int y) {
	if (y==0) return 1;
	if (y==1) return x%mod;
	if (y%2) return ((ll) x * bp(x, y-1)) % mod;
	int t = bp(x, y/2);
	return ((ll) t * t) % mod;
}

int n;

vector<vector<int> > gr;

vector<int> get() {


	vector<int> grundy(n, 0);

	gr.assign(n, {});

	int m;
	cin >> m;

	for (int i = 0; i < m; ++i) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		if (u > v) swap(u, v);
		gr[u].push_back(v);
	}

	for (int i = n-1; i >= 0; i--) {
		set<int> kek;
		for (int j = 0; j < gr[i].size(); ++j) {
			int to = gr[i][j];
			kek.insert(grundy[to]);
		}
		int Q = 0;
		while (kek.count(Q)) Q++;
		grundy[i] = Q;
	}

	vector<int> rg(n, 0);
	for (int i = 0; i < n; ++i) {
		int Q = bp(10, 18);
		Q = bp(Q, i+1);

		rg[grundy[i]] += Q;
		rg[grundy[i]] %= mod;
	}

	grundy = rg;


	return grundy;

}


// u can set modular arithmetic here
void hadamard(vector<int>& v){
	int K = v.size();
    for (int step=K; step > 1; step /= 2){
        for (int start=0; start < K; start += step){
            for (int w=0; w < step/2; w++){
                int F = (v[start+w] + v[start+step/2+w]) % mod;
                int S = (v[start+w] - v[start+step/2+w] + mod) % mod;
                v[start + w] = F;
                v[start+step/2+w] = S;
            }
        }
    }
}


vector<int> mult(vector<int> a, vector<int> b) {
	int n = 1;
	while (n < a.size() || n < b.size()) n *= 2;
	while (a.size() < n) a.push_back(0);
	while (b.size() < n) b.push_back(0);

    hadamard(a);
    hadamard(b);
    for (int i=0; i < a.size(); i++) a[i] = ((ll) a[i] * b[i]) % mod;
    hadamard(a);
	int R = bp(a.size(), mod-2);
    for (int i=0; i < a.size(); i++) a[i] = ((ll) a[i] * R) % mod;

    return a;
    // f is ur answer
}

int main(){
#ifdef LOCAL
	freopen("A_input.txt", "r", stdin);
	//freopen("A_output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	cin >> n;

	vector<vector<int> > arr;

	for (int i = 0; i < 3; ++i) {
		auto kek = get();
		arr.push_back(kek);
	}	

	vector<int> c = {0, 1}, d = {0, 1};
	vector<int> e = mult(c, d);

	vector<int> a = mult(arr[0], mult(arr[1], arr[2]));


	cout << a[0];

}


Measured memory_bytes: 8816
#include <bits/stdc++.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
string s;
bool answered;
 
void dfs(int d, int u){
	if(d == s.length()-1){
		int t = s[0] - '0';
		for(int i = 0; i < s.length()-1; i++){
			if(u & (1 << i)){
				t += s[i+1] - '0';
			}else{
				t -= s[i+1] - '0';
			}
		}
 
		if(t == 7 && !answered){
			cout << s[0];
			for(int i = 0; i < s.length()-1; i++){
				if(u & (1 << i)){
					cout << '+' << s[i+1];
				}else{
					cout << '-' << s[i+1];
				}
			}
			cout << "=7" << endl;
			answered = true;
			return;
		}
		return;
	}
 
	int b = (1 << d);
	dfs(d+1, u);
	dfs(d+1, u+b);
}
 
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	cin >> s;
	answered = false;
	dfs(0, 0);
}
//コピペしただけでよくわかってない

Measured memory_bytes: 256
fun main(args: Array<String>) {
    // Your code here!
    var (a,b) = readLine()!!.split(" ").map{it.toLong()}
    var msg = "IMPOSSIBLE"
    
    if((a+b) % 2 == 0L){
        println((a+b)/2)        
    }else{
        println(msg)   
    }
}


Measured memory_bytes: 37728
import numpy as np

n, k = map(int, input().split())
ans = 0
mod = 10 ** 9 + 7
arr = np.arange(n+1)
a = np.cumsum(arr)
b = np.cumsum(arr[::-1])

for i in range(k, n+1+1):
    ans += b[i-1] - a[i-1] + 1
print(ans%mod)

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const ll MOD = 1000000007;

int N;
int a[100010], b[100010];
pii p[200010];
int num[2];

int main() {
	cin >> N;

	rep(i, N) {
		cin >> a[i];
		p[i] = mp(a[i], 0);
	}

	rep(i, N) {
		cin >> b[i];
		p[N+i] = mp(b[i], 1); 
	}

	sort(p, p+N*2);

	ll ret = 1;
	rep(i, N*2) {
		int t = p[i].se;
		if (num[t^1] == 0) {
			++num[t];
		} else {
			ret = ret * num[t^1] % MOD;
			--num[t^1];
		}
	}

	cout << ret << endl;

	return 0;
}

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

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

int main(void) {
    int n, x = 0, max_x = 0;
    string s;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    cin >> s;
    REP(i, n) {
        x += (s[i] == 'I')? 1 : -1;
        max_x = max(max_x, x);
    }

    cout << (max_x < 0? 0 : max_x) << "\n";
    return 0;
}

Measured memory_bytes: 256
program atcoder322B
  character(99) :: S
  read(5,*)S
  N = len_trim(S)
  J = 0
  do K=1,(N-1)/2
     if(S(K:K)<S(N+1-K:N+1-K) .or. S(K:K)>S(N+1-K:N+1-K)) J=1
  end do
  if((N-1)/4*2 == (N-1)/2 ) then
     do K=1,(N-1)/4
        if(S(K:K)<S((N-1)/2+1-K:(N-1)/2+1-K).or.S(K:K)>S((N-1)/2+1-K:(N-1)/2+1-K)) J=1
     end do
  else
     do K=1,(N-3)/4
        if(S(K:K)<S((N-1)/2+1-K:(N-1)/2+1-K).or.S(K:K)>S((N-1)/2+1-K:(N-1)/2+1-K)) J=1
     end do
  end if
  if(J==1) then
     write(6,*)'No'
  else
     write(6,*)'Yes'
  end if
end program atcoder322B

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;

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

  int H,N; cin >> H >> N;
  vector<int> A(N), B(N);
  rep(i, N) {
    cin >> A[i] >> B[i];
  }

  vector<vector<ll>> dp(N+1, vector<ll>(H+1, 1ll<<60));
  dp[0][0] = 0;

  rep(i, N) {
    for (int j = 0; j <= H; ++j) {
      dp[i+1][j] = min(dp[i][j], dp[i+1][max(0, j-A[i])] + B[i]);
    }
  }

  cout << dp[N][H] << endl;
}


Measured memory_bytes: 78592
N=int(input())
a_list=list(map(int,input().split()))
a_set=set(a_list)
if len(a_set)==1:
    if sum(a_set)==0:
        print("Yes")
    else:
        print("No")
elif len(a_set)==2:
    a_1, _=sorted(a_set)
    if a_1==0:
        if a_list.count(a_1)*3==N:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

elif len(a_set)==3:
    a_1,a_2,a_3=a_set
    if a_list.count(a_1)==a_list.count(a_2) and a_list.count(a_2)==a_list.count(a_3):
        if a_1 ^ a_2 == a_3:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:print("No")


Measured memory_bytes: 20372
w = str(input())
n = int(input())
while ( n > 0 ):
    n = n -1
    l  =  list(map(str,input().split()))
    if (l[0] == "print" ):
        print (w[int(l[1]):int(l[2])+1])
    elif(l[0] == "replace"):
        p1 = int(l[1])
        p2 = int(l[2])
        w = w[:p1] + l[3] + w[p2+1:]
    elif(l[0] == "reverse"):
        p1 = int(l[1])
        p2 = int(l[2])
        t1 = w[:p1]
        t2 = w[p1:p2+1]
        t3 = w[p2+1:]
        w = t1 + t2[::-1] + t3



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

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

Measured memory_bytes: 256
#include<stdio.h>
int N,f[2],i,C,x,u;
char c[3];
int main()
{
	for(;scanf("%d\n",&N),N;)
	{
		for(i=f[0]=f[1]=C=u=0;i<N;i++)
		{
			scanf("%s",c);
			x=c[0]=='r'?0:1;
			if(c[1]=='u')
			{
				f[x]=1;
				if(f[0]==1&&f[1]==1&&!u){u=1;++C;}
			}
			else
			{
				f[x]=0;
				if(f[0]==0&&f[1]==0&&u){u=0;++C;};
			}
		}
		printf("%d\n",C);
	}
	return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                                                \
  ifstream in("atcoder-problems/code_festival_2017_quala_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N, M, K;
  cin >> N >> M >> K;

  rep(i, N + 1) rep(j, M + 1) {
    int tmp = N * j + M * i - 2 * (i * j);
    if (tmp == K) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
}

Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ull = unsigned long long;

#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define For(i, s, n) for(int i = s; i < (int)(n); ++i)

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

  vector<ull> As(N + 1);
  vector<ull> Bs(M + 1);

  {
    ull sum = 0;
    Rep(i, N) {
      ull j;
      cin >> j;
      sum += j;
      As[i + 1] = sum;
    }
  }
  {
    ull sum = 0;
    Rep(i, M) {
      ull j;
      cin >> j;
      sum += j;
      Bs[i + 1] = sum;
    }
  }

  int answer = 0;
  Rep(n, N + 1) {
    ull remain = K - As[n];
    auto bound = lower_bound(Bs.begin(), Bs.end(), remain);
    if (*bound > remain) bound--;
    if (bound != Bs.end()) {
      int pos = (int)(bound - Bs.begin());
      answer = max(answer, n + pos);
    }
  }

  cout << answer << endl;
  return 0;
}


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

int
main(int argc, char** argv) {
    std::string S;
    std::cin >> S;

    int ans = 0;
    std::map<char, int> dic;

    const char* wp = S.c_str();
    for (char wc : S) {
        auto search = dic.find(wc);
        if (search != dic.end()) {
            dic[wc]++;
        } else {
            dic[wc] = 1;
        }
    }

    std::printf("%s\n", dic.size() == 2 ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() 
{
	int i = 0, x;

	cin >> x;

	while (x != 0)
	{
	    i++;
		cout << "Case " << i << ": " << x << endl;
		
	    cin >> x;
		
	}
	
	return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
using namespace std;
#define ll long long 
vector <int> g[1000];
ll a[200010];
int main() {
	ll n;
	cin>>n;
	ll cnt=0;
	ll now=1;
	for(ll i=0;i<n;i++){
		cin>>a[i];
		if(a[i]!=now){
			cnt++;
		}
		else{
			now++;
		}
	}
	if(n==cnt){
		cout << -1;
		return 0;
	}
	cout << cnt;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */

int main(void){
    int n,k;
    cin >> n >> k;
    vector<double> p;
    for(int i=0; i<n; i++){
        double tmp;
        cin >> tmp;
        double kitai = (1+tmp)/2;
        p.push_back(kitai);
    }

    vector<double> rui(n+1);
    rui[0] = 0;
    for(int i=1; i<=n; i++){
        rui[i] = rui[i-1] + p[i-1];
    }

    double ans = 0.0;
    for(int i=0; i<=(n-k); i++){
        if((rui[i+k] - rui[i]) > ans) ans = (rui[i+k] - rui[i]);
    }

    cout << setprecision(12) << ans;
    return 0;
}

Measured memory_bytes: 3440
import itertools
import math

N = int(input())
towns = [list(map(int, input().split())) for _ in range(N)]

combi = itertools.combinations(range(N), 2)


def dist(combi):
    t0 = towns[combi[0]]
    t1 = towns[combi[1]]
    d = math.sqrt((t0[0] - t1[0]) ** 2 + (t0[1] - t1[1]) ** 2)
    return d


dist_list = {}
for c in combi:
    key = '{0[0]}_{0[1]}'.format(sorted(c))
    dist_list[key] = dist(c)

def total_dist(perm):
    d = 0
    for p in zip(perm[:-1], perm[1:]):
        key = '{0[0]}_{0[1]}'.format(sorted(p))
        d += dist_list[key]
    return d


perm = itertools.permutations(range(N), N)

result = 0
count = 0
for p in perm:
    count += 1
    result += total_dist(p)

result /= count
print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p;

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

int main()
{
  ll N,H;
  cin >> H >> N;

  vector<ll> vec(N);
  for (ll i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  ll sum = 0;

  for (ll i = 0; i < N; i++) {
    sum+=vec.at(i);
  }

  if(H<=sum){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 1024
import math
N, D = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(N)]

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        tmp = 0
        for k in range(D):
            tmp+=(x[i][k]-x[j][k])**2
        if(math.sqrt(tmp).is_integer()):
            cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int mod(ll x){
	while(x<0)
		x+=INF;
	return (x%INF);
}
int main(){
	//~ #ifndef ONLINE_JUDGE
    //~ freopen("file.in", "r", stdin);
	//~ #endif	
	int n,m;
	int A=0,B=0,sum=0;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);x=mod(x);
		A=mod(A+mod(mod((i-1)*1LL*x)-sum));
		sum=mod(sum+x);
	}sum=0;
	for(int i=1;i<=m;i++){
		int x;
		scanf("%d",&x);x=mod(x);
		B=mod(B+mod(mod((i-1)*1LL*x)-sum));
		sum=mod(sum+x);
	}
	printf("%d\n",mod(A*1LL*B));
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define for_(i, s, e) for (int i = s; i < e; i++)
#define for__(i, s, e) for (ull i = s; i < e; i++)
#define SSTR(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl "\n"


int main() {
    #ifndef ONLINE_JUDGE
	freopen("test.in", "r", stdin);
    #endif
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n; cin >> n;
    int ct = 0;
    for_(i, 1, n+1) {
        int k; cin >> k;
        if (i % 2 == 1 and k % 2 == 1) ct += 1;
    }

    cout << ct << endl;

    return 0;
}

Measured memory_bytes: 3588
#include<iostream>
using namespace std;
int main() {
	int cards[4][13]={0};
	int num, i, x, y;
	char ch;
	cin >> num;
	for (i = 0; i < num; i++) {
		cin >> ch >> y;
		if (ch == 'S') x = 0;
		else if (ch == 'H') x = 1;
		else if (ch == 'C') x = 2;
		else x = 3;
		cards[x][y - 1] = 1;
	}
	int j, k;
	for (j = 0; j < 4; j++) {
		for (k = 0; k < 13; k++) {
			if (cards[j][k] != 1) {
				if (j == 0) cout << "S " << k + 1 << endl;
				else if (j == 1) cout << "H " << k + 1 << endl;
				else if (j == 2) cout << "C " << k + 1 << endl;
				else cout << "D " << k + 1 << endl;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 3092
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Rated for Me
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  if (n < 1200) puts("ABC");
  else if (n < 2800) puts("ARC");
  else puts("AGC");
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int n=Integer.parseInt(sc.next());
		int h[]=new int[100];
		int sum=0;
		int j;

		for(int i=0;i<n;i++){
			h[i]=Integer.parseInt(sc.next());
			for(j=i;j>=0;j--){
				if(i!=0&&h[i]<h[j]){
					break;
				}
			}
			if(j==-1)sum+=1;

		}
		System.out.println(sum);
	}

}

Measured memory_bytes: 20948
use std::cmp::max;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a:usize = read();
    let b:usize = read();
    let c:usize = read();
    let mx = max(a, max(b, c));
    let condition = (mx - a) % 2 + (mx - b) % 2 + (mx - c) % 2;
    let add = if condition == 2 {
        1
    } else if condition == 1 {
        2
    } else {
        0
    };
    println!(
        "{}",
        (mx - a) / 2 + (mx - b) / 2 + (mx - c) / 2 + add
    );
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int H,W;
char A[1005][1005];

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

struct dat{int y,x,d;};

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

    cin >> H >> W;

    queue<dat> que;
    int dist[1005][1005];
    int cnt = 0;
    int ans = 0;

    for (int i = 1;i <= H;i++){
        for (int j = 1;j <= W;j++){
            dist[i][j] = -1;
            cin >> A[i][j];
            if(A[i][j] == '#'){
                que.push({i,j,0});
                cnt++;
                dist[i][j] = 0;
            }
        }
    }

    while(que.size()){
        dat from = que.front(); que.pop();
        //cout << from.y << " " << from.x << endl;
        for (int i = 0;i < 4;i++){
            int ty = from.y+dy[i];
            int tx = from.x+dx[i];
            if(dist[ty][tx] == -1 && (tx > 0 && ty > 0 && tx <= W && ty <= H)){
                dist[ty][tx] = from.d+1;
                que.push({ty,tx,from.d+1});
                ans = max(ans,dist[ty][tx]);
            }
        }
    }

    cout << ans << endl;

    return 0;

}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

    int n, m, r; std::cin >> n >> m >> r;
    vi route(r);
    rep(i, r) {
        std::cin >> route[i];
        --route[i];
    }
    vvi cost(n, vi(n, inf));
    rep(i, m) {
        int a, b, c; std::cin >> a >> b >> c;
        --a, --b;
        cost[a][b] = c, cost[b][a] = c;
    }
    rep(k, n) rep(i, n) rep(j, n) {
        chmin(cost[i][j], cost[i][k]+cost[k][j]);
    }
    sort(rng(route));
    int ans = inf;
    do {
        int tmp = 0;
        rep(i, r-1) {
            tmp += cost[route[i]][route[i+1]];
        }
        chmin(ans, tmp);
    } while (next_permutation(rng(route)));
    std::cout << ans << "\n";
}


Measured memory_bytes: 384
N=gets.chomp.to_i
MEMO=Array.new(N+1,nil)
MEMO[N]=0
targets=[N]
flg=true
while flg do
    targets_new=[]
    targets.each do |t|
        d=1
        if MEMO[t-d]==nil
            MEMO[t-d]=MEMO[t]+1
            targets_new.push(t-d)
            flg=false if t==d
        end
        d=6
        while t>=d do
            if MEMO[t-d]==nil
                MEMO[t-d]=MEMO[t]+1
                targets_new.push(t-d)
                flg=false if t==d
            end
            d*=6
        end
        d=9
        while t>=d do
            if MEMO[t-d]==nil
                MEMO[t-d]=MEMO[t]+1
                targets_new.push(t-d)
                flg=false if t==d
            end
            d*=9
        end
    end
    targets=targets_new
end
puts MEMO[0]

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

int N;
int main(){
  cin >> N;
  vector<long long> A(N);
  long long ans = 0;
  long long k = 0;
  for(int i = 0; i < N; i++){
    cin >> A[i];
    if( k >= 1 ){
      long long t = min( k, A[i] );
      ans += t;
      A[i] -= t;
    }
    ans += A[i] / 2;
    k = A[i] % 2;
    // cout << ans << " k=" << k << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
let [| N; D |] = stdin.ReadLine().Split() |> Array.map int

let X =
    [| for i in [ 1..N ] do
        yield (stdin.ReadLine().Split() |> Array.map int) |]

let rec resolver s i j =
    if i = N then s
    elif j = N then resolver s (i + 1) (i + 2)
    else
        let d = Array.map2 (fun x y -> (x - y) * (x - y)) X.[i] X.[j] |> Array.sum

        let t =
            d
            |> float
            |> sqrt
            |> ceil
            |> int
        if t * t = d then resolver (s + 1) i (j + 1)
        else resolver s i (j + 1)

resolver 0 0 1 |> stdout.WriteLine

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

def readlines(n):
    for i in range(n):
        for j, x in enumerate(input().split()):
            yield int(x), (i, j)

def bingo(card):
    if any(all(row) for row in card):
        return True
    
    if any(all(row[i] for row in card) for i in range(3)):
        return True
    
    if all(card[i][i] for i in range(3)):
        return True

    if all(card[2-i][i] for i in range(3)):
        return True

def main():
    A = dict(readlines(3))
    card = [[False]*3 for _ in range(3)]
    n = int(input())
    for _ in range(n):
        b = int(input())
        if b in A:
            y, x = A[b]
            card[y][x] = True
        if bingo(card):
            print("Yes")
            return
    
    print("No")


main()


Measured memory_bytes: 3192
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
int main(){
  random_device rnd;
  mt19937 mt(rnd());
  int D;
  cin >> D;
  vector<int> c(26);
  for (int i = 0; i < 26; i++){
    cin >> c[i];
  }
  vector<vector<int>> s(D, vector<int>(26));
  for (int i = 0; i < D; i++){
    for (int j = 0; j < 26; j++){
      cin >> s[i][j];
    }
  }
  vector<int> last(26, -1);
  for (int i = 0; i < D; i++){
    int t = min(7, D - i);
    vector<vector<int>> L(26, vector<int>(t, 0));
    for (int j = 0; j < 26; j++){
      for (int k = 0; k < t; k++){
        L[j][k] = c[j] * (i + k - last[j]);
      }
    }
    int mx = 0;
    int a = 0;
    vector<int> best(t);
    vector<vector<int>> L2 = L;
    for (int j = 0; j < 20000; j++){
      vector<int> next(t, 0);
      if (j < 10000){
        for (int k = 0; k < t; k++){
          next[k] = mt() % 26;
        }
      } else if (j < 19000){
        next = best;
        for (int k = 0; k < 3; k++){
          int pos = mt() % t;
          int upd = mt() % 26;
          next[pos] = upd;
        }
      } else {
        next = best;
        for (int k = 0; k < 2; k++){
          int pos = mt() % t;
          int upd = mt() % 26;
          next[pos] = upd;
        }
      }
      //calculate diff
      int diff = 0;
      for (int k = 0; k < t; k++){
        diff += s[i + k][next[k]];
        for (int l = k; l < t; l++){
          diff += L2[next[k]][l] - (l - k) * c[next[k]];
          L2[next[k]][l] = (l - k) * c[next[k]];
        }
      }
      if (diff > mx){
        mx = diff;
        best = next;
        /*
        cout << "best: " << endl;
        for (int k = 0; k < t; k++){
          cout << best[k] << ' ';
        }
        cout << endl;
        cout << "mx = " << mx << endl;
        */
      }
      for (int k = 0; k < t; k++){
        L2[next[k]] = L[next[k]];
      }
    }
    cout << best[0] + 1 << endl;
    last[best[0]] = i;
  }
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;
    return 0;
}

Measured memory_bytes: 3564
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;

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

    if (n >= 2 * k - 1) {
        puts("YES");
    } else {
        puts("NO");
    }

    return 0;
}


Measured memory_bytes: 256
import sys

import numba as nb
import numpy as np

input = sys.stdin.readline


@nb.njit("i8(i8[:],i8)", cache=True)
def binary_search(a, key):
    """Meguru type binary search"""
    ng = -1
    ok = len(a)

    def is_ok(a, key, idx):
        if a[idx] >= key:
            return True
        else:
            return False

    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(a, key, mid):
            ok = mid
        else:
            ng = mid

    return ok


@nb.njit("i8(i8,i8[:])", cache=True)
def solve(N, L):
    L.sort()
    ans = 0
    for a in range(N - 2):
        for b in range(a + 1, N - 1):
            c = binary_search(L, L[a] + L[b]) - 1
            ans += c - b
    return ans


def main():
    N = int(input())
    L = np.array(input().split(), dtype=np.int64)

    ans = solve(N, L)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 107060
#include <bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define compress(v) sort(all(v)), v.erase(unique(all(v)), v.end())
using namespace std;

typedef long long ll;
typedef pair<ll, ll> p;

ll n, d, cnt;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    cin >> n >> d; d *= d;
    for(int i=1; i<=n; i++){
        ll a, b; cin >> a >> b;
        if(a*a + b*b <= d) cnt++;
    }
    cout << cnt;
}

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

signed conc(vector<string> ans,int k){
    sort(ans.begin(),ans.end());
    cout << ans.at(k-1) << endl;;

    return 0;
}

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

    string s; cin >> s;
    int k; cin >> k;

    int n = s.size();

    vector<string> ans(25,"zzzzz");

    for(int i = 0;i < n;i ++){
        if(s.substr(i,1) < ans.at(0)) ans.at(0) = s.substr(i,1);
    }
    
    for(int j = 1;j < 5;j ++){
        for(int i = 0;i < n;i ++){
            if(s.substr(i,1) < ans.at(j) && s.substr(i,1) > ans.at(j-1)) ans.at(j) = s.substr(i,1);
        }
    }
    if(n == 1){
        conc(ans,k);
        return 0;
    } 


    for(int i = 0;i < n-1;i ++){
        if(s.substr(i,2) < ans.at(5)) ans.at(5) = s.substr(i,2);
    }
    
    for(int j = 6;j < 10;j ++){
        for(int i = 0;i < n-1;i ++){
            if(s.substr(i,1) < ans.at(j) && s.substr(i,2) > ans.at(j-1)) ans.at(j) = s.substr(i,2);
        }
    }
    if(n == 2){
        conc(ans,k);
        return 0;
    } 


    for(int i = 0;i < n-2;i ++){
        if(s.substr(i,3) < ans.at(10)) ans.at(10) = s.substr(i,3);
    }
    
    for(int j = 11;j < 15;j ++){
        for(int i = 0;i < n-2;i ++){
            if(s.substr(i,3) < ans.at(j) && s.substr(i,3) > ans.at(j-1)) ans.at(j) = s.substr(i,3);
        }
    }
    if(n == 3){
        conc(ans,k);
        return 0;
    } 


    for(int i = 0;i < n-3;i ++){
        if(s.substr(i,4) < ans.at(15)) ans.at(15) = s.substr(i,4);
    }
    
    for(int j = 16;j < 20;j ++){
        for(int i = 0;i < n-3;i ++){
            if(s.substr(i,4) < ans.at(j) && s.substr(i,4) > ans.at(j-1)) ans.at(j) = s.substr(i,4);
        }
    }
    if(n == 4){
        conc(ans,k);
        return 0;
    } 


    for(int i = 0;i < n-4;i ++){
        if(s.substr(i,5) < ans.at(20)) ans.at(20) = s.substr(i,5);
    }
    
    for(int j = 21;j < 25;j ++){
        for(int i = 0;i < n-4;i ++){
            if(s.substr(i,5) < ans.at(j) && s.substr(i,5) > ans.at(j-1)) ans.at(j) = s.substr(i,5);
        }
    }
    conc(ans,k);





}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL;
  typedef pair<ll,char> PLC;
  typedef pair<char,ll> PCL;

int main(void){
  int N,K;cin >> N >> K;
  int i;REP(i,N){
    int x;cin >> x;
  }
  int out = (N-1)/(K-1);
  if((N-1)%(K-1)!=0) out++;
  cout << out << endl;
  return 0;
}


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

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

	if (S[0] != S[1]) {
		printf("Yes\n");
		return 0;
	}

	if (S[0] != S[2]) {
		printf("Yes\n");
		return 0;
	}

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

Measured memory_bytes: 256
from random import random
from sys import setrecursionlimit

setrecursionlimit(10 ** 5)


class TreapNode:
    _value = None
    _priority = None
    _count = None
    _left = None
    _right = None

    def __init__(self, value):
        self._value = value
        self._priority = random()
        self._count = 1


def treap_rotate_right(n):
    l = n._left
    n._left = l._right
    l._right = n
    return l


def treap_rotate_left(n):
    r = n._right
    n._right = r._left
    r._left = n
    return r


def treap_insert(n, v):
    if n is None:
        return TreapNode(v)
    if n._value == v:
        n._count += 1
        return n
    if n._value > v:
        n._left = treap_insert(n._left, v)
        if n._priority > n._left._priority:
            n = treap_rotate_right(n)
    else:
        n._right = treap_insert(n._right, v)
        if n._priority > n._right._priority:
            n = treap_rotate_left(n)
    return n


def treap_delete(n, v):
    if n is None:
        raise Exception('no nodes')
    if n._value > v:
        n._left = treap_delete(n._left, v)
        return n
    if n._value < v:
        n._right = treap_delete(n._right, v)
        return n

    # n._value == v
    if n._count > 1:
        n._count -= 1
        return n

    if n._left is None and n._right is None:
        return None

    if n._left is None:
        n = treap_rotate_left(n)
    elif n._right is None:
        n = treap_rotate_right(n)
    else:
        # n._left is not None and n._right is not None
        if n._left._priority < n._right._priority:
            n = treap_rotate_right(n)
        else:
            n = treap_rotate_left(n)
    return treap_delete(n, v)


def treap_size(n):
    if n is None:
        return 0
    return n._count + treap_size(n._left) + treap_size(n._right)


def treap_str(n):
    if n is None:
        return ""
    result = []
    if n._left is not None:
        result.append(treap_str(n._left))
    result.append("%d:%d" % (n._value, n._count))
    if n._right is not None:
        result.append(treap_str(n._right))
    return ' '.join(result)


def treap_search(n, v):
    # v 未満で最大のノードを検索する. v 未満のノードがなければ None を返す
    if n is None:
        return None
    if n._value >= v:
        if n._left is None:
            return None
        return treap_search(n._left, v)
    # n._value < v
    if n._right is None:
        return n
    r = treap_search(n._right, v)
    if r is None:
        return n
    return r


class Treap:
    _root = None
    _size = 0

    def insert(self, v):
        self._root = treap_insert(self._root, v)
        self._size += 1

    def delete(self, v):
        self._root = treap_delete(self._root, v)
        self._size -= 1

    def __len__(self):
        return self._size

    def __str__(self):
        return treap_str(self._root)

    def search(self, v):
        return treap_search(self._root, v)


N = int(input())
A = [int(input()) for _ in range(N)]

t = Treap()
for a in A:
    n = t.search(a)
    if n is not None:
        t.delete(n._value)
    t.insert(a)
print(len(t))


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

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

    vector<int> t(n+1, 0);
    for(int i=1; i<=n; i++){
        t[i] = l + i - 1;
    }
    int taste = accumulate(t.begin(), t.end(), 0);

    int mindif = 1000000000;
    int ans;
    for(int i=1; i<=n; i++){
        int total = 0;
        for(int j=1; j<=n; j++){
            if(i==j) continue;
            total += t[j];
        }
        int dif = abs(taste - total);
        if(mindif > dif){
            mindif = dif;
            ans = total;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(int i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

signed main(){
   IOS;
   map<char,int> m;
   int q,a,b,c;
   cin >> q >> a >> b >> c;
   m['A']=a;
   m['B']=b;
   m['C']=c;
   vector<string> v(q);
   rep(i,0,q) cin >> v[i];
   string ans = "";
   rep(i,0,q){
      int x=m[v[i][0]],y=m[v[i][1]];
      if(x == 0 and y == 0){
         cout << "No\n";
         return 0;
      }
      else if(x == 0){
         m[v[i][0]]++;
         m[v[i][1]]--;
         ans+=v[i][0];
      }
      else if (y == 0){
         m[v[i][0]]--;
         m[v[i][1]]++;
         ans+=v[i][1];
      }
      else if (i == q-1){
         ans+=v[i][0];
      }
      else if (v[i][0] == v[i+1][0] or v[i][0] == v[i+1][1]){
         m[v[i][0]]++;
         m[v[i][1]]--;
         ans+=v[i][0];
      }
      else{
         m[v[i][0]]--;
         m[v[i][1]]++;
         ans+=v[i][1];
      }
      // cout << m['A'] << " " << m['B'] << " " << m['C'] << "\n";
   }
   cout << "Yes\n";
   rep(i,0,q){
      cout << ans[i] << "\n";
   }
}

Measured memory_bytes: 6684
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		if(n<=999) {
			System.out.println("ABC");
		}
		else if(n>=1000) {
			System.out.println("ABD");
		}

	}

}

Measured memory_bytes: 35664
#include <bits/stdc++.h>
using namespace std;
int main (){
  int a,b;
  int c=0;
  cin>>a>>b;
  int i;
    switch (a){
      case 1:
        c+=300000;
        break;
      case 2:
        c+=200000;
        break;
      case 3:
        c+=100000;
        break;
      default:
        break;
    }
  switch (b){
      case 1:
        c+=300000;
        break;
      case 2:
        c+=200000;
        break;
      case 3:
        c+=100000;
        break;
      default:
        break;
    }
  if(a==b&&a==1)
    c+=400000;
  cout<<c;
  return 0;
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007;

int main(){
    
    string S;cin>>S;
    if(S.size()==1) cout<<0<<endl;
    else {
        bool flag=true;
        for(int i=1;i<S.size();i++){
            if(S[i]!=S[i-1]) flag=false;
        }
        if(flag) cout<<0<<endl;
        else{
            int ans=S.size();
            for(char now='a';now<='z';now++){
                bool check=true;
                string T=S;
                int N=S.size(),cnt;
                while(check){
                for(int i=1;i<N;i++){
                    if(T[i]==now) T[i-1]=now;
                }
                    bool aaa=true;
                    for(int i=0;i<N-1;i++){
                        if(T[i]!=now) aaa=false;
                    }
                    if(aaa){
                        cnt=S.size()+1-N;
                        check=false;
                    }else N--;
                }
                ans=min(ans,cnt);
            }
            cout<<ans<<endl;
        }
    }
}


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

#define ll long long

void solve(){
	string s, t;
	cin>>s>>t;
	int cnt = 0;
	for(int i = 0; i<s.length(); i++){
		if(s[i] != t[i]) cnt++;
	}
	cout<<cnt<<endl;
}

int main(){
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int t = 1;// cin>>t;
        while(t--){
                solve();
        }
}


Measured memory_bytes: 3788