akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;
int main(){
	int n;
	cin >> n;
	ll a[3 * n];
	REP(i, 3*n) cin >> a[i];
	sort(a, a+3*n);
	ll ans = 0;
	REP(i, n) ans += a[3*n - 2*i - 2];
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
const double pi = 3.141592653589793238;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

void printV(vector<int> &v);
void printVV(vector<vector<int>> &vv);


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

  for(int i = 0; i <= N; i++) {
    for(int j = 0; j <= N-i; j++) {
      int k = N-i-j;
      if(10000*i + 5000*j + 1000*k == Y) {
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }


  cout << -1 << " " << -1 << " " << -1 << endl;

  return 0;
}


// ベクターの中身を全部出力
void printV(vector<int> &v) {
  cout << "  [ ";
  for(int i = 0; i < (int)v.size(); i++) {
    cout << v.at(i) << " ";
  }
  cout << "]" << endl;
}

void printVV(vector<vector<int>> &vv) {
  cout << "{" << endl;
  for(int i = 0; i < (int)vv.size(); i++) {
    cout << "  [ ";
    for(int j = 0; j < (int)vv.at(i).size(); j++) {
      cout << vv.at(i).at(j) << " ";
    }
    cout << "]," << endl;
  }
  cout << "}" << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
	static Stack<Integer> st;

	static void topologicalSort(ArrayList<Integer> graph[], int n)
	{
		int visited[]=new int[n];
		for(int i=0;i<n;i++)
		{
			dfs(graph, i, visited);
		}
	}

	static void dfs(ArrayList<Integer> graph[], int i, int visited[])
	{
		if(visited[i]==1)
			return;
		visited[i]=1;

		for(int child: graph[i])
			dfs(graph, child, visited);

		st.add(i);
	}

	public static void main(String[] args)
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int m=scan.nextInt();

		ArrayList<Integer> graph[]=new ArrayList[n];
		for(int i=0;i<n;i++)
			graph[i]=new ArrayList<>();

		for(int i=0;i<m;i++)
		{
			graph[scan.nextInt()-1].add(scan.nextInt()-1);
		}

		st=new Stack<>();
		topologicalSort(graph, n);
		int dp[]=new int[n];
		int maxAns=0;

		while(!st.isEmpty())
		{
			int top=st.pop();
			for(int ch: graph[top])
			{
				dp[ch]=Math.max(dp[ch], 1+dp[top]);
				maxAns=Math.max(maxAns, dp[ch]);
			}
		}
		System.out.println(maxAns);

	}
}

Measured memory_bytes: 106688
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;



int main(void)
{
	//変数の宣言
	int n,m;
	int a,b;
	ll d[100];
	char s[20];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int temp3=0;
	int vec[100010];
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;
	char stemp[100010];
	
	//データの読み込み


	scanf("%d",&n);
//	scanf_s("%d",&n);

//	scanf("%s",&s);
//	scanf_s("%s",&s,100010);


/*	for(i=0;i<n;i++){
//		scanf("%d",&b[i]);
		scanf_s("%d",&b[i]);
	}*/


/*	for(i=0;i<3;i++){
//		scanf("%s",&s);
		scanf_s("%s",&s[i],100010);
	}*/


	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

//	clock_t start=clock();

	d[0]=2;
	d[1]=1;

	for(i=2;i<n+1;i++){
		d[i]=d[i-1]+d[i-2];
	}




//	clock_t end=clock();

	//	printf("計算部分終了\n");

	//出力
	
	printf("%lld",d[n]);

//	printf("time=%lf",(double)(end-start)/CLOCKS_PER_SEC);
	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }
void modpow(ref long x, long y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }

void main()
{
	auto N = RD;
	auto S = RD!string;

	long ans;
	foreach (i; 0..N-2)
	{
		if (S[i..i+3] == "ABC")
			++ans;
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}


Measured memory_bytes: 256
import numpy as np

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

t_ary = input().split()
t_ary = np.array([int(e) for e in t_ary])

diff_ary = t_ary[1:] - t_ary[:-1]

#print(diff_ary < T)
#print(diff_ary)

tf_ary = diff_ary < T

total = 0
for i, flag in enumerate(tf_ary):
    if flag:
        total += diff_ary[i]
    else:
        total += T

total += T

print(total)

Measured memory_bytes: 35780
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

const ll mod = 1e9+7;

const ll size = 200100;
ll finv[size], fact[size];
ll Ap[size], Bp[size], ABp[size], hinv[size];
ll N, A, B, C;

ll nCk(ll n, ll k){
    if(n < k) return 0;
    return fact[n] * (finv[k]*finv[n-k]%mod) %mod;
}

ll modpow(ll x, ll n){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

ll inv(ll x){
    return modpow(x, mod-2);
}

void prepare(){
    fact[0] = 1;
    REP(i, size-1) fact[i+1] = fact[i]*(i+1)%mod;
    finv[size-1] = inv(fact[size-1]);
    for (ll i = size-1; i > 0; i--) {
        finv[i-1] = finv[i]*i%mod;
    }
    Ap[0] = 1; REP(i, size-1) Ap[i+1] = Ap[i]*A%mod;
    Bp[0] = 1; REP(i, size-1) Bp[i+1] = Bp[i]*B%mod;
    ABp[0] = 1; REP(i, size-1) ABp[i+1] = ABp[i]*(A+B)%mod;
}

int main(){
    cin >> N >> A >> B >> C;
    prepare();
    
    ll ans = 0;
    FOR(M, N, 2*N){
        ll term = (nCk(M-1, N-1)%mod * (Ap[N]*Bp[M-N]%mod + Ap[M-N]*Bp[N]%mod) %mod) * M%mod;
        term = term * inv(ABp[M]) %mod * 100 %mod * inv(100-C) %mod;
        ans = (ans+term)%mod;
    }
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 8064
#include<stdio.h>

int main(){

  int n,i,a;
  int S[100001];
  
  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&S[i]);
  }

  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,S[i]);
    if(i/2 >= 1){
      printf("parent key = %d, ",S[i/2]);
    }
    if(2*i <= n){
      printf("left key = %d, ",S[2*i]);
    }
    if(2*i+1 <= n){
      printf("right key = %d, ",S[2*i+1]);
    }
    printf("\n");
  }
   return 0;
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
    if (b==0) return 1;
    ll c = power(a,b>>1);
    c = (c*c)%mod;
    if (b&1) return (c*a)%mod;
    return c;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)2e5+5;
