akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <iterator>
#include <string>
#include <cmath>

# define PI 3.14159265358979323846

using namespace std;

int main(void) {

    int n;
    cin >> n;

    vector<int> xs;
    while (n--) {
        int e;
        cin >> e;
        xs.push_back(e);
    }

    int minSta = 1e9;
    for (int p = 1; p <= 100; p++) {
        int staUsed = 0;
        for (int x : xs) {
            staUsed += (x - p) * (x - p);
        }
        if (staUsed < minSta) minSta = staUsed;
    }
    cout << minSta << endl;
}

Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
const ll MOD = 1000000000000000001;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  vector<ll> v(n);
  rep(i,n) cin>>v[i];
  sort(ALL(v));
  if(n%2==1){
    rep(i,n){
      if((i+1)/2*2!=v[i]){
        cout<<0<<endl;
        return 0;
      }
    }
  }else{
    rep(i,n){
      if((i/2)*2+1!=v[i]){
        cout<<0<<endl;
        return 0;
      }
    }
  }
  ll ans=1;
  rep(i,n/2){
    ans*=2;
    ans%=mod;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
#define rn(i,n) for(int i=1;i<=n;i++)
#define N 1000;
#define INF 1000000007

int main() {


  string t;
  cin>>t;
  int cnt=0;
  r(i,t.size()-1){
    if(t.at(i) == t.at(i+1)){
        cout<<i+1<<" "<<i+2<<endl;
        return 0;
    }
  }

  r(i,t.size()-2){
    if(t.at(i)==t.at(i+2)){
      cout<<i+1<<" "<<i+3<<endl;
      return 0;
    }
  }

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


return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    System.out.println(Math.min(a,b)+Math.min(c,d));
  }
}

Measured memory_bytes: 23764
#include "bits/stdc++.h"
#include <chrono>
#include <random>
#include <cstdio>
#define ll long long int
#define endl '\n'
#define pb push_back
#define mp make_pair
// #define mod 998244353
#define rep(i,n) for(ll i=0;i<n;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define pll pair<ll, ll>
#define pint pair<int, int>
#define S second
#define F first
#define all(c) (c).begin(),(c).end()
using namespace std;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
const int N=500001;
// vector<pair<ll, ll> > adj[N];
// bool vis[N];
ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } 
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
#define pi 3.14159265358979323846264338
using namespace std; 
ll max(ll a, ll b){ if(a>b)return a;return b;}
ll min(ll a, ll b){ if(a < b) return a;return b;}
ll inf = 100000000000000000;
vector <int> adj[N];

void solve() 
{
    ll ans = 0;

    int n;
    cin>>n;

    vi a(n);
    rep(i, n) cin>>a[i];

    ll sum = 0;
    ll cost = 0;

    rep(i, n)
    {
        sum += a[i];
        if(i%2 == 0)
        {
            if(sum > 0) continue;
            else
            {
                // cout<<i<<endl;
                cost += 1 - sum;
                sum = 1;
                // cout<<cost<<endl;
            }
        }
        else
        {
            if(sum < 0) continue;
            else
            {
                // cout<<i<<endl;
                cost += sum + 1;
                sum = -1;
                // cout<<cost<<endl;
            }
        }
    }
    // cout<<cost<<endl;
    ans = cost;
    cost = 0;
    sum = 0;

    rep(i, n)
    {
        sum += a[i];
        if(i%2 != 0)
        {
            if(sum > 0) continue;
            else
            {
                // cout<<i<<endl;
                cost += 1 - sum;
                sum = 1;
                // cout<<cost<<endl;
            }
        }
        else
        {
            if(sum < 0) continue;
            else
            {
                // cout<<i<<endl;
                cost += sum + 1;
                sum = -1;
                // cout<<cost<<endl;
            }
        }
    }
    ans = min(ans, cost);

    cout<<ans<<endl;

}

int main()
{
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)

    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        // cout<<'\n';
    }

    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 15500
