akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#define pb push_back
#define int long long 
using namespace std;
typedef pair<int,int> pii;


int hako[1111];

void cal(int x){

  int i=0;
  while(x>0){
    if(x&1){
      hako[i]++;
    }    
    x>>=1;
    i++;
  }
}

signed main(){

  int n,k;
  cin>>n>>k;

  vector<int> a;
  int t;
  for(int i=0;i<n;i++){
    cin>>t;
    cal(t);
    a.pb(t);
  }
  
  int kk=0;
  int n2=n/2;
  for(int i=40;i>=0;i--){
    if(kk+(1LL<<i)>k) continue;
    //printf(":%lld %lld\n",i,kk);
    if(hako[i]<=(n2)){
      //printf("%lld : %lld\n",i,kk+(1<<i));
      kk+=(1LL<<i);
    }
  }
  //cout<<kk<<endl;
  int res=0;
  for(int i=0;i<n;i++){
    res+=kk^a[i];
  }
  cout<<res<<endl;
  // for(int i=0;i<13;i++){
  //   printf("%lld : %lld\n",i,hako[i]);
  // }
  
  return 0;
}



Measured memory_bytes: 1400
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;

#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()

ll n, k, m = 1e9 + 7;

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

    string s, t;
    cin >> s >> t;

    n = (int)s.size();
    k = (int)t.size();

    string f = "UNRESTORABLE";

    if(n < k) return cout << f << endl, 0;

    int idx = m;
    rep(i, n - k + 1) {
        bool z = true;
        rep(j, k) {
            if(s[i + j] != t[j] && s[i + j] != '?') {
                z = false;
                break;
            }
        }
        if(z) idx = i;
    }

    if(idx == m) {
        cout << f << endl;
    } else {
        rep(i, n) {
            if(i == idx) {
                s.replace(i, k, t);
                i += k - 1;
            } else {
                if(s[i] == '?') s[i] = 'a';
            }
        }
        cout << s << endl;
    }
}

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

using namespace std;

void solve()
{
   long long int n,res=0;
   cin>>n;

   for(int i=2;i<=1000010;i++)
   {
       if(n%i==0)
       {
           int pow=0;
           while(n%i==0)
           {
               pow++;
               n/=i;

               
           }
         
         for(int j=1;j<1000010;j++)
         {
           if(pow<j)
             break;
           pow-=j;
           res++;
         }

       }
   }

   if(n>1)
    res++;

    cout<<res;
}

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

    solve();
    return 0;

}


Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;

        static void Solve()
        {
            var o = ReadAndParseIntArr();
            int a = o[0];
            int b = o[1];
            int c = o[2];

            string ans = "NO";
            for(int i=0;i<1000;++i)
            {
                if(( b * i + c ) % a == 0)
                {
                    ans = "YES";
                    break;
                }
            }
            Console.WriteLine(ans);
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 13140
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<ll> t(n), a(n);

    for (int i = 0; i < n; ++i) {
        cin >> t[i] >> a[i];
    }

    long long x = 1, y = 1;

    for (int i = 0; i < n; ++i) {
        ll t0 = t[i], a0 = a[i];
        ll k0 = (x + t0 - 1) / t0, k1 = (y + a0 - 1) / a0;

        x = t0 * max(k0, k1);
        y = a0 * max(k0, k1);
    }

    cout << x + y << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
int a[1000100];
int jud(int n){
	int i;
	for (i=2;i<=sqrt(n);i++){
		if (n%i==0)
		return 0;
	}
	return 1;
}
int main(){
	int n;
	while (cin>>n){
		int i,j,res=0;
		memset(a,0,1000000*sizeof(int));
		for (i=2;i<=n;i++)
		if (!a[i]){
			if (jud[i]){
			res++;
			if (i<1000){
			for (j=i*i;j<1000000;j+=i){
				a[j]=1;
			}
			}
			}
		}
		cout<<res<<endl;
	}
	return 0;
}


Measured memory_bytes: 6980
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    long int n;
    cin >> n;
    long int peo,a=10e16;
    for(int i=0;i<5;i++)
    {
        cin >> peo;
        a=min(a,peo);
    }
    if(a>n) cout << 5 << '\n';
    else
    {
    long int aa=n/a;
    if(aa==0) aa=0;
    else
    {
        if(n%a==0) aa-=1;
    }
    long ans=5+aa;
    cout << ans << '\n';
    }
}

Measured memory_bytes: 256
import java.math.*

fun main(args: Array<String>) {
    var N = readInputLine().toInt()
    
    var ans = N

    for (i in 0..N) {
        var cnt = 0
        var t = i
        while (t > 0) {
            cnt += t % 6
            t /= 6
        }
        t = N - i
        while (t > 0) {
            cnt += t % 9
            t /= 9
        }
        ans = Math.min(ans, cnt)
    }

    println(ans)
}

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


