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

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;

class UnionFind {
   // まとめる 判定 サイズを知る
  public:
   // Aから見た親の番号を格納する。rootだったら-1*その集合のサイズ。
   vector<ll> Parent;
 
   // 初期化
   UnionFind(ll N) {
     Parent = vector<ll>(N, -1);
   }
 
   // Aのrootを調べる
   int root(ll A) {
     if (Parent[A] < 0) return A;  // マイナスならそれはroot
     return Parent[A] = root(Parent[A]);
   }
 
   // rootの値をプラスに戻して返す(サイズ)
   int size(ll A) {
     return -Parent[root(A)];
   }
 
   // くっつける関数
   bool connect(ll A, ll B) {
     // AとBのroot同士をくっつける
     A = root(A);  // ここのAは、"rootの場所"の意味
     B = root(B);
     if (A == B) return false;  // 既にくっついている
     if (size(A) < size(B))
       swap(A, B);            // 大きい方にくっつけるために中身交換
     Parent[A] += Parent[B];  // 中身更新
     Parent[B] = A;
     return true;
   }
 };

int main() {
    ll n,m;
    cin>>n>>m;
    ll now=(n*(n-1))/2;
    vll ans;
    ans.push_back(now);
    UnionFind tree(n);
    vector<pair<ll,ll>> pp;
    rep(i,m){
      ll x,y;
      cin>>x>>y;
      pp.push_back(make_pair(x,y));
    }
    
      
    for (int i=m-1;i>=0;i--){
        ll x,y;
        x=pp[i].first-1;
        y=pp[i].second-1;
        ll xs=tree.size(x);
        ll ys=tree.size(y);
        if (!tree.connect(x,y)){
            ans.push_back(now);
        }
        else{
            now=now-xs*ys;
            ans.push_back(now);
            //cout<<111<<endl;
        }
        //cout<<now<<endl;

    }
    for (int i=m-1;i>=0;i--){
        cout<<ans[i]<<endl;
    }

    return 0;
}

Measured memory_bytes: 5488
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n; cin >> n;
  vector<int> p(n+1, 0);
  REP(i,n) {
    int x; cin >> x; x--;
    if (x == i) p[i] = 1;
  }
  ll ans = 0;
  REP(i,n) {
    if (p[i]) {
      ans++;
      if (p[i+1]) p[i+1] = 0;
    }
  }

  COUT(ans);
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl "\n"
#define all(v) v.begin(),v.end()
#define mp make_pair
#define mm(a) memset(a,0,sizeof(a))
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define repn(i,a,b) for(ll i = a; i >= b; i--)
#define pb push_back
#define ff first
#define ss second
#define fto(k,m) for(auto k:m)
#define in_edges(m) repp(i, 1, m){ ll a, b; cin >> a >> b; adj[a].pb(b), adj[b].pb(a);}
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define MOD 1000000000000000007
#define pii 3.14159265358979323846
int main()
{
	    // freopen("in.txt","r",stdin);
	    // freopen("out","w",stdout);
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	    ll t;t=1;
	    // cin >> t;
	    while(t--)
	    {
			ll n,m; cin >> n>>m;ll a[m];ll h=0;

			rep(i,0,m)
			{
				cin >> a[i];
				h+=a[i];
			}
			if(n-h>=0)
			cout <<n-h;
			else cout<<-1;
		}
}


Measured memory_bytes: 3704
E = input()
F = E.split(" ")

a=int(F[0])
b=int(F[1])
c=int(F[2])
d=int(F[3])

xy1 = a*c
xy2 = a*d
xy3 = b*c
xy4 = b*d

if xy1 >= xy2 and xy1 >= xy3 and xy1 >= xy4:
    print(xy1)

elif xy2 >= xy1 and xy2 >= xy3 and xy2 >= xy4:
    print(xy2)

elif xy3 >= xy1 and xy3 >= xy2 and xy3 >= xy4:
    print(xy3)

else: 
    print(xy4)


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

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

N = INT()
A = LIST()
MAX = 1000001
  
mod = 1000000007

prime = [0 for i in range(MAX)] 
max_map = dict() 
  