import java.util.*;

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

    int N = sc.nextInt();
    Map<String, Integer> map = new HashMap<String, Integer>();

    for(int i = 0; i < N; i++){
      String tmp = sc.next();
      if(map.containsKey(tmp)){
        map.put(tmp, map.get(tmp) + 1);
      } else {
        map.put(tmp, 1);
      }
    }

    int M = sc.nextInt();
    for(int i = 0; i < M; i++) {
      String tmp = sc.next();
      if(map.containsKey(tmp)){
        map.put(tmp, map.get(tmp) - 1);
      } else {
        map.put(tmp, 0);
      }
    }

    List<Map.Entry<String, Integer>> list = new ArrayList<Map.Entry<String, Integer>>(map.entrySet());

    Collections.sort(list, new Comparator<Map.Entry<String, Integer>>() {

      public int compare(Map.Entry<String, Integer> l1, Map.Entry<String, Integer> l2){
        return l2.getValue().compareTo(l1.getValue());
      }
    });

      System.out.println(Math.max(list.get(0).getValue(),0));
    }
  }


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    VI a(n); cin >> a;
    bool ok = true;
    FOR(i, 0, n) {
        if (a[i] % 2 == 1)continue;
        if (a[i] % 3 == 0)continue;
        if (a[i] % 5 == 0)continue;
        ok = false;
    }
    cout << (ok ? "APPROVED\n" : "DENIED\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N, H[200010];
long long A[200010]; 
long long seg[524288]; 
void update(int k, long long a){
	k += 262143; 
	seg[k] = a; 
	while(k > 0){
		k = (k - 1) / 2; 
		seg[k] = max(seg[k * 2 + 1], seg[k * 2 + 2]); 
	}
}
long long query(int a, int b, int k, int l, int r){
	if(r <= a || b <= l) return 0; 
	if(a <= l && b >= r) return seg[k]; 
	else{
		long long vl = query(a, b, k * 2 + 1, l, (l + r) / 2); 
		long long vr = query(a, b, k * 2 + 2, (l + r) / 2, r); 
		return max(vl, vr); 
	}
}
int main(){
	cin >> N; 
	for(int i = 0; i < N; i++){
		cin >> H[i]; H[i] --; 
	}
	for(int i = 0; i < N; i++) cin >> A[i];
	for(int i = 0; i < N; i++){
		long long mx = query(0, H[i], 0, 0, 262144);
		update(H[i], mx + A[i]); 
	}
	cout << query(0, N, 0, 0, 262144); 
}

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


int main()
{
  int n; cin >> n;
  vector<vector<int>> a(n, vector<int>(n));
  rep(i, n)
    rep(j, n)
      cin >> a[i][j];
  rep(k, n)
    rep(i, n)
      rep(j, n)
        if (a[i][j] > a[i][k] + a[k][j])
        {
          printf("-1\n");
          return 0;
        }
  ll ans = 0;
  for (int i=0; i<n-1; i++)
    for (int j=i+1; j<n; j++)
    {
      bool check = true;
      rep(k, n)
        if (k != i && k != j && a[i][j] == a[i][k] + a[k][j])
          check = false;
      if (check)
        ans += a[i][j];
    }
  cout << ans << endl;
}

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

int main() {
  int a, b,c, d, e;
  cin >> a >> b >> c >> d >> e;
  int A, B, C, D, E = 0;
  int amount = 0;
  int f = 0;
  if(a%10 != 0) {
    A = a%10;
    a = a - A + 10;
  }
  else{
    A = 10;
  }
  if(b%10 != 0) {
    B = b%10;
    b = b - B + 10;
  }
  else{
    B = 10;
  }
  if(c%10 != 0) {
    C = c%10;
    c = c - C + 10;
  }
  else{
    C = 10;
  }
  if(d%10 != 0) {
    D = d%10;
    d = d - D + 10;
  }
  else{
    D = 10;
  }
  if(e%10 != 0) {
    E = e%10;
    e = e - E + 10;
  }
  else{
    E = 10;
  }
  f = min(min(A,B),min(E,min(C,D)));
  amount = (a+b+c+d+e) + f - 10;
  cout << amount << endl;
}


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

int main(){
  int k,n;
  
  scanf("%d%d",&k,&n);
  int a[n];
  for(int i=0;i<n;i++){
  	scanf("%d",&a[i]);
    
  }
  int d;
  d=a[0]+k-a[n-1];
  
  for(int i=0;i<n-1;i++){
    if(d<a[i+1]-a[i]){
      d=a[i+1]-a[i];
    }
  }
  
  printf("%d",k-d);
  
  return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);++i)