Measured memory_bytes: 31652
#include <stdio.h>

int main(void)
{
	double a, b, f;
	int d, r,a1,b1;

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

	a1 = a;
	b1 = b;


	d = a / b;
	r = a1 % b1;
	f = a / b;

	printf("%d %d %f", d, r, f);
	return 0;
}


Measured memory_bytes: 2104
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main(){
    vector <string>c(3);
    for(int i=0 ; i<3 ; i++){
        cin>>c[i];
        cout<<c[i].substr(i,1);
    }
    cout<<endl;

    return 0;
}


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

ll x;
ll ans = 0,cur = 100;
int main(){
	cin >> x;
	while (cur < x && cur < 10000){
		ll nxt = (cur/100+1)*100;
		if (nxt > x) break;
		ll itr = cur / 100;
		ll stp = (nxt-cur-1)/itr+1;
		ans += stp;
		cur += stp * itr;
	}
	while (cur<x) ans++, cur += (cur/100);
	cout << ans;
	return 0;
}

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

int main() {
	int n;
	vector<int> r;

	cin >> n;
	for(int i = 0; i < n; ++i) {
		int tmp;
		cin >> tmp;
		r.push_back(tmp);
	} // O(n)

	// ????°???§????????????????????????i??¨????????????r[i]???????´?
	int max = numeric_limits<int>::min();
	int min = r[0];
	for(int i = 1; i < n; ++i) {
		max = (max >= r[i]-min)?max:(r[i]-min);
		min = (min <= r[i])?min:(r[i]);
	}
	cout << max << endl;

	return 0;
}

Measured memory_bytes: 3912
#include<bits/stdc++.h>
using namespace std;
long long f[101][100001]={0},w[101],v[101],N,W,i,j,k;
int main()
{
	scanf("%lld %lld",&N,&W);
	for(i=1;i<=N;i++)
		scanf("%lld %lld",&w[i],&v[i]);
	for(i=1;i<=N;i++)
	{	
		for(j=1;j<=W;j++)
		{
			f[i][j]=f[i-1][j];
			if(j>=w[i])
				f[i][j]=max(f[i-1][j-w[i]]+v[i],f[i][j]);
		}
	}
	printf("%lld",f[N][W]);
	return 0;
}

Measured memory_bytes: 78336
#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;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

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