# function to return a^n 
def power(a, n):
    if n == 0: 
        return 1
    p = power(a, n // 2) % mod 
    p = (p * p) % mod 
      
    if n & 1: 
        p = (p * a) % mod 
    return p 
  
# function to find the smallest prime 
# factors of numbers upto MAX 
def sieve(): 
    prime[0], prime[1] = 1, 1
    for i in range(2, MAX): 
        if prime[i] == 0: 
            for j in range(i * 2, MAX, i): 
                if prime[j] == 0: 
                    prime[j] = i 
            prime[i] = i 

# function to return the LCM modulo M 
def lcmModuloM(arr, n): 
      
    for i in range(n): 
        num = arr[i] 
          
        temp = dict() 
          
        # temp stores mapping of prime factors  
        # to its power for the current element 
        while num > 1: 
               
            # factor is the smallest prime 
            # factor of num 
            factor = prime[num] 
              
            # Increase count of factor in temp 
            if factor in temp.keys(): 
                temp[factor] += 1
            else: 
                temp[factor] = 1
                  
            # Reduce num by its prime factor 
            num = num // factor 
              
        for i in temp: 
            # store the higest power of every prime 
            # found till now in a new map max_map 
            if i in max_map.keys(): 
                max_map[i] = max(max_map[i], temp[i]) 
            else: 
                max_map[i] = temp[i] 
              
    ans = 1
      
    for i in max_map: 
          
        # LCM is product of primes to their 
        # higest powers modulo M 
        ans = (ans * power(i, max_map[i])) % mod 
    return ans 
  
# Driver code
sieve()
arr = A
n = len(arr)
tmp = lcmModuloM(arr, n)

ans = 0
for i in range(N):
	ans = (ans + (tmp*power(A[i], mod-2))%mod) % mod
print(ans)


Measured memory_bytes: 16524
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	char a, b; cin >> a >> b;
	if (a == '9' || b == '9') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    g = gcd(a, b)
    return a * (b // g)


def main():
    A, B = map(int, input().split())
    print(lcm(A, B))
    return


main()


Measured memory_bytes: 2940
import sys
import math
import bisect
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    s = S()
    t = S()
    ans = 0
    for i in range(3):
        if s[i] == t[i]:
            ans += 1
    print(ans)
    return


# B
def B():
    a, b = LI()
    print(-(-(b - 1) // (a - 1)))
    return


# C
def C():
    N = I()
    H = LI()
    ans = 0
    cnt = 0
    for i in range(1, N):
        if H[i - 1] >= H[i]:
            cnt += 1
            ans = max(ans, cnt)
        else:
            cnt = 0
    print(ans)
    return


# D
def D():
    return


# E
def E():
    return


# F
def F():
    return


# Unittest
def resolve():
    C()
    return


# Solve
if __name__ == "__main__":
    C()


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    ll n, k;
    cin >> n >> k;
    vector<int> v(n);
    for(auto&& i : v) {
        cin >> i;
        i--;
    }

    vector<bool> flag(n, false);
    deque<int> tele;
    flag[0] = true;
    tele.push_back(0);

    int p = 0, start = 0;

    while(true){
        p = v[p];
        if(flag[p]){
            REP(i, tele.size()){
                if(tele[i] == p){
                    start = i;
                    break;
                }
            }
            break;
        }
        flag[p] = true;
        tele.push_back(p);
    }

    if(start > k){
        cout << tele[k] + 1 << endl;
        return 0; 
    }

    k -= start;

    while(tele.front() != p) tele.pop_front();
    ll mod = tele.size();

    cout << tele[k%mod] + 1 << endl;
    return 0;
}


Measured memory_bytes: 4764
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	int n = s.size();
	int res = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == t[i]) res++;
	}
	cout << res << endl;
}


Measured memory_bytes: 3548
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,k,a[55];cin>>n>>k;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	for(int i=2;i<=k;i++)
	{
		a[n-1]+=a[n-i];
	}
	cout<<a[n-1]<<endl;
	return 0;
}

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

std::pair<long long int, long long int> func2(long long int A, long long int B)
{
	if(A==0) return std::make_pair(0,-1);
	if(B==0) return std::make_pair(1,0);
	
	if(A>B)
	{
		long long int k = A/B;
		std::pair<long long int, long long int> P = func2(A%B,B);
		return std::make_pair(P.first,k*P.first+P.second);
	}
	else
	{
		long long int k = B/A;
		std::pair<long long int, long long int> P = func2(A,B%A);
		return std::make_pair(P.first+k*P.second,P.second);
	}
}

long long int A=1, B=1;
long long int ans = 1;
std::vector<long long int> V;
void func(int k)
{
	if(k==V.size())
	{
		long long int C1,C2,C3,S;
		std::pair<long long int, long long int> P = func2(A,B);
		
		if(P.first<0)
		{
			long long int C = (-P.first)/B;
			C++;
			P.first += C*B;
			P.second += C*A;
		}
		if(P.second<0)
		{
			long long int C = (-P.second)/A;
			C++;
			P.first += C*B;
			P.second += C*A;
		}
		C1 = (P.first-1)/B;
		C2 = (P.second-1)/A;
		C3 = C1<C2?C1:C2;
		P.first -= C3*B;
		P.second -= C3*A;
		S = P.second*B;
		ans = ans<S?ans:S;
		
		long long int temp = B;
		B = A;
		A = temp;
		
		P = func2(A,B);
		
		if(P.first<0)
		{
			long long int C = (-P.first)/B;
			C++;
			P.first += C*B;
			P.second += C*A;
		}
		if(P.second<0)
		{
			long long int C = (-P.second)/A;
			C++;
			P.first += C*B;
			P.second += C*A;
		}
		C1 = (P.first-1)/B;
		C2 = (P.second-1)/A;
		C3 = C1<C2?C1:C2;
		P.first -= C3*B;
		P.second -= C3*A;
		S = P.second*B;
		ans = ans<S?ans:S;
		
		temp = B;
		B = A;
		A = temp;
		return;
	}
	else
	{
		A*=V[k];
		func(k+1);
		A/=V[k];
		B*=V[k];
		func(k+1);
		B/=V[k];
	}
}
int main()
{
	for(int i=1;i<=18;i++) ans*=10;
	long long int a;
	scanf("%lld",&a);
	
	long long int b = 2*a;
	for(long long int i=2;i*i<=2*a;i++)
	{
		if(b%i==0)
		{
			long long int S = 1;
			while(b%i==0) S*=i, b/=i;
			V.push_back(S);
		}
	}
	if(b>1) V.push_back(b);
	
	func(0);
	printf("%lld",ans);
}

