akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;
using namespace atcoder;

typedef long long ll;

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 (a>b) { a=b; return 1; } return 0; }

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

	int n, q;
	cin >> n >> q;

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

	fenwick_tree<ll> fw(n);
	rep(i, n) fw.add(i, a[i]);

	rep(i, q){
		int t;
		cin >> t;

		if(t == 0){
			ll p, x;
			cin >> p >> x;
			fw.add(p, x);
		}else{
			ll l, r;
			cin >> l >> r;
			cout << fw.sum(l, r) << endl;
		}
	}

}


Measured memory_bytes: 12156
/*************************************************************************
     File Name: C.cpp
     ID: obsoles1
     BLOG: blog.csdn.net/obsolescence
     LANG: C++ 
     Mail: 384099319@qq.com 
     Created Time: 日 10/ 2 12:25:36 2016
 ************************************************************************/
#define MAX(x,y) ((x)>(y)?(x):(y))
#define MIN(x,y) ((x)<(y)?(x):(y))
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();++it)
#define ABS(x,y) ((x)>(y)?((x)-(y)):((y)-(x)))
#define MEM0(x) memset(x,0,sizeof(x))
#define MEM1(x) memset(x,-1,sizeof(x))
#define MEMX(x) memset(x,0x3f,sizeof(x))
#define pb push_back
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int sum;

int solve(int i,int x) {
  int bit=7-i,xx=x,y=0,cnt=0,b[10],j;
  MEM0(b);
  for (; xx; xx>>=1) b[cnt++]=xx&1;
  int m=cnt;
  //cout<<"m="<<m<<" bit="<<bit<<endl;
  for (j=0; j<MIN(m,bit); ++j) y+=((!b[j])<<j);
  for (j=MIN(m,bit); j<bit; ++j) y+=((!b[j])<<j);
  //for (j=bit; j<m; ++j) y+=(b[j]<<j);
  //for (j=0; j<m; ++j) cout<<b[j]<<" \n"[j==m-1];
  //cout<<"y="<<y<<endl;
  //cout<<"cnt="<<cnt<<endl;
  sum+=(x^y);
  //cout<<"x^y="<<(x^y)<<endl;
  //cout<<"sum="<<sum<<endl;
  return y;
}

