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

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
 
#define INF 10e9
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;
 
int main() {
    long long int n;
    cin >> n;

    vector<long long int> a(n+1);

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

    vector<long long int> l(n+1), r(n+2);

    l[0] = 0;
    l[1] = a[1];
    r[n] = a[n];
    r[n+1] = 0;
    for(i = 1; i < n; i++){
        l[i+1] = max(l[i], a[i+1]);
    }
    for(i = n-1; i >= 1; i--){
        r[i] = max(r[i+1], a[i]);
    }

    for(i = 1; i <= n; i++){
        cout << max(l[i-1], r[i+1]) << endl;
    }

}

Measured memory_bytes: 6272
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define setbitc(x) __builtin_popcount(x)
#define init(x,a) memset(x,a,sizeof(x))
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 1000005
//Variables Start
ll inf=1e18,MOD=1e9+7;
ll n,m,k,ar[N],br[N],dp[105][105][2];
string s[105],s1;
//Variables End

int main()
{
    ios
    int ti=1;
    //cin>>ti;
    while(ti--)
    {
		cin>>n>>m;
		rep(i,0,n)cin>>s[i];

		rep(i,0,n+1)rep(j,0,m+1)rep(k,0,2)dp[i][j][k]=inf;
		if(s[0][0]=='#')dp[0][0][1]=1;
		else dp[0][0][0]=0;
		rep(i,0,n)
		{
			rep(j,0,m)
			{
				if(s[i][j]=='.')
				{
					if(i>0)dp[i][j][0]=min(dp[i][j][0],min(dp[i-1][j][0],dp[i-1][j][1]));
					if(j>0)dp[i][j][0]=min(dp[i][j][0],min(dp[i][j-1][0],dp[i][j-1][1]));
				}
				else
				{
					if(i>0)dp[i][j][1]=min(dp[i][j][1],min(dp[i-1][j][0]+1,dp[i-1][j][1]));
					if(j>0)dp[i][j][1]=min(dp[i][j][1],min(dp[i][j-1][0]+1,dp[i][j-1][1]));
				}
			}
		}

		/*rep(i,0,n)
		{
			rep(j,0,m)
			{
				cout<<dp[i][j][0]<<" "<<dp[i][j][1]<<endl;
			}
			cout<<endl;
		}*/
		cout<<min(dp[n-1][m-1][0],dp[n-1][m-1][1])<<endl;        
    }
    return 0;
        
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n,k,c[100000];
    while(cin>>n>>k,n){
        bool zero=0;
    for(int i=0;i<k;i++){
        cin>>c[i];
        if(c[i]==0)
            k--,i--,zero=1;
    }
    sort(c,c+k);
    map<int,int>mp;
    for(int i=0;i<k;i++)
        mp[c[i]-i]++;
    if(zero){
        if(mp.size()==1){
            cout<<k+1<<endl;
        }
        vector<pair<int,int>>vec;
        for(auto x:mp)
            vec.push_back(x);
        int ans=0;
        for(int i=0;i<vec.size()-1;i++)
            if(vec[i].first+1==vec[i+1].first)
                ans=max(ans,vec[i].second+vec[i+1].second+1);
        cout<<ans<<endl;
    }else{
        int ans=0;
        for(auto x:mp)
            ans=max(ans,x.second);
        cout<<ans<<endl;
    }
    }
}



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

using namespace std;

int a, b, c, ma, nrfin;

