akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
typedef long double db;
#define pb push_back
#define mp make_pair
#define ub(v,val) upper_bound(v.begin(),v.end(),val)
#define lb(v,val) lower_bound(v.begin(),v.end(),val)
#define sortv(vec) sort(vec.begin(),vec.end())
#define rev(p) reverse(p.begin(),p.end());
#define v vector
#define PI 3.1415926535
#define len length()
#define repc(i,s,e) for(ll i=s;i<e;i++)
#define np(str) next_permutation(str.begin(),str.end())
#define fi first
#define se second
#define mset(a,val) memset(a,val,sizeof(a));
#define mt make_tuple
#define repr(i,n) for( i=n-1;i>=0;i--)
#define rep(i,n) for(  i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll M = 1e9 + 7;
ll INF = 1e18;
ll n, m;

int main() {
	// your code goes here
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll  i, j, t, k, x, y, z,  N;
	cin >> x >> y >> z;
	if (db(x) / db(z) <= db(y))
		cout << "Yes";
	else
		cout << "No";

	return 0;
}





Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(void){
	ios_base::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	int a,b;
	cin >> a >> b;
	if(a > 9 || b > 9) cout << "-1";
	else if(a == 0 || b ==0) cout << "-1";
	else cout << a*b;
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using ll=long long;
using namespace std;
const long MOD=1e9+7;
template<class T>
T lcm(T a,T b){
    return a/__gcd(a,b)*b;
}
template<class T>
void chmin(T &a,T b){
    if(a>b){
        a=b;
    }
}

int main(){
    long n;cin >> n;
    vector<long> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    long s,e;
    s=a[(n-1)/2];
    e=a[(n-1)/2+1];
    cout << e-s;
    return 0;
}

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

using namespace std;
int main(){
    long long int A, B, C, K, sum=0;

    cin>>A;
    cin>>B;
    cin>>C;
    cin>>K;

    if(K<=A){
        sum = sum + K*1;
    }
    else if(A<K && K<=A+B){
        sum = sum + A*1 + B*0;
    }
    else {
        sum = sum + A*1 + B*0 - (K-A-B)*1;
    }

    cout<<sum<<"\n";

    return 0;
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e5+3;
 
int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int n;
      cin>>n;
      int p[n];
      vector<pii> v;
      for(int i=0;i<n;i++) cin>>p[i],v.pb({p[i],i});
      sort(all(v));
      reverse(all(v));
      set<int> s;
      s.insert(-1);
      s.insert(n);
      s.insert(v[0].se);
      int ans=0;
      for(int i=1;i<n;i++)
      {
            int val=v[i].fi;
            int ind=v[i].se;
            auto o=s.lower_bound(ind);
            if((*o)>ind) o--;
            auto o1=o;
            auto oo=s.upper_bound(ind);
            auto ooo=oo;
            ooo++;
            if(o==s.begin())
            {

                  ans+=val*(ind+1)*(*(ooo)-*(oo));
            }
            else if(ooo==s.end())
            {
                  o1--;
                  ans+=val*(n-ind)*(*(o)-*(o1));
            }
            else{
                  o1--;
                  ans+=val*(ind-*(o))*(*(ooo)-*(oo));
                  ans+=val*(*(oo)-ind)*(*(o)-*(o1));
            }
            s.insert(ind); 
      }
      cout<<ans;
}
// I never lose. I either win or I learn

Measured memory_bytes: 7280
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long double a,b;
    cin >> a >> b;
    ll k = a*b;
    PRINT(k);
}


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

struct vertex {
	int estart;
	int parent;
	int max1,max2;
} v[200003];
struct edge {
	int enext;
	int to;
} e[400003];int en;
int n;
int rad;
void dfs(int i)
{
	int max1 = -1, max2 = -1;
	for(int j = v[i].estart;j != -1;j = e[j].enext) {
		int to = e[j].to;
		if(to == v[i].parent) continue;
		v[to].parent = i;
		dfs(to);
		if(v[to].max1 > max1) {
			max2 = max1;
			max1 = v[to].max1;
		} else if(v[to].max1 > max2) {
			max2 = v[to].max1;
		}
	}
	++max1, ++max2;
	if(max1 + max2 > rad)
		rad = max1 + max2;
	v[i].max1 = max1;
	v[i].max2 = max2;
}
int main()
{
	scanf("%d",&n);
	for(int i = 0;i < n;++i) {
		v[i].estart = -1;
	}
	for(int i = 0;i < n - 1;++i) {
		int a,b;
		scanf("%d%d",&a,&b);--a,--b;
		e[en].enext = v[a].estart;e[en].to = b;v[a].estart = en++;
		e[en].enext = v[b].estart;e[en].to = a;v[b].estart = en++;
	}
	dfs(0);++rad;
	if(rad % 3 == 2) {
		printf("Second\n");
	} else {
		printf("First\n");
	}
}