int main() {
  int t,n,x,i;
  cin>>t;
  for (int nc=1; nc<=t; ++nc) {
    cin>>n>>x;
    int xx=x;
    //cout<<"n="<<n<<" x="<<x<<endl;
    sum=0;
    //for (i=n-2; i>=0; --i) {
    if (n>2) x=solve(1,x);
    for (i=0; i<n-3; ++i) x=solve(1,x);
    if (n>1) x=solve(0,x);
    //}
    sum+=x;
    int sum1=sum;
    sum=0;
    x=xx;
    //cout<<"--------"<<endl;
    if (n>2) x=solve(0,x);
    for (i=0; i<n-3; ++i) x=solve(0,x);
    if (n>1) x=solve(0,x);
    //cout<<"x="<<x<<endl;
    sum+=x;
    //cout<<"sum="<<sum<<" sum1="<<sum1<<endl;
    sum=MAX(sum,sum1);
    cout<<sum<<endl;
  }
}


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

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

  int ans = 0;
  for (int i = 0; i <= n; i++) {
    string s1 = s.substr(0, i), s2 = s.substr(i);
    map<char, int> m1, m2;
    for (char c : s1)
      m1[c] = 1;
    for (char c : s2)
      m2[c] = 1;
    int la = 0;
    for (char c = 'a'; c <= 'z'; c++)
      if (m1[c] && m2[c])
        la++;
    ans = max(ans, la);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque
import itertools

n,m,x=map(int, input().split())

li = deque()

sum = -1
ans = 0
for i in range(n):
    li.append(list(map(int, input().split())))

for i in range(1,n+1):
    for v in itertools.combinations(li, i):
        ok = True
        for j in range(1,m+1):
            ans = 0
            for k in v:
                ans += k[j]
                if ans >= x:
                    break
            if ans < x:
                ok = False
                break

        if ok == True:
            s=0
            for j in range(i):
                s+=v[j][0]
            if sum > s or sum == -1:
                sum=s


print(sum)


Measured memory_bytes: 68756
# -*- coding: utf-8 -*-

import sys
import copy

sys.setrecursionlimit(1000000)

# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~

A, P  = map(int, input().split())

P += A * 3

print(P // 2)


Measured memory_bytes: 3572
#include <iostream>

using namespace std;

int main(){
    int n;
    int i;
    long a[9999];
    long max,min,sum;
    
    sum = 0;
    
    cin >> n;
    
    for(i = 0;i < n;i++){
        cin >> a[i];
    }
    
    max = a[0];
    min = a[0];
    sum = a[0];
    
    for(i = 1;i < n;i++){
        sum = sum + a[i];
        if(max < a[i]){
            max = a[i];
        }
        if(min > a[i]){
            min = a[i];
        }
    }
    
    cout << min << ' ' << max << ' ' << sum << endl;
    
    return 0;
    
    
}


Measured memory_bytes: 3156
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- getl toInt
  unless (n == 0) $ do
    solve n <$> replicateM n (getl toInt) >>= mapM_ print
    main

solve :: Int -> [Int] -> [Int]
solve n xs = f T 0 (sort xs) (sort ([1..2*n] \\ xs))
  where
    f tn fld ts hs
      | null ts = [length hs, 0]
      | null hs = [0, length ts]
      | tn == T && null t2s = f H 0 ts hs
      | tn == T = f H (head t2s) (t1s ++ (tail t2s)) hs
      | tn == H && null h2s = f T 0 ts hs
      | otherwise = f T (head h2s) ts (h1s ++ (tail h2s))
      where
        (t1s,t2s) = partition (<= fld) ts
        (h1s,h2s) = partition (<= fld) hs
        
toInt :: String -> Int
toInt = read

getl :: (String -> a) -> IO a
getl f = f <$> getLine

data Player = T | H deriving (Show,Eq)

Measured memory_bytes: 4140
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, groupby
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X, Y = MAP()

cnt = 1
A = X

while A <= Y:
	A = 2*A
	cnt += 1

print(cnt-1)

Measured memory_bytes: 5716
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
const ll INF = 1e9 + 7;
typedef pair<int,int> P;// pair型は２つの値の組を表せる

int main(){
    int n,m; cin >> n >> m; //桁数n,条件がm個
    vector<P> p(m);
    //p[i].firstが左から～桁目
    //p[i].secondがその桁の数値
    rep(i,m) cin >> p[i].first >> p[i].second;
    //候補0~999を試す
    rep(x,1000){
        int keta=1;//0桁が存在しないため
        int nx=x/10;
        vector <int> d(1,x%10);//下一桁をd配列に入れる！
        while(nx){
            keta++;
            d.push_back(nx%10);
            nx/=10;
        }
        reverse(d.begin(),d.end());
        
        if (keta!=n) continue;
        bool ok=true;
        rep(i,m){
            if (d[p[i].first-1]!=p[i].second) ok=false;
        }
        if(ok){
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FOR(i,j,n,m) for(int i=j;i<n;i+=m)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.F<<","<<_p.S<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}

template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=(ll)1e18;

int main(){
  IOS();
  ll a,b;
  cin>>a>>b;
  ll n = b - a;
  ll tp = n*(n+1)/2;
  cout<<tp - b<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<cstring>

using namespace std;

#ifdef LDEBUG
#define debug(x) cout << #x << ":" << x << endl
#else
#define debug(...)
#endif

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

typedef unsigned long long u64;
typedef long long i64;

int p,q,h,w;

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

        cin >> p >> q >> h >> w;
        cout << (p-h) * (q-w) << endl;

        return 0;
}


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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vll = V<ll>;
using VVll = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Msi = M<string, int>;

const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()


int main() {
    int n;
    cin >> n;
    int maxi = 0;
    int cnt = 0;
    int now = -1;
    REP(i, n) {
        int h; cin >> h;
        if (h <= now) {
            cnt++;
            now = h;
        } else {
            if (maxi < cnt) {
                maxi = cnt;
            }
            cnt = 0;
            now = h;
        }
    }
    if (maxi < cnt) {
        maxi = cnt;
    }
    std::cout << maxi << '\n';

    return 0;
}


Measured memory_bytes: 256
t = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())

print(t[k-1])


Measured memory_bytes: 2940
N, M = list(map(int, input().split()))
LR = [list(map(int,input().split())) for i in range(M)]
max = 1
min = 100000
for i in range(M):
    if max < LR[i][0]:
        max = LR[i][0]
    if min > LR[i][1]:
        min = LR[i][1]
if max <= min:
    print(min - max + 1)
else:
    print(0)

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

int main() {
  string N;
  cin >> N;
  if ((N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3]))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

ll n,w;
ll wt[102],val[102];
ll dp[102][100005];
ll find(int index,int curr_wt)
{
	if(index==n)
	return 0;
	if(dp[index][curr_wt]!=-1)
	return dp[index][curr_wt];
	ll ans=0;
	if(wt[index]<=curr_wt)
	{
		ans=max(ans,val[index]+find(index+1,curr_wt-wt[index]));
		ans=max(ans,find(index+1,curr_wt));
		return dp[index][curr_wt]= ans;
	}
	else
	{
		ans=max(ans,find(index+1,curr_wt));
		return dp[index][curr_wt]=ans;
	}
}
int main()
{
	cin>>n>>w;
	for(int i=0;i<n;i++)
	{
		cin>>wt[i]>>val[i];
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<=w;j++)
		dp[i][j]=-1;
	}
	dp[0][0]=0;
	ll ans=find(0,w);
	cout<<ans;
}

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

int main() {
    string s;
    cin >> s;
    string ans="NO";
    if(s=="AKIHABARA") ans="YES";
    else if(s=="KIHABARA") ans="YES";
    else if(s=="AKIHBARA") ans="YES";
    else if(s=="AKIHABRA") ans="YES";
    else if(s=="AKIHABAR") ans="YES";
    else if(s=="KIHBARA") ans="YES";
    else if(s=="KIHABRA") ans="YES";
    else if(s=="KIHABAR") ans="YES";
    else if(s=="AKIHBRA") ans="YES";
    else if(s=="AKIHBAR") ans="YES";
    else if(s=="AKIHABR") ans="YES";
    else if(s=="KIHBRA") ans="YES";
    else if(s=="KIHBAR") ans="YES";
    else if(s=="KIHABR") ans="YES";
    else if(s=="AKIHBR") ans="YES";
    else if(s=="KIHBR") ans="YES";
    cout << ans << endl;
}

Measured memory_bytes: 256
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

k = inn()
a = inl()
l = r = 2
for i in range(k-1,-1,-1):
    nl = ((l+a[i]-1)//a[i])*a[i]
    nr = (r//a[i])*a[i] + a[i]-1
    #ddprint("l {} r {} nl {} nr {}".format(l,r,nl,nr))
    if r<nl or nr<l:
        print(-1)
        exit()
    l = nl
    r = nr
print("{} {}".format(l,r))


Measured memory_bytes: 63856
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;
const int AMAX = 100000;
ll cnt[AMAX + 1];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    ll K;
    cin >> N >> K;

    for (int i = 0; i < N; ++i)
    {
        int A, B;
        cin >> A >> B;
        cnt[A] += B;
    }

    for (int ans = 1; ans <= AMAX; ++ans)
    {
        if (K <= cnt[ans])
        {
            cout << ans << endl;
            break;
        }
        K -= cnt[ans];
    }

    return 0;
}

Measured memory_bytes: 1024
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(M)]
list = [{} for _ in range(N)]
for x in AB:
    if x[1]-1 not in list[x[0]-1].keys():
        list[x[0]-1][x[1]-1] = 1
    if x[0]-1 not in list[x[1]-1].keys():
        list[x[1]-1][x[0]-1] = 1
#print(list)
ans = 0
for n, x in enumerate(list):
    cand = [H[i] for i in x.keys()]
    flag = 1
    for t in cand:
        if H[n] <= t:
            flag = 0
            break
    if flag == 1:
        ans += 1
print(ans)

Measured memory_bytes: 119668
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            bool check = true;
            var str = Console.ReadLine();
            var n = str.Length;
            var data = str.ToCharArray();
            for(int i = 0; i < (n - 1) / 2; i++)
            {
                if (data[i] != data[n - i - 1]) check = false;
            }
            for (int i = 0; i < ((n - 1) / 2 + 1) / 2; i++)
            {
                if (data[i] != data[(n - 1) / 2 - i - 1]) check = false;
            }
            if (check == true)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
// 0227
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	while(1){
		int n, m;
		vector<int> ve;

		cin>>n>>m;
		if((n == 0) && (m == 0 ))
			break;

		for(int i=0;i<n;i++){
			int c;
			cin>>c;
			ve.push_back(c);
		}

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

		int cost = 0;
		for(int i=1;i<=n;i++)
			if(i%m != 0)
				cost += ve[n-i];
		
		cout<<cost<<endl;
	}
	return 0;
}

Measured memory_bytes: 1228
#include <iostream>
using namespace std; 
int main(){
    class kyoris{
    public:
        int u,r,l,d;
        kyoris(int m, int h, int x, int y){
            u = h - y;
            r = m - x;
            l = x;
            d = y;
        }
    };
    int m,h,x,y,r;
    cin >> m >> h >> x >> y >>r;
    kyoris k(m,h,x,y);
    if(k.u >= r && k.r >= r && k.l >= r && k.d >= r){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define x1 xdddddddddddddddddd
#define y1 ydddddddddddddddddd

string s;

ll ans,t;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> s;
    for(int i=0;i<s.lg;i++){
        if(s[i]=='W') ans+=t;
        else t++;
    }
    cout << ans;
}


Measured memory_bytes: 720
/*
Author: CNYALI_LK
LANG: C++
PROG: F.cpp
*/
#include<bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define all(x) x.begin(),x.end()
using namespace std;
const double eps=1e-8;
const double PI=acos(-1.0);
typedef long long ll;
template<class T>void chkmin(T &a,T b){a=a<b?a:b;}
template<class T>void chkmax(T &a,T b){a=a>b?a:b;}
template<class T>T sqr(T a){return a*a;}
template<class T>T mmin(T a,T b){return a<b?a:b;}
template<class T>T mmax(T a,T b){return a>b?a:b;}
template<class T>T aabs(T a){return a<0?-a:a;}
int r[102424];
int t[102424],y[102424];
int a[102424],b[102424],c[102424];
#define min mmin
#define max mmax
#define abs aabs
int main(){
#ifdef cnyali_lk
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
	int l,k,q,d;
	a[0]=0;
	b[0]=0x3f3f3f3f;
	c[0]=-0x3f3f3f3f;
	scanf("%d%d",&l,&k);
	for(int i=1;i<=k;++i)scanf("%d",r+i);
	a[1]=(-r[1]);
	b[1]=0x3f3f3f3f;
	c[1]=0;
	for(int i=2;i<=k;++i){
		d=r[i]-r[i-1];
		if(i&1){
			a[i]=a[i-1]-d;
			b[i]=b[i-1]-d;
			c[i]=mmax(c[i-1]-d,0);
		}
		else{
			a[i]=a[i-1]+d;
			b[i]=mmin(mmax(b[i-1],c[i-1])+d,l);
			c[i]=min(c[i-1]+d,l);
		}
	}
	scanf("%d",&q);
	for(int i=1;i<=q;++i){
		scanf("%d",t+i);
		int lx,rx,mid;
		scanf("%d",y+i);
		lx=0;rx=k;
		while(lx<=rx){
			mid=(lx+rx)>>1;
			if(t[i]>=r[mid])lx=mid+1;
			else rx=mid-1;
		}
		--lx;
		t[i]-=r[lx];
		y[i]=max(min(y[i]+a[lx],b[lx]),c[lx]);
		if(lx&1){
			y[i]=min(y[i]+t[i],l);
		}
		else{
			y[i]=max(y[i]-t[i],0);
		}
		printf("%d\n",y[i]);
	}
	return 0;
}



Measured memory_bytes: 3584
#include <stdio.h>

int main(){
  int n;
  scanf("%d", &n);
  int x[n], y[n];
  for(int i = 0; i < n; i++){
    scanf("%d %d", &x[i], &y[i]);
  }
  int max = 0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(i != j){
        int p = x[j] - x[i];
        int q = y[j] - y[i];
        int cnt = 0;
        for(int s = 0; s < n; s++){
          for(int t = 0; t < n; t++){
            if((x[s] + p == x[t]) && (y[s] + q == y[t])){
              cnt++;
            }
          }
        }
        if(cnt > max){
          max = cnt;
        }
      }
    }
  }
  printf("%d\n", n - max);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>

int main(){
    int h, m, s;
    std::cin >> s;

    h = s / 3600;
    s -= h * 3600;
    m = s / 60;
    s -= m * 60;
    
    std::cout << h << ":" << m << ":" << s << std::endl;
    
    return 0;
}


Measured memory_bytes: 3080
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#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>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x);
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

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

    //start from here

    readb(h1, m1) readb(h2, m2) read(k)

    int x1 = h1*60 + m1; int x2 = h2*60 + m2;

    cout << x2 - x1 - k;


    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REYNA(i, a, b) for (int i=(a); i<(b); ++i)
#define scanf(...) scanf(__VA_ARGS__)?:0
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PLL, int> PLLI;
typedef pair <PII, PII> PP;
typedef pair <PII, int> PPI;
typedef pair <ll, int> PLI;
typedef unsigned int ui;
const int mod = 1e9+7;
const int inf = 1e9+9;
const int maxn = 2010;
int f[maxn], A[maxn], B[maxn], C[maxn];
ll X;
int n, m;
int find(int x)
{
	if (f[x] == x) return x;
	f[x] = find(f[x]);
	return f[x];
}

void lacz(int x, int y)
{
	x = find(x); y = find(y);
	if (x == y) return;
	f[x] = y;
}

inline ll potmod(ll a, ll b)
{
	ll res = 1;
	while (b > 0)
	{
		if (b & 1) res = (res * a)%mod;
		a = (a * a)%mod;
		b /= 2;
	}
	return res;
}
ll weight;

pair <ll, bool> createMST(int without)
{
	vector <pair <int, PII> > sor;
	FOR(i, 1, n) f[i] = i;
	ll cost = 0;
	if (without)
	{
		cost += C[without];
		lacz(A[without], B[without]);
	}
	
	FOR(i, 1, m)
		if (i != without) sor.pb(mp(C[i], mp(A[i], B[i])));
	
	sort(sor.begin(), sor.end());
	for (auto u : sor)
	{
		if (find(u.e2.e1) == find(u.e2.e2));
		else cost += u.e1, lacz(u.e2.e1, u.e2.e2);
	}
	
	return mp(cost, (cost == weight));
}

bool canBe[maxn];
ll COST[maxn];

int main()
{
	boost;
	cin >> n >> m >> X;
	FOR(i, 1, m) cin >> A[i] >> B[i] >> C[i];
	weight = createMST(0).e1;
	FOR(i, 1, m) 
	{
		pair <ll, bool> help = createMST(i);
		canBe[i] = help.e2; COST[i] = help.e1;
	}
	if (weight > X) OUT(0);
	if (weight == X)
	{
		int stake = 0;
		FOR(i, 1, m) stake += canBe[i];
		ll tmp = (potmod(2, stake) - 2 + mod)%mod;
		OUT(tmp * potmod(2, m - stake) % mod);
	}
	assert(weight < X);
	//MST is of one type
	ll ok_edges = 0, forced = 0, free = 0;
	FOR(i, 1, m)
	{
		if (canBe[i]) ++forced;
		else if (!canBe[i] && COST[i] < X) ++forced;
		else if (!canBe[i] && COST[i] == X) ++ok_edges;
		else if (!canBe[i] && COST[i] > X) ++free;
	}
	
	if (ok_edges == 0) OUT(0);
	ll waysFree = (potmod(2, ok_edges) - 1 + mod) % mod;
	waysFree = waysFree * potmod(2, free) % mod;
	OUT(2 * waysFree % mod);
}


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

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1e9;
using namespace std;
typedef long long ll;

int n,m;
ll p[100100], y[100100];
vector <ll> v[100100];

int main(){
  std::cin >> n >> m;
  rep(i,1,m+1){
    std::cin >> p[i] >> y[i];
    v[p[i]].push_back(y[i]);
  }
  rep(i,1,n+1){
    sort(all(v[i]));
  }
  rep(i,1,m+1){
    int ken = p[i];
    int city = lower_bound(all(v[ken]), y[i]) - v[ken].begin()+1;
    std::cout <<setw(6)<<setfill('0') <<ken <<setw(6)<<setfill('0')<< city << '\n';
  }

}


Measured memory_bytes: 8576
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iomanip>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
const long double EPS = 1.0E-14;
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define setpre(n) fixed << setprecision(n)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
  
}
ll a,b,x;
ld rad(ld x){
  return (x*M_PI)/180.0;
}
ll findData(ld i){
  ld tri=0;
  //findDataが単調減少のときはbinaryの不等号を反転させる
  if(b*tan(M_PI/2.0-rad(i))<=a) tri = a*b*b*tan(M_PI/2.0-rad(i))/2.0;
  else tri = (ld)(a*a*b)-(a*a*a*tan(rad(i)))/2.0;
  
  if(x <= tri) return 0;
  else return 1;
}
ld binaryFloor(ld max, ld min, ll target){
  //targetの数値以下の最大
  ld mid;
  ll count=0;
  while(max>min && count < 1000){
    mid = (max+min)/2.0;
    if(findData(mid) > target) max = mid-EPS;
    else min = mid;
    count++;
  }
  return min;
}
int main(void){
  initialize();
  ll i,j,k,result=0;
  cin >> a >> b >> x;
  cout << setpre(10) << binaryFloor(90.0,0.0,0) << endl;
  
  return 0;
}