#define reps(i,n) for(int i = 1;i <= (n);++i)
using namespace std;
int main(){
  int n,a,b;
  cin >> n >> a >> b;
  cout << min(a*n,b) << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long int MOD = 1000000007;
const long long  INF = 1LL << 60;

int main(void){
    int N, K; cin >> N >> K;
    vector<int> h(N); for(int i = 0; i < N; i++) cin >> h[i];
    
    vector<ll> dp(N+1000, INF);
    dp[0] = 0;
    for(int i = 0; i < N; i++){
        for(int j = 1; j <= K; j++){
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]));
        }
    }
    cout << dp[N-1] << endl;
}


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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"
#define Pair pair <int, int>

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
	T a; K b;
};
typedef struct {
	vector <int> to;
	int cost;
} edge;
const int MOD = 1000000007;

long long int* fac, *finv, *inv;

/*
 * @fn comInit
 * @brief O(max): 前処理
 * @param max: 最大のN(N <= 10^7)
 */
void comInit( int max ) {
	max++;
	fac = new long long int[ max ];
	finv = new long long int[ max ];
	inv = new long long int[ max ];
	fac[ 0 ] = fac[ 1 ] = inv[ 1 ] = finv[ 0 ] = finv[ 1 ] = 1;
	for (int i = 2; i < max; ++i){
		fac[ i ] = fac[ i - 1 ] * i % MOD;
		inv[ i ] = MOD - inv[ MOD % i ] * ( MOD / i ) % MOD;
		finv[ i ] = finv[ i - 1 ] * inv[ i ] % MOD;
	}
}
/*
 * @fn comInit
 * @brief O(max): 前処理
 * @param max: 最大のN
 */
ll nCr( int n, int r ) {
	if (n < r || n < 0 || r < 0) return 0;
	return fac[ n ] * ( finv[ r ] * finv[ n - r ] % MOD ) % MOD;
}
/*
 * @fn modpow
 * @brief a^n % mod
 * @param a: 基数
 * @param n: 指数
 * @param mod: 法
 */
ll modpow( ll a, ll n, ll mod ) {
	ll res = 1;
	while (n > 0){
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main( void ){
	ll N, K; cin >> N >> K;
	ll sum = 0;
	rep( i, K, N + 2 )
		sum = ( sum + ( ll )i * ( N - i + 1 ) + 1 ) % k_mod;
	cout << sum << endl;
}

template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)

typedef unsigned long long ull;
typedef long long ll;

const int INF = 1001001001;
const ll MOD = 1e9 + 7;

using namespace std;
using P = pair<int,int>;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

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

  string s; map<char, ll> count;
  rep(i, n) {
      cin >> s;
      if (s[0] == 'M' || s[0] == 'A' || 
          s[0] == 'R' || s[0] == 'C' || s[0] == 'H')
      {
          count[s[0]] += 1;
      }
  }

  char patterns[5] = { 'M', 'A', 'R', 'C', 'H' };
  ll ans = 0; ll sum = 0;
  rep(i, 3) {
      for (ll j = i+1; j < 4; j++)
      {
          /* code */
          for (ll k = j+1; k < 5; k++)
          {
              ans += count[patterns[i]] * count[patterns[j]] * count[patterns[k]];
          }
      }
      
  }

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

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

int main() {
  int N, T;
  cin >> N >> T;
  
  vector<pair<int , int>> p(N);
  
  for(int i = 0; i < N ; i++){
    int a;
    int b;
    cin >> a >> b;
    p.at(i) = make_pair(a, b);
  }

  int minv = 1001;
  for(int i = 0; i < N ; i++){
    int a;
    int b;
    tie(a, b) = p.at(i);
    
    if(T >= b){
      minv = min(a, minv);
    }
  }
    
  if(minv < 1001) cout << minv << endl;
  else cout << "TLE" << endl;
}

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

int main(){
    int x, a, b;
    int n;
    cin >> x >> a >> b >> n;
    for(int i = 0; i < n; i++){
        string s;   cin >> s;
        if(s[0] == 'n') x += a;
        if(s[0] == 't') x += b;
        if(s[0] == 'k') x = 0;
        x = max(x, 0);
    }
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 3208
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int N,mi=__INT32_MAX__,ma=0;
    cin>>N;
    vector<int> a(N,0);
    REP(i,N){
        int p;cin>>p;
        mi=min(mi,p);
        ma=max(ma,p);      
    }
    cout<<abs(mi-ma)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mset(m,v) memset(m,v,sizeof(m))
#define pr(a,s) printf("Case #%lld: %lld\n",a,s)
#define mod 1000000007
#define mp make_pair
#define all(a)                a.begin(),a.end()
#define pb push_back
#define scan(a) scanf("%d",&a)
#define scanl(a) scanf("%lld",&a)
#define se second
#define fi first
#define pi 3.14159265358979323
#define pii pair<ll,ll>

#define trace1(x)             cout <<#x<<": "<<x<< endl;
#define trace2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;

const int MAXM = 1e5+3;
const ll inf = 1e15;

ll arr[MAXM];

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String line = null;
        while ((line = reader.readLine()) != null) {
            if (line.isEmpty()) {
                continue;
            }
            double q = Double.parseDouble(line);
            if (q == -1.0) {
                break;
            }
            double x = q * 0.5;
            double eps = 0.00001 * q;
            while (true) {
                double xx = x * x;
                double xxx = xx * x;
                if (Math.abs(xxx - q) < eps) {
                    break;
                }
                x -= (xxx - q) / (3.0 * xx);
            }
            out.println(String.format("%.6f", x));
        }
    }
}