Measured memory_bytes: 3256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int n;
	cin>>n;
    int a[n];
    bool flag=true;

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

    int ans=0;
    bool flaga=false;
    bool flage=false;
    while(flaga==false&&flag==true){
        for(int i=0;i<n;i++){
            if(a[n-1]%2==0){
                flage=true;
            }
            a[i]=a[i]/2;
            if(a[i]%2==1){
                flaga=true;
                break;
            }
        }

        //  if(ans!=0&&flage==true){
        //      ans++;
        //      break;
        //  }      

        ans++;
        flage=false;
        flage=false;
    }

    cout << (flag?ans:0) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define nd second
#define st first
#define pb push_back
#define pa make_pair

using namespace std;
typedef long long int lo;
const int mod=1000000007;
lo a,b,c,d,e,g,h[500005],arr[500005];
lo dp[500005][13];

int main(){
// 	freopen("in.txt","r",stdin);
// 	freopen("out.txt","w",stdout);
	string s;
	cin >> s;
	dp[0][0] = 1;
	for(lo i=0;i<s.size();i++){
		for(lo k=0;k<13;k++){
			lo bas,son;
			(s[i]=='?')?bas=0:bas=s[i]-'0';
			(s[i]=='?')?son=9:son=s[i]-'0';
			for(lo j=bas;j<=son;j++){
				dp[i+1][(k*10+j)%13]=(dp[i+1][(k*10+j)%13]+dp[i][k])%mod;
			}
		}
	}
	cout << dp[s.size()][5] <<endl;
}

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