struct UnionFind
{
  vector<int> data;
  UnionFind(){}
  UnionFind(int sz):data(sz, -1){};
  int size(int x) { return -data[find(x)]; }
  int find(int x) {
    if(data[x] < 0) return x;
    return data[x] = find(data[x]);
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  void unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x == y) return;
    if(data[x] < data[y]) swap(x, y);
    data[x] += data[y]; data[y] = x;
    return;
  }
};


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

  int n, m;
  cin >> n >> m;
  vector<Pi> edge;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    edge.emplace_back(a, b);
  }
  int ans = 0;
  rep(i, m) {
    UnionFind uf(n);
    rep(j, m) {
      if(i == j) continue;
      int u, v;
      tie(u, v) = edge[j];
      uf.unite(u, v);
    }
    if(uf.size(0) != n) ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
#sys.stdin = open("input.txt", "r")
#sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)



n,A,B=l()

mnn=A*(n-1)+B
mxx=A+B*(n-1)
print(max(mxx-mnn+1,0))

    



Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int n;
char a[100],b[100];
long long dp[2000][2];
int main()
{
	scanf("%d%s%s",&n,a+1,b+1);
	if(a[1]==a[2])
		dp[2][1]=6;
	else
		dp[1][0]=3;
	for(int i=2+(a[1]==a[2]);i<=n;i++)
	{
		if(i<n && a[i]==a[i+1])
			dp[i+1][1]=(dp[i-1][0]*2+dp[i-1][1]*3)%MOD,i++;
		else
			dp[i][0]=(dp[i-1][0]*2+dp[i-1][1])%MOD;
	}
	printf("%d\n",(dp[n][0]+dp[n][1])%MOD);
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
as = gets.split.map(&:to_i)
bs = as.map.with_index { |a, i| a - (i + 1) }

b = bs.sort[n / 2]
ans = as.map.with_index { |a, i| (a - (b + i + 1)).abs }.inject(:+)
puts ans


Measured memory_bytes: 20720
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

vector<vector<ll>> dp;
void print_pair(pll a){
  cerr<<"("<<a.first<<", "<<a.second<<") ";
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}
void solve(long long R, long long G, long long B, long long N){
    dp.resize(3);
    REP(3){
        dp[i].resize(N+1);
    }
    REP(N/R+1){
        dp[0][R*i]=1;
    }
    For(i,N+1){
        for(long long j = 0; i+j*G <= N; j++){
            dp[1][i+j*G]+=dp[0][i];
        }
    }
    For(i,N+1){
        for(long long j = 0; i+B*j <= N; j++){
            dp[2][i+j*B]+=dp[1][i];
        }
    }
    cout<<dp[2][N]<<endl;
}

int main(){
    long long R;
    scanf("%lld",&R);
    long long G;
    scanf("%lld",&G);
    long long B;
    scanf("%lld",&B);
    long long N;
    scanf("%lld",&N);
    solve(R, G, B, N);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
using lint=int64_t;
using namespace std;

int main()
{
	int N,K;
	int P[200010]={};

	cin >> N >> K;
	for(int i=0;i<N;i++)
		cin >> P[i];
	
	int sum[200010]={};
	for(int i=1;i<N;i++)
		sum[i]=sum[i-1]+(P[i-1]<P[i]?1:0);
	
	int ans=0;
	bool flag=false;
	for(int i=0;i<N-K+1;i++)
	{
		if(sum[i+K-1]-sum[i]==K-1)
			flag=true;
	}
	if(flag)
		ans++;
	
	for(int i=0;i<N-K+1;i++)
	{
		if(sum[i+K-1]-sum[i]!=K-1)
			ans++;
	}

	set<int> s;
	for(int i=0;i<K;i++)
		s.insert(P[i]);
	for(int i=0;i<N-K;i++)
	{
		s.insert(P[i+K]);
		if(sum[i+K-1]-sum[i]!=K-1 && sum[i+K]-sum[i+1]!=K-1 && sum[i+K-1]-sum[i+1]!=K-2)
		{
			auto minitr=s.begin();
			auto maxitr=s.rbegin();
			if(*minitr==P[i] && *maxitr==P[i+K])
				ans--;
		}
		s.erase(P[i]);
	}

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


Measured memory_bytes: 11136
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
int W,H,x,y,r;
    cin >> W >> H >> x >> y >>r;
    if(W-r >= x && H-r >= y && x >= r && y >= r){
         cout << "Yes" << endl;
    }else{
         cout << "No" << endl;
    }
    return 0;
}


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

int main(){
    int flag=1;
    int n,a;
    int ans=0;

    cin >>n;
    for (int i = 0; i < n; i++){
        cin >>a;
        ans +=(a-1);
    }
    cout << ans <<endl;
    //cout <<fixed<<setprecision(16)<< ans <<endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

vl fact(100005);

ll Fact(ll n){
	if(fact[n]) return fact[n];
	if(!n) return fact[n]=1;
	return fact[n]=Fact(n-1)*n%mod;
}

ll Pow_mod(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

ll Division_mod(ll n,ll m){
	return n*Pow_mod(m,mod-2)%mod;
}

ll Combination(ll n,ll k){
	if(n<k) return 0;
	return Division_mod(Fact(n),Fact(n-k)*Fact(k)%mod);
}

int n;

int main(){
	cin>>n;
	vi a(n,-1);
	int A,B;
	for(int i=0;i<=n;i++){
		int t;
		cin>>t;
		t--;
		if(a[t]!=-1){
			A=a[t];
			B=i;
		}
		else a[t]=i;
	}
	for(int i=1;i<=n+1;i++){
		if(i==1) cout<<n<<endl;
		else if(i==n+1) cout<<1<<endl;
		else{
			ll res=(Combination(n-1,i)+Combination(n-1,i-2))%mod;
			(res+=2*Combination(n-1,i-1)%mod-Combination(A+n-B,i-1)+2*mod)%=mod;
			cout<<res<<endl;
		}
	}
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	set<char> Set;
 	for (int ii = 0; ii < 4; ++ii){
 		Set.insert(s[ii]);
	}

	bool ans = true;
	if (Set.size() != 2) {
		ans = false;
	} else {
		int cnt = 0;
		for (int ii = 1; ii < 4; ++ii){
			if (s[0] == s[ii]){
				cnt++;
			}
		}
		if (cnt != 1){
			ans = false;
		}
	}

	if (ans){
				cout << "Yes" << "\n";
	} else {
				cout << "No" << "\n";		
	}

	return 0;
}


Measured memory_bytes: 256
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import product, combinations,permutations
from copy import deepcopy, copy
from math import sqrt, log10
import sys
sys.setrecursionlimit(4100000)



if __name__ == '__main__':
    A, X, C = list(input().split())

    print('A'+X[0]+'C')

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

int main() {
  const string t = "keyence";
  string input;

  getline(cin, input);

  const int size = input.size();

  for (int i = 0; i < size; i++) {
    for (int j = i; j < size; j++) {
      string str = input;
      //cout << str << endl;
      //cout << "erase:" << i << " to " << j << endl;
      str.erase(str.begin()+i, str.begin()+j);
      //cout << str << endl;
      if (str == t) {
        cout << "YES" << endl;
        return 0;
      }

      
    }
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>

using namespace std;
vector<int> prime;
bool isPrime[10000001];

void PrimeCalc()
{
	memset(isPrime, 1, sizeof(isPrime));
	isPrime[0] = isPrime[1] = false;
	for(int i = 2; i < 10000001; ++i)
	{
		if(isPrime[i])
		{
			prime.push_back(i);
			for(int j = 2 * i; j < 10000001; j += i)
			{
				isPrime[j] = false;
			}
		}
	}
}

void solve()
{
	PrimeCalc();
	int n;
	while(cin >> n, n)
	{
		for(int i = n; i >= 13; --i)
		{
			if(isPrime[i] && isPrime[i - 2] && isPrime[i - 6] && isPrime[i - 8])
			{
				cout << i << endl;
				break;
			}
		}
	}
}

int main()
{
	solve();
	return(0);
}

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

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

int gcd(int a, int b)
{
    if(b == 0) return a;
    return gcd(b, a % b);
}

int main()
{
    int N;
    int A[100001];

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

    vector<int> l_pre(N + 2);
    for(int i = 1; i <= N; i++) {
        l_pre[i] = gcd(A[i], l_pre[i - 1]);
        IFD cout << l_pre[i] << " ";
    }
    IFD cout << endl;

    vector<int> l_post(N + 2);
    for(int i = N; i >= 1; i--) {
        l_post[i] = gcd(l_post[i + 1], A[i]);
        IFD cout << l_post[i] << " ";
    }
    IFD cout << endl;

    int ans = -1;
    for(int i = 1; i <= N; i++) {
        ans = max(ans, gcd(l_pre[i - 1], l_post[i + 1]));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int N;
int a[MAX_N];

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  REP(i, N) cin >> a[i];

  map<int, int> mp;
  REP(i, N) { mp[a[i]]++; }
  ll ans = 0;
  for (auto m : mp) {
    // m.second 分全部取り除くか
    // 余剰分を取り除くかのどちらか少ない方
    if (m.second >= m.first && m.second - m.first < m.second) {
      ans += m.second - m.first;
    }
    else {
      ans += m.second;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5120
house = { "1" => Array.new(3).map{Array.new(10,0)}, "2" => Array.new(3).map{Array.new(10,0)}, "3" => Array.new(3).map{Array.new(10,0)}, "4" => Array.new(3).map{Array.new(10,0)}}

gets.to_i.times do 
  b, f, r, v = gets.split
  f = f.to_i - 1
  r = r.to_i - 1
  v = v.to_i
  house[b][f][r] += v
end

house.each_with_index{|(key, value), i|
  value.each{|v|
    puts " #{v.join(" ")}"
  }
  if i != house.size - 1
    puts "####################"
  end
}


Measured memory_bytes: 6884
n = gets.to_i
t = 1
a = 1
n.times do
  ti, ai = gets.split.map(&:to_i)
  if a < ai
    a = ai
  elsif a % ai != 0
    a += ai - a % ai
  end
  if t < ti
    t = ti
  elsif t % ti != 0
    t += ti - t % ti
  end

  if t / ti < a / ai
    t = ti * a / ai
  else
    a = ai * t / ti
  end
end
puts t + a


Measured memory_bytes: 1788
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x-I .)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int N; cin >> N;
    vector<P> d(N);
    rep(i,N)cin >> d[i].first >> d[i].second;
    bool ok = false;
    int row = 0;
    rep(i,N){
        if(d[i].first == d[i].second)++row;
        else row = 0;
        if(row >= 3)ok = true;
    }
    if(row >= 3)ok = true;
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define N 200005
 
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	

	ll n,k,i,j;
	cin>>n>>k;
	ll a[N],visited[N];
	for(i=1;i<=n;i++){
		cin>>a[i];
		visited[i]=0;
	}
	// k++;
	vector <ll> s;
	i=1;
	while(!visited[i]){
		s.pb(i);
		visited[i]=1;
		i=a[i];
	}
	ll len=0;
	for(j=0;j<s.size();j++){
		if(s[j]==i){
			len=(ll)s.size()-j;
			break;
		}
	}

	if(k<(ll)s.size()){
		cout<<s[k]<<endl;
	}
	else{
		k-=j;
		k%=len;
		cout<<s[j+k]<<endl;
	}
	// for(i=0;i<s.size();i++){
	// 	cout<<s[i]<<endl;
	// }
	return 0;
}

Measured memory_bytes: 8424
n=int(input())
G=[[] for i in range(n)]
for i in range(n-1):
    a,b,c=map(int,input().split())
    G[a-1].append((b-1,c))
    G[b-1].append((a-1,c))
q,k=map(int,input().split())
k=k-1
stack=[k]
dis=[-1]*n
dis[k]=0
while stack!=[]:
    new=[]
    for j in stack:
        d=dis[j]
        for i in G[j]:
            if dis[i[0]]==-1:
                dis[i[0]]=d+i[1]
                new.append(i[0])
    stack=new
for i in range(q):
    x,y=map(int,input().split())
    x=x-1
    y=y-1
    print(dis[x]+dis[y])



Measured memory_bytes: 79776
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    
		String x = "";
		try {
			x = in.readLine();
			int num = Integer.parseInt(x);

			x = in.readLine();
			
			String[] values = x.split(" ");

			int value = Integer.parseInt(values[0]);
			int min = value;
			int max = value;
			long sum = value;
			
			for (int i = 1; i < num; i++) {
				value = Integer.parseInt(values[i]);
				
				if (min > value) min = value;
				if (max < value) max = value;
				sum = sum + value;
			}
			
			System.out.println(min + " " + max + " " + sum);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

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

int main(){
    string s;
    cin >> s;
    rep(i,4){
        if(s[i] == s[i+1]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,q,k,id[100010];
ll a[100010],b[100010],t[100010],ans[100010];
bool cmp(int x,int y)
{
	if (a[x]==a[y])
	{
		return x>y;
	}
	return a[x]<a[y];
}
int main()
{
	scanf("%d%d",&n,&q);
	a[0]=n;
	for (int i=1;i<=q;i++)
	{
		scanf("%lld",&a[i]);
		id[i]=i;
	}
	sort(id,id+q+1,cmp);
	int lst=-1;
	for (int i=0;i<=q;i++)
	{
		if (id[i]>lst)
		{
			b[++k]=a[id[i]];
			lst=id[i];
		}
	}
	t[k]=1;
	for (int i=k;i;i--)
	{
		ll now=b[i];
		while (now>=b[1] && i>1)
		{
			int x=upper_bound(b+1,b+k+1,now)-b;
			x--;
			if (x==i)
			{
				x--;
			}
			t[x]+=now/b[x]*t[i];
			now%=b[x];
		}
		ans[1]+=t[i];
		if (now+1>n)
		{
			continue;
		}
		ans[now+1]-=t[i];
	}
	for (int i=1;i<=b[1];i++)
	{
		ans[i]+=ans[i-1];
	}
	for (int i=1;i<=b[1];i++)
	{
		printf("%lld\n",ans[i]);
	}
	for (int i=b[1]+1;i<=n;i++)
	{
		puts("0");
	}
	return 0;
}
//独坐幽篁里，弹琴复长啸。
//深林人不知，明月来相照。
//——王维《竹里馆》

Measured memory_bytes: 5248
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && b == c) {
		cout << 1 << endl;
	} else if (a != b && b != c && c != a) {
		cout << 3 << endl;
	} else {
		cout << 2 << endl;
	}
}


Measured memory_bytes: 256
N,M = map(int, input().split(" "))
drink = []
for i in range(N):
  A,B = input().split(" ")
  drink.append([int(A), int(B)])

drink.sort()
cost = 0

for j in range(N):
  if M == 0:
    break
  else:
    if M >= drink[j][1]:
      cost += drink[j][0] * drink[j][1]
      M -= drink[j][1]
    else:
      cost += drink[j][0] * M
      M = 0
print(cost)
  
  


Measured memory_bytes: 20012
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		char[] r = new char[4];
		char[] a = new char[4];
		while (br.read(r) == 4 && br.read() != -1 && (br.read(a) == 4)
				&& br.readLine() != "dummy") {
			int hit = 0, brow = 0;
			for (int i = 0; i < 4; i++) {
				for (int j = 0; j < 4; j++) {
					if (r[i] == a[j]) {
						if (i == j) {
							hit++;
						} else {
							brow++;
						}
						break;
					}
				}
			}
			System.out.println(hit + " " + brow);
		}

	}
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────────────────

ll f(ll x) {
	ll res = 0;
	while (x % 2 == 0) {
		x /= 2;
		res++;
	}
	return res;
}

int main() {
	ll n, m;
	cin >> n >> m;
	vi a(n);
	rep(i, n) cin >> a[i];

	rep(i, n) {
		if (a[i] % 2 == 1) {
			cout << 0 << endl;
			return 0;
		}
		a[i] /= 2;
	}

	ll t = f(a[0]);
	rep(i, n) {
		if (f(a[i]) != t) {
			cout << 0 << endl;
			return 0;
		}
		a[i] >>= t;
	}
	m >>= t;

	ll l = 1;
	rep(i, n) {
		l = LCM(l, a[i]);
		if (l > m) {
			cout << 0 << endl;
			return 0;
		}
	}
	m /= l;
	ll ans = (m + 1) / 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    
    if(a < b) {
      System.out.println("a < b");
    }else if(a > b) {
      System.out.println("a > b");
    }else if(a == b){
      System.out.println("a == b");
    }
  }
}

Measured memory_bytes: 26252
package main

import (
	"fmt"
)

func main() {
	var N, w int
	var S string
	fmt.Scan(&N, &S)
	max := 0
	for _, v := range S {
		if string(v) == "I" {
			w++
		} else {
			w--
		}
		if w > max {
			max = w
		}
	}
	fmt.Println(max)

}

Measured memory_bytes: 512
n = int(input())
v = list(map(int, input().split()))

if len(set(v)) == 1:
    print(n // 2)
else:
    cnt_even = [[0, i] for i in range(10 ** 5 + 1)]
    cnt_odd = [[0, i] for i in range(10 ** 5 + 1)]
    for i in range(n):
        if i % 2 == 0:
            cnt_even[v[i]][0] += 1
        else:
            cnt_odd[v[i]][0] += 1

    cnt_even.sort()
    cnt_odd.sort()

    if cnt_even[-1][1] == cnt_odd[-1][1]:
        print(n - max(cnt_even[-1][0] + cnt_odd[-2][0], cnt_even[-2][0] + cnt_odd[-1][0]))
    else:
        print(n - cnt_even[-1][0] - cnt_odd[-1][0])

Measured memory_bytes: 112636
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using static System.Console;
namespace AtCoder.AGC014
{
    class CookieExchanges
    {
        public static void Main()
        {
            var abc = ReadLine().Trim().Split(' ').Select(n => int.Parse(n)).ToArray();
            var a = abc[0]; var b = abc[1]; var c = abc[2];
            if (Judge(a) && Judge(b) && Judge(c))
            {
                var a2 = (b + c) / 2; var b2 = (a + c) / 2; var c2 = (a + b) / 2;
                if (Judge(a2) && Judge(b2) && Judge(c2))
                {
                    WriteLine(MinElse(CalZero(a2 - a), CalZero(b2 - b), CalZero(c2 - c)));
                }
                else
                {
                    WriteLine(1);
                }
            }
            else
            {
                WriteLine(0);
            }
        }
        static bool Judge(int n)
        {
            return n % 2 == 0;
        }
        static int CalZeroSub(int n)
        {
            if (n == 0) return 1;
            else if (n % 2 == 0) return CalZero(n / 2) + 1;
            else return 1;
        }
        static int CalZero(int n)
        {
            if (n == 0) return int.MaxValue;
            else return CalZeroSub(n);
        }
        static int MinElse(params int [] arg)
        {
            return arg.All(n => n == int.MaxValue) ? -1 : arg.Min();
        }
    }
}

/*
ai = (bi-1 + ci-1) / 2
bi = (ai-1 + ci-1) / 2
ci = (ai-1 + bi-1) / 2

ai + ci = (ai-1 + ci-1) / 2 + (ai-2 + ci-2) / 2
bi+1 = bi/2 + bi-1/2
bi+1 - xbi = y(bi - xbi-1)
bi+1 = (x + y)bi - xybi-1
x^2 - 0.5x - 0.5
(x - 1/4) ^ 2 - (3/4)^2
(x - 1) (x + 1/2) = 
bi+1 - bi = 1/2(bi - bi-1)
b2 = (a1 + c1) / 2
bi+1 - bi % 2 == 1 => ret i+1
(x - a)(x - b) = x^2 - (a + b)x + ab


(a, b, c) | 0 0.5 0.5|
          | 0.5 0 0.5|
          | 0.5 0.5 0|
*/

Measured memory_bytes: 13396
n = int(input())
a = list(map(int, input().split()))
b = [0]*(2+max(a))

for i in range(n):
    b[a[i]] += 1

ans = 0

for i in range(len(b)):
    if b[i] != 0:
        ans = max(ans, b[i-1]+b[i]+b[i+1])
print(ans)


Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int i=a,inc=(b-a)/abs(b-a); i!=b ; i+=inc)
#define deb(x) cout<<#x<<"->"<<x<<endl;
#define print(arr,a,b) for(int i=a;i!=b;i++){cout<<arr[i]<<" ";}cout<<endl;
using ll=long long int;
int arr_min(int arr[],int a,int b){ int min=arr[0]; for(int i=a;i!=b;i++){if(min>arr[i]) min=arr[i];}return min;}
int arr_max(int arr[],int a,int b){ int max=arr[0]; for(int i=a;i!=b;i++){if(max<arr[i]) max=arr[i];}return max;}

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

	#ifndef ONLINE_JUDGE
      	freopen("input.txt", "r", stdin);
      	freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t-->0){
    	int r;
    	cin>>r;
    	cout<<fixed<<setprecision(20);
    	float x=float(22)/float(7);
    	// cout<<x;
    	float ans=(2*x*r);
    	cout<<ans<<endl;

    	
    	
    }
    return 0;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/range/algorithm.hpp>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int main() {
  int n;
  cin >> n;
  Graph G(n);
  rep(i, n) {
    string s;
    cin >> s;
    rep(j, n) {
      if (s[j] == '1') {
        G[i].push_back(j);
      }
    }
  }

  bool flag = false;
  int ans = 0;
  rep(i, n) {
    // BFS のためのデータ構造
    vector<int> dist(n, -1);  // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[i] = 0;
    que.push(i);  // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
      int v = que.front();  // キューから先頭頂点を取り出す
      que.pop();

      // v から辿れる頂点をすべて調べる
      for (int nv : G[v]) {
        if (dist[nv] == dist[v]) flag = true;
        if (dist[nv] != -1) continue;  // すでに発見済みの頂点は探索しない

        // 新たな白色頂点 nv について距離情報を更新してキューに追加する
        dist[nv] = dist[v] + 1;
        que.push(nv);
      }
    }

    ans = max(ans, *max_element(dist.begin(), dist.end()) + 1);
  }
  if (flag) ans = -1;
  cout << ans << endl;
}

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

int main()
{
  char a[100],b[100];
  int n;
  
  scanf("%s", a);
  scanf("%s", b);
  
  n = strlen(a);
  
  if(strncmp(a,b,n)==0 && strlen(b)==n+1)
  {
    printf("Yes");
  }else
  {
   printf("No"); 
  }
  return 0; 
}


Measured memory_bytes: 1704
import sys

def main():
    N, M = list(map(int,input().split()))
    p_S = [None] * M

    wa_cnt = [0] * N
    ac_flags = [0] * N

    for i in range(M):
        p_S[i] = list(input().split())
        p_S[i][0] = int(p_S[i][0])

    wa_ans, ac_ans = 0, 0

    for j in p_S:
        if j[1] == 'WA':
            wa_cnt[j[0] - 1] += 1

        if j[1] == 'AC' and ac_flags[j[0] - 1] == 0:
            wa_ans += wa_cnt[j[0] - 1]
            ac_ans += 1
            ac_flags[j[0] - 1] = 1


    print(ac_ans, wa_ans)

main()

Measured memory_bytes: 25056
N, M, Q = map(int, input().split())

LR = [[0] * (N + 1) for _ in range(N + 1)]

for _ in range(M):
    L, R = map(int, input().split())
    LR[L][R] += 1

for l in range(1, N + 1):
    for r in range(1, N + 1):
        LR[l][r] = LR[l - 1][r] + LR[l][r - 1] - LR[l - 1][r - 1] + LR[l][r]

ans = []
for _ in range(Q):
    p, q = map(int, input().split())
    cnt = LR[q][q] - LR[q][p - 1] - LR[p - 1][q] + LR[p - 1][p - 1]
    ans.append(cnt)

print(*ans, sep='\n')

Measured memory_bytes: 19148
N = int(input())
b = []
max_num = 0
for i in range(N):
  a = int(input())
  b.append(a)
  max_num = max(a,max_num)
max_num2 = 0  
num = b.count(max_num)
if num >1:
  for i in range(N):
    print(max_num)
elif num ==1:
  for i in b:
    if i == max_num:
      pass
    else:
      max_num2 = max(max_num2,i)
  for i in b:
    if max_num == i:
      print(max_num2)
    else:
      print(max_num)
    
  
  

Measured memory_bytes: 16768
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> cost(M), t(M);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		cost[i] = a;
		int tmp = 0;
		for (int i = 0; i < b; i++) {
			int c;
			cin >> c;
			c--;
			tmp += (1 << c);
		}
		t[i] = tmp;
	}
	vector<ll> dp(10000,INF);
	dp[0] = 0;
	for (int i = 0; i < (1 << N); i++) {
		for (int j = 0; j < M; j++) {
			dp[(i | t[j])] = min(dp[(i | t[j])], dp[i] + cost[j]);
		}
	}
	if (dp[(1 << N) - 1] != INF) {
		cout << dp[(1 << N) - 1] << endl;
	}
	else {
		cout << -1 << endl;
	}
	
}

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

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
ll dp[N][2];
ll a[N];
ll cur;



int main () {
	SpeedForce;
	cin >> n;
	dp[0][1] = -INF;	
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
		for (int j = 0; j < 2; j ++) {
			for (int k = 0; k < 2; k++) if (a[i] >= j + k) {
				dp[i][k] = max(dp[i][k], dp[i-1][j] + (a[i] - j - k) / 2 + j);
			}
		}
		if (a[i] == 0) dp[i][1] = -INF;
		dp[i][0] = max(dp[i][0], dp[i][1]);
	}

	cout << dp[n][0] << '\n'; 
	return Accepted;
}

// B...a

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

#define ll long long
int dp[200005];
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin>>n;
    int stones[n];
    for(int i=0; i<n; i++){
        cin>>stones[i];
    }
    for(int i=0; i<n; i++){
        if(i==0){
            dp[0] = 0;
        }
        else if(i==1){
            dp[1] = abs(stones[1] - stones[0]);
        }
        else{
            dp[i] = min(dp[i-1]+abs(stones[i-1]-stones[i]), dp[i-2]+abs(stones[i-2]-stones[i]));
            
        }
    }
    cout<<dp[n-1];
}



Measured memory_bytes: 4400
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

min_temp = float('inf')
ans = None
for i in range(N):
    temp = abs(A - (T - H[i] * 0.006))
    if min_temp > temp:
        min_temp = temp
        ans = i
print(ans + 1)

Measured memory_bytes: 3064
import collections
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    TMP = [0] * N

    for i in A:
        TMP[i-1] += 1
    
    sort_TMP = sorted(TMP, reverse=True)
    max_ball = 0
    cnt = 1

    for a in sort_TMP:
        if cnt <= K:
            cnt += 1
            max_ball += a
        else:
            break
    
    print(N-max_ball)


main()

Measured memory_bytes: 76756
import java.util.*;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int count = 0;
		for(int x = 0;x <= k;x++) {
			for(int y = 0;y <= k;y++) {
				int z = s - x - y;
				if(z >= 0 && z <= k) count ++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 19924
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List

solve :: Int -> [Int] -> (Int,Int)
solve n as = (p, q)
  where
    p = maximum as
    (_, q) = minimum $ map f $ filter (/= p) as
      where f a = (abs (2 * a - p), a)

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> (Int,Int)
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_n]:remLines1 = remLines0
      n = readBInt bs_n
      line2:remLines2 = remLines1
      as = map readBInt line2
  in solve n as

outAnswer :: (Int,Int) -> IO ()
outAnswer (x,y) = putStrLn $ unwords $ map show [x,y]

main :: IO ()
main = outAnswer . tmain =<< B.getContents


Measured memory_bytes: 7932
#include<bits/stdc++.h>//k
using namespace std;
int main()
{
    int n;
    cin>>n;
    int cnt=0;
    for(int i=n; i>=1; i--)
    {
        string s=to_string(i);
        if(s.size()%2)
            cnt++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define MOD 1000000007
#define MOD2 998244353

int main(){
	ll n, k;
	cin >> n >> k;
	n %= k;
	if (n <= k/2){
		cout << n;
	}
	else {
		cout << k-n;
	}
	cout<< endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <array>

long long int calPattern(int lower, int n, int sum, std::vector<std::vector<std::vector<long long int>>> &memo) {
	if (n == 0 && sum == 0) return 1;
	if (n == 0 && sum != 0) return 0;
	if (lower > 100) return 0;
	if (memo[lower][n][sum] < 0) {
		memo[lower][n][sum] = 0;
		for (auto i = lower; i <= 100 && i <= sum; ++i) {
			memo[lower][n][sum] += calPattern(i + 1, n - 1, sum - i, memo);
		}
	}
	return memo[lower][n][sum];
}
int main() {
	std::vector<std::vector<std::vector<long long int>>> memo(101, std::vector<std::vector<long long int>>(10, std::vector<long long int>(1001, -1)));
	int n, s;
	std::cin >> n >> s;
	while (n != 0) {
		std::cout << calPattern(0, n, s, memo) << std::endl;
		std::cin >> n >> s;
	}

}


Measured memory_bytes: 11012
#include <iostream>
#include<sstream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<iomanip>
#define  mem(a,b) memset(a,b,sizeof(a))

const int mo=1000000007;
const int inf=0x3f3f3f3f;
double pi=3.14159265358979323846;
double e= 2.71828182845904523536;
typedef long long ll;
using namespace std;

int main()
{
    int a[4];
    int ans=0;
    cin>>a[0]>>a[1]>>a[2];
    do
    {
        sort(a,a+3);
        if(a[0]==a[2])
            break;
        if(a[2]-a[0]>1)
            a[0]+=2;
        else if(a[2]-a[0]==1)
        {
            a[0]++;
            a[1]++;
        }
        ++ans;
    }while(1);
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256
s = input()
n = len(s)
if s != s[::-1]:
  print("No")
elif s[0:(n-1)//2] != s[(n-1)//2-1::-1]:
  print("No")
elif s[(n+3)//2-1:n] != s[n-1:(n+3)//2-2:-1]:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 9092
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long 
#define pb push_back
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod (long long)1000000007
#define mod2 998244353
#define INT_MAX1 900000000
#define MAXN 1000000
#define INF INT_MAX

bool cp(string s)
{
    string s1 = s;
    reverse(s1.begin(), s1.end());
    return s==s1;
}


void solve()
{
    string s;
    cin >> s;
    string a = s.substr(0, s.size()/2);
    string b = s.substr(s.size()/2+1, s.size()/2);
    if(s.size()%2 and cp(s) and cp(a) and cp(b))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

signed main()
{
    
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    string ans = "win";
    if (a + b + c > 21) {
        ans = "bust";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
import java.io.IOException;
import java.util.Scanner;

public class Main
{
	public static void main(String[] Arguments) throws IOException 
	{
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt(), t = sc.nextInt();
		X -= Math.min(X, t);
		System.out.println(X);
	}
}


Measured memory_bytes: 35640