Measured memory_bytes: 11000
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    let S = parseInt(arg[0].split(" ")[0]);
    let C = Math.floor(parseInt(arg[0].split(" ")[1]) / 2);
    
    let cnt = 0;
    
    if(S > C) {
        console.log(C);
    } else {
        C -= S;
        console.log(S + Math.floor(C / 2))
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 22964
#include <iostream>
#include <vector>
#include <queue>

#define int long long

using namespace std;

signed main()
{
    priority_queue<int> q;
    priority_queue<int> space;
    int N;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        int n;
        cin >> n;
        q.push(n);
    }

    int ans = 0;
    space.push(q.top());
    q.pop();
    for(int i=1;i<N;i++){
        ans += space.top();
        space.pop();
        space.push(q.top());
        space.push(q.top());
        q.pop();
    }

    cout << ans << endl;
}

Measured memory_bytes: 7580
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
char s[105],t[105];
int main(){
scanf("%s%s",s,t);
int len=strlen(s);
for (int i=1;i<=len;++i){
  if (!strcmp(s,t)) return puts("Yes"),0;
  char tmp=t[0];
  for (int j=0;j<len-1;++j) t[j]=t[j+1];
  t[len-1]=tmp;
  }puts("No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct aaa{
	int x,y;
}a[200010];
int n,m,i,j,k,x,y,flag,ans,v[402][402],mp[402];
int main(){
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++)scanf("%d%d",&a[i].x,&a[i].y);
	for(i=1;i<=n;i++){
		v[i][i]=1;
		for(j=m;j;j--){
			x=a[j].x;y=a[j].y;
			if(v[i][x]&&v[i][y]){
				mp[i]=1;break;
			}
			if(v[i][x]||v[i][y])v[i][x]=v[i][y]=1;
		}
	}
	for(i=1;i<=n;i++)
		for(j=i+1;j<=n;j++){
			flag=0;
			if(mp[i]||mp[j])continue;
			for(k=1;k<=n;k++)if(v[i][k]&&v[j][k]){
				flag=1;break;
			}
			if(!flag)ans++;
		}
	printf("%d",ans);
}

Measured memory_bytes: 5084
import math

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