Measured memory_bytes: 4168
# -*- coding: utf-8 -*-

N = int(input().strip())
s_list = [input().strip() for _ in range(N)]
#-----

check_dic={}
cnt=0
for i,s in enumerate(s_list):
    key = "".join(sorted(s))
    
    if key not in check_dic:
        check_dic[key] = 1
    else:
        cnt += check_dic[key]
        check_dic[key] += 1

print(cnt)


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

#define PI 3.14159265358979323846
#define int long long int
#define ff first
#define ss second
#define pb push_back

#define N 1010
#define MOD 1000000007

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);

    int n;
    cin >> n;

    int k = n % 100;
    int k1 = n / 100;

    int no = k / 5 + (k % 5 != 0);

    if(k1 < no)
    	cout << 0;
    else
    	cout << 1;
   	return 0;	
   		
}

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

#define INF 1001001001
#define MAX 1e18

const int mod = 998244353;

int main() {
  ll n;
  int x, m;
  cin >> n >> x >> m;
  vector<int> used(m,-1);
  vector<ll> a(m);
  a[0] = x;
  ll ans = 0;
  int lpst = -1, lped = -1;
  for (ll i = 0; i < n; i++) {
    used[a[i]] = i;
    ans += a[i];
    a[i+1] = a[i]*a[i]%m;
    if (used[a[i+1]]!=-1) {
      lpst = used[a[i+1]];
      lped = i;
      n -= lped+1;
      break;
    }
  }
  if (lpst == -1) {
    cout << ans << endl;
    return 0;
  }
  ll sum = 0;
  int cnt = 0;
  for (int i = lpst; i <= lped; i++) {
    sum += a[i];
    cnt++;
  }

  ans += sum*(n/cnt);
  for (int i = lpst; i < lpst+n%cnt; i++) ans += a[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4556
package main

import "fmt"

func main() {
	var h, n int
	fmt.Scan(&h, &n)
	a := make([]int, n)
	sum :=0
	for i:=0; i<n; i++{
		fmt.Scan(&a[i])
		sum += a[i]
	}

	if sum >= h{
		fmt.Println("Yes")
	}else{
		fmt.Println("No")
	}
}

Measured memory_bytes: 6312
float a;n,v,r,h,c[99];main(w){for(;scanf("%d%d",&n,&w)*n;r=h=a=!printf("%f\n",a/r/h+.01)){for(;n--;v/=w,++c[r<v?r=v:v])scanf("%d",&v);for(;n++<r;a+=v*(r-n))h=fmax(h,v=c[n]),c[n]=0;}}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast",3,"inline")
#include <bits/stdc++.h>
using namespace std;
int n,m,ans;
int main(){
	ios_base::sync_with_stdio(false);
	cin>>n>>m;
	if((n+m)%2)cout<<"IMPOSSIBLE";
	else cout<<(n+m)/2;
	return 0;
}


Measured memory_bytes: 256
/*
ID: wangjun30
TASK:
LANG: C++
*/
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int n,ans=1e9;
	cin>>n;
	int num[n];
	for(int i=0;i<n;i++)
		cin>>num[i];
	for(int i=0;i<n-1;i++){
		int a=0,b=0;
		for(int j=0;j<=i;j++)
			a+=num[j];
		for(int j=i+1;j<n;j++)
			b+=num[j];
		ans=min(abs(a-b),ans);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
/*-----------------------------------------------,
|  __                                       __   |
| |  |--.-----.---.-.----.----.-----.-----.|  |_ |
| |  _  |  -__|  _  |  __|  __|  -__|  _  ||   _||
| |_____|_____|___._|____|____|_____|   __||____||
|                                   |__|         |
`-----------------------------------------------*/
#include<algorithm>
#include<array>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
typedef long long ll; typedef long double ld ;using namespace std;
#define INF 1000000000000
#define MOD 10000007
#define ALL(name) (name).begin(),(name).end()
#define REP(counter, limit) for (long long counter = 0; counter < limit; counter++)
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){ios::sync_with_stdio(0);cin.tie(nullptr); /*cout<<fixed<<setprecision(20);*/};}setupios;
int main() {

  string a,b;
  cin>>a>>b;
  if(a.size()>b.size()){
    cout<<"GREATER"<<endl;
    return 0;
  }else if(a.size()<b.size()){
    cout<<"LESS"<<endl;
    return 0;
  }else{
    int n=a.size();
    for(int i=0;i<n;i++){
      if(stoi(a.substr(i,1))>stoi(b.substr(i,1))){
        cout<<"GREATER"<<endl;
        return 0;
      }else if(stoi(a.substr(i,1))<stoi(b.substr(i,1))){
        cout<<"LESS"<<endl;
        return 0;
      }
    }
    cout<<"EQUAL"<<endl;
  }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 10
using namespace std;
char s[N][N];
int H,W;
int main(){
	cin>>H>>W;
	for(int i=1;i<=H;i++)
		scanf("%s",s[i]+1);
	int lastr=0,lastc=1;
	for(int i=2;i<=H+W;i++){
		int num=0;
		for(int r=1;r<=min(i-1,H);r++){
			int c=i-r;if(c>W||s[r][c]!='#') continue;
			if(num==0&&(abs(lastr-r)+abs(lastc-c)==1)) lastr=r,lastc=c,num++;
			else return puts("Impossible"),0;
		}
	}
	puts("Possible");
	return 0;
}

Measured memory_bytes: 256
// Atcoder Beginner Contest 178
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(ll i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl

int main() 
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cerr.tie(0);
	ll n;
	cin>>n;
	if(n<2)
	{
		cout<<0<<Endl;
		return 0;
	}
	ll ans = 1;
	FOR(i,0,n)
	{
		ans*=9;
		ans%=1000000007;
	}
	ans*=2;
	ans%=1000000007;
	ll ch = 1;
	FOR(i,0,n)
	{
		ch*=8;
		ch%=1000000007;
	}
	ll he = 1;
	FOR(i,0,n)
	{
		he*=10;
		he%=1000000007;
	}
	ll Ans = he-ans+ch;
	cout<<(Ans<0?Ans+1000000007:Ans)%1000000007<<Endl;
	return 0;
}

Measured memory_bytes: 3640
<?php
fscanf(STDIN, "%d %d %d %d", $W, $H, $x, $y);

$flag = 0;
if($W/2==$x&&$H/2==$y){
  $flag++;
}


   
  echo  ($W*$H/2)." ".$flag."\n";

 

 
?>

Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define INF 999999999
using namespace std;

int main() {
  int N;
  std::cin >> N;
  bool ans = false;
  int a = N/100;
  N = N%100;
  if (a == 7) {
    ans = true;
  }
   a = N/10;
  N = N%10;
  if (a == 7) {
    ans = true;
  }
  a = N;
  if (a == 7) {
    ans = true;
  }
  if (ans) {
    std::cout << "Yes" << '\n';
  }
  else{
    std::cout << "No" << '\n';
  }
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 100000
#define NIL -1

typedef struct
{
  int p;
  int l;
  int r;
}Node;

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d){
  if(u == NIL){
    return;
  }
  D[u] = d;
  setDepth(T[u].l, d + 1);
  setDepth(T[u].r, d + 1);
}

int setHeight(int u){
  int h1 = 0, h2 = 0;

  if(T[u].l != NIL){
    h1 = setHeight(T[u].l) + 1;
  }
  if(T[u].r != NIL){
    h2 = setHeight(T[u].r) + 1;
  }
  return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u){
 if(T[u].p == NIL) return NIL;
 if(T[T[u].p].l != u && T[T[u].p].l != NIL){
   return T[T[u].p].l;
 }
 if(T[T[u].p].r != u && T[T[u].p].r != NIL){
   return T[T[u].p].r;
 }
 return NIL;
}

void print(int u){
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].p);
  printf("sibling = %d, ", getSibling(u));

  int deg = 0;
  if(T[u].l != NIL) deg++;
  if(T[u].r != NIL) deg++;
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if(T[u].p == NIL) printf("root\n");
  else if(T[u].l == NIL && T[u].r == NIL) printf("leaf\n");
  else  printf("internal node\n");
}