const int Q = 301;

ll rec(ll x) {
    if (x<2) return x;
    return 1 + 2*rec(x/2);
}
void solve() {
    ll h;
    cin>>h;
    cout<<rec(h);
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

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

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 256
// finish date: 2018/03/10

#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>

void minusMapSecond(map<int, int> &mp, int key) {
    mp[key]--;
    if (mp[key] == 0) mp.erase(key);
}

int main() {
    int H, W, N;
    cin >> H >> W >> N;
    int a;
    vvi ans(H, vi(W, 0));
    int x = -1, y = 0;
    FOR(i, 1, N + 1) {
        cin >> a;
        rep(j, a) {
            if (x + 1 < W && ans[y][x + 1] == 0) {
                ans[y][x + 1] = i;
                x++;
            } else if (0 <= x - 1 && ans[y][x - 1] == 0) {
                ans[y][x - 1] = i;
                x--;
            } else {
                ans[y + 1][x] = i;
                y++;
            }
        }
    }
    rep(i, H) {
        rep(j, W) {
            cout << ans[i][j] << " " ;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  int n,m;
  cin>>n>>m;
  priority_queue<P,vector<P>,greater<P>> q;
  ll a,b;
  rep(i,n){
    cin>>a>>b;
    q.push(P(a,b));
  }
  ll ans=0;
  while(m>0){
    P k=q.top();q.pop();
    if(m-k.se>=0) ans+=k.fi*k.se;
    else ans+=m*k.fi;
    m-=k.se;
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 2420
n = int(input())
r = []
for _ in range(n):
    x,l = map(int,input().split())
    r.append([x+l, x-l])
r.sort()
tmp = r[0]
cnt = 0
for i in range(1, n):
    if r[i][1] < tmp[0]:
        cnt += 1
    else:
        tmp = r[i]
print(n-cnt)

Measured memory_bytes: 20104
#include <bits/stdc++.h>
using namespace std;
const int n = 50;

vector<long long> solve(long long k) {
    long long base = (n-1) + (k/n);
    long long m = k % n;
    vector<long long> a(n, base);
    for (int i = 0; i < m; i++) a[i] += n;
    for (int i = 0; i < n; i++) a[i] -= m;
    return a;
}

int main() {
    long long k;
    cin >> k;
    vector<long long> a = solve(k);
    
    cout << a.size() << endl;
    for (auto e : a) cout << e << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
const int MAX = 100000;

int main() {
	int N;
	long long K;
	scanf("%d %lld\n", &N, &K);

	long long num[MAX+1] = {0};

	int a, b;
	for (int i = 0; i < N; i++) {
		scanf("%d %d", &a, &b);

		num[a] += b;
	}

	for (int i = 1; i <= MAX; i++) {
		K -= num[i];

		if (K <= 0) {
			printf("%d\n", i);
			break;
		}
	}
}


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

using namespace std;

int main() 
{
    char a, b;
    cin >> a >> b;
    
    if((a == 'H' && b == 'H') || (a == 'D' && b == 'D'))
        cout << "H\n";
    else
        cout << "D\n";
    
    return 0;
}

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

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

    int ans;
    if(a < 10 && b < 10){
        ans = a * b;
    }
    else{
        ans = -1;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

void greedy(int N, const vll& A) {
    ll cur = 1000;
    REP(i, N - 1) {
        ll stock = 0;
        if (A[i] < A[i + 1]) stock = cur / A[i];
        cur += (A[i+1] - A[i]) * stock;
    }

    print(cur);
}

void chmax(ll& a, ll b) {
    if (a < b) a = b;
}


void dp(int N, const vll& A) {
    vll dp(N + 1, 0);
    dp[0] = 1000;
    REP(i, N) {
        REP(j, i + 1) {
            chmax(dp[i+1], dp[j] % A[j] + dp[j] / A[j] * A[i]);
        }
    }

    print(dp[N]);
}


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    vll A(N);
    REP(i, N) cin >> A[i];

//    greedy(N, A);

    dp(N, A);
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

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

//START OF CODE ->->->->->->->

void solve()
{
    int n;
    cin>>n;

    int x = n%10;

    if ( x == 2 || x == 4 || x == 5 || x == 7 || x == 9 )
    {
        cout<<"hon"<<endl;
    }
    else if ( x == 3 )
    {
        cout<<"bon"<<endl;
    }
    else
    {
        cout<<"pon"<<endl;
    }
    
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3640
#include <iostream>
#include <sstream>

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

    std::string valRev;
    long counter = 0;
    for(long i = a; i <= b; ++i){
        std::stringstream ss;
        ss << i;
        valRev = ss.str();
        std::reverse(valRev.begin(), valRev.end());
        // std::cout << "valRev: " << valRev << std::endl;
        if(valRev == ss.str()){
            ++counter;
        }
    }

    std::cout << counter << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int max3(int a, int b, int c);

int main(void){

  int a, b;
  int sum, abs,mul;

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

  sum=a+b;
  abs=a-b;
  mul=a*b;

  printf("%d\n", max3(sum, abs, mul));

  return 0;
}

int max3(int a, int b, int c){
  int max=a;
  if(max<b) max=b;
  if(max<c) max=c;
  return max;
}


Measured memory_bytes: 128
fun main(args: Array<String>?): Unit {
    println(Array(readLine()!!.toInt()){ readLine()!!.trim()}.map{w -> ('a' .. 'z').map{a -> w.count{c -> c == a}}.toIntArray()}.let{a -> ('a' .. 'z').map{c -> c.toString().repeat(a.map{l -> l[c - 'a']}.min()!!)}}.joinToString(""))
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;

int main() {
	string s,ans;
	cin >> s;
	vector<string>ss;
	rep(i, 4) {
		ss.push_back(s.substr(i, 1));
	}
	int num = stoi(ss[0]);
	ans = ss[0];
	cin >> s;
	for (int i = 0; i < (1 << 3); i++) {
		num = stoi(ss[0]);
		rep(j, 3) {
			if (i & (4 >> j)) {
				num += stoi(ss[j+1]) * (-1);
			}
			else {
				num += stoi(ss[j+1]);
			}
		}
		if (num == 7) {
			rep(j, 3) {
				if (i & (4 >> j)) {
					ans += "-" + ss[j+1];
				}
				else {
					ans += "+" + ss[j+1];
				}
			}
			break;
		}
	}
	cout << ans << "=7" << endl;
	return 0;
}

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

int pushBack(long *A, long x, int len) {
    A[len]=x;
    return len+1;
}

void randomAccess(long *A, int p) {
    printf("%ld\n", A[p]);
}

int popBack(long *A, int len) {
    A[len] = '\0';
    return len-1;
}

int main(void) {
    int i, p, q, query, len=0;
    long *A, x;

    scanf("%d", &q);
    A = (long *)malloc(sizeof(long)*q);
    memset(A, '\0', q);

    for (i=0; i<q; i++) {
        scanf("%d", &query);
        if (query==0) {
            scanf("%ld", &x);
            len=pushBack(A, x, len);
        } else if (query==1) {
            scanf("%d", &p);
            randomAccess(A, p);
        } else if (query==2) {
            len=popBack(A, len);
        }
    }
    free(A);
    
    return 0;
}



Measured memory_bytes: 3036
from itertools import product

n, m = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))

ans = 0
for bit in product([0, 1], repeat=n):
    for ksi, pi in zip(ks, p):
        cnt = sum(bit[sij - 1] for sij in ksi[1:])
        if cnt % 2 != pi:
            break
    else:
        ans += 1
print(ans)


Measured memory_bytes: 74340
#include<stdio.h>

#define Max 101
#define inf 1000000000
#define NIL -1
#define WHITE 1
#define BLACK 0


int d[Max],pi[Max],color[Max];
int G[Max][Max],n;

void dijkstra(void );

int main(){
  int i,j,v,c;
  int id,num;

  scanf("%d",&n);

  for(i=0 ; i<n ; i++){
    color[i] = WHITE;
    for(j=0 ; j<n ; j++) G[i][j] = inf;
  }

  for(i=0 ; i<n ; i++){
    scanf("%d%d",&id,&num);
    for(j=0 ; j<num ; j++){
      scanf("%d%d",&v,&c);
      G[id][v] = c;
    }
  }

  dijkstra();

  for(i=0 ; i<n ; i++){
    printf("%d %d\n",i,d[i]);
  }

  return 0;
}


void dijkstra(){
  int u,v,mincost;
  int i,j;

  for(i=0 ; i<n ; i++){
    d[i] = inf;
    pi[i] = NIL;
  }
  d[0] = 0;

  while(1){
    mincost = inf;
    for(i=0 ; i<n ; i++){
      if(color[i] != BLACK && d[i] < mincost){
	mincost = d[i];
	u = i;
      }
    }
    if(mincost == inf) break;

    color[u] = BLACK;

    for(v=0 ; v<n ; v++){
      if(color[v] != BLACK){
	if(d[u] + G[u][v] < d[v]){
	  pi[v] = u;
	  d[v] = G[u][v] + d[u];
	}
      }
    }
  }

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl
#define first(v) get<0>(v)
#define second(v) get<1>(v)
#define third(v) get<2>(v)
template <typename T> bool chmax(T &a, T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


int main(){
    ll L;
    cin >> L;
    ll R;
    cin >> R;
    Map M;
    if(R-L>2020){
        print(0);return 0;
    }
    for(ll i=L;i<=R;i++){
        ll k=i%2019LL;
        M[k]++;
    ;}
    ll ans=INF;
    for(ll i=0;i<2018;i++){
       for(ll j=i+1;j<2019;j++){
           if(M[i]&&M[j]){
               ll k=(i*j)%2019;
               chmin(ans,k);
           }
       ;}
    ;}
    print(ans);

    return 0;
}


Measured memory_bytes: 384
# IN=[list(map(int,i.split())) for i in Input.split('\n')]
# K,N=IN[0]
# A=IN[1]
K,N=list(map(int,input().split()))
A=list(map(int,input().split()))
A.append(K)
A=A[::-1]
B=[]
for i in range(len(A)-1):
    B.append(A[i]-A[i+1])
B[0]=B[0]+A[-1]
print(K-max(B))
# print(A,B)

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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

#define maxn 100005
int A[maxn];
ll dp[maxn];

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

    for (int i = 0; i < N; ++i)
        scanf("%d", A + i);

    dp[1] = abs(A[0] - A[1]);

    for (int i = 2; i < N; ++i) {
        dp[i] = dp[i - 1] + abs(A[i - 1] - A[i]);

        for (int k = 2; k <= K && i - k >= 0; ++k)
            dp[i] = min(dp[i], dp[i - k] + abs(A[i - k] - A[i]));
    }

    printf("%lld\n", dp[N - 1]);
    return 0;
}

Measured memory_bytes: 1408
///
// File:  b.go
// Author: ymiyamoto
//
// Created on Sun May 13 15:37:22 2018
//
package main

import (
	"fmt"
)

var X int

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func pow(a, b int) int {
	if b == 0 {
		return 1
	}
	return a * pow(a, b-1)
}

func main() {
	fmt.Scan(&X)
	if X == 1 {
		fmt.Println(1)
		return
	}

	m := 0
	for i := 2; i <= X; i++ {
		for j := 2; pow(i, j) <= X; j++ {
			m = max(m, pow(i, j))
		}
	}

	fmt.Println(m)
}


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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  /* your code */
  NodePointer now = nil->next;
  while(now != nil && now->key != key){
    now = now->next;                  }
  return now;
}
void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur;
  cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}
void deleteNode(NodePointer t){
  /* your code */
  if(t==nil) return;

  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  /* your code */
  deleteNode(nil->prev);
}

void delete(int key){
  /* your code */
  deleteNode(listSearch(key));
}

void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  /* your code */
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
 }
int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 32980
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let K = scan.word::<i64>();
    let A = scan.word::<i64>();
    let B = scan.word::<i64>();

    let x = (A - 1) / K;
    let y = B / K;
    let ok = x < y;

    println!("{}", if ok { "OK" } else { "NG" });
}


Measured memory_bytes: 2080
#include<stdio.h>
int main(void)
{
	int n;
    int l[200];
    int i,j;
    int t;
    int s;
	scanf("%d",&n);
    for(i=0;i<2*n;i++){
       scanf("%d",&l[i]);
    }
    for(i=0;i<2*n;i++){
        for(j=i+1;j<2*n;j++){
			if(l[i]<l[j]){
				t=l[i];
				l[i]=l[j];
				l[j]=t;
			}
        }
	}
    for(i=0;i<n;i++){
        s+=l[i*2+1];
    }
    printf("%d\n",s);
    return 0;
}

Measured memory_bytes: 128
#define Bobyama
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 10000;
int N;
int a[MAX_N], b[MAX_N];
int c[MAX_N];

int ans[MAX_N];
bool visited[MAX_N];

vector<int> G[MAX_N];

void rec(int v, int& idx) {
  visited[v] = true;
  for (int i = 0; i < len(G[v]); ++i) {
    if (!visited[G[v][i]]) {
      rec(G[v][i], idx);
    }
  }
  ans[v] = c[idx++];
}


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

  cin >> N;
  rep(i, N-1) cin >> a[i] >> b[i];
  rep(i, N) cin >> c[i];

  rep(i, N-1) {
    G[--a[i]].push_back(--b[i]);
    G[b[i]].push_back(a[i]);
  }

  sort(c, c+N);

  ll sum = 0;
  for (int i = 0; i+1 < N; ++i) {
    sum += c[i];
  }

  int idx = 0;
  rec(0, idx);

  cout << sum << endl;
  rep(i, N) {
    cout << ans[i] << (i+1 == N ? '\n' : ' ');
  }

  return 0;
}


Measured memory_bytes: 1536
N=int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
s=len(make_divisors(N-1))
p=make_divisors(N)
for i in range(1,len(p)):
  q=N
  while True:
    if q%p[i]==0:
      q/=p[i]
    else:
      break
  if (q-1)%p[i]==0:
    s+=1
print(s-1)

Measured memory_bytes: 3316
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) (a < b ? b : a)
#define min(a,b) (a > b ? b : a)

using namespace std;

int code(char c) {
	if (c == '<')return 1;
	else return -1;
}

int main() {
	int N;
	cin >> N;
	cout << N * N;


	return 0;
}

Measured memory_bytes: 256
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

string s;
int use[1234],k;
set<char> aa;

main(){
	cin>>s;
	rep(i,s.size()){
		use[s[i]]++;
		aa.insert(s[i]);
	}
	if(aa.size()%2==1)dump("No");
	else if(aa.size()==4)dump("Yes");
	else{
		if((use['N']&&use['S'])||(use['W']&&use['E']))dump("Yes");
		else {
			dump("No");
			hi;
			debug(use['N'],use['S']);
		}
	}
	
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && a != c){
        cout << "Yes";
    }
    else if(a == c && a != b){
        cout << "Yes";
    }
    else if(b == c && b != a){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    return 0;

}

Measured memory_bytes: 256
import java.util.*;
public class Main{
public static void sortbyColumn(int arr[][], int col) 
    { 
        // Using built-in sort function Arrays.sort 
        Arrays.sort(arr, new Comparator<int[]>() { 
            
          @Override              
          // Compare values according to columns 
          public int compare(final int[] entry1,  
                             final int[] entry2) { 
  
            // To sort in descending order revert  
            // the '>' Operator 
            if (entry1[col] > entry2[col]) 
                return 1; 
            else
                return -1; 
          } 
        });  // End of function call sort(). 
    } 
public static void main(String args[]){
     int N,W;
    Scanner obj=new Scanner(System.in);
    N=obj.nextInt();
    W=obj.nextInt();
    int arr[][]=new int[N+1][2];
    arr[0][0] = 0;
    arr[0][1] = 0;
    for(int i=1;i<=N;i++){
    for(int j=0;j<2;j++){
     arr[i][j]=obj.nextInt();
   }
   
   }

sortbyColumn(arr,0);

long dp[][]=new  long[N+1][W+1];
for(int i=1;i<=N;i++){
   for(int j=1;j<=W;j++){
     if(j-arr[i][0] >= 0) {
    	 dp[i][j]=arr[i][1];
    	 dp[i][j]+=dp[i-1][j-arr[i][0]];
     }
     dp[i][j]=Math.max(dp[i-1][j], dp[i][j]);
     //System.out.print(dp[i][j]+" ");
   }
   //System.out.println();
}


System.out.println(dp[N][W]);
 
}

}


Measured memory_bytes: 140356
#include <bits/stdc++.h>
using namespace std;
char s[100005];
int acOcc[100005];
int main() {
    int n, q;
    scanf("%d%d", &n, &q);
    scanf("%s", s);
    for (int i = 1; i < n; i++) {
        acOcc[i] = acOcc[i - 1] + (s[i] == 'C' && s[i - 1] == 'A');
    }
    while (q-- > 0) {
        int l, r;
        scanf("%d%d", &l, &r);
        printf("%d\n", acOcc[r - 1] - acOcc[l - 1]);
    }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int a[6];
int main()
{
    int j=1;
    for(int i=1;i<=5;i++){
        cin>>a[i];
        if(a[i]==0){
            j=i;
        }
    }
    cout<<j;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	int i = 0;
	for (i = 0; i < n; i++)
	{
		if (a[i] % 2 == 0)
		{
			if (!((a[i]%3 == 0) || (a[i] % 5 == 0))) break;
		}
	}

	if (i == n) cout << "APPROVED";
	else cout << "DENIED";
}	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
// int w[1001],v[1001],W,n;
// int dp[1001][1001];
long long int w[101],v[101],W,n;
long long int dp[101][100001];
int main(){
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cin>>n>>W;
   for(int i=1;i<=n;i++)
      cin>>w[i]>>v[i];
   for(int i=1;i<=n;i++){
      for(int j=0;j<=W;j++){
         dp[i][j]=dp[i-1][j];
         if(j-w[i]>=0)
            dp[i][j]=max(dp[i][j],dp[i-1][j-w[i]]+v[i]);
      }
   }
   cout<<dp[n][W]<<endl;
}

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

long count(int sign0, vector<long> a, int n) {
    long count = 0;
    long total = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 1) {
            if ((total + a.at(i)) * sign0 < 0) total += a.at(i);
            else {
                count += abs(total + a.at(i)) + 1;
                total = -1 * sign0;
            }
        } else if (i % 2 == 0) {
            if ((total + a.at(i)) * sign0 > 0) total += a.at(i);
            else {
                count += abs(total + a.at(i)) + 1;
                total = sign0;
            }
        }
    }
    return count;
}

int main() {
    int n;
    cin >> n;
    vector<long> a(n);
    for (int i = 0; i < n; i++) cin >> a.at(i);

    long plus = count(1, a, n);
    long minus = count(-1, a, n);
    cout << min(plus, minus) << endl;
}


Measured memory_bytes: 1804
#include<stdio.h>

int N, M;
int V[1000000];

int root(int x) {
  if(V[x] == -1) return x;
  else return V[x] = root(V[x]);
}

void merge(int a, int b) {
  a = root(a);
  b = root(b);
  if(a == b) return;
  V[a] = b;
}

int main() {
  int unique[1000000] = {};
  scanf("%d%d", &N, &M);
  for(int i = 0;i < N;i++) V[i] = -1;
  for(int i = 0;i < M;i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--; b--;
    merge(a, b);
  }
  int ans = -1;
  for(int i = 0;i < N;i++) {
    if(unique[root(i)]++ == 0) ans++;
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 6024
import java.util.*;
import java.lang.Math;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        double[] x = new double[N];
        double[] y = new double[N];
        for (int i=0; i<N; i++) {
        		x[i] = sc.nextDouble();
        		y[i] = sc.nextDouble();
        }
        double sum = 0;
        for (int i=0; i<N-1; i++) {
        		for (int j=i+1; j<N; j++) {
        			sum += Math.sqrt(Math.pow((x[i]-x[j]), 2)+Math.pow((y[i]-y[j]), 2));
        		}
        }
        int n = N*(N-1)/2;
         System.out.println(sum*(N-1)/n);
    }
}

Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main(void) {
	int n;
	cin >> n;
	vector<int> x(n);
	int minv, maxv; minv = INF;maxv = 0;
	rep(i, 0, n) {
		cin >> x[i];
		minv = min(minv, x[i]);
		maxv = max(maxv, x[i]);
	}
	int ans = INF;
	rep(i, minv, maxv+1) {
		int sumv = 0;
		rep(j, 0, n) {
			sumv += (x[j] - i)*(x[j] - i);
		}
		ans = min(ans, sumv);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#define INF 1001001001001001001
using namespace std;
typedef long long ll;

ll seg[300010];

ll NN;

void init(ll n){
	NN=1;
	while(n>NN) NN*=2;
	for(ll i=NN;i<NN*2;i++){
		seg[i]=(1LL<<31)-1;
	}
	for(ll i=NN-1;i>=1;i--){
		seg[i]=min(seg[i*2],seg[i*2+1]);
	}
}

void update(ll x,ll val){
	x+=NN;
	seg[x]=val;
	while(x>1){
		x/=2;
		seg[x]=min(seg[x*2],seg[x*2+1]);
	}
}

ll getmin(ll a,ll b,ll k=1,ll l=0,ll r=-1){
	if(r<0) r=NN;

	if(r<=a||b<=l) return INF;
	if(a<=l&&r<=b) return seg[k];

	ll vl=getmin(a,b,2*k,l,(l+r)/2);
	ll vr=getmin(a,b,2*k+1,(l+r)/2,r);
	return min(vl,vr);
}

queue<ll> que;

int main(){
	ll n,q;
	cin>>n>>q;
	init(n);
	ll com,x,y,ans;
	for(ll i=1;i<=q;i++){
		cin>>com>>x>>y;
		if(com==0) update(x,y);
		else{
			ans=getmin(x,y+1);
			que.push(ans);
		}
	}
	while(!que.empty()){
		cout<<que.front()<<endl;
		que.pop();
	}
	return 0;
}




Measured memory_bytes: 5380
def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [None]*n
    dp[0], dp[1] = 0, abs(h[0]-h[1])
    for i, hi in enumerate(h[2:], 2):
        di = 10**9
        m = max(0, i-k)
        for dj, hj in zip(dp[m:i], h[m:i]):
            hh = hj-hi
            if hh>0:
                d = dj + hh
            else:
                d = dj - hh
            if di > d:
                di = d
        dp[i] = di
    print(dp[-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 13908
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define pb push_back
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (i64)(x).size()
#define bit(n) (1LL<<(n))
typedef vector<i64> vi;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

i64 pow_mod(i64 n, i64 k, i64 m){
  i64 r = 1;
  for(;k;k>>=1){
    if(k&1) r=(r*n)%m;
    n=(n*n)%m;
  }
  return r;
}

void Main()
{
  string N;
  cin >> N;
  i64 K;
  cin >> K;

  i64 ans=0;

  if(K==1){
    ans = i64(N[0]-'0')+(sz(N)-1)*9;
  }
  if(K==2){
    ans += 9*9*(sz(N)-1)*(sz(N)-2)/2;
    ans += i64(N[0]-'0'-1)*9*(sz(N)-1);
    rep(i,1,sz(N)){
      if(N[i]=='0') continue;
      ans += i64(N[i]-'0');
      ans += (sz(N)-1-i)*9;
      break;
    }
  }
  if(K==3){
    ans += 9*9*9*(sz(N)-1)*(sz(N)-2)*(sz(N)-3)/(3*2);
    ans += i64(N[0]-'0'-1)*9*9*(sz(N)-1)*(sz(N)-2)/2;
    rep(i,1,sz(N)){
      if(N[i]=='0') continue;
      ans += 9*9*(sz(N)-1-i)*(sz(N)-2-i)/2;
      ans += i64(N[i]-'0'-1)*9*(sz(N)-1-i);
      rep(ii,i+1,sz(N)){
        if(N[ii]=='0') continue;
        ans += i64(N[ii]-'0');
        ans += (sz(N)-1-ii)*9;
        break;
      }
      break;
    }
  }

  cout << ans << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n, k;
    cin >> n >> k;
    vl x(n);
    rep(i, n) cin >> x[i];
    ll ans = 1e18;
    rep(i, n - k + 1) {
        ll a = x[i];
        ll b = x[i+k-1];
        ll tmp = 0LL;
        if(a < 0) {
            a = -a;
            if(b > 0) tmp = 2*min(a, b) + max(a, b);
            else tmp = a;
        }
        else tmp = b;
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
n=int(input())
k=1
a=[len(str(n))]
for i in range(2,int(n**0.5)+100):
	if n%i==0:
		n//=i
		k*=i
		a.append(max(len(str(n)),len(str(k))))
		k=1
		n*=i
print(min(a))

Measured memory_bytes: 3064
(N,K) = map(int,input().split())
l = input().split()
max = 0
for i in range(N):
    l[i]= int(l[i])
    if max <= l[i]:
        max = l[i]

lb = 0
ub = max

def cut(m):
    k = 0
    for i in range(N):
        k += -((-1*l[i])//m)-1
    return k

while ub - lb > 1:
    if cut((ub+lb)//2)>K:
        lb = (ub+lb)//2
    else:
        ub = (ub+lb)//2

print(ub)




Measured memory_bytes: 24896