N, M = list(map(int, input().split()))
S = input()
T = input()
g = gcd(N, M)
lcm = N*M//g
if N%M==0 or M%N==0:
    exist = True
    if N>M:
        for i in range(M):
            if S[N//M*i]!=T[i]:
                exist = False
                break
    else:
        for i in range(N):
            if T[M//N*i]!=S[i]:
                exist = False
                break
    if exist:
        print(max(N, M))
    else:
        print(-1)
else:
    n_s = lcm//N
    n_t = lcm//M
    mul = n_s*n_t
    exist = True
    for i in range(0, lcm, mul):
        if S[i//n_s]!=T[i//n_t]:
            exist = False
            break
    if exist:
        print(lcm)
    else:
        print(-1)


Measured memory_bytes: 3444
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int[] dp = new int[N+1];
	dp[0] = 0;
	for(int i = 1; i<N+1; i++) {
	    dp[i] = Integer.MAX_VALUE;
	    int power = 1;
	    while(power<=i) {
		dp[i] = Math.min(1+dp[i-power],dp[i]);
		power *= 6;
	    }
	    power=1;
	    while(power<=i) {
		dp[i] = Math.min(1+dp[i-power],dp[i]);
		power *= 9;
	    }
	}
	System.out.println(dp[N]);
    }
}

Measured memory_bytes: 22996
const input = require('fs').readFileSync('/dev/stdin', 'utf8');

const list = input.trim().split('\n');
const n = list.shift() | 0;

let diffMax;
let current = list[0];
for (let i = 1; i < n; i++) {
  const value = list[i] | 0;
  const diff = value - current;
  diffMax = diffMax === undefined ? diff : Math.max(diff, diffMax);
  current = current > value ? value : current;
}
console.log(diffMax);



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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define FI first
#define SE second
#define MP make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;
typedef pair < ll , ll > pll;

const double PI = acos(-1);
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const int INF = 1e9;


ll addMod(ll a, ll b){
	if(a + b >= MOD) return a + b - MOD;
	return a + b;
}

ll mulMod(ll a, ll b){
	return (a*b)%MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a,b/2);
	tmp = mulMod(tmp,tmp);
	if(b & 1) tmp = mulMod(tmp,a);
	return tmp;
}

ll GCD(ll a, ll b){
	if(a > b) return GCD(b,a);
	if(a == 0) return b;
	return GCD(b%a,a);
}

//////////////////////////////////////////////



int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string str;
	cin >> str;
	str[3] = '8';
	cout << str << endl;
	return 0;
}

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

const int mN = 200200;
const int MOD = 1e9+7;
typedef long long ll;

ll sum(ll n) {
	return n*(n+1)/2;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, k;
	cin >> n >> k;
	ll cnt = 0;
	for (int i=k; i<=n+1; i++) {
		ll s_max = sum(n) - sum(n-i);
		ll s_min = sum(i-1);
		cnt += s_max - s_min + 1;
		//cerr << s_max - s_min + 1 << "\n";
		cnt %= MOD;
	}
	cout << cnt;
}

Measured memory_bytes: 3652
# include<iostream>
# include<string>
# include<algorithm>

using namespace std;

int main(void){
  string str;
  cin >> str;
  sort(str.begin(), str.end());

  if(str[0] == str[1] && str[2] == str[3] && str[0] != str[2])
    puts("Yes");
  else
    puts("No");

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int n;
char S[1010];
int main(){
	scanf("%d",&n);
	scanf("%s",S+1);
	if(n%2==1)return puts("No"),0;
	for(int i=1;i<=n/2;i++)
		if(S[i]!=S[i+n/2])return puts("No"),0;
	puts("Yes");
}

Measured memory_bytes: 128
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int k = sc.nextInt();
		int n = sc.nextInt();
		int[] a = new int[n];
		int sum = 0;
		for(int i = 0; i < n; i++){
		    a[i] = sc.nextInt();
		}
		
		// 計算
		int result = 0;
		int max = 0;
		for(int i = 1; i < n; i++){
		    max = max(max, a[i] - a[i-1]);
		}
		max = max(max, a[0] + k - a[n-1]);
		result = k - max;
		
		// 出力
		System.out.println(result);
	}
}



Measured memory_bytes: 76840
#include <stdio.h>
#include <stdlib.h>
#define MAX 100000
  
typedef struct node * Node;
#define NIL NULL
 
int main(){
    int i,j,n;
    int A[MAX+1];
    scanf("%d",&n);
    for(i=1; i<n+1; i++){
        scanf("%d",&A[i]);
    }
    for(i=1;i<n+1;i++){
        printf("node %d: key = %d, ",i,A[i]);
        if(i>1)printf("parent key = %d, ",A[i/2]);
        if(i*2<n+1)printf("left key = %d, ",A[i*2]);
        if(i*2+1<n+1)printf("right key = %d, ",A[i*2+1]);
        printf("\n");
    }
}


Measured memory_bytes: 2052
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

#define max(a,b) ((a>b)?(a):(b))
#define min(a,b) ((a<b)?(a):(b))