int main(void)
{
  int v, l, r, root = 0, i;

  scanf("%d", &n);

  for(i = 0; i < n; i++)  T[i].p=NIL;
  for(i = 0; i < n; i++){
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL)  T[l].p=v;
    if(r != NIL)  T[r].p=v;
  }
  for(i = 0; i < n; i++){
    if(T[i].p == NIL) root=i;
  }

  setDepth(root, 0);
  setHeight(root);

  for(i = 0; i < n; i++)  print(i);
  return 0;
}



Measured memory_bytes: 2048
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY
N=gets.to_i
s=get_nsp
t=get_nsp
if s.join("")==t.join("")
    puts N
    exit
end
i=0
ans=2*N
while i<N
  if s[i..N-1].join("")==t[0..N-1-i].join("")
      ans=2*N-(N-i)
      break
  end
  i+=1
end
puts ans

Measured memory_bytes: 1788
import collections
class UnionFind:
    def __init__(self, max_size):
        self.parent = [i for i in range(max_size+1)]
        self.depth = [0 for _ in range(max_size+1)]
        self.cnt = [1 for i in range(max_size+1)]
    # 菲再起にしたい　Whileでスタックに突っこみながら見てスタックの中身全部に代入
    def find(self, x):
        de = collections.deque()
        t = x
        while t!=self.parent[t]:
            de.append(t)
            t = self.parent[t]
        while de:
            tmp = de.pop()
            self.parent[tmp] = t
        return t
    
    def unite(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return
        elif self.depth[x]<self.depth[y]:
            self.parent[x] = y
            self.cnt[y] += self.cnt[x]
        else:
            self.parent[y] = x
            self.cnt[x]+=self.cnt[y]
            if self.depth[x]==self.depth[y]:
                self.depth[x]+=1
    def same(self, x, y):
        return self.find(x)==self.find(y)
    def size(self,x):
        return self.cnt[self.find(x)]

n,m = map(int,input().split())
utree = UnionFind(n+10)
for _ in range(m):
    x,y,z = map(int,input().split())
    utree.unite(x,y)
s = {utree.find(i) for i in range(1,n+1)}
print(len(s))

Measured memory_bytes: 59296
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BBalance solver = new BBalance();
        solver.solve(1, in, out);
        out.close();
    }

    static class BBalance {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] arr = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
                sum += arr[i];
            }
            int cur = 0;
            int prev = 0;
            for (int i = 0; i < n; i++) {
                prev = cur;
                cur += arr[i];
                if (2 * cur >= sum) {
                    out.println(Math.min((2 * cur - sum), (sum - 2 * prev)));
                    break;
                }
            }

        }

    }
}