using namespace std;
int main()
{
	int a;
	cin >> a;
	for (int i = 1; i <= 9; i++) {
		if (a % i == 0 && a / i >= 1 && a / i <= 9) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

string solve(string& text1, string& text2) {

    int n = text1.size();
    int m = text2.size();
    
    if(n == 0) return text2;
    if(m == 0) return text1;
    
    vector<vector<int>> dp(n, vector<int>(m, 0));
    
    for(int i=0; i<n; ++i)
    {
        if(text1[i] == text2[0]) dp[i][0] = 1;
        else if(i != 0) dp[i][0] = dp[i-1][0];
    }
    
    for(int j=0; j<m; ++j)
    {
        if(text1[0] == text2[j]) dp[0][j] = 1;
        else if(j != 0) dp[0][j] = dp[0][j-1];
    }
    
    for(int i=1; i<n; ++i)
    {
        for(int j=1; j<m; ++j)
        {
            if(text1[i] == text2[j])
                dp[i][j] = 1 + dp[i-1][j-1];
            else
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);                
        }
    }
        
    string ans = "";
    int r = n - 1, c = m - 1;

    while(r >= 0 && c >= 0)
    {
        if(text1[r] == text2[c])
        {
            ans += text1[r];
            r--;
            c--;
        }
        else
        {
            if(r > 0 && c > 0)
            {
                if(dp[r][c-1] > dp[r-1][c]) c--;
                else r--;
            }
            else if(r > 0) r--;
            else c--;
        }
    }

    reverse(ans.begin(), ans.end());

    return ans;
}


int main() {
    string s, t;
    cin >> s >> t;

    cout << solve(s, t) << endl;

    return 0;
}

Measured memory_bytes: 38592
#include <bits/stdc++.h>
using namespace std;
int main () {
    int n; cin >> n;
    vector<double> x(n);
    vector<string> u(n);
    double count=0;
    for (int i=0;i<n;i++) {
        cin >> x[i] >> u[i];
        if(u[i]=="JPY") {
            count+= x[i];
        }
      else if (u[i]=="BTC") {
          count+= x[i] * 380000.0;
      }
    }
    cout << count << endl;
}

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

int main() {
  
  string o, e;
  cin >> o >> e;
  
  int a = o.size(), b = e.size();
  
  REP(i,a-1) cout << o[i] << e[i];
  
  if (a == b) cout << o[a-1] << e[b-1];
  else cout << o[a-1];

}


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

const int maxn = 3e5 + 10;
const long long inf = 1e18;

int n, m;
long long a[maxn], f[maxn], g[maxn], y[maxn], q[maxn], sum[maxn], h[maxn], temp[maxn];

inline bool check1 (int a, int b, int k) {return y[b] - y[a] < 1LL * (b - a) * k;}
inline bool check2 (int a, int b, int k) {return 1LL * (k - b) * (y[k] - y[a]) - 1LL * (k - a) * (y[k] - y[b]) < 0;}
inline void shift (int a, int b, long long c[]) {c[a] = max (c[a], c[b] + 1LL * (a - b) * (a - b + 1) / 2 - sum[a] + sum[b]);}

void get_dp (long long f[])
{
    int st = 0, ed = 0;
    q[ed++] = 0;
    for (int i = 1; i <= n; i++)
    {
        sum[i] = sum[i - 1] + a[i];
        for (; st < ed - 1 && check1 (q[ed - 2], q[ed - 1], i); ed--);
        f[i] = f[i - 1];
        shift (i, q[ed - 1], f);
        y[i] = f[i] + 1LL * i * (i - 1) / 2 + sum[i];
        for (; st < ed - 1 && check2 (q[ed - 2], q[ed - 1], i); ed--);
        q[ed++] = i;
    }
}

inline void rev (long long f[]) {for (int i = 1; i <= n / 2; i++) swap(f[i], f[n - i + 1]);}

inline void divide_conquer (long long f[], long long g[], int l, int r)
{
    if (l == r)
    {
        h[l] = max (h[l], f[l - 1] + g[r + 1] - a[l] + 1);
        return ;
    }
    if (l > r) return;
    int mid = l + r >> 1;
    int st = 0, ed = 0;
    for (int i = l - 1; i <= r; i++)
    {
        for (; st < ed - 1 && check2 (q[ed - 2], q[ed - 1], i); ed--);
        if (i < mid) q[ed++] = i, temp[i] = f[i];
        else
        {
            temp[i] = -inf;
            temp[i] = max(temp[i] , f[q[ed - 1]] + 1LL * (i - q[ed - 1]) * (i - q[ed - 1] + 1) / 2 - sum[i] + sum[q[ed - 1]] + g[i + 1]);
        }
    }
    for (int i = r - 1; i >= mid; i--) temp[i] = max (temp[i], temp[i + 1]);
    for (int i = r; i >= mid; i--) h[i] = max (h[i], temp[i]);

    divide_conquer (f, g, l, mid);
    divide_conquer (f, g, mid + 1, r);
}

int main()
{
    //freopen("C:/Users/MACHENIKE/Desktop/data.in","r",stdin);
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%lld", a + i);
    scanf("%d", &m);

    rev (a);
    get_dp (g); rev(g);
    rev (a);
    get_dp (f);

    for (int i = 0; i <= n + 1; i++) h[i] = -inf;
    divide_conquer (f, g, 1, n);
    rev(a); rev(g); rev(f); rev(h);
    for (int i = 1; i <= n; i++)
    {
        sum[i] = sum[i - 1] + a[i];
        y[i] = g[i] + 1LL * i * (i - 1) / 2 + sum[i];
    }
    divide_conquer (g, f, 1, n);
    rev(h); rev(g); rev(f); rev(a);

    while (m--)
    {
        int u, v;
        scanf("%d %d", &u, &v);
        printf("%lld\n", max (f[u - 1] + g[u + 1], h[u] - (v - a[u])));
    }
    return 0;
}


Measured memory_bytes: 21376
#ifdef LOCAL
//#define _GLIBCXX_DEBUG
#endif
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<char> Vc;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;
typedef vector<vector<char>> VVc;
typedef vector<vector<vector<ll>>> VVV;
typedef vector<vector<vector<vector<ll>>>> VVVV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define rEach(i, mp) for (auto i = mp.rbegin(); i != mp.rend(); ++i)
#ifdef LOCAL
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define dbgarrmint(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j].x<<" ";}cerr<<endl;}
#else
#define dbg(...)
#define dbgmap(...)
#define dbgarr(...)
#define dbgdp(...)
#define dbgmint(...)
#define dbgarrmint(...)
#endif
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int solve(){
    ll n,k;
    cin>>n>>k;
    Vec a(n);
    cin>>a;
    sort(ALL(a));
    ll ans = 0;
    rep(i,k){
        ans += a[i];
    }
    cout<<ans<<endl;
    return  0;
}

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


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
char a[5],b[5];
int main(){
	scanf("%s%s",a,b);
	if(a[0]=='H'&&b[0]=='H'){
		printf("H");
	}else if(a[0]=='D'&&b[0]=='D'){
		printf("H");
	}else if(a[0]=='D'&&b[0]=='H'){
		printf("D");
	}else printf("D");
}

Measured memory_bytes: 256
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
A=[list(map(int,input().split())) for i in range(N)]
count=0
for a in A:
    p=0
    for i in range(M):
        p+=a[i]*B[i]
    p+=C
    if p>0:count+=1
print(count)

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