bool comp(int a,int b){
  return a > b;
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n),aToKey(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
    a[i]--;
    aToKey[a[i]]=i;
  }
  set<int> hushi;
  hushi.insert(-1);
  hushi.insert(n);
  long long sum=0;
  int left,right;
  set<int>::iterator center;
  for(int i=0;i<n;i++){
    hushi.insert(aToKey[i]);
    center=hushi.find(aToKey[i]);
    left=*(--center);
    right=*(++(++center));
    sum+=(long long)(i+1)*(long long)(aToKey[i]-left)*(long long)(right-aToKey[i]);
  }
  cout << sum << endl;

  return 0;
}


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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  int N;
  cin >> N;
  cout << N / 3 << endl;
}

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

int main(){
	int k, s;
	cin >> k >> s;

	int ans = 0;
	for(int i = 0; i <= k; i++){
		for(int j = 0; j <= k; j++){
			if(s-(i+j) <= k && 0 <= s-(i+j))
				ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int inf=1e9;
int main(void)
{
    ll a,b;
    cin >> a >> b;
    if((a+b)%2LL!=0)
    {
        cout << "IMPOSSIBLE" << endl;
    }
    else
    {
        cout << (a+b)/2LL << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
#define ll long long
using namespace std;
int main(){
    ll n,now=0,ans=0;
    cin>>n;
    rep(i,0,n){
        ll a;
        cin>>a;
        if(--a==now)now++;
        else ans++;
    }
    if(now)cout<<ans<<endl;
    else cout<<"-1"<<endl;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}


int64 N;
vector<int64> A;
int64 now;
vector<PLL> res;


int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
  cin >> N;
  A.resize(N);
  REP(i, N) cin >> A[i];
  sort(all(A));
  int64 idx = 0;
  now = 0;
  while(idx+1 < A.size()-1 && A[idx+1] < 0) idx++;
  now = A[idx];
  FOR(i, idx+1, A.size()-1) {
    res.emplace_back(now, A[i]);
    now -= A[i];
  }
  int64 now2 = A.back();
  REP(i, min(idx, (int64)A.size()-1)) {
    res.emplace_back(now2, A[i]);
    now2 -= A[i];
  }
  res.emplace_back(now2, now);
  now2 -= now;
  cout << now2 << endl;
  REP(i, N-1) cout << res[i].fs << " " << res[i].sc << endl;
}


Measured memory_bytes: 4336
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S,T; cin>>S>>T;
    int sizeS=S.size(),sizeT=T.size();
    sort(S.begin(),S.end());
    sort(T.begin(),T.end());
    reverse(T.begin(),T.end());
    int maximum=max(sizeS,sizeT);
    int minimum=min(sizeS,sizeT);
    for(int i=0;i<maximum;i++) {
        if (S[i] < T[i]) {
            cout << "Yes";
            return 0;
        } else if (S[i] > T[i]) {
            cout << "No";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = (1LL<<31)-1;
const int mod = 1e9 + 7;

// SegmentTree
template<class T> struct Min {
  using Type = T;
  T nil;
  Min(){}
  Min(T nil):nil(nil){}
  T operator()(T a, T b) { return a < b ? a : b; }
};
template<class T> struct Max {
  using Type = T;
  T nil;
  Max(){}
  Max(T nil):nil(nil){}
  T operator()(T a, T b) { return a > b ? a : b; }
};
template<class T> struct Sum {
  using Type = T;
  T nil;
  Sum(){}
  Sum(T nil):nil(nil){}
  T operator()(T a, T b) { return a + b; }
};

template<class Monoid> struct SegmentTree {
  using T = typename Monoid::Type;
  vector<T> data;
  Monoid func;
  int sz;
  SegmentTree(int n, Monoid f):func(f) {
    sz = 1; while(sz < n) sz <<= 1;
    data.resize(2*sz-1, func.nil);
  }
  void update(int k, T x) {
    k += sz-1;
    data[k] = x;
    while(k > 0) {
      k = (k-1)/2;
      data[k] = func(data[2*k+1], data[2*k+2]);
    }
  }
  void add(int k, T x) {
    k += sz-1;
    data[k] += x;
    while(k > 0) {
      k = (k-1)/2;
      data[k] = func(data[2*k+1], data[2*k+2]);
    }
  }
  T query(int a, int b, int k, int l, int r) {
    if(r <= a || b <= l) return func.nil;
    if(a <= l && r <= b) return data[k];
    return func(query(a, b, 2*k+1, l, (l+r)/2), query(a, b, 2*k+2, (l+r)/2, r));
  }
  T query(int a, int b) {
    return query(a, b, 0, 0, sz);
  }
};

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, q;
  cin >> n >> q;
  SegmentTree<Min<int> > seg(n, Min<int>(inf));
  rep(i, q) {
    int com, x, y;
    cin >> com >> x >> y;
    if(com == 0) seg.update(x, y);
    else cout << seg.query(x, y+1) << endl;
  }

  return 0;
}

Measured memory_bytes: 4808
#include <iostream>
#include <vector>

#define ll long long
#define INF 100000000000000

using namespace std;

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

  ll A[20];
  ll x[20][20], y[20][20];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    for (int j = 0; j < A[i]; j++) {
      cin >> x[i][j] >> y[i][j];
      x[i][j]--;
    }
  }

  int ans = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    vector<bool> flag(N, false);
    for (int k = 0; k < N; k++) {
      if (((bit >> k) & 1) == 1)
        flag[k] = true;
    }

    int res = 0;
    bool check = true;
    for (int i = 0; i < N; i++) {
      bool f = true;
      for (int j = 0; j < A[i]; j++) {
        if (flag[i]) {
          if ((y[i][j] != flag[x[i][j]])) {
            f = false;
            break;
          }
        }
      }
      if (!f)
        check = false;
    }
    if (check) {
      for (int i = 0; i < N; i++) {
        if (flag[i])
          res++;
      }
    }
    ans = max(res, ans);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
i=int(input())
for j in range(i):
    a,b,c=map(int,input().split())
    d=[a,b,c]
    list=sorted(d)
    x=int(list[0])
    y=int(list[1])
    z=int(list[2])
    if x**2+y**2==z**2:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n=0;
    while(cin>>n,n){
        int people[n];
        for(int i=0;i<n;i++)cin>>people[i];
        sort(people,people+n);
        long long int ans=0,now=0;
        for(int i=0;i<n;i++){
            ans+=now;
            now+=people[i];
        }
        cout<<ans<<endl;
    }
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int a, b, c;
  cin >> a >> b >> c;
  cout << max({a, b, c})-min({a, b, c}) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define endl "\n"
using Edge = pair<int,ll>;
using Graph = vector<vector<Edge>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};


int main(void){
  int n,k; cin >> n >> k;
  combination c(n+5);

  mint ans = 0;
  FOR(i,0,k){
    mint res = c(n,i);
    res *= c(n-1,i);
    ans += res;
  }
  cout << ans.x << endl;

  
}




Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

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

const ll INF = 1e17;
const ll MOD = 1e9+7;

// https://math.nakaken88.com/textbook/cp-binary-exponentiation-and-recursive-function/
ll modPow(ll a, ll n) {
  if (n == 1) return a % MOD;
  if (n % 2 == 1) return (a * modPow(a, n - 1)) % MOD;
  ll t = modPow(a, n / 2);
  return (t * t) % MOD;
}

int main() {
    // input, ready
    int N,K;
    cin >> N >> K;

    vector<ll> A(K+1);
    for (int i =1; i<K+1; i++) {
      A[i] = modPow(K/i, N);
    }

    ll ans = 0;
    for (int i=K; i>=1; i--) {
      for (int j=2; j*i<=K; j++) {
        A[i] -= A[i*j];
      }
      ans += A[i]*i;
      ans += MOD;
      ans %= MOD;
    }
    ans += MOD;
    ans %= MOD;    

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4000
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  int N; cin >>N;
  vector<int> P(N); rep(i, N){ cin >>P[i]; P[i]--; }
  vector<int> A(N);
  rep(i, N){
    int a = P[i];
    if (a == 0) A[a]++;
    else A[a] = A[a-1] + 1;
  }
  int res = N;
  rep(i, N) chmin(res, N-A[i]);
  cout <<res <<endl;
}


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

int main(){
  int N,D,X;
  cin >> N >> D >> X;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  int choco = 0;
  int sum = X;
  for(int i=0;i<N;i++){
    choco=1;
    while(choco*A.at(i)+1<=D){
      choco++;
    }
    sum += choco;
  }
  cout << sum << endl;
}

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

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     SPEED       ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	hell        1000000007
#define 	rep(i,n)    for(i=0;i<n;i++)
#define 	repe(i,a,b) for(i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search
#define 	mp          make_pair

ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2);
	if(b%2==0)
		return((c%hell)*(c%hell))%hell;
	return ((((c%hell)*(c%hell))%hell)*(a%hell))%hell;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());
ll h[100005],dp[100005],n;


ll f(ll x)
{
	if(x==n-1) return 0;
	if(x>n-1) return hell;
	if(dp[x]==-1)
	{
		dp[x]=min(f(x+1)+abs(h[x+1]-h[x]),f(x+2)+abs(h[x+2]-h[x]));
	}
	return dp[x];
}

int main()
{
	SPEED;
	ll k,t,c=0,i,j,m,cs=0;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>n;
		// n=s.length();
		// ll a[n];
		rep(i,n)
		{
			cin>>h[i];
			dp[i]=-1;
		}
		dp[0]=0;dp[1]=abs(h[0]-h[1]);
		repe(i,2,n)
		{
			dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
		}
		cout<<dp[n-1];
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
    long long GCD(long long a, long long b){
        while(b !=0){
            long long r=a%b;
            a=b;
            b=r;
        }
    return a;
    }

signed main(){
    int x,y;
    scanf("%d %d",&x,&y);
    printf("%d\n",GCD(x,y));
    return(0);
}


Measured memory_bytes: 3212
def main():
    s = input()
    t = input()
    count = max = 0
    for i in range(len(s) - len(t) + 1):
        count = 0
        for j in range(len(t)):
            if s[i+j] == t[j]:
                count+=1
        if max < count :
            max = count
    print(len(t) - max)


if __name__ == "__main__":
    main()



Measured memory_bytes: 9096
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
s=gs
t=gs
l=s.length
l.times do |i|
  cnt+=1 if s[i]!=t[i]
end
puts cnt

Measured memory_bytes: 15072
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x1, x2, x3, x4, x5;
    cin>>x1>>x2>>x3>>x4>>x5;
    if(x1==0) {
        cout<<"1"<<endl;
    } else if(x2==0) {
        cout<<"2"<<endl;
    } else if(x3==0) {
        cout<<"3"<<endl;
    } else if(x4==0) {
        cout<<"4"<<endl;
    } else {
        cout<<"5"<<endl;
    }
    return 0;

}

Measured memory_bytes: 3564
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
const int siz = 1e6 + 5;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;
dd dist(dd a, dd b) {
	return (a*a + b*b);
}
void solve(){
	int n;
	cin >> n;
	dd X = 0, Y = 0, d, e, P = 0.1;
	vector<pair<double, double> > a(n);
	for(int i = 0; i < n; ++i){ 
		cin >> a[i].first >> a[i].second;
		X += a[i].first; Y += a[i].second;
	}
	X /= n; 
	Y /= n;
	for (int i = 0; i < 30000; i++) {
		int f = 0;
		d = dist(X - a[0].first, Y - a[0].second);
		for (int j = 1; j < n; j++) {
			e = dist(X - a[j].first, Y - a[j].second);
			if (d < e) { 
				d = e;
				 f = j; 
				}
		}
		X += (a[f].first - X)*P;
		Y += (a[f].second - Y)*P;
		P *= 0.999;
	}
	cout << sqrt(d) << endl;
}

int main(){
	#ifndef RAY
		//freopen("input.txt", "r", stdin);
	#endif
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
		int t = 1;
		//cin >> t;
		while(t--){
				cout << fixed << setprecision(15);
			solve();
		}
	return 0;
}
	


Measured memory_bytes: 256
import sys
from collections import Counter

n, *v = map(int, sys.stdin.read().split())

def main():
    c1 = sorted(Counter(v[::2]).items(), reverse=True, key=lambda x: x[1])
    c2 = sorted(Counter(v[1::2]).items(), reverse=True, key=lambda x: x[1])
    
    if c1[0][0] != c2[0][0]:
        return n // 2 - c1[0][1] + n // 2 - c2[0][1]
    else:
        if len(c1) == len(c2) == 1:
            return n // 2
        elif len(c1) == 1:
            return n // 2 - c2[1][1]
        elif len(c2) == 1:
            return n // 2 - c1[1][1]
        else:
            return n - max(c1[0][1] + c2[1][1], c1[1][1] + c2[0][1])

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 20564