Measured memory_bytes: 21504
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL d[2010][2010];
LL a[2010];
LL Min(LL A,LL B){return A<B?A:B;}
int main(){
	LL n,x;
//	cout<<1<<endl;
	scanf("%lld%lld",&n,&x);
	for(int i=1;i<=n;++i){
		scanf("%lld",&a[i]);
	}
//	memset(d,0x3f3f3f3f,sizeof(d));
	LL Ans=0;
	for(int i=1;i<=n;++i)d[i][0]=a[i],Ans+=a[i];
	for(int K=1;K<=n-1;++K){
//		cout<<1<<endl;
		LL ans=0;
		for(int i=1;i<=n;++i){
			int pos=(i-K)<=0?n-abs(i-K):i-K;
			d[i][K]=Min(a[pos],d[i][K-1]);
			ans+=d[i][K];
//			cout<<ans<<endl;
		}
		ans+=K*x;
		Ans=min(ans,Ans);
	}
	cout<<Ans<<endl;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  int l, r;
  int A = 0;
  
  for(int i = 0; i < N; i++){
      cin >> l >> r;
      A += r - l + 1; 
  }
  cout << A << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <unordered_map>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for(int i = (int)n - 1; j <= i; --i)

constexpr ll MOD = 0x3b9aca07;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

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

	ll k; cin >> k;
	
	ll q = k / 50;
	ll r = k % 50;

	int n = 50;
	vector<ll> a(n);
	rep(i, 0, n) a[i] = q + i;
	rep(i, 0, 50) {
		if (i == r) break;
		a[i] += 50;
		rep(j, 0, 50) 
			if (i != j) --a[j];
	}

	cout << n << '\n';
	rep(i, 0, n) cout << a[i] << " \n"[i == n - 1];
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main(void) {
    vector<int> nums(5);
    int k;
    for(int i=0;i<5;i++){
        cin >> nums[i];
    }
    cin >> k;

    bool ans = true;
    for(int i=0;i<4;i++){
        for(int j=i;j<5;j++) {
            if (abs(nums[i] - nums[j]) > k) {
            ans = false;
            }
        }
    }

    cout << ( (ans)? "Yay!" : ":(" ) << endl;

}

Measured memory_bytes: 256
s = input()
len_ = len(s)
half = len(s) // 2
ans = 0

if len_ % 2 == 0:
    front = s[:half]
    back = s[half:][-1::-1]
    for i in range(len(front)):
        if front[i] != back[i]:
            ans += 1
else:
    front = s[:half]
    back = s[half+1:][-1::-1]
    for i in range(len(front)):
        if front[i] != back[i]:
            ans += 1

print(ans)


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

const int MAX_N=114514;
ll fact[MAX_N], fact_inv[MAX_N];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1){
			res=res*a%MOD;
		}
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

ll comb(ll n, ll r){
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}

void init_comb(int n){
	fact[0]=1;
	REP(i, n){
		fact[i+1]=fact[i]*(i+1)%MOD;
	}
	fact_inv[n]=power(fact[n], MOD-2);
	FORR(i, 0, n){
		fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
	}
	return;
}