Measured memory_bytes: 23892
# -coding: utf-8 -

n = int(input())
a =list(map(int, input().split()))

a = sorted(a, reverse = True)

#print(a)

alice = 0
for i in range(len(a)):
    if i%2 == 0:
        alice += a[i]

#print(alice)

bob = sum(a) - alice

print(alice - bob)
        




Measured memory_bytes: 3060
n = int(input())
ab = []
for i in range(n):
    ab.append(tuple(map(int,input().split())))
ab.sort(key=lambda x: x[1])
m = 0
ans = "Yes"
for ai,bi in ab:
    m += ai
    if m > bi:
        ans = "No"
print(ans)


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

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

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

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

    double ans = 0;

    REP(i,n)
    {   
        int tmp = i+1;
        double tot = 1.0 / n;
        while (tmp < k)
        {
            tot /= 2;
            tmp *= 2;
        }

        ans += tot;
    }

    // ans =  ans / (double)n;
    printf("%.9f\n",ans);
    return 0;
}



Measured memory_bytes: 256
# import bisect
# from collections import Counter, defaultdict, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n = input()
    print("ABC" + n)

if __name__ == '__main__':
    main()

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
#define mp            make_pair
template<class T, class S> inline bool minup(T& m, const S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, const S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-10;

string s, t;
int n;
int res;

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

  rep(i, n){
    cin >> t;
    t += t;
    rep(i, t.size() - s.size()) if(t.substr(i, s.size()) == s){
      res += 1;
      break;
    }
  }

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 1212
import bisect

n = int(input())
a = sorted([int(i) for i in input().split()])

idx = bisect.bisect_right(a,0)

res = -sum(a[:idx]) + sum(a[idx:])

if idx%2==1:
    if idx<n:
        c = min(abs(a[idx-1]), abs(a[idx]))
        res -= 2*c
    else:
        res -= 2*abs(a[idx-1])
        
print(res)


Measured memory_bytes: 64880
#include<stdio.h>
#include<string.h>
int main()
{	int n=0,f=0,t=1;
	char s[11];
	scanf("%s",s);
	if(s[0]=='A')
	{for(n=1;n<strlen(s);n++)
	if(s[n]=='C'&&n!=strlen(s)-1&&!f&&n!=1)
	f=1;
	else if(64<=s[n]&&s[n]<=90)
	t=0;
	}
	if(f&&t)
	printf("AC\n");
	else
	printf("WA\n");
}

Measured memory_bytes: 128
#include <cstdio>
#include <queue>

using std::queue;

const int MAXN=100005,MAXM=200005;
int n;
int he[MAXN],inD[MAXN];

struct line{int to,nex,w;}ed[MAXM];

inline void addE(int u,int v,int d){
	static int cnt;
	ed[++cnt]=(line){v,he[u],d};
	he[u]=cnt;
}

inline bool topo_sort(){
	static int dis[MAXN],last[MAXN];
	static queue<int> que;
	for(int i=1;i<=n;++i){
		if(!inD[i]){
			que.push(i);
			last[i]=i;
		}
	}
	int u;
	while(que.size()){
		u=que.front();
		que.pop();
		for(int i=he[u],v,d;i;i=ed[i].nex){
			v=ed[i].to,d=dis[u]+ed[i].w;
			if(!last[v] || dis[v]==d){
				last[v]=last[u];
				dis[v]=d;
				if(--inD[v]==0) que.push(v);
			}
			else if(last[v]!=last[u]){
				last[v]=last[u];
				dis[v]=d;
				if(--inD[v]==0) que.push(v);
			}
			else return false;
		}
	}
	for(int i=1;i<=n;++i){
		if(inD[i]) return false;
	}
	return true;
}

int main(){
	int m;
	scanf("%d%d",&n,&m);
	for(int i=1,u,v,d;i<=m;++i){
		scanf("%d%d%d",&u,&v,&d);
		addE(u,v,d);
		++inD[v];
	}
	if(topo_sort()) puts("Yes");
	else puts("No");
	return 0;
}

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

def main():
    N, K = map(int, input().split())

    MOD = int(1e9) + 7

    val = N-K+1

    kai = [1] * (max(val+1, K))
    for i in range(2, len(kai)):
        kai[i] = kai[i-1] * i
        kai[i] %= MOD

    for i in range(1, K+1):
        if val-i < 0:
            print(0)
            continue
        tmp = kai[val] * pow(kai[val-i], MOD-2, MOD) * pow(kai[i], MOD-2, MOD)
        tmp %= MOD
        # print(K-1, K-i, i-1)
        tmp *= kai[K-1] * pow(kai[K-i], MOD-2, MOD) * pow(kai[i-1], MOD-2, MOD)
        tmp %= MOD
        print(tmp)

if __name__ == "__main__":
    main()

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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

typedef long long LL;

const int INF = 0x3f3f3f3f;


int main(void) {
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    unordered_set<int> s;
    int n, x;
    cin >> n;
    bool f = true;
    for (int i = 0; i < n; ++i) {
        cin >> x;
        if (s.find(x) != s.end()) {
            f = false;
        }
        s.insert(x);
    }
    cout << (f ? "YES":"NO") << endl;

    return 0;
}



Measured memory_bytes: 8520
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
using Graph=vector<vector<int>>;
template<class T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, T b){ if(a>b){ a=b; return 1; } return 0; }

int main(){
    string s;
    cin>>s;
    for(int i=0;i<3;++i){
        cout<<s[i];
    }
    cout<<endl;
}

Measured memory_bytes: 3596
#abc104c all green 
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(d)]
all_sum = []
for bit in range(1<<d):
    s = 0
    a = 0
    rest = []
    for i in range(d):
        if bit & (1<<i):
            s += pc[i][0]*100*(i+1) + pc[i][1]
            a += pc[i][0]
        else :
            rest.append(i)
    
    if s >= g :
        all_sum.append(a)
    else :
        k = max(rest)
        diff = g - s
        for j in range(pc[k][0]):
            if j*(k+1)*100 >= diff:
                all_sum.append(a+j)
print(min(all_sum))

Measured memory_bytes: 9120