akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=2001 ;
ll n ;
vector<pll>v ;
ll dp[N][N] ;
ll fun(ll i,ll j)
{
    if(i>j)
        return 0 ;
    else if(dp[i][j]!=-1)
        return dp[i][j] ;
    else
    {
        ll in=i+n-1-j ;
        ll vl=v[in].ff ;
        ll id=v[in].ss ;
        ll ans=vl*abs(i-id)+fun(i+1,j) ;
        ans=max(ans,vl*abs(id-j)+fun(i,j-1)) ;
        return dp[i][j]=ans ;
    }
}
int main()
{
   fast ;
   cin>>n ;
   for(ll i=0;i<n;i++)
   {
       ll x ;
       cin>>x ;
       v.pb({x,i}) ;
   }
   sort(all(v)) ;
   reverse(all(v)) ;
   for(ll i=0;i<N;i++)
   {
       for(ll j=0;j<N;j++)
        dp[i][j]=-1 ;
   }
   cout<<fun(0,n-1) ;

}


Measured memory_bytes: 35096
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
#include <chrono>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef tuple<ll,ll,ll> tll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=250;
//templete
int main() {
	stack<int> sta;
	string S;
	cin>>S;
	int ans=0;
	for(int i=0;i<S.length();i++){
		if(sta.empty())
			sta.push(S[i]-'0');
		else if(sta.top()!=S[i]-'0'){
			ans+=2;
			sta.pop();
		}
		else
			sta.push(S[i]-'0');
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 768
n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort
bc = []
m.times do |i|
  bc << gets.split.map(&:to_i) # b枚、cに書き換える
end
bc = bc.sort_by{|x|x[1]}
n.times do |i|
  if a[i] < bc[-1][1]
    a[i] = bc[-1][1]
    bc[-1][0] -= 1
    bc.pop if bc[-1][0] == 0
    break if bc.empty?
  end
end
p a.inject(:+)


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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<vector<char>> a(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> a.at(i).at(j);
    }
  }
  
  for (int i = 0; i < H; i++) {
    bool empty = true;
    for (int j = 0; j < W; j++) {
      if (a.at(i).at(j) == '#') {
        empty = false;
        break;
      }
    }
    if (empty) a.at(i).clear();
  }
  
  for (int j = 0; j < W; j++) {
    bool empty = true;
    for (int i = 0; i < H; i++) {
      if (a.at(i).empty()) continue;
      if (a.at(i).at(j) == '#') {
        empty = false;
        break;
      }
    }
    if (empty) {
      for (int i = 0; i < H; i++) {
        if (a.at(i).empty()) continue;
        a.at(i).at(j) = '\0';
      }
    }
  }
  
  for (int i = 0; i < H; i++) {
    if (a.at(i).empty()) continue;
    for (int j = 0; j < W; j++) {
      if (a.at(i).at(j) == '\0') continue;
      cout << a.at(i).at(j);
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	for (;;) {
		int n, k, s; cin >> n >> k >> s;
		if (n == 0) break;
		int cnt = 0;
		int comb = (1 << k) - 1;
		while (comb < (1 << n)) {
			int sum = 0;
			for (int i = 0; i < n; i++)
				if (comb & (1 << i)) sum += i + 1;
			if (sum == s) cnt++;
			int x = comb & -comb, y = comb + x;
			comb = (((comb & ~y) / x) >> 1) | y;
		}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 1160
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
char S[102];
char T[102];
int main(){
  rd(S);
  rd(T);
  wt_L(T);
  wt_L(S);
  wt_L("\n");
  return 0;
}
// cLay varsion 20191229-1 [beta]

// --- original code ---
// char S[102], T[102];
// {
//   rd(S,T);
//   wtN(T,S,"\n");
// }


Measured memory_bytes: 256
#include <iostream>

using namespace std;

long N, D, Q;
long d[500000], q[500000];
long dp1[500000], dp2[500001];

int main(){
    
    cin >> N >> D;
    for(int i = 0; i < N; i++) cin >> d[i];
    cin >> Q;
    for(int i = 0; i < Q; i++) {
        cin >> q[i];
        q[i]--;
    }
    dp1[0] = D;
    for(int i = 1; i < N; i++) {
        dp1[i] = min(abs(dp1[i-1]), abs(abs(dp1[i-1])-d[i-1]));
    }
    dp2[N] = 1;
    if(d[N-1] == 1) dp2[N-1] = 2;
    else dp2[N-1] = 1;
    for(int i = N-2; i >= 0; i--){
        if(d[i] <= dp2[i+1]) dp2[i] = dp2[i+1]+d[i];
        else if(d[i] < 2*dp2[i+1]){
            dp2[i] = dp2[i+1]+d[i];
        }else{
            dp2[i] = dp2[i+1];
        }
    }
    for(int i = 0; i < Q; i++){
        //cout << dp1[q[i]] << ' ' << dp2[q[i]+1] << endl;
        if(dp1[q[i]] >= dp2[q[i]+1]){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
}

Measured memory_bytes: 17536
package main

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

func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

func min(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func main() {
	var n int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	a := make([]int64, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		x, _ := strconv.Atoi(sc.Text())
		a[i] = int64(x)
	}
	ans := min(solve(a, 0), solve(a, 1))
	fmt.Println(ans)
}

func solve(a []int64, ra int) int64 {
	s := int64(0) // S_i = \sum_i a[i]
	ans := int64(0)
	for i, e := range a {
		if i%2 == ra {
			if s+e >= 0 {
				ans += abs(-1 - s - e)
				s = -1
				continue
			}
		} else {
			if s+e <= 0 {
				ans += abs(1 - s - e)
				s = 1
				continue
			}
		}
		s += int64(e)
	}
	return ans
}


Measured memory_bytes: 3072
n, y = list(map(int,input().split()))
def main():
    for i in range(n+1):
        for j in range(n+1-i):
            total = 10000*i+5000*j+1000*(n-i-j)
            if total == y:
                return print(i,j,n-i-j)
    return print('-1 -1 -1')

main()

Measured memory_bytes: 9176
from collections import deque

n = int(input())
mod = 10 ** 9 + 7
graph = [[] for _ in range(n + 1)]
for _ in range(n - 1):
    x, y = map(int, input().split())
    graph[x].append(y)
    graph[y].append(x)

start = 1

que = deque([1])
par = [-1] * (n + 1)
topo = []
while que:
    v = que.popleft()
    topo.append(v)
    for u in graph[v]:
        if par[v] == u:
            continue
        par[u] = v
        que.append(u)

dpb = [0] * (n + 1)
dpw = [0] * (n + 1)

for i in topo[::-1]:
    dpb[i] = 1
    dpw[i] = 1
    for j in graph[i]:
        if j == par[i]:
            continue
        dpb[i] *= dpw[j]
        dpw[i] *= dpb[j] + dpw[j]
    dpw[i] %= mod
    dpb[i] %= mod

print((dpw[1] + dpb[1]) % mod)


Measured memory_bytes: 31796
#pragma warning(disable : 4996)
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef tuple<ll,ll,ll> tl3;
// https://atcoder.jp/contests/abc176/tasks/abc176_c
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n;
    cin >> n;
    vector<ll> v(n);
    for(int i = 0;i<n;i++){
        cin >> v[i];
    }
    stack<ll> s;
    ll ans = 0;
    for(int i = 0;i<n;i++){
        if(s.empty()){
            s.push(v[i]);
        }
        else{
            if(s.top() <= v[i]){
                s.push(v[i]);
            }
            else{
                ans += (s.top() - v[i]);
            }
        }
    }
    cout << ans;


    return 0;
}



Measured memory_bytes: 6348
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=1000000000000000000LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll a[n];
    ll sum = 1;
    bool maki = false;
    for(int i=0;i<n;i++){
    	cin >> a[i];
    	if(a[i] == 0LL) maki = true;
    }
    if(maki){
    	cout << 0 << endl;
    	return 0;
    }
    for(int i=0;i<n;i++){
    	if(INF % sum == 0){
    		if(a[i] > INF / sum){
    			cout << -1 << endl;
    			return 0;
    		}
    		sum *= a[i];
    	}else{
    		if(a[i] - 1 >= INF / sum){
    			cout << -1 << endl;
    			return 0;
    		}else{
    			sum *= a[i];
    		}
    	}
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 4436
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int s[32] = {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};
int k;
cin >> k;
cout << s[k-1] << endl;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long i64;
i64 N,Cnt[100010],Sum;
int main(){
    cin>>N;
    for(int i=1;i<=N;i++){
        int Tmp;
        cin>>Tmp;
        Cnt[Tmp]++;
        Sum+=Tmp;
    }
    i64 Q;
    cin>>Q;
    for(int i=1;i<=Q;i++){
        int B,C;
        cin>>B>>C;
        Sum-=Cnt[B]*B;
        Sum+=Cnt[B]*C;
        Cnt[C]+=Cnt[B];
        Cnt[B]=0;
        cout<<Sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 4356
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstring>
#include <map>

#define ll long long
const ll MOD = 1e9 + 7;
const ll INF = 1 << 29;


int main()
{
    ll N, K;
    std::cin >> N >> K;

    std::vector<ll> a(N, 0);
    for (auto k=0; k<K; ++k)
    {
        ll d;
        std::cin >> d;
        for (auto i=0; i<d; ++i)
        {
            ll v;
            std::cin >> v;
            v--;
            a[v]++;
        }
    }

    ll result = 0;
    for (auto i=0; i<N; ++i)
    {
        if (a[i] == 0)
            result++;
    }
    std::cout << result << std::endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <iomanip>
#include <queue>
#include <deque>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <cmath>
#include <map>
#include <unordered_map>
#include <utility>
using namespace std;

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	map<int,bool> was;
	ll max1 = 0;
	ll max2 = 0;
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if(was[x]) {
			if(x > max1) {
				max2 = max1;
				max1 = x;
			} else if(x > max2) {
				max2 = x;
			}
			was[x] = false;
		} else {
			was[x] = true;
		}
	}
	cout << max1*max2;
	return 0;
}



Measured memory_bytes: 4992
loop do
  h, w = gets.chomp.split(/\s/).map(&:to_i)
  break if h == 0 && w == 0
  h.times do |i|
    case i
    when 0, h-1
      puts "#" * w
    else
      puts "#" + "." * (w-2) + "#"
    end
  end
  puts ''
end

Measured memory_bytes: 8824
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
    
    int S; cin >> S;
    cout << 0 << " " << 0 << " ";
    int x1, x2, y1, y2;

    int lb = 1;
    int ub = MOD;
    while(ub - lb > 1){
        int mid = (lb + ub) / 2;
        if(mid * mid >= S) ub = mid;
        else lb = mid;
    }
    
    x1 = ub;
    y2 = ub;
    x2 = 1;
    y1 = x1 * y2 - S;
    cout << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
# A = tuple(map(lambda n: int(n) - 1, input().split()))
A = tuple(map(int, input().split()))

costs = [-1] * N
loc = 1

if K <= N:
    for i in range(K):
        loc = A[loc - 1]
    print(loc)

else:
    costs[loc - 1] = 0
    for i in range(1, K):
        loc = A[loc - 1]

        if costs[loc - 1] >= 0:
            break

        costs[loc - 1] = i

    offset = costs[loc - 1]
    loop = i - offset

    K -= i
    K %= loop

    for _ in range(K):
        loc = A[loc - 1]
    print(loc)

Measured memory_bytes: 32432
#include<stdio.h>

int main(){
  int i,count=0;
  char s[100001],c;

  scanf("%s",s);
  c=s[0];
  for(i=1;s[i]!='\0';++i){
    if(s[i]!=c){
      ++count;
      c=s[i];
    }
  }
  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
 
 
typedef long long ll;
 
 
int main () {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  double nodo = 0;
  int sitsuryo = -1;
  int anssato = -1;
  for (auto i = 0; i <= 30; ++i) {
    for (auto j = 0; j <= 30; ++j) {
      int mizu = A * 100 * i + B * 100 * j;
      if (mizu > F) continue;
      int sato = F - mizu;
      sato = min(sato, mizu / 100 * E);
      for (auto k = 0; k * C <= sato; ++k) {
        int nokori = sato - k * C;
        int realsato = k * C + (nokori/D) * D;
        double nownodo = ((double)realsato) / (realsato + mizu);
        if (nodo <= nownodo) {
          nodo = nownodo;
          sitsuryo = realsato + mizu;
          anssato = realsato;
        }
      }
    }
  }
  cout << sitsuryo << " " << anssato << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

// Convex Hull Trick for min query
template<typename T, typename U=__int128>
class ConvexHullTrick {
private:
  deque<pair<T,T>> data;
  bool check(const pair<T,T> &p3){
    auto &p1 = data[data.size()-2];
    auto &p2 = data[data.size()-1];
    return (U)(p2.fi-p1.fi)*(p3.se-p2.se) < (U)(p2.se-p1.se)*(p3.fi-p2.fi);
  }
public:
  ConvexHullTrick(){ }
  // additions of 'a' shold be NON-INCREASING
  void add(T a, T b){
    auto p = mp(a,b);
    while(data.size()>=2 && !check(p)) data.pop_back();
    data.push_back(p);
  }
  inline T val(int i, T x) {
    return data[i].fi*x + data[i].se;
  }
  // queries shold be NON-DECREASING
  T query(T x){
    while(data.size()>=2 && val(0, x) >= val(1, x)) data.pop_front();
    return val(0, x);
  }
  inline bool empty(){
    return data.empty();
  }
};

int main(){
  int n,T;
  cin>>n>>T;
  vector<pair<int, pair<int,int>>> v(n);
  rep(i,n) cin>>v[i].se.fi>>v[i].se.se>>v[i].fi;
  // <f,<t,p>>
  sort(all(v));

  vector<vector<long>> dp(n, vector<long>(T+1,0));
  vector<ConvexHullTrick<long,long>> cht(T+1);

  rep(i,n){
    long f = v[i].fi, t = v[i].se.fi, p = v[i].se.se;
    for(int j=T; j>=t; j--){
      if(j == t) dp[i][j] = p;
      else if(cht[j-t].empty()) continue;
      else dp[i][j] = -cht[j-t].query(f) + p - f*f;
      cht[j].add(-2*f, -(dp[i][j] - f*f));
    }
  }

  // rep(i,n){
  //   long f = v[i].fi, t = v[i].se.fi, p = v[i].se.se;
  //   for(int j=T; j>t; j--){
  //     for(int k=0; k<i; k++)
  //       dp[i][j] = max(dp[i][j], dp[k][j-t] + p - (f-v[k].fi)*(f-v[k].fi));
  //   }
  //   dp[i][t] = p;
  // }

  long ans = 0;
  rep(i,n) rep(j,T+1) ans = max(ans, dp[i][j]);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 118536
#include<bits/stdc++.h>
     
    using namespace std;
     
    int main()
    {
    	
        int n;
		double d;
        cin>>n>>d;
        vector< vector<int> > points(n,vector<int>(2));
        int ans=0;
        for(int i=0;i<n;i++){
        	cin>>points[i][0];
			cin>>points[i][1];
	   }
	   for(int i=0;i<n;i++){
	   	double val=sqrt(double(pow(points[i][0],2)+pow(points[i][1],2)));
	   	if((val) <= d) ans++;
	   	
	   }
		cout<<ans<<endl;
		
		
		return 0;
    }

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


int main()
{
    long int n,i,j,k,a=1,count=0;
	scanf("%ld",&n);
	
	vector<long int> v;
	
	for(i=0;i<n;i++)
	{
		scanf("%ld",&j);
		v.push_back(j);		
	}
	
	sort(v.begin(),v.end());
	
	for(i=0;i<v.size();i=j)
	{
		
		for(j=i+1;j<v.size();j++)	
		{
			if(v[i] == v[j]) a++;
			else break;
		}
		if(a&1) count++;
		a=1;
	}
	
	printf("%ld",count);
}

Measured memory_bytes: 4332
// AGC030F.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 330, mod = 1e9 + 7;

int n, ai[MAX_N << 1], dp[MAX_N << 1][MAX_N][MAX_N], both_nexist, single_exist, seq[MAX_N << 1], m;
bool vis[MAX_N << 1], pending[MAX_N << 1];

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n << 1; i++)
        scanf("%d", &ai[i]);
    for (int i = 1; i <= n << 1; i += 2)
    {
        if (ai[i] > 0 && ai[i + 1] > 0)
            vis[ai[i]] = vis[ai[i + 1]] = true;
        else if (ai[i] < 0 && ai[i + 1] < 0)
            both_nexist++;
        else
            single_exist++, pending[max(ai[i], ai[i + 1])] = true;
    }
    for (int i = (n << 1); i >= 1; i--)
        if (!vis[i])
            seq[++m] = i;
    dp[0][0][0] = 1;
    for (int i = 1; i <= m; i++)
        for (int j = 0; j <= both_nexist + single_exist; j++)
            for (int k = 0; k <= single_exist; k++)
            {
                if (!pending[seq[i]])
                {
                    dp[i][j + 1][k] = (0LL + dp[i][j + 1][k] + dp[i - 1][j][k]) % mod;
                    if (j > 0)
                        dp[i][j - 1][k] = (0LL + dp[i][j - 1][k] + dp[i - 1][j][k]) % mod;
                    if (k > 0)
                        dp[i][j][k - 1] = (0LL + dp[i][j][k - 1] + 1LL * k * dp[i - 1][j][k] % mod) % mod;
                }
                else
                {
                    dp[i][j][k + 1] = (0LL + dp[i][j][k + 1] + dp[i - 1][j][k]) % mod;
                    if (j > 0)
                        dp[i][j - 1][k] = (0LL + dp[i][j - 1][k] + dp[i - 1][j][k]) % mod;
                }
            }
    int ans = dp[m][0][0];
    for (int i = 1; i <= both_nexist; i++)
        ans = 1LL * ans * i % mod;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 255744
fun main(args: Array<String>) {
    val (n, m) = readInputLine().split(" ").map {it.toInt()}
    
    val graph = mutableMapOf<Int, MutableList<Int>>()
    
    for (i in 1..m) {
        val (u, v) = readInputLine().split(" ").map {it.toInt()}
        val edge = graph.get(u) ?: mutableListOf<Int>()
        edge.add(v)
        graph.put(u, edge)
    }
    
    val (s, t) = readInputLine().split(" ").map {it.toInt()}
    
    val alreadyNodes = mutableSetOf<Int>(s)
    var nowNodes = setOf<Int>(s)
    
    var cnt = 0
    
    while (!nowNodes.contains(t)) {
        if (nowNodes.none()) {
            println(-1)
            return
        }
    
        val firstStep = mutableSetOf<Int>()
        
        nowNodes.forEach { firstStep.addAll(graph.get(it) ?: listOf<Int>()) }

        val secondStep = mutableSetOf<Int>()
        
        firstStep.forEach { secondStep.addAll(graph.get(it) ?: listOf<Int>()) }
        
        val thirdStep = mutableSetOf<Int>()
        
        secondStep.forEach { thirdStep.addAll(graph.get(it) ?: listOf<Int>()) }
        
        nowNodes = thirdStep.minus(alreadyNodes)
        alreadyNodes.addAll(nowNodes)
        cnt++
    }

    println(cnt)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 113608
#include<bits/stdc++.h>
using namespace std;
#define int long long int

int c=0;
int vs[200004];
int fun(int x)
{
	if(vs[x]==x)
		return x;
	return vs[x]=fun(vs[x]);
}


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(30)<<fixed;

	
	int n,m;
	cin>>n>>m;
	int x,y;
	for(int i=0;i<200004;i++)
		vs[i]=i;
	for(int i=0;i<m;i++)
	{
		cin>>x>>y;
		vs[fun(max(x,y))]=vs[fun(min(y,x))];
		// for(int i=1;i<=n;i++)
		// 	cout<<vs[i]<<" ";
		// cout<<endl;
	}
	int a[200005]={0};
	int mx=0;
	// for(int i=1;i<=n;i++)
	// 	cout<<vs[i]<<" ";
	// cout<<endl;
	for(int i=1;i<=n;i++)
	{
		a[fun(i)]++;
		mx=max(a[vs[i]],mx);
	}
	cout<<mx<<endl;
	return 0;
}


Measured memory_bytes: 8440
#include<iostream>
using namespace std;
int main()
{
    long long A,B,K;
    cin >> A >> B >> K;

    long long A_ans,B_ans; 

    if(A>=K){
        A_ans = A - K;
        B_ans = B;
    }else{
        if(B>=K-A){
            A_ans = 0;
            B_ans = B - (K - A);
        }else{
            A_ans = 0;
            B_ans = 0;
        }
    }

    cout << A_ans << " " << B_ans << endl;

    return 0;

}

Measured memory_bytes: 256
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);
        abc156_a solver = new abc156_a();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc156_a {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int R = in.nextInt();

            if (N < 10) {
                out.println(R + (100 * (10 - N)));
            } else {
                out.println(R);
            }
        }

    }
}



Measured memory_bytes: 23764
def main():
    import numpy as np
    import sys
    input = sys.stdin.readline

    n,w = map(int,input().split())
    l = [list(map(int,input().split())) for i in range(n)]

    dp = np.zeros((n+1,w+1),dtype="int64")
    for i in range(n):
        dp[i+1][:l[i][0]] = dp[i][:l[i][0]]
        dp[i+1][l[i][0]:] = np.maximum(dp[i][l[i][0]:],dp[i][:-l[i][0]]+l[i][1])
    print(dp[n][w])

if __name__ == "__main__":
    main()

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

int sum(vector<int> v){
    int sum = 0;
    for(int i=0;i<v.size();i++){
        sum +=v[i];
    }
    return sum;
}

bool gtsum(vector<int> v,int x){
    if(sum(v)<x)
        return true;
    else
        return false;
}
bool hantei(vector<int> v, int x){
    if(x<0)
        return false;
    if(gtsum(v,x))
        return false;
    if(v.empty()){
        if(x==0)
            return true;
        else
            return false;
    }
    else{
        vector<int>::iterator it = v.begin();
        int first = *it;
        v.erase(it);
        vector<int> rest = v;
        return hantei(rest,x-first) || hantei(rest,x);
    }
}





int main(){
    int n; cin >> n;
    vector<int> v;
    for(int i=0;i<n;i++){
        int a; cin >> a;
        v.push_back(a);
    }
    int m; cin >> m;
    for(int i=0;i<m;i++){
        int x; cin >> x;
        if(hantei(v,x))
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }
}

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

//Function Macros:
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main()
{
    int n;
    cin >> n;
    setpre(10);
    if (n % 2 == 0)
    {
        cout << 0.5 << endl;
    }
    else
    {
        cout << (n / 2 + 1) / (double)(n) << endl;
    }
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

LL n;
LL a[100005];
LL k;
LL numbits[70];
int main(){
	cin >> n >> k;
	FOR(i,0,n) cin >> a[i];
	FOR(i,0,n){
		for (LL j = 0, nx = a[i]; nx > 0; j++, nx>>=1){
			if (nx & 1) numbits[j]++;
		}
	}
//	for (int i = 0; i < 64; i++) cout << numbits[i] << " \n"[i==63];
	LL ans = 0LL;
	for (int i = 63; i >= 0; --i){
		LL now = 1LL << i;
		if (now > k){
			ans += now * numbits[i];
		} else {
			LL m1 = now * numbits[i];
			LL m2 = now * (n - numbits[i]);
			if (m1 >= m2){
				ans += m1;
			} else {
				ans += m2;
				k -= now;
			}
		}
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll N=2e5+7;
struct stu{
	ll x,y;
	bool friend operator < (const stu &a,const stu &b){
		if(a.x==b.x) return a.y>b.y;
		return a.x>b.x;
	}
}arr[N];
map<stu,ll>mp;
ll ksm(ll x,ll y){
	ll res=1;
	while(y){
		if(y&1) res=res*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return res%mod;
}

int main(){
	ll n,x,y;
	cin>>n;
	stu c; 
	int pos=0;
	for(ll i=1;i<=n;i++){
		cin>>c.x>>c.y;
		if(c.x==0&&c.y==0){
			mp[{0,0}]++;
			continue ;
		}
		ll g=__gcd(c.x,c.y);
		c.x/=g;c.y/=g;
		if(c.x<0){
			c.x=0-c.x;
			c.y=0-c.y;
		}
		if(mp[c]==0){
			arr[pos++]=c;
		}
		mp[c]++; 
	}
	ll ans=1;
	for(ll i=0;i<pos;i++){
		if(mp[arr[i]]==0) continue ; 
		ll a1=arr[i].x*(-1);
		ll b1=arr[i].y;
		ll c1=__gcd(a1,b1);
		b1/=c1;a1/=c1;
		if(b1<0) {
			b1=0-b1;
			a1=0-a1;
		}
		ll tmp=0;
		if(mp[{b1,a1}]==0){
			tmp+=ksm(2,mp[arr[i]]); 
		}
		else {
			tmp+=ksm(2,mp[arr[i]]);
			tmp=(tmp+mod)%mod;
			tmp+=ksm(2,mp[{b1,a1}]);
			tmp-=1;
			tmp=(tmp+mod)%mod;
			mp[{b1,a1}]=0;
		}
		ans*=tmp;
		ans=ans%mod;
	}
	ans=(ans+mp[{0,0}]-1+mod)%mod;
//	ans=ans%mod;
//	ans=(ans-1+mod)%mod;
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 31496
var cards = function()
{
  var array = [];
  var suit = ['S','H','C','D'];
  var numbers = [1,2,3,4,5,6,7,8,9,10,11,12,13];
  for (var i = 0; i < suit.length; i++) {
    for (var j = 0; j < numbers.length; j++) {
      array.push(suit[i] + ' ' + numbers[j].toString());
    }
  }
return array;
}

var input = function()
{
  return require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
};

var out = function(x)
{
  console.log(x);
  return x;
}

var array = input();
cards().filter(function(element)
{
  return array.indexOf(element) == -1;
}).forEach(out);

Measured memory_bytes: 7648
#include <bits/stdc++.h>
#define MOD 998244353
#define MAX 10000006
using namespace std;
long long factorial[MAX] = {0}, finverse[MAX] = {0},
          inverse[MAX] = {0};

void smodfact() {
  factorial[0] = factorial[1] = 1;
  finverse[0] = finverse[1] = 1;
  inverse[1] = 1;
  for(int i = 2; i < MAX; ++i) {
    factorial[i] = factorial[i - 1] * i % MOD;
    inverse[i] = MOD - (inverse[MOD % i] * (MOD / i)) % MOD;
    finverse[i] = finverse[i - 1] * inverse[i] % MOD;
  }
}

long long calccomb(long long n, long long k) {
  if(n == k && n == 0) return 1;
  if(n < 0 || k < 0 || n < k) return 0;
  return factorial[n] * finverse[k] % MOD *
         finverse[n - k] % MOD;
}

long long cpow(long long base, long long x) {
  long long ans = 1;
  while(x) {
    if(x & 1) (ans *= base) %= MOD;
    (base *= base) %= MOD;
    x >>= 1;
  }
  return ans;
}

long long n;

long long solve();

int main() {
  smodfact();
  cin >> n;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = cpow(3, n);
  for(int i = n / 2 + 1; i <= n; ++i) {
    long long now = calccomb(n, i) * 2 % MOD;
    (now *= cpow(2, n - i)) %= MOD;
    ans -= now;
    (ans += MOD) %= MOD;
  }
  return ans;
}

Measured memory_bytes: 234624
# coding: utf-8
# Here your code



N = int(input())
result = len(str(N))

for i in range(1,int(pow(N,0.5)+1)):
    if(N % i == 0):
        s = max(len(str(i)), len(str(int(N/i))))
        result = min(s,result)
print(result)




Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define ll long long 
int main(){
    ll a,b,c,k,s=0;
    cin>>a>>b>>c>>k;
    while(k){
        if(a!=0){
            s++;
            k--;
            a--;
        }
        else if(b!=0)
        {   
            b--;
            k--;
        }
        else
        {
            s--;
            k--;
            c--;
        }
        
        
    }
    cout<<s;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>

using namespace std;
#define MAX 100005
static const int INF=1<<19;

int main(){
	int N,W;
	int dp[MAX];
	int ans=0;
	
	fill(dp,dp+MAX,-INF);
	dp[0]=0;
	
	scanf("%d %d",&N,&W);
	for(int i=0;i<N;i++){
		int v,w,m;
		scanf("%d %d %d",&v,&w,&m);
		for(int k=0;m>0;k++){
			int key=min(m,(1<<k));
			m-=key;
			int nv=key*v;
			int nw=key*w;
			for(int j=W;j>=nw;j--){
				dp[j]=max(dp[j],dp[j-nw]+nv);
			}
		}
	}
	for(int i=0;i<=W;i++) ans=max(ans,dp[i]);
	printf("%d\n",ans);
}


Measured memory_bytes: 3624
#include<stdio.h>
int main()
{
    int i,j,a[10],temp;
    for(i=0;i<10;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<10;i++){
        for(j=0;j<10;j++){
            if(a[i]>a[j]){
                temp=a[j];
               a[j]=a[i];
               a[i]=temp;
            }
        }
    }
    for(i=0;i<3;i++){
        printf("%d\n",a[i]);
    }
    return 0;
}



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

struct TCoordinate
{
	double x;
	double y;
};

struct TCircle
{
	double CenterX;
	double CenterY;
	double Radius;
};

TCircle GetCircle(TCoordinate P1, TCoordinate P2, TCoordinate P3)
{
	
}

TCoordinate GetCenterPoint(TCoordinate P1, TCoordinate P2, TCoordinate P3)
{
	double x1 = P1.x;
	double x2 = P2.x;
	double x3 = P3.x;
	double y1 = P1.y;
	double y2 = P2.y;
	double y3 = P3.y;
	double x, y, r;
	if(y1 == y2 || y2 == y3 || y3 == y1){
		if(y2 == y3){
			swap(x3, x1);
			swap(y3, y1);
		}else if(y3 == y1){
			swap(x2, x3);
			swap(y2, y3);
		}
		double xa = (x2 + x3) / 2;
		double ya = (y2 + y3) / 2;
		double a  = (-x3 + x2) / (y3 - y2);
		x = (x1 + x2) / 2;
		y = a * (x - xa) + ya;
	}else{
		double xa = (x1 + x2) / 2;
		double ya = (y1 + y2) / 2;
		double a  = (-x2 + x1) / (y2 - y1);
		double xb = (x2 + x3) / 2;
		double yb = (y2 + y3) / 2;
		double b  = (-x3 + x2) / (y3 - y2);
		x = (b * xb - a * xa - yb + ya) / (b - a);
		y = a * (x - xa) + ya;
	}
	return {x, y};
}

double GetRadius(TCoordinate P1, TCoordinate P2, TCoordinate P3)
{
	double x1 = P1.x;
	double x2 = P2.x;
	double x3 = P3.x;
	double y1 = P1.y;
	double y2 = P2.y;
	double y3 = P3.y;
	double x, y, r;
	if(y1 == y2 || y2 == y3 || y3 == y1){
		if(y2 == y3){
			swap(x3, x1);
			swap(y3, y1);
		}else if(y3 == y1){
			swap(x2, x3);
			swap(y2, y3);
		}
		double xa = (x2 + x3) / 2;
		double ya = (y2 + y3) / 2;
		double a  = (-x3 + x2) / (y3 - y2);
		x = (x1 + x2) / 2;
		y = a * (x - xa) + ya;
	}else{
		double xa = (x1 + x2) / 2;
		double ya = (y1 + y2) / 2;
		double a  = (-x2 + x1) / (y2 - y1);
		double xb = (x2 + x3) / 2;
		double yb = (y2 + y3) / 2;
		double b  = (-x3 + x2) / (y3 - y2);
		x = (b * xb - a * xa - yb + ya) / (b - a);
		y = a * (x - xa) + ya;
	}
	return sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));
}

int main()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		TCoordinate P1, P2, P3;
		cin >> P1.x >> P1.y >> P2.x >> P2.y >> P3.x >> P3.y;
		TCoordinate CenterPoint = GetCenterPoint(P1, P2, P3);
		double Radius = GetRadius(P1, P2, P3);
		cout << fixed << setprecision(3);
		cout << CenterPoint.x << ' ' << CenterPoint.y << ' ' << Radius << endl;
	}
	return 0;
}

Measured memory_bytes: 3164
#include<iostream>
#include<string>
using namespace std;
int main() {
  string s;
  cin >> s;

  char out[10];
  int len = 0;  // present length

  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'B') {
      if (len > 0) len--;
    }
    else {
      out[len] = (char)s[i];
      len++;
    }
  }

  for (int i = 0; i < len; i++) cout << out[i];
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
//#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define owo(i,a, b) for(int i=(a);i<(b); ++i)
#define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ttgl, null_type,less<ttgl>, rb_tree_tag,tree_order_statistics_node_update>*/
 
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
const ll root = 62;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const double PI = acos(-1);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
const int mxN = 3001;
int n, q;
int arr[mxN];
ttgl query[mxN];
ll dp_prev[mxN][mxN];
ll dp[mxN][mxN];
int main() {
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    cin>>n>>q;
    owo(i, 0, n) {
        cin>>arr[i];
    }
    ll inv2 = modInv(2);
    owo(i, 0, q) {
        cin>>query[i].first>>query[i].second;
        if(query[i].first>query[i].second)swap(query[i].first, query[i].second);
        query[i].first--;
        query[i].second--;
    }
    owo(i, 0, n) {
        owo(j, 0, n) {
            if(i==j)continue;
            if(arr[i]>arr[j]) {
                dp_prev[i][j] = 1;
                dp[i][j] = 1;
            }
        }
    }
    owo(i, 0, q) {
        int a = query[i].first;
        int b = query[i].second;
        owo(j, 0, n) {
            if(j==a||j==b)continue;
            dp[j][a] = (dp_prev[j][a]*inv2 + dp_prev[j][b]*inv2)%MOD;
            dp[a][j] = (dp_prev[a][j]*inv2 + dp_prev[b][j]*inv2)%MOD;
            dp[j][b] = (dp_prev[j][b]*inv2 + dp_prev[j][a]*inv2)%MOD;
            dp[b][j] = (dp_prev[b][j]*inv2 + dp_prev[a][j]*inv2)%MOD;
        }
        dp[a][b] = (dp_prev[a][b]*inv2 + dp_prev[b][a]*inv2)%MOD;
        dp[b][a] = dp[a][b];
        owo(j, 0, n) {
            dp_prev[j][a] = dp[j][a];
            dp_prev[j][b] = dp[j][b];
            dp_prev[a][j] = dp[a][j];
            dp_prev[b][j] = dp[b][j];
            
        }
    }
    ll mul = binpow(2, q);
    ll ans = 0;
    owo(i, 0, n){
        owo(j, i+1, n) {
            ans= (ans + dp[i][j])%MOD;
        }
    }
    ans = (ans*mul)%MOD;
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 144332
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
#include<map>
#include<set>
#include <climits>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int N,K;
    cin>>N>>K;
    if(K>(N-1)*(N-2)/2){
        cout<<-1<<endl;
    }else{
        int x=(N-1)*(N-2)/2-K;
        cout<<(N-1)+x<<endl;
        for(int i=2;i<=N;i++){
            cout<<i<<" "<<1<<endl;
        }
        int count=0;
        for(int i=2;i<N;i++){
            for(int j=i+1;j<=N;j++){
                if(count==x) return 0;
                count++;
                cout<<i<<" "<<j<<endl;
            }
        }
    }
}


Measured memory_bytes: 256
n,x=gets.split.map &:to_i
s=0
loop {
  if x==0||n==x
    break
  end
  case n-x<=>x
  when 0
    s+=x*3
    break
  when 1
    q=n/x-1
    s+=x*3*q
    n,x=n-x*q,x
  when -1
    q=n/(n-x)-1
    s+=(n-x)*3*q
    n,x=n-(n-x)*q,x-(n-x)*q
  end
}
p s

Measured memory_bytes: 1788
#####segfunc######
def segfunc(x, y):
    return x | y


def init(init_val):
    # set_val
    for i in range(n):
        seg[i + num - 1] = set(init_val[i])
        # built
    for i in range(num - 2, -1, -1):
        seg[i] = segfunc(seg[2 * i + 1], seg[2 * i + 2])


def update(k, x):
    k += num - 1
    seg[k] = set(x)
    while k:
        k = (k - 1) // 2
        seg[k] = segfunc(seg[k * 2 + 1], seg[k * 2 + 2])


def query(p, q):
    if q <= p:
        return ide_ele
    p += num - 1
    q += num - 2
    res = ide_ele
    while q - p > 1:
        if p & 1 == 0:
            res = segfunc(res, seg[p])
        if q & 1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
        p = p // 2
        q = (q - 1) // 2
    if p == q:
        res = segfunc(res, seg[p])
    else:
        res = segfunc(segfunc(res, seg[p]), seg[q])
    return res


#####単位元######
ide_ele = set()

n = int(input())
S = input().strip()
Q = int(input())

num = 2 ** (n - 1).bit_length()
seg = [set()] * 2 * num

init(S)


for _ in range(Q):
    a, b, c = [x for x in input().split()]
    if a == "1":
        update(int(b) - 1, c)
    else:
        print(len(query(int(b) - 1, int(c))))


Measured memory_bytes: 367676
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const int mod = 1e+9 + 7;

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

    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> t(n);
    for(int i = 0; i < n; ++i){
        cin >> s[i] >> t[i];
    }
    string x;
    cin >> x;
    int pos = 0;
    for(int i = 0; i < n; ++i){
        if(s[i] == x){
            pos = i;
            break;
        }
    }
    int res = 0;
    for(int i = pos+1; i < n; ++i){
        res += t[i];
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
const int INF = 1e18;

int d[3] ={-2,-1,0};
int ans[10];

signed main(){
    int h, w, n; cin >> h >> w >> n;
    map<pair<int,int>,int> mp;
    REP(i,n){
        int a, b; cin >> a >> b; a--; b--;
        REP(i,3)REP(j,3){
            if(a+d[i] > -1 and a+d[i] < h-2 and b+d[j] > -1 and b+d[j] < w-2) mp[{a+d[i],b+d[j]}]++;
        }
    }
    for(auto v:mp) ans[v.second]++;
    ans[0] = (h-2)*(w-2);
    REPS(i,9) ans[0] -= ans[i];
    REP(i,10) cout << ans[i] << '\n';
}

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

using namespace std;

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

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

    int p[N];
    fill(p, p+N, -1);
    p[0] = A[0];
    sort(p, p+N);
    for(int i=1; i<N; i++){
        int ind = lower_bound(p, p+N, A[i])-p;
        p[ind-1] = A[i];
    }

    int ans = 0;
    for(int i=0; i<N; i++){
        if(p[i] != -1) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		double a = stdIn.nextInt();
		double b = stdIn.nextInt();
		
		double c = Math.ceil((a + b) / 2);
		System.out.println((int)c);
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <map>
#include <time.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int f(int n) {
  if(n % 2) {
    return (n * 3) + 1;
  }else {
    return n / 2;
  }
}

signed main() {
  int s;
  cin >> s;
  map<int, int> mp;
  int ans = 0;
  while(true) {
    ans++;
    mp[s] = true;
    s = f(s);
    if(mp[s]) {
      cout << ans + 1 << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import collections

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

s = 0

for i in list(c.values()):
    s += i * (i - 1) / 2
    
for i in range(n):
    ca = c[a[i]]
    print(int(s - (ca * (ca - 1) // 2) + ((ca - 1) * (ca - 2) // 2)))


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

int main(){
  long N,M;
  cin >> N >> M;
  vector<vector<long>> A(N+M, vector<long>(2));
  for(int i=0; i<N; i++){
    cin >> A.at(i).at(0);
    A.at(i).at(1)=1;
  }
  for(int i=N; i<N+M; i++){
    cin >> A.at(i).at(1) >> A.at(i).at(0);
  }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  long sum=0,j=0;
  for(int i=0; ; i++){
    sum+=A.at(i).at(0)*min(A.at(i).at(1),N-j);
    j+=min(A.at(i).at(1),N-j);
    if(j==N)break;
  }
  cout << sum << endl;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#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 fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    cin >> n;
    const int n_max = 104;
    int dp[n_max][5][5][5]; // A:0 G:1 C:2 T:3 空白:4
    REP(j,5) REP(k,5) REP(l,5) dp[0][j][k][l] = 0;
    dp[0][4][4][4] = 1;

    REP(i,n){
        REP(j,5){
            REP(k,5){
                REP(l,4){
                    dp[i+1][j][k][l] = 0;
                    if(j == 0 and k == 1 and l == 2) continue;
                    if(j == 0 and k == 2 and l == 1) continue;
                    if(j == 1 and k == 0 and l == 2) continue;
                    REP(m,5){
                        if(m == 0 and k == 1 and l == 2) continue;
                        if(m == 0 and j == 1 and l == 2) continue;
                        Add(dp[i + 1][j][k][l], dp[i][m][j][k]);
                    } 
                }
            }
        }
    }
    int ans = 0;
    REP(j,4) REP(k,4) REP(l,4) Add(ans,dp[n][j][k][l]);
    cout << ans << endl;   

}

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

int main() {
  char c;
  cin >> c;
  
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 3568
#! env/bin/local python3
# -*- coding:utf-8 -*-

a, b, c, k = map(int, input().split())

"""
k < a -> a
k <= a + b -> a
k > a + b -> a - (k - (a + b))
"""

if k < a:
    print(k)
elif k <= a + b:
    print(a)
else:
    print(a - (k - (a + b)))


Measured memory_bytes: 9176