int main() {
	cin.tie(0)->sync_with_stdio(false);

	ll k; cin >> k;

	int cnt = 1;
	int pad = 0;
	if (k % 2 == 0) cnt = -1;
	else if (k % 5 == 0) cnt = -1;
	else {
		int digit = 0;
		int tmp = k;
		while (tmp) {
			tmp /= 10;
			digit++;
		}
		pad = digit - 1;
		ll n = 7;
		while (--digit) {
			n *= 10;
			n += 7;
		}
		if (n < k) {
			n *= 10;
			n += 7;
			pad++;
		}
		while (true) {
			if (n % k == 0) break ;
			n %= k;
			n *= 10;
			n += 7;
			cnt++;
		}
	}
	cout << cnt + pad << '\n';

	return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
int main(void) {
	int K, X, i;
	scanf("%d %d", &K, &X);
	for (i = X - K + 1; i < X + K; i++) {
		if (i >= -1000000 && i <= 1000000) {
			printf("%d ", i);
		}
	}
	return 0;
}

Measured memory_bytes: 128
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineerin College

'''
import sys
from collections import deque,defaultdict as dd 
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input()
def mi():return map(int,input().split())
def li():return list(mi())
abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod=1000000007
#mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]



def solve():
    
    
    
    # for _ in range(ii()):
    
    
    n,m = mi()
    
    par = [i for i in range(n+1)]
    sz = [1]*(n+1)
    
    def find(i):
        if i == par[i]:
            return par[i]
        par[i] = find(par[i])
        return par[i]
    
    def union(u,v):
        u = find(u)
        v = find(v)
        if u!= v:
            if sz[u]>sz[v]:
                par[v] = u
                sz[u]+=sz[v]
            else:
                par[u] = v
                sz[v] += sz[u]
    
    
    for i in range(m):
        x,y = mi()
        union(x,y)
    print(max(sz))
    
    
if __name__ =="__main__":
    # read()
    solve()
    

Measured memory_bytes: 88464
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
inline int read()
{
	int x=0,t=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')t=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*t;
}
int n;
int main()
{
	cin>>n;
	int flag=0;
	for(int i=1;i<=9;i++)
	{
		if(n%i==0)
		{
			if(n/i>=1&&n/i<=9)
			{
				puts("Yes");
				flag=1;
				break;
			}
		}
	}
	if(!flag) puts("No");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int a;
    cin >> a;
    cout << 1110 - a << endl;
}

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

bool check(string s)
{
    int n=s.size();
    for (int i=1;i<=n/2;i++)
    {
        if (s[i-1]!=s[n-i]) return 0;
    }
    return 1;
}

int main()
{
    string s,a,b;
    getline(cin,s);
    int n=s.size();
    a=s.substr(0,(n-1)/2);
    b=s.substr((n+3)/2-1,(n-1)/2);
    if ((check(s)) and (check(a)) and (check(b)))
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    return 0;
}




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

int main() {
    int N,D,X; cin>>N>>D>>X;
    int A[N];
    for(int i=0;i<N;++i)cin>>A[i];
    
    int ans = X;
    for(int i=0;i<N;++i){
        int tmp = 1 + (D-1)/A[i];
        ans += tmp;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3640
n = int(input())
a = list(map(int,input().split()))
p = 1
c = 0
a.sort()
for i in range(n):
	p = a[i]*p
	if p > pow(10,18):
		break
	c += 1

if c == n:
	print(p)
else:
	print(-1)

Measured memory_bytes: 21776
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
int N, M;
typedef pair<int, pair<int, int> > P;
unordered_map<int, int> Mp;

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

  cin >> N >> M;
  int p, y;
  vector<P> L(M);
  rep(i, M){
    cin >> p >> y;
    P pr = make_pair(y, make_pair(p, i));
    L[i]=pr;
  }

  sort(L.begin(), L.end());
  vector<P> Ans(M);
  rep(i, M){
    int p = L[i].second.first;
    Mp[p] += 1;
    P pr = make_pair(L[i].second.second, make_pair(Mp[p], p));
    Ans[i] =  pr;
  }
  sort(Ans.begin(), Ans.end());
  rep(i, M){
    int idx = Ans[i].second.first;
    int p = Ans[i].second.second;
    cout << setfill('0') << right << setw(6) << p;
    cout << setfill('0') << right << setw(6) << idx << endl;
  }

  return 0;
}



Measured memory_bytes: 7972
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
using namespace std;
int main() {
    int N;
    double T,A;
    cin >> N;
    cin >> T >> A;
    vector<int> H(N);
    for(int i=0;i<N;i++){
        cin >> H.at(i) ;
    }
    vector<double> temp(N) ;
    for(int i=0;i<N;i++){
        temp.at(i) = T -(H.at(i))*0.006 ;
    }
    int suitable_price ;
    double min_differ = 9999999;
    double diff;
    for(int i=0;i<N;i++){
        if(A > temp.at(i)){
            diff = A - temp.at(i) ;
            if(diff < min_differ){
                min_differ = diff;
                suitable_price = i+1;
            }
        }
        else{
            diff = temp.at(i) - A;
            if(diff < min_differ){
                min_differ = diff;
                suitable_price = i+1;
            }
        }
    }
    cout  << suitable_price << endl;
}

Measured memory_bytes: 3660
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

vector<int> A(2000010);
int H;

void heapIncreaseKey(int i, int k){
    if(i > 1 && A[i/2] < k){
        swap(A[i], A[i/2]);
        heapIncreaseKey(i/2, k);
    }
}

void insert(int k){
    H++;
    A[H] = k;
    heapIncreaseKey(H, k);
}

void maxHeapify(int i){
    int l = 2 * i, r = 2 * i + 1;
    int largest = i;
    if(l <= H && A[l] > A[largest]) largest = l;
    if(r <= H && A[r] > A[largest]) largest = r;

    if(largest != i){
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}

int heapExtractMax(){
    int heap_max = A[1];
    A[1] = A[H];
    H--;
    maxHeapify(1);
    return heap_max;
}

int main(){
    H = 0;
    while(1){
        string S;
        cin >> S;
        if(S == "insert"){
            int k;
            cin >> k;
            insert(k);
        }
        else if (S == "extract") {
            cout << heapExtractMax() << endl;
        }
        else break;
    }
}


Measured memory_bytes: 10592
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    rep(i, n){
        cin >> a[i];
        sum += a[i];
    }
    ll ans = sum;
    for(ll i = 1; i < n; i += 2){
        ans -= 2*a[i];
    }
    rep(i, n){
        if(i > 0) cout << " ";
        if(i != 0) ans = 2*a[i-1] - ans;
        cout << ans;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3952
n = int(input())
h = [tuple(map(int, input().split())) for i in range(n)]
L = [x[0] for x in h]
R = [x[1] for x in h]

lmax = max(L)
lidx = L.index(lmax)
rmin = min(R)
ridx = R.index(rmin)

ret = max(0, 1 + rmin - lmax) + max(0, 1 + max(r - l for l, r in h))

g = [[max(0, 1 + r - lmax), max(0, 1 + rmin - l)] for l, r in h]
g.sort(key=lambda x: (x[0], -x[1]))
A = [x[0] for x in g]
B = [x[1] for x in g]
minb = 10**9
for i in range(n-1):
    if minb > B[i]:
        minb = B[i]
    if ret < minb + A[i+1]:
        ret = minb + A[i+1]
print(ret)

Measured memory_bytes: 47236
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

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 long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var NK = Sarray();
            var N = NK[0];
            var K = NK[1];
            var ans = 0L;
            for (var k = K; k <= N + 1; ++k)
            {
                var l = k * N % Mod;
                var r = k * (k - 1) % Mod;
                ans = (ans + l - r + 1) % Mod;
            }
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 28224
#include<stdio.h>
#include<string.h>
int huiwen(char a[],int y)
{
	int i,m;
	for(i=0;i<y/2;i++)
	{
		if(a[i]!=a[y-i-1])
		break;
	}
	if(i==y/2)
	m=1;
	else
	m=0;
	return m;
}
int main()
{
	char s[101],b[100];
	int length;
	int i;
	scanf("%s",s);
	length=strlen(s);
	if(huiwen(s,length)==1)
	{
		for(i=0;i<(length-1)/2;i++)
		{
			b[i]=s[i];
		}
		if(huiwen(b,(length-1)/2)==1)
		printf("Yes\n");
		else
		printf("No\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	int a,s[10001],d[10001],f,g,h,i,j,x[10001],z,c,v;
	v=0;
	scanf("%d",&a);
	for(i=1;i<=a;i++){
		scanf("%d %d",&s[i],&d[i]);
		f=s[i];
		x[i]=f*100+d[i];
	}
	scanf("%d",&g);
	h=a+g;
	for(i=1;i<=g;i++){
		scanf("%d %d",&s[a+i],&d[a+i]);
		f=s[a+i];
		x[a+i]=f*100+d[a+i];
	}
	for(i=1;i<=h;i++){
		for(j=i+1;j<=h;j++){
			if(x[i]==x[j]){
				x[j]=100000;
				s[j]=100000;
				d[j]=100000;
			}
			if(x[i]>x[j]){
				c=x[i];
				x[i]=x[j];
				x[j]=c;
				c=s[i];
				s[i]=s[j];
				s[j]=c;
				c=d[i];
				d[i]=d[j];
				d[j]=c;
			}
		}
	}
//	for(i=1;i<=h;i++)	printf("%d\n",x[i]);
	for(i=1;i<=h;i++){
		if(x[i]>10000){
			v++;
		}
	}
	printf("%d:%02d",s[1],d[1]);
	for(i=2;i<=h-v;i++){
		printf(" %d:%02d",s[i],d[i]);
	}
	printf("\n");
	return 0;
}

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


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

	vector<long long> l(90);
	l[0] = 2;
	l[1] = 1;
	for (int i = 2; i <= n; i++) {
		l[i] = l[i-1] + l[i-2];
	}
	
	cout << l[n] << endl;
	return 0;
}

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

const int INF = 2147483647;
const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};int dy[4] = {0,-1,0,1};
int main() {
    int n;cin >> n;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++) b[i] = a[n-i-1];
    vector<int> dp(n+1,INF);
    for(int i=0;i<n;i++){
	vector<int>::iterator itr = lower_bound(dp.begin(),dp.end(),b[i]);
	vector<int>::iterator itr2 = upper_bound(dp.begin(),dp.end(),b[i]);
	if(*itr != b[i]) *itr = b[i];
	else *itr2 = b[i];
    }

    int ans = lower_bound(dp.begin(),dp.end(),INF)-dp.begin();
    cout << ans << endl;
    return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  dsu d(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    d.merge(a,b);
  }
  int cnt = d.groups().size();
  int ans = cnt-1;
  cout << ans << endl;
  return 0;
}

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

int main() {
  int n,x,count,ans;
  cin>>n;
  vector<int> a(n/2);
  vector<int> b(n/2);
  vector<pair<int,int>> c(n/2);
  vector<pair<int,int>> d(n/2);
  for(int i=0;i<n/2;i++) cin>>a.at(i)>>b.at(i);
  for(int i=0;i<n/2;i++){
    c[i].first=0;
    d[i].first=0;
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  x=0;
  count=1;
  
  for(int i=0;i<n/2-1;i++){
    if(a.at(i)==a.at(i+1)){
      count++;
      c[x].first=count;
      c[x].second=a.at(i);
    }
    else{
      c[x].first=count;
      c[x].second=a.at(i);
      x++;
      count=1;
    }
  }
  
  x=0;
  count=1;
  
  for(int i=0;i<n/2-1;i++){
    if(b.at(i)==b.at(i+1)){
      count++;
      d[x].first=count;
      d[x].second=b.at(i);
    }
    else{
      d[x].first=count;
      d[x].second=b.at(i);
      x++;
      count=1;
    }
  }
  
  sort(c.begin(),c.end());
  sort(d.begin(),d.end());
  reverse(c.begin(),c.end());
  reverse(d.begin(),d.end());
  
  if(c[0].second!=d[0].second)
    ans=c[0].first+d[0].first;
  else if(c[0].first==c[1].first)
    ans=c[0].first+d[0].first;
  else if(d[0].first==d[1].first)
    ans=c[0].first+d[0].first;
  else{
    ans=max(c[0].first+d[1].first,c[1].first+d[0].first);
  }
  
  ans=n-ans;
  cout<<ans<<endl;
}

Measured memory_bytes: 1408
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;
type I = usize;

const D: usize = 40;

fn xor(v: usize) -> usize {
    let mut i = 1;
    let mut ret = 0;
    for _ in 0..D {
        if v/i % 2 == 1 {
            if v%2 == 0 {
                ret += i;
            }
        }
        if i == 1 {
            if v%4 == 1 || v%4 == 2 {
                ret += i;
            }
        }
        i *= 2;
    }
    ret
}

fn main() {
    input!{
      a: usize,
      b: usize,
    }
    let ax = xor(a-1);
    let bx = xor(b);
    println!("{}", bx^ax);
}


Measured memory_bytes: 4352
<>;@a=sort{$a-$b}glob<>;
$c=2;
for(($a[0]==$a[1])+1..$#a){
	if($a[$_]==$a[$_-1]){
		++$c
	}elsif($a[$_]==$a[$_-1]+1){
		$||=$c<2;
		$c=1
	}else{
		$||=1
	}
}
print$a[0]==$a[2]|$||$c<2|$a[-1]!=2*$a[0]-($a[0]==$a[1])?Imp:P,ossible


Measured memory_bytes: 768
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <math.h>


long int merge(long int a1[], long int a2[], long int b1[], long int b2[], long int a1_size, long int a2_size, long int b1_size, long int b2_size, long int a[], long int b[]);
long int mergeSort(long int a[], long int a_size, long int b[], long int b_size);

int main(void)
{
	long int n;
	long int sum = 0;
	long int i, j;
	long int a[200000] = {0};
	long int b[200000] = {0};
	
	scanf("%ld", &n);
	
	for(i = 0; i < n; i++) {
		scanf("%ld%ld", &a[i], &b[i]);
	}
	
	mergeSort(a, n, b, n);
	/*
	for(i = 0; i < n; i++) {
		printf("%ld %ld\n", a[i], b[i]);
	}
	*/
	for(i = 0; i < n; i++) {
		sum += a[i];
		if(sum > b[i]) {
			printf("No\n");
			return 0;
		}
	}
	
	printf("Yes\n");
	
	return 0;
}

long int merge(long int a1[], long int a2[], long int b1[], long int b2[], long int a1_size, long int a2_size, long int b1_size, long int b2_size, long int a[], long int b[])
{
	long int i = 0, j = 0;
	
	while( (i < a1_size ) || (j < a2_size) ) {
		if( (j >= a2_size ) || ( (i < a1_size) && (b1[i] < b2[j]) ) ) {
			a[i + j] = a1[i];
			b[i + j] = b1[i];
			i++;
		} else {
			a[i + j] = a2[j];
			b[i + j] = b2[j];
			j++;
		}
	}
	
	return 0;
}

long int mergeSort(long int a[], long int a_size, long int b[], long int b_size)
{
	long int m = a_size / 2, n = a_size - m;
	long int a1[m];
	long int a2[n];
	long int b1[m];
	long int b2[n];
	long int i, j;
	
	if(a_size > 1) {
		for(i = 0; i < m; i++) {
			a1[i] = a[i];
			b1[i] = b[i];
		}
		for(i = 0; i < n; i++) {
			a2[i] = a[m + i];
			b2[i] = b[m + i];
		}
		mergeSort(a1, m, b1, m);
		mergeSort(a2, n, b2, n);
		merge(a1, a2, b1, b2, m, n, m, n, a, b);
	}
	
	return 0;
}


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

vector<int> g[100005];
map<int, int> mp;

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
  int n,m;cin>>n>>m;
  for(int i=0;i<m;i++){
    int a,b;cin>>a>>b;a--,b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  queue<int> q;
  q.push(0);
  // int dist=1;
  mp[0]=1;
  while(!q.empty()){
    int v = q.front();q.pop();
    for(auto u : g[v]){
      if(mp[u])continue;
      // cout<<v<<':'<<u<<endl;
      mp[u]=v+1;
      q.push(u);
    }
    // dist++;
  }

  cout<<"Yes"<<endl;
  for (auto& kv : mp) {
    if(kv.first==0)continue;
    cout<<kv.second<<endl;
  }

  
  return 0;
}


Measured memory_bytes: 14624
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    s = S()
    if s[:n//2] == s[n//2:]:
        return 'Yes'

    return 'No'


print(main())




Measured memory_bytes: 7756
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 20;

int d, dig;
long long ans = 0;
long long p10[MAXN];
int b[MAXN];

void check(int L)
{
	// cerr << L << " : ";
	// for(int i = 0; i <= (L - 1) / 2; i++)
	// 	cerr << b[i] << ' ';
	// cerr << endl;
	long long ret = 9 - abs(b[0]);
	for(int i = 1; i <= (L - 1) / 2; i++)
		ret *= 10 - abs(b[i]);
	ans += ret;
}

void search(int h, int L, long long lef)
{
	if(h == L / 2)
	{
		if(lef == 0)
		{
			b[h] = 0;
			check(L);
		}
		return ;
	}
	long long lam = p10[L - h - 1] - p10[h];
	long long tmp1 = ceil((double)lef / lam), tmp2 = floor((double)lef / lam);
	if(-9 <= tmp1 && tmp1 <= 9)
	{
		b[h] = tmp1;
		search(h + 1, L, lef - tmp1 * lam);
	}
	if(tmp1 != tmp2 && -9 <= tmp2 && tmp2 <= 9)
	{
		b[h] = tmp2;
		search(h + 1, L, lef - (tmp2) * lam);
	}
}

void calc(int L)
{
	memset(b, 0, sizeof(b));
	search(0, L, d);
}

void work()
{
	dig = (int)(log10(d) + 1e-12) + 1;
	p10[0] = 1;
	for(int i = 1; i <= 18; i++)
		p10[i] = p10[i - 1] * 10;
	for(int i = dig; i <= 2 * dig; i++)
		calc(i);
	cout << ans << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> d;

	work();

	return 0;
}


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

int main() {
    char b; cin >> b;

    if (b == 'A')
        cout << 'T' << endl;
    else if (b == 'T')
        cout << 'A' << endl;
    else if (b == 'G')
        cout << 'C' << endl;
    else
        cout << 'G' << endl;
    return 0;
}

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

#define dump(...) DUMPOUT<<"  ";DUMPOUT<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<std::endl;DUMPOUT<<"    ";dump_func(__VA_ARGS__)
#define PI 3.14159265358979323846
#define EPS 1e-10
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(j) (j).begin(), (j).end()
#define SZ(j) ((int)(j).size())

const int D = 365;

long long eval(vector<int> out, vector<int> c, vector<vector<int>> s) {
    long long sat = 0;
    vector<int> last(26, 0);
    // for d in range(D):
    REP(d, D) {
        //     assert(1 <= out[d] and out[d] <= 26)
        assert(1 <= out[d] and out[d] <= 26);
        //     j = out[d] - 1
        int j = out[d]-1;
        //     last[j] = d + 1
        last[j] = d+1;
        //     for i in range(26):
        REP(i, 26) {
            //         sat -= (d + 1 - last[i]) * c[i]
            sat -= (d+1-last[i]) * c[i];
        }
        //     sat += s[d][j]
        sat += s[d][j];
        // cout << sat << endl;
    }
        
    // print("satisfaction: {}".format(sat))
    return sat;
    // print("score: {}".format(max(0, 1000000 + sat)))
}

vector<vector<int>> val(vector<int> c, vector<vector<int>> s, int sw, int cw) {
    vector<vector<int>> v(D, vector<int>(26));
    REP(d, D) REP(i, 26) {
        v[d][i] = s[d][i]*sw + c[i]*cw; 
    }

    return v;
}

int main() {

    int tempD;
    cin >> tempD;

    vector<int> c(26);
    REP(i, 26) cin >> c[i];

    vector<vector<int>> s(D, vector<int>(26));
    REP(d, D) REP(i, 26) cin >> s[d][i];

    vector<int> res(D, 1);

    int value = eval(res, c, s);
    FOR(cw, 0, 60) {
        FOR(sw, 0, 60) {
            vector<int> temp(D);
            vector<vector<int>> v = val(c, s, sw, cw);
            REP(d, D) {
                int t = -1;
                REP(i, 26) {
                    if (v[d][i] < 0) {
                        cout << v[d][i] << endl;
                        exit(1);
                    }
                    
                    if (v[d][i] > t) {
                        t = v[d][i];
                        temp[d] = i+1;
                    }
                }
            }

            int tval = eval(temp, c, s);
            if (tval > value) {
                value = tval;
                res = temp;
            }
        }
    }
    
    for (int e : res) cout << e << endl;

    return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main() {
	double a,b,h,m;cin>>a>>b>>h>>m;
	double th1,th2;
	th1=M_PI*2*m/60;
	th2=M_PI*2*h/12+M_PI*2/12*m/60;
	double ans=a*a+b*b-2*b*a*cos(th1-th2);
	ans=sqrt(ans);


	cout<<setprecision(13)<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4216