// 素因数分解
vector<pii> prime_factor(int n){
	vector<pii> res;
	for(int i=2; i*i<=n; ++i){
		if(n%i!=0){
			continue;
		}
		int num=0;
		while(n%i==0){
			++num;
			n/=i;
		}
		res.push_back(pll(i, num));
	}
	if(n!=1){
		res.push_back(pll(n, 1));
	}
	return res;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin>>n>>m;
	vector<pii> f=prime_factor(m);
	init_comb(n+30);
	ll ans=1;
	for(auto i : f){
		ans=(ans*comb((i.second+n-1), n-1))%MOD;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

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

int dy[5] = {-1, 0, 1, 0, 0};
int dx[5] = {0, -1, 0, 1, 0};

int main(void) {
    int r;

    cin>>r;
    cout<<r*r<<endl;
}


Measured memory_bytes: 256
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
ans = 0
for _ in range(N):
    A = list(map(int, input().split()))
    s = 0
    for a, b in zip(A, B):
        s += a * b
    if s + C > 0:
        ans += 1
print(ans)

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

int main(){
   int a,b,c;
   cin>>a>>b>>c;
   if((a==5 && b==5 && c==7)||(a==5 && b==7 && c==5)||(a==7 && b==5 && c==5))
   cout<<"YES";
   else cout<<"NO";
   return 0;
}



Measured memory_bytes: 3560
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author indy256
 */

#include <bits/stdc++.h>

using namespace std;

void solve(istream &in, ostream &out) {
    int n;
    in >> n;

    for (int x = 1; x <= n; ++x) {
        if ((int) (x * 1.08) == n) {
            out << x << '\n';
            return;
        }
    }

    out << ":(" << '\n';
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solve(in, out);
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[])
{
  int A, B, C;
  int count5 = 2;
  int count7 = 1;
  
  scanf("%d%d%d", &A, &B, &C);

  A == 7 ? count7-- : A == 5 ? count5-- : 0;
  B == 7 ? count7-- : B == 5 ? count5-- : 0;
  C == 7 ? count7-- : C == 5 ? count5-- : 0;
  
  (count5 | count7) == 0 ? printf("YES") : printf("NO");
  
  return 0;
}

Measured memory_bytes: 1708
#include<stdio.h>
int main(){
  int l[100];
  int i;
  int temp;
  int j;
  int number;
  int k;
  scanf("%d",&number);
  for(i=0;i<number;i++){
    scanf("%d",&l[i]);
  }
  for(i=0;i<number-1;i++){
    printf("%d ",l[i]);
  }
  printf("%d\n",l[number-1]);
  for(i=1;i<number;i++){
    temp=l[i];
    j=i-1;
    while(j>=0&&l[j]>temp){
      l[j+1]=l[j];
      j=j-1;
    }
      l[j+1]=temp;
    for(k=0;k<number-1;k++){
      printf("%d ",l[k]);
    }
    printf("%d\n",l[number-1]);
  }
  return 0;
}



Measured memory_bytes: 2140
import java.util.Scanner;

public class Main {
     public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int g = sc.nextInt();//g=(r+n)/2  2g=r+n
         System.out.println(2*g-r);
       
    }
    
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
    int N,M; cin >> N >> M;
    vector<int> k(M),p(M);
    vector<vector<int>> s(M,vector<int>(N));
    for(int i=0;i<M;i++){
        cin >> k[i];
        for(int j=0;j<k[i];j++){
            cin >> s.at(i).at(j);
        }
    }
    for(int i=0;i<M;i++){
        cin >> p[i];
    }
    int ans = 0;
    vector<int> b(N+1);//binary number
                       //スイッチのオンオフを0か1かでM+1個定義
                       //M+1が１、すなわち1000...0になったら全通り試したので停止
    int a=0;
    while(1){
        for(int i=0;i<N;i++){
            if(b[i]==2){
                b[i] = 0;
                b[i+1]++;
            }
        }
        //以上がN個のスイッチのオンオフ切り替えの全探索
        
        if(b[N]==1)break;

        for(int i=0;i<M;i++){
            int count = 0;
            for(int j=0;j<k[i];j++){
                if(b[s.at(i).at(j)-1]==1){//「-1」は実際の入力は1からであるため
                    count++;
                }
            }                
            if(count%2!=p[i])break;
            //以上がM個ある電球のうち電球iの必要スイッチと実際のスイッチの照らし合わせ

            if(i==M-1){
                ans++;
            }
            //以上が、とあるスイッチオンオフの組み合わせにおける成功の可否
        }
        b[0]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

ll arr[1000010];

void Eratosthenes(ll n) {
	for (int i = 0; i <= n; i++)
		arr[i] = 1;

	for (int i = 2; i <= sqrt(n); i++) {
		if (arr[i]) {
			for (int j = 0; i*(j + 2) <= n; j++)
				arr[i*(j + 2)] = 0;
		}
	}
}

int main()
{
	ll n;
	while (cin >> n, n)
	{
		ll cnt = 0;
		Eratosthenes(n);
		for (int i = 2; i <= n / 2 + n % 2; i++) {
			if (arr[i]) {
				if (arr[n - i])cnt++;
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

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

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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; }

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x, y;
  cin >> x >> y;
  if((y-2*x) % 2 == 0 && (4*x-y) % 2 == 0 && (y-2*x) >= 0 && (4*x-y) >= 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3652
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <stack>
#include <vector>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <set>
#include <limits>
#include <numeric>
#include <array>
using namespace std;


int main()
{
	string input;
	cin >> input;
	int counter = 0;
	int n = input.size();

	for (int i = 0; i < n / 2; ++i)
	{
		if (input[i] != input[n - i - 1]) ++counter;
	}

	cout << counter << endl;

	return 0;
}

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

int main()
{
	bool is_prime[1000000];
	memset(is_prime,false,sizeof(is_prime));
	for(int i=2;i<1000000;i++){
		if(!is_prime[i]){
//			cout<<i<<endl;
			for(int m=i*2;m<1000000;m+=i){
				is_prime[m]=true;
			}
		}
	}
	int n;
	while(cin>>n){
		int ans=0;
		for(int i=2;i<=n;i++){
			if(!is_prime[i]) ans++;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 2144
/**
*	  Name: Ajay
*	  Institute: IIITH 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define LL long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vii vector<ppi>
#define vll vector<LL>
#define mp make_pair
#define fi first
#define se second
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void input()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}
int f(int n)
{
	int x=0;
	while(n%2==0)
	{
		n=n>>1;
		x++;
	}
	return x;
}
int main()
{      
  
  int n,m,i,j,t;
  cin>>n;
  LL mx=0;
  for(i=0;i<n;i++)
  {
  	int x;
  	cin>>x;
  	if(x%2==0)
  	{
  		mx+=f(x);
  	}
  }
  cout<<mx;
  return 0;
}


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

bool search(int s, vector<int> p){
    for(int i = 0; i < p.size(); i++){
        if(s == p[i]){
            return true;
        }
    }
    return false;
}

int main(){
    int X, N;
    cin >> X >> N;
    vector<int> p(N);
    for(int i = 0; i < N; i++){
        cin >> p[i];
    }
    int ans;
    int cnt = 0;
    bool flag_dec = false;
    while(true){
        if(!search(X + cnt, p)){
            ans = X + cnt;
            break;
        }
        if(flag_dec){
            cnt = -1 * cnt;
            cnt--;
        }
        else{
            cnt = -1 * cnt;            
        }
        flag_dec = !flag_dec;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <climits>

using namespace std;
 
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define t_times int t; cin >> t; while(t--)
#define fr(i, st, n) for(int i = (int )st; i < (int )n; i++)
#define rfr(i, en, st) for(int i = (int )en; i >= (int )st; i--)
#define all(c) (c).begin(), (c).end()
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
 
typedef long long int LL;
typedef pair< int, int> ii;
typedef vector< int> vi;
typedef vector< ii> vii;
typedef vector< vi> vvi;
 
const int mod = 1e9 + 7;
const LL INF = 9e18 + 2e17;
const int inf = 2e9;
const double eps = 1e-10;
 // START FROM HERE

int main(int argc, char const *argv[])
{
	fastio;

	int n, k; cin >> n >> k;
	vi h(n); fr(i,0,n) cin >> h[i];

	vi dp(n,INT_MAX);
	dp[0] = 0;
	fr(i,1,n) {
		fr(j,max(i-k,0),i) {
			dp[i] = min(dp[i], dp[j] + abs(h[j]-h[i]));
		}
	}
	cout<<dp[n-1]<<endl;




	return 0;
}

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

int main() {
  string str;
  cin >> str;
  int n = static_cast<int>(str.size());
  bool flag = str == "keyence";
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      string tmp = str.substr(0, i) + str.substr(j+1, n-j-1);
      if (tmp == "keyence")
        flag = true;
    }
  }
  cout << (flag ? "YES" : "NO") << endl;
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  string s; cin >> s;
  int sz = SZ(s);

  vector<vector<int>> cnt(2*sz+1), add(2*sz+1);
  stack<char> st;
  int pos = 0;
  int depth = 0;
  ll now = 0;
  for(int i=0;i<sz;++i) {
    //cout << s[i] << ":" << depth << endl;
    if(s[i] == '(') {
      st.push('(');
      if(SZ(cnt[depth+sz]) > 0) cnt[depth+sz].push_back(cnt[depth+sz].back() + 1);
      else cnt[depth+sz].push_back(1);
      depth++;
      cnt[depth+sz].push_back(0);
      pos++;
    } else if(s[i] == ')') {
      st.push(')');
      depth--;
      if(SZ(cnt[depth+sz]) > 0) add[pos].push_back(cnt[depth+sz].back());
      else add[pos].push_back(0);
      now += add[pos].back();
      pos++;
    } else if(st.top() == '(') {
      pos--;
      cnt[depth+sz].pop_back();
      depth--;
      cnt[depth+sz].pop_back();
      st.pop();
    } else if(st.top() == ')') {
      pos--;
      now -= add[pos].back();
      add[pos].pop_back();
      depth++;
      st.pop();
    } else {
      assert(false);
    }
    cout << now << endl;
  }
  
}


Measured memory_bytes: 28436
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: i64 = sc.cin();
    let k: i64 = sc.cin();
    let s: Vec<char> = sc.cin::<String>().chars().collect();

    let mut g: i64 = 0;
    {
        let mut last = 'a';
        for &c in s.iter() {
            if last == c { continue }
            last = c;
            g += 1;
        }
    }
    g = max!(g - 2 * k, 1);
    put!(n - g);

}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352
import java.util.*;
public class Main {
	public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
      // 取得
	  String s = sc.next();
      int min=753;
      for(int i=0;i<s.length()-2;i++){
        String str = s.substring(i,i+3);
        int n = Integer.parseInt(str);
        int d = Math.abs(753-n);
        min = Math.min(min,d);
      }
       System.out.println(min);
    }
}

Measured memory_bytes: 35592
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;

int main(){
    int K;cin>>K;
    K--;
    int ans[]={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};
    cout<<ans[K]<<endl;
}


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

int main()
{
	int n,k;
	cin>>n>>k;
	vector<int>dist(n),val(n);
	fill(val.begin(),val.end(),1<<30);
	int i,j;
	for(i=0;i<n;i++) cin>>dist[i];
	val[0]=0;
	for(i=0;i<n;i++)
	{
       for(j=1;j<=k;j++)
       {
		if(i+j<n)
		  val[i+j]=min(val[i+j],val[i]+abs(dist[i+j]-dist[i]));
		
		if(i+2<n)
		val[i+j]=min(val[i+j],val[i]+abs(dist[i+j]-dist[i]));
       }
	}
	// for(i=0;i<n;i++)
	//  cout<<val[i]<<" ";
	//  cout<<endl;
	cout<<val[n-1]<<endl;
}

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

int a[10002];
int ans;
int main()
{
	int sn;cin>>sn;
	int n=2*sn;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		ans+=a[i];
		i+=1;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())

ans=""
amari=[]

while n>=25:
    amari.insert(0,n%26)
    n//=26

amari.insert(0,n)

for i in range(len(amari)-1,0,-1):
    if amari[i]<=0:
        amari[i-1]-=1
        amari[i]+=26

for i in range(len(amari)):
    if amari[i]==1:
        ans+="a"
    elif amari[i]==2:
        ans+="b"
    elif amari[i]==3:
        ans+="c"
    elif amari[i]==4:
        ans+="d"
    elif amari[i]==5:
        ans+="e"
    elif amari[i]==6:
        ans+="f"
    elif amari[i]==7:
        ans+="g"
    elif amari[i]==8:
        ans+="h"
    elif amari[i]==9:
        ans+="i"
    elif amari[i]==10:
        ans+="j"
    elif amari[i]==11:
        ans+="k"
    elif amari[i]==12:
        ans+="l"
    elif amari[i]==13:
        ans+="m"
    elif amari[i]==14:
        ans+="n"
    elif amari[i]==15:
        ans+="o"
    elif amari[i]==16:
        ans+="p"
    elif amari[i]==17:
        ans+="q"
    elif amari[i]==18:
        ans+="r"
    elif amari[i]==19:
        ans+="s"
    elif amari[i]==20:
        ans+="t"
    elif amari[i]==21:
        ans+="u"
    elif amari[i]==22:
        ans+="v"
    elif amari[i]==23:
        ans+="w"
    elif amari[i]==24:
        ans+="x"
    elif amari[i]==25:
        ans+="y"
    elif amari[i]==26:
        ans+="z"

print(ans)

Measured memory_bytes: 9308
import itertools

n = int(input())
count_m = 0
count_a = 0
count_r = 0
count_c = 0
count_h = 0
sum = 0


for i in range(n):
    a = input()
    if a[0] == 'A':
        count_a += 1
    elif a[0] == 'C':
        count_c += 1
    elif a[0] == 'H':
        count_h += 1
    elif a[0] == 'M':
        count_m += 1
    elif a[0] == 'R':
        count_r += 1

l = [count_m, count_a, count_r, count_c, count_h]
c = itertools.combinations(l, 3)

for f, j, k in c:
    sum += f*j*k

print(sum)





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

int main()
{
    int N,M;
    cin >> N >> M;
    if(N == M) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
/*
** Author: MAC45
*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.tie(0);
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt","wt",stdout);
    ll N, K, d, A, treat = 0;
    cin >> N >> K;
    ll trick[N + 1] = {0};
    while (K--)
    {
        cin >> d;
        while (d--)
        {
            cin >> A;
            trick[A]++;
        }
    }
    for (ll i = 1; i <= N; i++)
    {
        if (trick[i] == 0)
            treat++;
    }
    cout << treat << endl;
    return 0;
}


Measured memory_bytes: 3696
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int h[] = new int[n + 1];
        for (int i = 1; i < n + 1; i++) {
            h[i] = sc.nextInt();
        }
        int dp[] = new int[n + 1];
        dp[1] = 0;
        for (int i = 2; i < n + 1; i++) {
            int tmp = Integer.MAX_VALUE;
            for (int j = i - k; j < i; j++) {
                if (j < 1)
                    continue;
                int sa = Math.abs(h[i] - h[j]);
                int wa = dp[j] + sa;
                if (wa < tmp) {
                    tmp = wa;
                }
            }
            dp[i] = tmp;
        }
        System.out.println(dp[n]);
    }
}


Measured memory_bytes: 49960
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
lis = [int(abs(a-b)),int(abs(a-c)),int(abs(a-d)),int(abs(a-e)),int(abs(b-c)),int(abs(b-d)),int(abs(b-e)),int(abs(c-d)),int(abs(c-e)),int(abs(d-e))]
tes = 0
for item in lis:
    if item > k:
        tes += 1
if tes == 0:
    print('Yay!')
else:
    print(":(")


Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <cstdio>
#define LL long long

using namespace std;

__int128 a,b,c;

inline __int128 read(){
    __int128 x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}

int main()
{
    a=read();
    b=read();
    c=read();
    if(c-a-b<=0)
    {
        printf("No\n");
        return 0;
    }
    if (  a*b*4< (c-a-b)*(c-a-b)  ) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
import sys
from sys import stdin

INF = float("inf")
def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


n = I()
d = LI()
hp = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        hp += d[i] * d[j]
print(hp)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
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; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll f(ll x)
{
    switch (x % 4)
    {
    case 0:
        return x;
    case 1:
        return 1;
    case 2:
        return x + 1;
    case 3:
        return 0;
    }
}

int main()
{
    ll a, b; cin >> a >> b;
    if (a != 0) a--;

    ll ans = f(a) ^ f(b);
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long p = sc.nextLong();
		HashMap<Long, Integer> map = new HashMap<>();
		for (long i = 2; i * i <= p; i++) {
			int count = 0;
			while (p % i == 0) {
				count++;
				p /= i;
			}
			if (count != 0) {
				map.put(i, count);
			}
		}
		if (p != 1) {
			map.put(p, 1);
		}
		long ans = 1;
		for (Map.Entry<Long, Integer> entry : map.entrySet()) {
			long x = entry.getValue();
			for (int i = 0; i < x / n; i++) {
				ans *= entry.getKey();
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23380
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
char s[5];
int main()
{
    scanf("%s",s+1);
    for(int i=2;i<=4;i++)
    {
        if(s[i]==s[i-1])
        {
            puts("Bad");
            return 0;
        }
    }
    puts("Good");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int A,B;
    cin>>A>>B;
    if(A==B)
    cout<<"Draw";
else
    if(A==1)
        cout<<"Alice";
    else
        if(B==1)
        cout<<"Bob";
 
else
    if(A>B)
     cout<<"Alice";
 
else
if(A<B)
cout<<"Bob";
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstdio>
#include <map>
#include <set>
#include <utility>
#include <string>
#include <functional>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, x, y, z;
    cin >> n;
    ll i, j;
    for(i = 1; i <= 3500; i++) {
        for(j = 1; j <= 3500; j++) {
            ll num = n * i * j;
            ll den = 4 * i * j - n * (i + j);
            if(den > 0 && num % den == 0) {
                x = i;
                y = j;
                z = num / den;
                break;
            }
        }
    }
    cout << x << " " << y << " " << z;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = long long;
using u32 = unsigned long long;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using vi32 = vector<i32>;
using vu32 = vector<u32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf64 = vector<f64>;
using vstr = vector<string>;
using vvi32 = vector<vi32>;
using vvu32 = vector<vu32>;
using vvi64 = vector<vi64>;
using vvu64 = vector<vu64>;
using vvf64 = vector<vf64>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

i64 dp[110][25];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  i32 n;
  cin >> n;
  vi32 v(n);
  rep(i, n) cin >> v[i];
  dp[1][v[0]] = 1;
  reps(i, n - 2) rep(j, 21) {
    if (j + v[i] <= 20) {
      dp[i + 1][j + v[i]] += dp[i][j];
    }
    if (j - v[i] >= 0) {
      dp[i + 1][j - v[i]] += dp[i][j];
    }
  }
  cout << dp[n - 1][v[n - 1]] << endl;
  return 0;
}



Measured memory_bytes: 3168
# -*- coding: utf-8 -*-
MOD = 10**9+7

n = int(input())
s = input()

if s[0]=="W" or s[-1]=="W":
    print(0)
    exit()

lr = ["L"]
for i in range(1,2*n):
    if s[i-1]==s[i]:
        if lr[i-1]=="L":
            lr.append("R")
        else:
            lr.append("L")
    else:
        lr.append(lr[i-1])

la = [0 for _ in range(2*n+1)]
ra = [0 for _ in range(2*n+1)]
for i in range(2*n):
    if lr[i]=="L":
        la[i+1] = la[i]+1
        ra[i+1] = ra[i]
    else:
        la[i+1] = la[i]
        ra[i+1] = ra[i]+1
if la[-1]!=ra[-1]:
    print(0)
    exit()

res = 1
for i in range(2*n):
    if lr[i]=="R":
        res *= la[i]-ra[i]
        res %= MOD

for i in range(2,n+1):
    res = (res*i)%MOD

print(res)


Measured memory_bytes: 14592
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;

const lld N = 200043;
const lld MOD = 1000000007;

lld add(lld x, lld y)
{
    x =((x%MOD)+(y%MOD))%MOD;
    while(x >= MOD) x -= MOD;
    while(x < 0) x += MOD;
    return x;
}
int factor[1000005] = { 0 };
lld mul(lld x, lld y)
{
    return ((x%MOD)*(y%MOD))% MOD;
}

lld binpow(lld x, lld y)
{
    lld z = 1;
    while(y)
    {
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}

lld inv(lld x)
{
    return binpow(x, MOD - 2);
}
void fun()
{
    factor[1] = 1;
    for (lld i = 2; i < 1000005; i++)
        factor[i] = i;

    for (lld i = 4; i < 1000005; i += 2)
        factor[i] = 2;
    for (lld i = 3; i * i < 1000005; i++) {
        if (factor[i] == i) {
            for (lld j = i * i; j < 1000005; j += i) {
                if (factor[j] == j)
                    factor[j] = i;
            }
        }
    }
}
lld divide(lld x, lld y)
{
    return mul(x, inv(y));
}

// Combinations

/*
lld fact[N];

void precalc()
{
    fact[0] = 1;
    for(lld i = 1; i < N; i++)
        fact[i] = mul(fact[i - 1], i);
}

lld C(lld n, lld k)
{
    return divide(fact[n], mul(fact[k], fact[n - k]));
}
*/
lld fun2(lld n)
{
    if (n == 1)
        return 1;

    lld ans = 1;
    lld dup = factor[n];
    lld c = 1;
    lld j = n / factor[n];
    while (j != 1) {
        if (factor[j] == dup)
            c += 1;
        else {
            dup = factor[j];
            ans = ans * (c + 1);
            c = 1;
        }
        j = j / factor[j];
    }
    ans = ans * (c + 1);

    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t,i,j;
    //cin>>t;
    t=1;
    while(t--)
    {
        fun();
        lld n;
        cin>>n;
        lld ans=0;
        for(i=1;i<n;i++)
            ans+=fun2(n-i);
        cout<<ans<<endl;
    }
}





Measured memory_bytes: 7556
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstdio>
using namespace std;

int main(){
	string c;
	cin >> c;
	sort(c.begin(), c.end());
	if(c[0]==c[1] and c[1]!=c[2] and c[2]==c[3])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

}


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

int main() {
    double w;
    while (cin >> w) {
        if (w <= 48.00) {
            cout << "light fly" << endl;
        } else if (48.00 < w && w <= 51.00) {
            cout << "fly" << endl;
        } else if (51.00 < w && w <= 54.00) {
            cout << "bantam" << endl;
        } else if (54.00 < w && w <= 57.00) {
            cout << "feather" << endl;
        } else if (57.00 < w && w <= 60.00) {
            cout << "light" << endl;
        } else if (60.00 < w && w <= 64.00) {
            cout << "light welter" << endl;
        } else if (64.00 < w && w <= 69.00) {
            cout << "welter" << endl;
        } else if (69.00 < w && w <= 75.00) {
            cout << "light middle" << endl;
        } else if (75.00 < w && w <= 81.00) {
            cout << "middle" << endl;
        } else if (81.00 < w && w <= 91.00) {
            cout << "light heavy" << endl;
        } else { 
            cout << "heavy" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 0
"use strict";

const main = arg => {
    const input = arg.trim().split("\n");
    const K = parseInt(input[0].split(" ")[0])
    const N = parseInt(input[0].split(" ")[1]) 
    const A = input[1].split(" ").map(n => parseInt(n));
    A.sort((a,b) => a - b)
    let min = Number.POSITIVE_INFINITY
    for(let i = 1; i<N-1; i++){
        let d1 = K - (A[i] - A[i-1])
        let d2 = K - (A[i+1] - A[i])
        min = Math.min(min, d1)
        min = Math.min(min, d2)
    }
    // i = 0
    min = Math.min(min, A[N-1]-A[0])
    console.log(min)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  

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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define CIN(v) cin >> v;
#define COUT(v) cout << v << "\n";

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

  int N;
  CIN(N);

  COUT(N * N * N);

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

        char s[13];
        scanf("%s",s);

        int i = 0;

        while(s[i]){
                printf("%c",s[i]);
                if(i==3){
                        printf(" ");
                }   
                i++;
        }   
printf("\n");
return 0;
}


Measured memory_bytes: 128
n = int(input())
s = input()
ans=[]
a = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
a_list=[]
for j in a:
	a_list.append(j)
for i in range (len(s)):
	ans.append(a_list[a_list.index(s[i])+n].upper())
print("".join(ans))


Measured memory_bytes: 3700
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class DSemiCommonMultiple {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int[] a = in.readIntArray(n);

            long lcm = 1;
            for (int x : a) {
                lcm = NumberTheory.lcm(lcm, x);
                if (lcm / 2 > m) {
                    out.println(0);
                    return;
                }
            }

            for (int x : a) {
                if ((lcm / 2) % x != x / 2) {
                    out.println(0);
                    return;
                }
            }

            long answer = m / (lcm / 2);
            answer = (answer + 1) / 2;
            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] readIntArray(int n) {
            int[] x = new int[n];
            for (int i = 0; i < n; i++) {
                x[i] = nextInt();
            }
            return x;
        }

    }

    static class NumberTheory {
        public static long gcd(long a, long b) {
            long c;
            while (a != 0) {
                c = a;
                a = b % a;
                b = c;
            }
            return b;
        }

        public static long lcm(long a, long b) {
            return (a / gcd(a, b)) * b;
        }

    }
}



Measured memory_bytes: 40796
using System;
using System.Linq;

namespace ABiscuitGenerator
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力の取得
            var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = inputs[0];
            var b = inputs[1];
            var t = inputs[2];

            var biscuits = t / a * b;

            // 解答の出力
            Console.WriteLine(biscuits);
        }
    }
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;

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; }

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

/*------------------------------------/
for library*/

/*------------------------------------*/

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

    int N;
    cin>>N;
    vector<ll> A(N);
    int cnt = 0;
    ll min_abs = INFLL;;
    ll sum = 0;
    rep(i,N){
        cin>>A[i];
        if(A[i]<0)cnt++;
        chmin(min_abs, abs(A[i]));
        sum += abs(A[i]);
    }
    if(cnt % 2 == 1){
        sum -= 2 * min_abs;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 1024
#!python3

iim = lambda: map(int, input().rstrip().split())

from collections import deque

def resolve():
    H, W = iim()

    M = [input() for i in range(H)]

    def search(y, x):
        q = []
        m = [[0]*W for i in range(H)]

        m[y][x] = 1
        q = deque([(y,x, 0)])
        ans = 0
        while q:
            y, x, k = q.popleft()
            ans = max(ans, k)
            for i, j in ((1, 0), (-1, 0), (0, 1), (0, -1)):
                yy = y + i
                xx = x + j

                if 0 <= xx < W and 0 <= yy < H:
                    if M[yy][xx] == "." and m[yy][xx] == 0:
                        m[yy][xx] = 1
                        q.append((yy, xx, k+1))

        return ans

    ans = 0
    for y in range(H):
        for x in range(W):
            if M[y][x] == ".":
                ans = max(ans, search(y, x))
    print(ans)
if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3316