int main() {
    cin >> a >> b >> c;
    if (a > b)
        swap(a, b);
    if (a > c)
        swap(a, c);
    if (b > c)
        swap(b, c);
    if (a == b && a == c)
        return !(cout << 0);
    if ((a % 2 == b % 2) && (b % 2) != (c % 2))
        nrfin++, a++, b++;
    if ((c % 2) == (a % 2))
        nrfin += ((c - a) >> 1),
        a = c;
    if ((c % 2) == (b % 2))
        nrfin += ((c - b) >> 1),
        b = c;
    if (a == b && a == c)
        return !(cout << nrfin);
    if (a > b)
        swap(a, b);
    if (a > c)
        swap(a, c);
    if (b > c)
        swap(b, c);
    nrfin++, b++, c++;
    nrfin += ((b - a) >> 1);
    return !(cout << nrfin);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

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

int main(){
	int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

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

  vector<ll> cumsum(n+1, 0);
  for(int i = 0; i < n; ++i){
    cumsum[i+1] = cumsum[i] + a[i];
  }
  sort(cumsum.rbegin(), cumsum.rend());

  ll ans = 1;
  for(int i = 0; i < n; ++i){
    if(2 * cumsum[i+1] >= cumsum[i] - cumsum[i+1]){
      ans++;
    }
    else{
      break;
    }
  }

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



Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define PB push_back
#define ar2 array<int, 2>
typedef long long LL;
const LL P = 998244353;
const int N = 505;
mt19937 rng(time(0));

int n, x, y, a[N*N], dp[N][N], v[N][N];
int dx[] = {-1,0,0,1}, dy[] = {0,-1,1,0};

void update(int x, int y){
	v[x][y] = 0;
	queue<ar2> Q;
	Q.push({x, y});
	while(!Q.empty()){
		ar2 ele = Q.front();
		Q.pop();
		int x = ele[0], y = ele[1];
		rep(i,0,3){
			int x1 = x + dx[i], y1 = y + dy[i];
			if(dp[x][y] + v[x][y] < dp[x1][y1]){
				dp[x1][y1] = dp[x][y] + v[x][y];
				Q.push({x1, y1});
			}
		}
	}
}

int main(){
	#ifndef ONLINE_JUDGE
	//freopen("test.in","r",stdin);
	#endif
	scanf("%d",&n);
	rep(i,1,n*n) scanf("%d",a+i);
	
	rep(i,1,n) rep(j,1,n)
		dp[i][j] = min(min(i-1, n-i), min(j-1, n-j)),
		v[i][j] = 1;
	
	int ans = 0;
	rep(q,1,n*n){
		x = a[q] - 1;
		y = x % n + 1, x = x / n + 1;
		
		ans += dp[x][y];
		update(x, y);		
	}
	cout<<ans<<endl;
	return 0;
}

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

#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORTASC(c) sort((c).begin(), (c).end())
#define SORTDESC(c, t) sort((c).begin(), (c).end(), std::greater<t>());
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

const double PI = acos(-1.0);

using ll = long long;
using namespace std;

int main()
{
    ll n;

    cin >> n;

    cout << setprecision(20) << (n-1)/2 << endl;

    return 0;
}

Measured memory_bytes: 256
T=""
Fword = input().lower()
while True:
    s = input()
    if s == "END_OF_TEXT":
        break
    T += s.lower()
    T += " "

#print(T)
list = T.split()
#print(list)

sum=0
for word in list:
    if word == Fword:
        sum+=1

print(sum)


Measured memory_bytes: 5552
import java.util.*;

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

		while(true){
			int n = sc.nextInt();
			if(n == 0) break;

			int[][] m = new int[n][n];
			ArrayList<Integer> mins = new ArrayList<Integer>();
			for(int i=0;i<n;i++){
				int min = Integer.MAX_VALUE;
				for(int j=0;j<n;j++){
					m[i][j] = sc.nextInt();
					min = Math.min(min,m[i][j]);
				}
				mins.add(min);
			}

			int ans = 0;
			for(int j=0;j<n;j++){
				int max = Integer.MIN_VALUE;
				for(int i=0;i<n;i++){
					max = Math.max(max,m[i][j]);
				}
				if(mins.contains(max)){
					ans = max;
					break;
				}
			}

			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
import java.util.*;
import java.io.*;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        int[] rec = new int[4];
        for(int i=0;i<3;i++){
            int a=sc.nextInt()-1,b=sc.nextInt()-1;
            rec[a]++;rec[b]++;
        }
        Arrays.sort(rec);
        String ans = rec[0]==1&&rec[1]==1&&rec[2]==2&&rec[3]==2?"YES":"NO";
        System.out.println(ans);
    }
}


Measured memory_bytes: 21460
def main():
    import sys
    n = int(input())
    a = list(map(int, input().split()))

    box = [0 for _ in range(n+1)]
    result = []
    for i in range(n, 0, -1):
        counter = 0
        for j in range(1, (n//i)+1):
            counter += box[j*i]
        if counter % 2 != a[i-1]:
            box[i] = 1
            result.append(i)
    """
    for i in range(1, n+1):
        counter = 0
        for j in range(1, (n//i)+1):
            counter += box[j*i]
        if counter%2 != a[i-1]:
            print(-1)
            sys.exit()
    """
    print(len(result))
    if len(result) != 0:
        print(*result[::-1])  
if __name__ == '__main__':
    main()      

Measured memory_bytes: 14744
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <fstream>
#include <unordered_map>

using namespace std;

ifstream fin("data.txt");

unordered_map<int, int> v;
int k, n, aux, x;

int main() {

  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    cin >> x;
    v[x] = 1;
  }

  for (int i = n; ; i++) {
    aux = i;
    while (aux) {
      if (v.find(aux % 10) != v.end()) break;
      aux /= 10;
    }
    if (aux == 0) {
     cout << i;
     break;
    }
  }
  return 0;
}


Measured memory_bytes: 3608
N=int(input())
s=list(str(input()))
char=[chr(i) for i in range(65, 65+26)]
for i in range(len(s)):
  s[i]=char.index(s[i])+N
  if s[i]>=26:
    s[i]-=26
  s[i]=char[s[i]]
print(''.join(s))

Measured memory_bytes: 3060
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#define re register
using namespace std;
typedef long long ll;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=100000+10;
const int LIM=100005;

int n,S[N],a[N],b[N];

int c[(LIM<<1)+10];
inline void add(int x,int y) { for (;x<=LIM<<1;x+=x&-x) c[x]+=y; }
inline int sum(int x) { int s=0; for (;x;x-=x&-x) s+=c[x]; return s; }

inline ll calc(int mid) {
    for (re int i=1;i<=n;++i) b[i]=a[i]<mid?-1:1;
    for (re int i=2;i<=n;++i) b[i]+=b[i-1];
    memset(c,0,sizeof(c)); add(LIM,1); ll res=0;
    for (re int i=1;i<=n;++i) res+=i-sum(b[i]+LIM),add(b[i]+LIM,1);
    return res;
}

inline int check(int mid) { return calc(S[mid])<1ll*n*(n+1)/2/2+1; }

int main() {
    n=read();
    for (re int i=1;i<=n;++i) S[i]=a[i]=read();
    sort(S+1,S+n+1); int top=unique(S+1,S+n+1)-S-1;
    int L=1,R=top;
    while (L<R) {
        int mid=(L+R+1)>>1;
        if (check(mid)) L=mid;
        else R=mid-1;
    }
    printf("%d\n",S[L]);
    return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


#line 1 "lib/modint.hpp"



#include <iostream>

// Modint
struct Mint {
    static const long long mod = (long long)1e9 + 7;
    long long val;

    Mint() { val = 0; }
    Mint(long long a) { val = a; verify_value(); }

    void verify_value() {
        if (val >= mod) val %= mod;
        if (val < 0) val %= mod, val += mod;
    }

    Mint pow(long long p) const {
        Mint cur = Mint(val), ret = 1;
        while (p > 0) {
            if (p & 1) ret *= cur;
            cur *= cur;
            p >>= 1LL;
        }
        return ret;
    }
    Mint inv() const {
        if (val == 0)
            std::cerr << "WARNING: inv() is called with 0." << std::endl;
        return pow(mod - 2);
    }

    Mint operator+() const { return *this; }
    Mint operator-() const { return Mint(mod - val); }

    Mint operator+=(const Mint &a) {
        val += a.val;
        if (val >= mod) val -= mod;
        return Mint(val);
    }
    Mint operator*=(const Mint &a) {
        val *= a.val;
        if (val >= mod) val %= mod;
        return Mint(val);
    }
    Mint operator-=(const Mint &a) { return *this += -a; }
    Mint operator/=(const Mint &a) { return *this *= a.inv(); }

    Mint operator++() { return *this += Mint(1); }
    Mint operator--() { return *this -= Mint(1); }
    Mint operator++(int) {
        Mint ret = *this;
        ++(*this);
        return ret;
    }
    Mint operator--(int) {
        Mint ret = *this;
        --(*this);
        return ret;
    }

    operator long long() const { return val; }
};

Mint operator+(const Mint &a, const Mint &b) {
    long long ret = a.val + b.val;
    if (ret >= Mint::mod) ret -= Mint::mod;
    return Mint(ret);
}
Mint operator*(const Mint &a, const Mint &b) {
    long long ret = a.val * b.val;
    if (ret >= Mint::mod) ret %= Mint::mod;
    return Mint(ret);
}
Mint operator-(const Mint &a, const Mint &b) { return a + (-b); }
Mint operator/(const Mint &a, const Mint &b) { return a * b.inv(); }

std::ostream &operator<<(std::ostream &out, const Mint &a) { return out << a.val; }
std::istream &operator>>(std::istream &in, Mint &a) {
    in >> a.val;
    a.verify_value();
    return in;
}

Mint pow(Mint a, long long b) {
    return a.pow(b);
}


int main() {
    int n; std::cin >> n;
    std::vector<int> c;
    for (int i = 0; i < n; i++) {
        int t; std::cin >> t;
        if (c.empty() || c.back() != t) c.push_back(t);
    }
    n = c.size();
    std::map<int, int> prev;
    std::vector<int> nxtid(n, -1);
    for (int i = n - 1; i >= 0; i--) {
        if (prev.count(c[i])) {
            nxtid[i] = prev[c[i]];
        }
        prev[c[i]] = i;
    }
    std::vector<Mint> dp(n + 2);
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
        dp[i + 1] += dp[i];
        if (nxtid[i] != -1) dp[nxtid[i]] += dp[i];
    }
    std::cout << dp[n] << std::endl;
    return 0;
}


Measured memory_bytes: 12788
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstdio>

using namespace std;

const long long INF = 100000000000;
const long long MOD = 1000000007;

long long f(long long N){
  string s = to_string(N);
  long long ret = 0;
  for (int i = 0; i < s.length();i++){
    ret += s[i] - '0';
  }
  return ret;
}

int main()
{
  long long N, A, B;
  cin >> A >> B;
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); i++){
    if(i==A){
      if(s[i]!='-'){
        cout << "No" << endl;
        return 0;
      }
      continue;
    }
    if(!('0'<=s[i] && s[i]<='9')){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.14159265359

int main() {
    int n,m;
    string a[60],b[60];
    bool flag = true;
    cin >> n >> m;
    for(int i=0;i<n;i++)cin >> a[i];
    for(int i=0;i<m;i++)cin >> b[i];
    for(int sy=0;sy<n;sy++){
        if(sy+m-1>n)break;
        for(int sx=0;sx<n;sx++){
            flag = true;
            for(int ay=0;ay<m;ay++){
                for(int ax=0;ax<m;ax++){
                    if(a[sy+ay][sx+ax] != b[ay][ax]){
                        flag = false;
                        break;
                    }
                }
                if(!flag)break;
            }
            if(flag){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{	
    int n;
    cin>>n;
    vector<int> A(n,0),temp(n);
    for(int i=0;i<n;i++){
        cin>>A[i];
        temp[i] = A[i];
    }
    int count = 0;
    sort(A.begin(),A.end());
    for(int i=0;i<n;i++){
        if(A[i]!=temp[i])
            count++;
    }
    
    if(count>2)
    cout<<"NO"<<endl;
    else
    cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 256
def solve():
    N = int(input())
    A = map(int, input().split())
    b = []
    left = []
    right = []
    for i,a in enumerate(A):
        if i%2 == 0:
            right.append(a)
        else:
            left.append(a)
            # b.insert(0, a)

    if N % 2 == 1:
        right.reverse()
        b = right+left
    else:
        left.reverse()
        b = left + right
    print(' '.join(map(str, b)))
    
solve()

Measured memory_bytes: 29500
# a, b, c, x, y = gets.split.map(&:to_i)
n = gets.to_i

ret = 100000
(1..n).each do |a|
  b = n / a
  break if a > b
  next unless n == a * b

  tmp = [a.to_s.size, b.to_s.size].max
  ret = tmp if ret > tmp
end
puts ret


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

namespace abc089_b
{
    class program
    {
        static void Main(string[] args)
        {
            ChangeLocalDebugInput();
            Console.ReadLine();
            string[] s = Console.ReadLine().Split(' ');

            List<string> sl = new List<string>();
            sl.AddRange(s);

            int num = sl.Distinct().Count();

            string output = "";
            if (num == 3)
            {
                output = "Three";
            } else if (num == 4)
            {
                output = "Four";
            }
            Console.WriteLine(output);
        }


        [System.Diagnostics.Conditional("LOCAL_DEBUG")]
        static void ChangeLocalDebugInput()
        {
            Console.SetIn(new System.IO.StreamReader("../../stdin.txt"));
        }
    }
}


Measured memory_bytes: 13276
def keta(string):
    t = int(string)
    keta_sum = sum([int(i) for i in string])
    return t / keta_sum, t
    
tmp = []
for j in range(20):
    for i in range(0, 10000):
        if (i + 1) % 10 == 0:
            continue
        num = str(i) + j*"9"
        if num == "0":
            continue
        tmp.append(keta(num))

k = int(input())
tmp = sorted(tmp)
ans = []
for i, num in tmp:
    if not ans:
        ans.append(num)
    elif ans[-1] < num:
        ans.append(num)
for i in range(k):
    print(ans[i])

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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
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; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}


/* math_method */
int ceil(int a, int b){return a / b + (a % b > 0);}


/* main */

int n, l;
void in(){
    cin >> n >> l;
}

void solve(){

    int ans = 0;
    int ret = inf;
    int hoge = -1;
    rep(i,0,n){
        int tmp = l + i;
        ans += tmp;
        if(abs(tmp) < ret){
            hoge = tmp;
            ret = abs(tmp);
        }
    }
    ans -= hoge;
    print(ans);


}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long tint;
 
const tint INF = 2e14+1;
const long double PI = 3.141592;
const int MOD = 998244353;
 
#define forsn(i, s, n) for(int i=s;i<int(n);i++)
#define forn(i, n) forsn(i, 0, n)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define NACHO ios_base::sync_with_stdio(0);cin.tie(NULL);
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

int main(){
	char a; cin >> a;
	cout << (char)(a+1) << "\n";
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define REP(i, n) FOR(i,0,n)
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int main()
{
    lint N;
    cin >> N;
    lint ret = 1;
    lint las = -1, del = 0;
    REP(i, N)
    {
        lint X;
        cin >> X;
        ret = ret * (i + 1 - del) % 1000000007;
        if (X == las + 1) del++;
        else las += 2;
    }
    cout << ret << endl;
}


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

int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int ans=2e9;
    for(int i=0;i<n;i++){
        int cnt=0;
        while(a[i]%2==0){
            cnt++;
            a[i]/=2;
        }
        ans=min(cnt,ans);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <math.h>
#include <string>

using namespace std;

int main(){
	string N;
	cin >> N;
	int count = 0;
	if(N[0] == N[1] && N[1] == N[2]) count++;
	else if(N[1] == N[2] && N[2] == N[3]) count++;

	if(count > 0){
		cout << "Yes" << endl;
	} else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquest;
typedef priority_queue<string,vector<string>,greater<string>> rpriquest;
typedef priority_queue<int,vector<int>,greater<int>> rpriqueint;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}
ll lcm(ll l,ll a){
    return a/__gcd(l,a)*l;
}
ll exp(ll a, ll b,ll c){
  if(b==0)return 1;
  if(b%2==0){
    ll t =exp(a,b/2,c);
    return t*t%c;
  }
  else return exp(a,b-1,c)*a%c;
}
const ll big=1000000007;
bool vec_finder(vector<ll> vec, int number) {
  auto itr = find(vec.begin(), vec.end(), number);
  size_t index = distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
int exp(int a, int b, int c){
  if(b==0)return 1;
  if(b%2==0){
int t =exp(a,b/2,c);
return t*t%c;
  }
  else return exp(a,b-1,c)*a%c;
}

int main(){
  int n;cin >> n;
  int w;cin >> w;
  vector<int> v(n),weight(n);
  rep(i,n)cin >> v[i] >> weight[i];
  
  //dp[i][j]:=i個めまでに重さj以下の時のvのmax
  vector<vector<int>> dp(n+1,vector<int>(w+1));
  
  //0個の時
  rep(i,w+1)dp[0][i]=0;
  
  rep(i,n)rep(j,w+1){
    //i番を選ぶ
    if(j>=weight[i])
    dp[i+1][j]=max(dp[i][j-weight[i]]+v[i],dp[i][j]);
    //else
    else dp[i+1][j]=dp[i][j];
  }
  //cout << dp[2][3] << endl;
  cout << dp[n][w] << endl;
}


Measured memory_bytes: 6768
#include <stdio.h>

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

    int damage = 0;
    for (int i = 0; i < n; i++) {
        int val;
        scanf("%d", &val);
        damage += val;
    }

    if (h <= damage){
        printf("Yes\n");
    } else {
        printf("No\n");
    }
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import math
import sys
import itertools
import numpy as np

h, w = map(int, input().split())

m = 10000000000000000000000000
m = min(m, (1 if h % 3 else 0) * w)
m = min(m, (1 if w % 3 else 0) * h)
for _ in range(2):
    for i in range(1, h+1):
        v = np.array([i*w, w//2*(h-i), (w-w//2)*(h-i)])
        m = min(m, max(v) - min(v))
    h, w = w, h

print(m)

Measured memory_bytes: 14404
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define se second
#define debi cerr<<"hello sparky\n"
#define deb(x) cerr<<#x<<x<<"\n"
using namespace std;


int main(){
	ll n;
	cin>>n;
	vector<ll> v;
	for(int i=0;i<n;i++){
		ll temp;
		cin>>temp;
		v.pb(temp);
	}
	ll ans = 0;
	ll mod = (ll)(1e9+7);
	ll ma = *max_element(v.begin(),v.end());
	int siz =0;
	vector<ll> pow(62);
	pow[0] =1;
	for(int i=1;i<=61;i++){
		pow[i] = ((pow[i-1]%mod)*(2%mod))%mod;
	}
	while(ma>=1){
		siz++;
		ma = ma>>1;
	}
	vector<int> count_1(siz+1,0);
	for(int i=0;i<n;i++){
		ma = v[i];
		int curr =0;
		while(ma>=1){
			if(ma&1){
				count_1[curr]++;
			}
			curr++;
			ma = ma>>1;
		}
	}
	deb(siz);
	for(int i=0;i<siz;i++){
		//deb(count_1[i]);
		ans = ((ans%mod) + (((abs(count_1[i]-n)*count_1[i])%mod)*(pow[i]%mod))%mod)%mod; 
	}
	cout<<ans;
}


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

int main(){
  long long a,b,k;
  cin>>a>>b>>k;
  if(k<=a){
    cout<<a-k<<' '<<b<<endl;
    }
  else if(k<=a+b){
    cout<< 0 <<' '<<b- (k-a) <<endl;
    }
  else{cout<< 0 <<' '<< 0 <<endl;}
return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	a:=nextInt()
	b:=nextInt()

	if a < 1 || a > 9 {
		fmt.Printf("-1")
		return
	}
	if b < 1 || b > 9 {
		fmt.Printf("-1")
		return
	}

	fmt.Printf("%d", a * b)
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using lint = long long;
typedef pair<int,int> P;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  int res=0;
  rep(i,n){
      res+=(n-i)*(n+1-i)/2;
  }
  rep(i,n-1){
      int a,b;cin>>a>>b;
      if(a>b)swap(a,b);
      int buf=a*(n-b+1);
      res-=buf;
  }
  cout<<res<<"\n";
  return 0;
}

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

using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 998244353;
const double PI = 3.141592653589793238463;
const int MAXN = 2e5 + 5;

ll fastPow(ll x, ll b) {
    if (b == 0)
        return 1;
    else if (!(b & 1)) {
        return fastPow(x * x, b / 2);
    } else
        return x * fastPow(x * x, (b - 1) / 2);
}

bool isPal(string h) {
    string rev = h;
    reverse(rev.begin(), rev.end());
    return rev == h;
}

//__builtin_popcount ();
int main() {
    FAST
    double l;
    cin >> l;
    double side=l/3.0;
    double ans=side*side*side;
    printf("%.12f\n",ans);

    return 0;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp
{
    class Program
    {
        public static void Main()
        {
            int counter = 0;
            var line = Console.ReadLine();
            int num = int.Parse(line);
            if(num >= 100000)
            {
                counter = 9 + 900 + 90000;
            }
            else if(num >= 10000)
            {
                counter = 9 + 900;
                for(int i = 10000; i <= num; i++)
                {
                    counter += 1;
                }
            }
            else if(num >= 1000)
            {
                counter = 9 + 900;
            }
            else if(num >= 100)
            {
                counter = 9;
                for(int i = 100; i <= num; i++)
                {
                    counter += 1;
                }
            }
            else if(num >= 10)
            {
                counter = 9;
            }
            else if(num >= 1)
            {
                for(int i = 1; i <= num; i++)
                {
                    counter += 1;
                }
            }
            Console.WriteLine("{0}", counter);
        }
    }
}

Measured memory_bytes: 13268
#include<map>
#include<set>
#include<ctime>
#include<cmath>
#include<queue>
#include<bitset>
#include<vector>
#include<cstdio>
#include<cctype>
#include<string>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define lc (x<<1)
#define rc (x<<1|1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define ll long long
#define pi pair<int,int>
using namespace std;
const int N=1e5+10,size=1<<20,mod=998244353;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	x=0; int f=1; char c=gc;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c))x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x<0) putchar('-'),x=-x;
	if(x>9) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {qw(x); putchar(' ');}
template<class o> void pr2(o x) {qw(x); puts("");}

//math
ll gcd(ll x,ll y) {return !x?y:gcd(y%x,x);}
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}
ll power(ll a,ll b=mod-2) {
	ll c=1;
	while(b) {
		if(b&1) c=c*a%mod;
		b /= 2; a=a*a%mod;
	}
	return c;
}

int m,n;
string s;


int main() {
	cin>>m>>s; n=s.size();
	if(n<=m) cout<<s;
	else {
		while(n>m) s.pop_back(),n--;
		s+="...",cout<<s;
	}
	return 0;
}



Measured memory_bytes: 3640
//17571@nith.ac.in @Ankit Verma
#include <bits/stdc++.h>
using namespace std;
#define ff          first
#define ss          second
#define pb          push_back
#define MP          make_pair
#define int         long long
#define ll          long long
#define inf         0x3f3f3f3f
#define MOD         1000000007
#define ld          long double
#define eb          emplace_back
#define pii         pair<int,int>
#define ull         unsigned long long
#define all(v)      v.begin(), v.end()
#define f(i,x,n)    for(int i=x;i<n;i++)
#define fr(i,x,n)   for(int i=x;i>=n;i--)
#define fastio      ios::sync_with_stdio(false)

void IO() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
const int N = 1e5 + 1;
int32_t main() {
	//IO();
	fastio;
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n, m, q, j; cin >> n >> m >> q;
	j = 1;
	vector <array <int, 4> > inp;
	vector <int> A; int ans = -1;
	for (int i = 0; i < q; i++) {
		int a, b, c, d; cin >> a >> b >> c >> d;
		--a, --b;
		inp.pb({a, b, c, d});
	}
	function <void(int)> dfs = [&](int src) {
		if (A.size() == n) {
			int cnt = 0;
			for (auto &i : inp) {
				if (A[i[1]] - A[i[0]] == i[2]) {
					cnt += i[3];
				}
			} 
			ans = max(ans, cnt);
			return;
		}
		for (; src <= m; src++) {
			A.pb(src);
			dfs(src);
			A.pop_back();
		}
	};
	dfs(1);
	cout << ans << endl;

	return 0;
}

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

int main() {
  int64_t N, K;
  cin >> N >> K;
  
  int64_t ans = N % K;
  while (ans >= 0) {
    ans -= K;
  }
  if (ans + K > abs(ans)) {
    cout << abs(ans) << endl;
  }
  else {
    cout << ans + K << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

const int N = 1e7 + 5, MOD = 1e9 + 7;

ll arr[N];

int main() {
	fastIO;
#ifdef LOCAL
	freopen("input.in", "rw", stdin);
#endif
	for (int i = 1; i < N; ++i) {
		for (int j = i; j < N; j += i) {
			arr[j]++;
		}
	}
	ll total = 0;
	int n;
	cin >> n;
	for (int i = 0; i <= n; ++i) {
		total += 1ll * i * arr[i];
	}
	cout << total;
	return 0;
}


Measured memory_bytes: 81720
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define N 1000005
using namespace std;

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

ll n, k, ans, a[N];

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%lld %lld",&n ,&k);
	for(ll i = 1; i <= n; i++)
		scanf("%lld",a + i);
	sort(a + 1, a + n + 1);
	for(ll i = 1; i <= n - k; i++)
		ans += a[i];
	printf("%lld\n", ans);
	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;int main(){int a,b,c,d,e,f,g,h[]={0,0,31,59,90,120,151,181,212,243,273,304,334};while(1){cin>>a>>b>>c>>d>>e>>f;if(a==-1)break;g=f-c+h[e]-h[b]+(d-a)*365;if(e<3)d--;if(b<3)a--;g+=d/4-a/4-d/100+a/100+d/400-a/400;cout<<g<<endl;}}

Measured memory_bytes: 0
class LazySegmentTreeBase
  def initialize(arr, l = 0, r = arr.size - 1)
    @l, @r = l, r
    @lazy = nil
    if l == r
      @agg = arr[l]
    else
      c = (l + r) / 2
      @left_child = self.class.new(arr, l, c)
      @right_child = self.class.new(arr, c + 1, r)
      @agg = aggregation_of(@left_child.agg, @right_child.agg)
    end
  end

  attr_reader :agg, :l, :r

  def update(l, r, x)
    if l == @l && r == @r
      defer(x)
    else
      force
      if r <= @left_child.r
        @left_child.update(l, r, x)
      elsif @right_child.l <= l
        @right_child.update(l, r, x)
      else
        @left_child.update(l, @left_child.r, x)
        @right_child.update(@right_child.l, r, x)
      end
      @left_child.force
      @right_child.force
      @agg = aggregation_of(@left_child.agg, @right_child.agg)
    end
  end

  def force
    return if !@lazy
    x = @lazy
    @lazy = nil
    whole_update(x)
    @left_child.update(@left_child.l, @left_child.r, x) if @left_child
    @right_child.update(@right_child.l, @right_child.r, x) if @right_child
  end

  def query(l, r)
    force
    return @agg if l == @l && r == @r
    if r <= @left_child.r
      return @left_child.query(l, r)
    elsif @right_child.l <= l
      return @right_child.query(l, r)
    else
      agg_left = @left_child.query(l, @left_child.r)
      agg_right = @right_child.query(@right_child.l, r)
      return aggregation_of(agg_left, agg_right)
    end
  end
end

class LazySegmentTree < LazySegmentTreeBase
  def initialize(arr, l = 0, r = arr.size - 1)
    super(arr, l, r)
  end

  def defer(x)
    if @lazy
      @lazy += x
    else
      @lazy = x
    end
  end

  def whole_update(x)
    @agg += x
  end

  def aggregation_of(x, y)
    [x, y].min
  end
end

n, q = gets.split.map(&:to_i)
seg = LazySegmentTree.new(Array.new(n, 0))
q.times do
  c, x, y, z = gets.split.map(&:to_i)
  if c == 0
    seg.update(x, y, z)
  else
    puts seg.query(x, y)
  end
end


Measured memory_bytes: 34924
n = input()
swap_n = []
for i in n:
    if i == "1":
        i = "9"
        swap_n.append(i)
    elif i == "9":
        i = "1"
        swap_n.append(i)
    else:
        swap_n.append(i)
num = "".join(swap_n)
print(int(num))   

Measured memory_bytes: 3060
import  java.io.*;

public class Main{ 
        public static void main(String[] args){
            int i,a,temp,c;
            int b[];
            String line;
            b = new int[200];
            try{
                //Scanner n = new Scanner(System.in);
                BufferedReader k = new BufferedReader(new InputStreamReader(System.in));
                String ac = k.readLine();
                a = Integer.parseInt(ac);
                for(i=1;i<=a;i++){
                    b[i] = i;
                }
                String cc = k.readLine();
                c = Integer.parseInt(cc);
                for(i=0;i<c;i++){
                    line = k.readLine();
                    String suuti[] = line.split(",");
                    int d = Integer.parseInt(suuti[0]);
                    int e = Integer.parseInt(suuti[1]);
                    temp = b[d];
                    b[d] = b[e];
                    b[e] = temp;
                }
                for(i=1;i<=a;i++){
                    System.out.println(b[i]);
                }
            }catch(IOException e) {
                System.out.println(e);
            } catch(NumberFormatException e){
                System.out.println(e);
            }
        }
    }


Measured memory_bytes: 24224
#pragma GCC target ("avx,avx2,fma")
#pragma GCC optimize ("unroll-loops")

#include <iostream>
#include <vector>

using namespace std;

int upbound;
const int MOD = 1000000007;
vector<int> g, dp;

inline int Solve(const int& x)
{
	if (x == 0) return 1;
	if (dp[x] != -1) return dp[x];
	int p = __builtin_popcount(x), r = 0;
	for (int y = x & g[p - 1]; y; y &= y - 1)
	{
		r += Solve(x & ~(y & -y));
		if (r >= MOD) r -= MOD;
	}
	dp[x] = r;
	return r;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, r;
	char p;
	cin >> n;
	upbound = (1 << n);
	g = vector<int>(n), dp = vector<int>(upbound, -1);
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j) {
			cin >> p;
			if (p == '1')
				g[i] |= (1 << j);
		}
	cout << Solve(upbound - 1);
}


Measured memory_bytes: 11388
mod=1000000007
n,m,x=map(int,input().split())
w=[]
for i in range(n):
    w.append([int(i) for i in input().split()])
ans=mod
for i in range(2**n):
    d=0
    chk=[0]*m
    for j in range(n):
        if (i>>j&1):
            d+=w[j][0]
            for k in range(m):
                chk[k]+=w[j][k+1]

    if min(chk)>=x:
        ans=min(ans,d)
#print(ans)
print(ans if ans!=mod else -1)


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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
 
#define VV(T) vector<vector< T > >
 
template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  reep(i,0,n)
#define clr(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
#define PB push_back

const int INF = (1e9);
const ll MOD = 1e9+7;
const double EPS = 1e-5;
const double PI=atan2(0,-1);

int main(void){
    int n,T,time;
    cin >> n >> T;
    int sum = n*T;
    int ptime = 0;
    cin >> ptime;
    rep(i,n-1){
        cin >> time;
        if(time - ptime < T)
            sum -= (T - (time - ptime));
        ptime = time;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
n=int(input())
a=sorted([[i]+list(map(int,input().split()))for i in range(n)],key=lambda x:x[1])
s=[]
for i in range(n-1):
    s.append((a[i+1][1]-a[i][1],a[i][0],a[i+1][0]))
a=sorted(a,key=lambda x:x[2])
for i in range(n-1):
    s.append((a[i+1][2]-a[i][2],a[i][0],a[i+1][0]))
s.sort()
t=[i for i in range(n)]
def f(x):
    if x==t[x]:
        return x
    t[x]=f(t[x])
    return f(t[x])
c=0
for i,j,h in s:
    j,h=f(j),f(h)
    if h!=j:
        t[j]=h
        c+=i
print(c)

Measured memory_bytes: 50184
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define pb push_back
#define endl '\n'
#define PI acos(-1)
#define bitcount(a) __builtin_popcountll(a)
#define P pair<int,int>
#define ff first
#define ss second
typedef tree<int,null_type,less_equal <int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
long double eps=1e-9;
int mod=1e9+7;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	double a,b,x;
	cin>>a>>b>>x;
	double half=(a*a*b)/2.0;
	if(x<=half)
	{

		double ans=atan((b*b*a)/(2.0*x));
		ans=(ans*180.0)/PI;
		cout<<fixed<<setprecision(10)<<ans;
	}
	else
	{
		double ans=atan((2.0*(b*a*a-x))/(a*a*a));
		ans=(ans*180.0)/PI;
		cout<<fixed<<setprecision(10)<<ans;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int A, B;
	cin >> A >> B;

	if ( (A <= 8) && (B <= 8) ){
		cout << "Yay!" << endl;
	} else {
		cout << ":(" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
s = input()
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        print(str(i+1)+" "+str(i+2))
        break
    if (i != len(s)-2) and (s[i]==s[i+2]):
        print(str(i+1)+" "+str(i+3))
        break
else:
    print("-1 -1")    

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

using namespace std;
using ll = long long;

const ll INF = 1LL << 60;

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

    ll maxz = -INF, minz = INF;
    ll maxw = -INF, minw = INF;
    for (int i = 0; i < n; i++) {
        ll x, y;
        cin >> x >> y;
        ll z = x + y;
        ll w = x - y;
        maxz = max(maxz, z);
        maxw = max(maxw, w);
        minz = min(minz, z);
        minw = min(minw, w);
    }

    cout << max(maxz - minz, maxw - minw) << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
const int MAX=2e5+10;
const int modn=1e9+7;
typedef long long ll ;
#define endl '\n'
#define cwk     freopen("D:\\workplace\\CLion\\in.in","r",stdin),freopen("D:\\workplace\\CLion\\out.out","w",stdout)
using namespace std;
int n,m,a,b;
int s[MAX];
int find_(int x){
    if(s[x]!=x) s[x]=find_(s[x]);
    return s[x];
}
void union_(int x,int y){
    x=find_(x);
    y=find_(y);
    if(x!=y)
        s[x]=s[y];
}
vector<int>v[MAX];
void solve(){
    for(int i=0;i<MAX;i++)
        s[i]=i;
    cin>>n>>m;
    while(m--){
        cin>>a>>b;
        union_(a,b);
    }
    int maxn=0;
    for(int i=1;i<=n;i++) {
        s[i]=find_(s[i]);
        v[s[i]].push_back(i);
        int p=v[s[i]].size();
        maxn=max(maxn,p);
    }
    cout<<maxn;

}
signed main() {
    //ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    //cwk;
    int _=1;
    //cin>>_;
    while(_--){
        solve();
    }
    return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

bool U[100005];
ll N;

ll dfs(ll n, vector<ll> v, vector<ll> u, int l = 0)
{
    if (u.size() == n)
    {
        ll m = 1;
        REP(i, n)
        {
            m *= u[i];
        }
        return N / m;
    }

    ll sum = 0;
    FOR(i, v.size(), l)
    {
        u.push_back(v[i]);
        sum += dfs(n, v, u, i + 1);
        u.pop_back();
    }
    return sum;
}

int main()
{
    cin >> N;
    ll n = N;

    vector<ll> prime;
    memset(U, 0, sizeof(U));
    FOR(i, 100000, 2)
    {
        if (U[i])
            continue;
        prime.push_back(i);
        for (int j = i; j < 100000; j += i)
            U[j] = true;
    }

    vector<ll> p;
    REP(i, prime.size())
    {
        if (n % prime[i] != 0)
            continue;
        while (n % prime[i] == 0)
            n /= prime[i];
        p.push_back(prime[i]);
    }
    if (n > 1)
        p.push_back(n);

    ll sum = 0;

    FOR(i, p.size() + 1, 1)
    {
        vector<ll> v;
        ll s = dfs(i, p, v);
        if (i % 2 == 1)
            sum += s;
        else
            sum -= s;
    }

    cout << N - sum << endl;

    return 0;
}


Measured memory_bytes: 3384
#include <algorithm>
#include <bitset>
#include <climits>
#include <complex>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <thread>
#include <tuple>
#include <type_traits>
#include <vector>

#include <stdio.h>

using ll = long long;
using namespace std;

vector<vector<bool>> v;
vector<bool> visited;
int n;

int dfs(int idx, int c) {
    int ans = 0;
    // printf("idx:%d, c:%d\n", idx, c);

    if (c == n) {
        return 1;
    }
    for (int i = 0; i < n; i++) {
        if (v[idx][i] == true && visited[i] == false) {
            visited[i] = true;
            ans += dfs(i, c + 1);
            visited[i] = false;
        }
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(false);
    int m;
    cin >> n >> m;

    v.resize(n, vector<bool>(n, false));
    visited.resize(n, false);
    int a, b;
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        a--;
        b--;
        v[a][b] = v[b][a] = true;
    }

    visited[0] = true;
    int ans = dfs(0, 1);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3196
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
using namespace std;

long long PowMod(long long a,int b=1e9+5,long long Mod=1e9+7) {
	long long ret=1;
	while(b) {
		if(b&1)ret=ret*a%Mod;
		a=a*a%Mod;
		b>>=1;
	}
	return ret;
}


int main(){
    int x,y;scanf("%d%d",&x,&y);
    int n,m;
    if ( (2*x-y)%3==0 && (2*x-y>=0)  ) n=(2*x-y)/3;
    else {printf("0\n");return 0;}
    if ( (2*y-x)%3==0 && (2*y-x>=0)  ) m=(2*y-x)/3;
    else {printf("0\n");return 0;}

    m+=n;
    long long ans=1;
    for (int i=n+1;i<=m;++i){ ans*=i;ans%=int(1e9+7);}
    for (int i=2;i<=m-n;++i) {ans*=PowMod(i);ans%=int(1e9+7);}
    printf("%lld\n",ans);

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int ans[55]={};
  int n,m;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    ans[a]++;ans[b]++;
  }
  for(int i=1;i<=n;i++) cout<<ans[i]<<endl;
  return 0;
}


Measured memory_bytes: 256