akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
#define fo(i,n) for(int i=0;i<n;++i)
#define fos(j,i,n) for(int j=i;j<n;++j)
#define N 100004
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define abs(x) (x<0?(-x):x)
#define dis(k) cout << k << endl
#define forr(i,n) for(int i= n-1;i>=0;--i)
#define dbg(vari) cerr<<#vari<<" = "<<(vari)<<endl;
typedef vector< ll int > vi;
typedef vector< vi > vvi;
typedef pair< ll int,ll int > ii;

int main(){
	fast;
	int t;
	t=1;
//	cin >> t;
	while(t--){
		int n;
		double k;
		cin >> n >> k;
		vector<double> v(n);
		fo(i,n)
			cin >> v[i];
		double sum=0;
		fo(i,k){
			sum+=v[i]/2;
		}
		double ma=sum;
		int j=0;
		fos(i,k,n){
			sum+=(v[i]/2-v[j]/2);
			j++;
			ma=max(sum,ma);
		}
		dbg(ma);
		ma+=k/2;
		cout <<fixed << setprecision(12) <<  ma;
	}
	
	return 0;
}


Measured memory_bytes: 1792
while True:
    try:
        n = map(int,tuple(raw_input()))
    except EOFError:
        break
    tmp=list(n)
    while len(tmp)>1:
        tmp2 = [str((int(tmp[i])+int(tmp[i+1])))[-1] for i in range(len(tmp)-1)]
        tmp = tmp2
    else:
        print int(tmp[0])

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
#define MOD 998244353

int mpow(int a, int b) {
	int res = 1;
	for (; b; b >>= 1) {
		if (b & 1) res = (int64_t) res * a % MOD;
		a = (int64_t) a * a % MOD;
	}
	return res;
}
int main() {
	int n = ri();
	int a[n];
	for (int i = 0; i < n; i++) a[i] = ri();
	std::vector<int64_t> cnt(1000001);
	for (int i = 0; i < n; i++) cnt[a[i]] += a[i];
	for (int i = 0; i <= 1000000; i++) cnt[i] %= MOD;
	
	std::vector<std::vector<int> > divs(1000001);
	for (int i = 1; i <= 1000000; i++)
		for (int j = 2; j <= 1000000 / i; j++) divs[i * j].push_back(i);
	
	auto converted = cnt;
	for (int x = 1; x <= 1000000; x++) {
		converted[x] %= MOD;
		for (int y : divs[x]) converted[y] += converted[x];
	}
	for (auto &i : converted) i %= MOD, i *= i, i %= MOD;
	for (int x = 1000000; x >= 1; x--) {
		converted[x] %= MOD;
		for (int y : divs[x]) converted[y] -= converted[x];
	}
	for (int i = 0; i < n; i++) converted[a[i]] -= (int64_t) a[i] * a[i];
	int64_t ans = 0;
	for (int i = 1; i <= 1000000; i++) {
		converted[i] = converted[i] % MOD + MOD;
		if (converted[i] >= MOD) converted[i] -= MOD;
		ans += (int64_t) converted[i] * 499122177 % MOD * mpow(i, MOD - 2) % MOD;
		// if (converted[i]) std::cerr << i << ":" << converted[i] << std::endl;
	}
	std::cout << ans % MOD << std::endl;
	
	return 0;
}


Measured memory_bytes: 131200
#include<stdio.h>
int main(void){
  int a,b,max;
  scanf("%d %d",&a,&b);
  max = (a+b>a-b) ? a+b: a-b;
  max = (max>a*b) ? max: a*b;
  printf("%d" ,max);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int n,x;cin>>n>>x;
  vi m(n);
  rep(i,n)cin>>m[i];
  vsort(m);
  rep(i,n){
    x-=m[i];
  }
  int ans=n+x/m[0];
  cout(ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma O3
#define int long long
using namespace std;
int a[3],b[3],ab[5001],ba[5001*5001];
signed main(){
//	freopen(".inp","r",stdin);
//	freopen(".out","w",stdout);
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin>>n;
	for(int i=0;i<3;i++) cin>>a[i];
	for(int i=0;i<3;i++) cin>>b[i];
	for(int i=0;i<=n;i++){
		for(int j=0;j<3;j++){
			if(i-a[j]>=0) ab[i]=max(ab[i],ab[i-a[j]]+b[j]-a[j]);
		}
	}
	n+=ab[n];
	for(int i=0;i<=n;i++){
		for(int j=0;j<3;j++){
			if(i-b[j]>=0) ba[i]=max(ba[i],ba[i-b[j]]+a[j]-b[j]);
		}
	}
	n+=ba[n];
	cout<<n;
}


Measured memory_bytes: 195584
N = int(input())
A = []
lst = [list(format(i, '0%db' % N)) for i in range(2**N)]
X = [[] for i in range(N)]
Y = [[] for i in range(N)]

for i in range(N):
    tmp_A = int(input())
    A.append(tmp_A)
    for j in range(tmp_A):
        tmp_x,tmp_y = input().split()
        X[i].append(int(tmp_x)-1)
        Y[i].append(tmp_y)

ans = -1

for i in range(2**N):
    flag = 1
    for j in range(N):
        if lst[i][j] == "1":
            for k in range(A[j]):
               if lst[i][X[j][k]] != Y[j][k]:
                   flag = 0
    if flag:
        tmp = 0
        for j in lst[i]:
            if j == "1":
               tmp += 1
        if tmp > ans:
            ans = tmp

print(ans)

Measured memory_bytes: 11500
#include<iostream> 
using namespace std; 
int main() {
	int a, b, c; 
	cin >> a; 
	cin >> b; 
	cin >> c; 
	if ((a == 5 && b == 7 && c == 5) || (a == 5 && b == 5 && c == 7) || (a == 7 && b == 5 && c == 5))
	{
		cout << "YES" << "\n";

	}
	else
	{
		cout << "NO" << "\n";
			
	}

}

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

int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0;i < n;i++){
    cin >> a[i];
  }
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  long long ans = 0;
  for (int i = 0;i < (n+1)/2;i++){
    ans += a[i]*2;
  }
  ans -= a[0];
  if (n%2 == 1){
    ans -= a[n/2];
  }
  
  cout << ans << endl;
}



Measured memory_bytes: 4820
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
   
   ll x,y;
   cin>>x>>y;
   ll t=4*x-y;
  if(t%2!=0)
  {
      cout<<"No"<<endl;
      return 0;
  }
  else                                                                                                
  {
      ll i=t/2;
      ll m=x-i;
      if(i<0 || m<0 || i>x || m>x)
      {
          cout<<"No"<<endl;
          return 0;
      }
      if(i+m==x && 2*i + 4*m==y)
      {
          cout<<"Yes"<<endl;
          return 0;
      }
  }
  cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#define ll long long
using namespace std;
const ll md = 1000000007;
ll dp[22][2097200]={};
bool pp[21][21]={},bt[22][2097200]={};
int n;
int rs(int d,int s)
{
	//cout<<d<<" "<<s<<"\n";
	if (d==0) {return 1;}
	if (!bt[d][s])
	{
		bt[d][s]=1;
		for (int i=0;i<n;i++)
		{
			if (pp[d-1][i]&&!(s&(1<<i)))
			{
				dp[d][s]+=rs(d-1,s|(1<<i));
				dp[d][s]%=md;
			}
		}
	}
	return dp[d][s];
}
int main()
{
	cin>>n;
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<n;j++)
		{
			cin>>pp[i][j];
		}
	}
	cout<<rs(n,0)<<"\n";
	return 0;
}

Measured memory_bytes: 352512
import collections
n = int(input())
lsp = list(map(int,input().split()))
lse = []
lso = []
for i in range(n):
    if i%2 == 0:
        lse.append(lsp[i])
    else:
        lso.append(lsp[i])

countere = collections.Counter(lse)
countero = collections.Counter(lso)

valuee = sorted(list(countere.values()),reverse=True)+[0]
valueo = sorted(list(countero.values()),reverse=True)+[0]

keyse = []
for i in countere.keys():
    if countere[i] == valuee[0]:
        keyse.append(i)
keyso = []
for i in countero.keys():
    if countero[i] == valueo[0]:
        keyso.append(i)
factor = 0
if len(keyse) == 1 and len(keyso) == 1 and keyso == keyse:
    factor = min(valuee[0]-valuee[1],valueo[0]-valueo[1])

print(n-valuee[0]-valueo[0]+factor)

Measured memory_bytes: 23488
# vim: set fileencoding=utf-8:
import bisect


def main():
    N, K = map(int, raw_input().split())
    x = [int(ele) for ele in raw_input().split()]
    o = bisect.bisect_right(x, 0)
    top = min(o + K, N)
    bottom = max(o - K, 0)
    best = 999999999999
    for i in xrange(K):
        if top < bottom + i + K:
            break

        l = x[bottom + i]
        r = x[bottom + i + K - 1]
        if l < 0 <= r:
            best = min(best, 2 * min(abs(l), r) + max(abs(l), r))
        elif l < 0 and r < 0:
            best = min(best, abs(l))
        elif 0 <= l and 0 <= r:
            best = min(best, abs(r))

    print(best)


if __name__ == "__main__":
    main()


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

int main() {
  vector<int> a(5);
  int N,D,ret;

  cin>> N >> D;

  if(N%(2*D+1)!=0)
  ret=N/(2*D+1)+1;
  else ret=N/(2*D+1);

  
  cout<<ret<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
void swap(int *a, int *b){
    int t = *a;
    *a = *b;
    *b = t;
}
int main() {
    int x,y;
    while (cin >> x >> y && (x != 0 || y != 0)) {
        if (x > y)swap(&x,&y);
        cout << x << " " << y << endl;
    }
    return 0;
}

Measured memory_bytes: 3104
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int x,y;
  cin>>x>>y;
  int ans=INF;
  if(x<=y) ans=min(ans, y-x);
  if(-x<=y) ans=min(ans, y+x+1);
  if(x<=-y) ans=min(ans, -y-x+1);
  if(-x<=-y) ans=min(ans, -y+x+2);
  cout<<ans<<endl;
}


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

void comb(std::vector<std::vector<unsigned long long int>> &c)
{
    for (int i = 0; i < c.size(); i++)
    {
        c[i][0] = 1;
        c[i][i] = 1;
    }
    for (int i = 1; i < c.size(); i++)
    {
        for (int j = 1; j <= (i / 2 + 1); j++)
        {
            c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
            c[i][i - j] = c[i][j];
        }
    }
}

int main(){
    int n, m;
    std::cin >> n >> m;
    std::vector<std::vector<unsigned long long int>> c(n + m + 1, std::vector<unsigned long long int>(n + m + 1));

    comb(c);

    std::cout << c[n + m][2] - n * m << std::endl;

    return 0;
}

Measured memory_bytes: 3824
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	int n;
	string s;

	cin >> n >> s;

	vector<int> left(n);
	for (int i = 0; i < n; i++) {
		left[i] = s[i] == 'W';
	}

	for (int i = 1; i < n; i++) {
		left[i] += left[i - 1];
	}

	vector<int> right(n);
	for (int i = n - 1; i >= 0; i--) {
		right[i] = s[i] == 'E';
	}

	for (int i = n - 2; i >= 0; i--) {
		right[i] += right[i + 1];
	}

	int ans = INF;
	for (int i = 0; i < n; i++) {
		int cost = left[i] + right[i] - 1;
		ans = min(ans, cost);
	}

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


Measured memory_bytes: 2964
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}

   

int main(){
        lint N;
        lint ans=0;
        cin>>N;
        vector<lint> x;
        vector<lint> y;
        vector<lint> z;
        vector<lint> yz;
       rep(i,N){
       lint G;
       cin>>G;
       x.push_back(G);}
        sort(x.begin(),x.end());
        rep(i,N){
        lint G;
        cin>>G;
        y.push_back(G);}
        sort(y.begin(),y.end());
      rep(i,N){
      lint G;
      cin>>G;
      z.push_back(G);}
        sort(z.begin(),z.end());

        rep(i,N){
           auto dis=upper_bound(z.begin(),z.end(),y[i]);
            lint d=z.end()-dis;
            yz.push_back(d);
        }
        reverse(yz.begin(),yz.end());
        rep(i,N){
            if(i==0)continue;
            yz[i]+=yz[i-1];
        }
        rep(i,N){
              auto dis=upper_bound(y.begin(),y.end(),x[i]);
            lint d=y.end()-dis;
            if(d==0)continue;
            ans+=yz[d-1];
        }
        cout<<ans;
      
}

Measured memory_bytes: 4084
#include<iostream>
using namespace std;
int main()
{
    string S,T;
    cin>>S>>T;
    int count=0;
    for(int i=0;i<S.length();i++){
        if(S[i]!=T[i]){
            count++;
        }
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 3900
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll a,b;
    cin >> a >> b;
    cout << (a-1)/(2*b+1)+1;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    
    cout<<(n-k>0?k*x+(n-k)*y:n*x)<<endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

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

int ctoi(char c) {
    if (c >= '0' && c <= '9') {
        return c - '0';
    }
    return 0;
}

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

    int y, m, d;

    y = ctoi(s[0]) * 1000 + ctoi(s[1]) * 100 + ctoi(s[2]) * 10 + ctoi(s[3]);
    m = ctoi(s[5]) * 10 + ctoi(s[6]);
    d = ctoi(s[8]) * 10 + ctoi(s[9]);


    if (y > 2019) {
        cout << "TBD" << endl;
        return 0;
    } else if (y < 2019) {
        cout << "Heisei" << endl;
        return 0;
    }

    if (m > 4) {
        cout << "TBD" << endl;
        return 0;
    } else if (m < 4) {
        cout << "Heisei" << endl;
        return 0;
    }

    if (d <= 30) {
        cout << "Heisei" << endl;
        return 0;
    } else {
        cout << "TBD" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
n = int(input())
a = [int(input()) for i in range(n)]
b = 1
ans = 0
two = False

for i in range(len(a)):
    b = a[b-1]
    ans += 1
    if b == 2:
        two = True
        break

if two:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 7084
#include<bits/stdc++.h> 
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	int n;
	long long ans=1;
	cin>>n;
	long long a[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]==0)
		{
			cout<<0<<endl;
			return 0;	
		}	
	}
	double d;
//	for(int i=1;i<=n;i++)
//		cout<<a[i]<<" "<<endl;
	for(int i=1;i<=n;i++)
	{
		d=1000000000000000000.0/(double)ans;
//		printf("%.5f,%d\n",d,a[i]);
		if(d<(double)a[i])
		{
			cout<<"-1"<<endl;
			return 0;
		}
		ans*=a[i];
	}
	if(ans>1000000000000000000)
		cout<<-1<<endl;
	else
		cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4392
class UnionFind:
  def __init__(self, n):
    self.p = [-1]*n
    # union by rank
    self.r = [1]*n
 
  def find(self, x):
    if self.p[x] < 0:
      return x
    else:
      self.p[x] = self.find(self.p[x])
      return self.p[x]

  def union(self, x, y):
    rx, ry = self.find(x), self.find(y)

    if rx != ry:
      if self.r[rx] > self.r[ry]:
        rx, ry = ry, rx
      if self.r[rx] == self.r[ry]:
        self.r[ry] += 1
      self.p[ry] += self.p[rx]
      self.p[rx] = ry

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def count_member(self, x):
    return -self.p[self.find(x)]

n,m=map(int,input().split())
ab=[]
for i in range(m):
  a,b=map(int,input().split())
  ab.append((a,b))
ans=0
for i in range(m):
  uf=UnionFind(n+1)
  connection=0
  for j in range(m):
    if i==j:continue
    a,b=ab[j]
    uf.union(a,b)
  connection=uf.count_member(1)
  if connection!=n:ans+=1
print(ans)



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

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

    vector<unsigned long long> a(N*3);
    for(int i = 0; i < N*3; i++) cin >> a[i];

    sort(a.rbegin(), a.rend());

    unsigned long long ans = 0;
    int i = 1;
    while(N--){
        ans += a[i];
        i += 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    x, k, d = rli()
    x = abs(x)
    if x >= k*d:
        print(x-k*d)
        return
    # print(len(str(x)), len(str(k)), len(str(d)))
    n = x//d
    if n % 2 != k % 2:
        print(abs(x%d-d))
    else:
        print(x%d)


if __name__ == '__main__':
    main()


Measured memory_bytes: 8940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sd second
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> a(n);
    fr(i,n) cin>>a[i];
    multiset<int> st;
    fr(i,n){
        auto it=st.lower_bound(a[i]);
        if(it==st.begin()) st.insert(a[i]);
        else{
            int m=*(--it);
            st.erase(it);
            st.insert(a[i]);
        }
    }
    cout<<st.size()<<endl;
}

Measured memory_bytes: 5376
'use strict';

Array.prototype._sort = Array.prototype.sort;
Array.prototype.sort = function (fn) {
	if (fn) {
		return this._sort(fn);
		
	} else if (typeof this[0] === 'number') {
		return this._sort((a, b) => a - b);
		
	} else {
		return this._sort();
	}
};

function gcd(a, b) {
	while (true) {
		if (a > b) {
			a = a % b;
			if (a === 0) return b;
		} else {
			b = b % a;
			if (b === 0) return a;
		}
	}
}

const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');

const NS = lines[0].split(' ');
const N = Number(NS[0]);
const S = Number(NS[1]);

console.log(3 * (N - gcd(N - S, S)));

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

#define ll long long int
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(a) (a).begin(), (a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x, 0, sizeof(x))
#define MINF(x) memset(x, 0x3f, sizeof(x))
#define MMINUS(a) memset(a, 0xff, sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double EPS = 1.0 / LINF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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

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

using namespace std;

int N;
int A[ten(5) + 1];

int main()
{
    ll ans = 0;
    int ncnt = 0;

    cin >> N;
    int mini = INF;
    REP(i, N)
    {
        cin >> A[i];
        if (abs(A[i]) < mini) {
            mini = abs(A[i]);
        }
        if (A[i] < 0) ncnt++;
        ans += abs(A[i]);
    }

    if (ncnt & 1) ans -= 2 * mini;
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1<<30;

int main(){
  int n, m;cin>>n>>m;
  vector<pair<int, int>> edge(m);
  for(int i=0;i<m;i++){
  	int a, b;cin>>a>>b;a--;b--;
    edge[i]=make_pair(a, b);
  }
  int ans=0;
  for(int i=0;i<m;i++){
  	vector<bool> visited(n, false);
  	queue<int> que;
    que.push(0);
    while(que.size()){
      int v=que.front();que.pop();
      visited[v]=true;
      for(int j=0;j<m;j++){
      	if(j==i)continue;
        int a=edge[j].first, b=edge[j].second;
        if(a==v&&!visited[b])que.push(b);
        else if(b==v&&!visited[a])que.push(a);
      }
    }
    bool connected=true;
    for(int i=0;i<n;i++){
      if(!visited[i]){connected=false;break;}
    }
    ans+=(int)!connected;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
// 半径 r の円の面積と円周の長さを求めるプログラムを作成して下さい。
import java.util.Scanner;
import java.lang.Math;
import java.math.BigDecimal;

class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		double r = Double.parseDouble(str);
		double area = r * r * Math.PI;
		double circle = 2 * r * Math.PI;
		System.out.println(BigDecimal.valueOf(area).toPlainString() + " " + BigDecimal.valueOf(circle).toPlainString());
	}
}


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

#define MAX 100

int cnt;
int n;

void BubbleSort(int A[]) {
  for ( int i = 0; i < n; i++ ) {
    for ( int j = n - 1;  j > 0; j--) {
      if (A[j] < A[j - 1]) {
        swap(A[j], A[j- 1]);
        cnt++;
      }
    }
  }
}

int main() {
  int A[MAX];

  cin >> n;

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

  BubbleSort(A);

  for ( int i = 0; i < n - 1; i++ ) {
    cout << A[i] << " " << flush;
  }
  cout << A[n - 1] << endl;
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 3096
package main

import (
  "fmt"
)

func main() {
  var s,a,b int
  fmt.Scan(&s,&a,&b)
  var result int = 0
  result += a * (s/(a+b))
  if (s%(a+b)) < a {
    result += (s%(a+b))
  }else{
    result += a
  }
  fmt.Println(result)
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  long long N, T;
  cin >> N >> T;

  long long t[N];
  for (int i = 0; i < N; ++i)
    cin >> t[i];

  long long ret = 0;
  for (int i = 1; i < N; ++i) {
    if (T > t[i] - t[i - 1])
      ret += t[i] - t[i - 1];
    else
      ret += T;
  }

  ret += T;

  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n;
  cin >> n;
  ll a[n];
  rep(i,n){
    cin >> a[i];
  }
  sort(a,a+n);
  reverse(a,a+n);
  ll ans =0;
  for(ll i = 0; i< n;i++){
    if(i%2==0) ans += a[i];
    else ans -= a[i];
  }
  pri(ans);
  
  return 0;
}


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

int main(){
    int h,w,d;
    cin >> h >> w >> d;
    pair<int,int> point[h*w+1];
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            int t;
            cin >> t;
            point[t] = make_pair(i,j);
        }
    }
    int q;
    cin >> q;
    int l[q],r[q];
    for(int i=0; i<q; i++){
        cin >> l[i] >> r[i];
    }
    long long ans[h*w+1];
    for(int i=1; i<d+1; i++){
        ans[i] = 0;
    }
    for(int i=d+1; i<h*w+1; i++){
        ans[i] = ans[i-d] + abs(point[i].first-point[i-d].first)
                + abs(point[i].second-point[i-d].second);
    }
    for(int i=0; i<q; i++){
        cout << ans[r[i]] - ans[l[i]] << endl;
    }
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <functional>
 
using namespace std;
 
int main(void) {
	unsigned long int length, num = 0;
	char a[100001];
	string S;
	cin >> S;
	length = (unsigned long int)(S.length());
    
    for(int i = 0 ; i < length ; i++){
	    a[i] = S[i];
	}

    for(int i = 1 ; i < length ; i++){
        if(a[i] == a[i-1]){
            if(a[i] == '0'){
                a[i] = '1';
            }else{
                a[i] = '0';
            }
            num++;
        }
    }

    cout << num;
	return 0;
}

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

int main() {
  int N;
  vector<int>a(200000);
  vector<int>b(200000);
  vector<int>ans(200000);  
  cin >> N;
  for(int i=0; i<N; i++) {
    cin >> a.at(i);
  }
  b = a;
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  int max = b[0];
  int flag = 0;
  int cnt = 0;
  int max_second;
  while(flag==0){
    if(b[cnt]!=b[cnt+1]){
      max_second = b[cnt+1];
      flag += 1;
    }
    cnt++;
  }
  
  for(int i=0; i<N; i++){
    if(cnt == 1 && a[i] == max){
      ans[i] = max_second;
    } else {
      ans[i] = max;
    }
  }
  for(int i=0; i<N; i++) {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 3968
r1,c1,r2,c2 = map(int,input().split())

MOD = 10**9+7
MAXN = r2+c2+5
fac = [1,1] + [0]*MAXN
for i in range(2,MAXN+2):
    fac[i] = fac[i-1] * i % MOD

def inv(n):
    return pow(n,MOD-2,MOD)

def comb(n,r):
    if n < r: return 0
    if n < 0 or r < 0: return 0
    return fac[n] * inv(fac[r]) * inv(fac[n-r]) % MOD

ans = comb(r2+c2+2,r2+1) - comb(r2+c1+1,c1) - comb(r1+c2+1,r1) + comb(r1+c1,r1)
ans %= MOD
print(ans)

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

int main() {
  int N;
  cin >> N;
  vector<int> V(N);
  for (int i = 0; i < N; i++) {
    cin >> V.at(i);
  }
  sort(V.begin(), V.end());
  reverse(V.begin(), V.end());
  vector<double> X(N);
  X.at(0) = 0.5;
  for (int i = 1; i < N - 1; i++) {
    X.at(i) = X.at(i - 1) * 0.5;
  }
  X.at(N - 1) = X.at(N - 2);
  
  double ans = 0.0;
  for (int i = 0; i < N; i++) {
    ans += V.at(i) * X.at(i);
  }
  
  cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt(), K = in.nextInt();
        boolean[] hasCandies = new boolean[N];
        for (int i = 0; i < K; i++) {
            int M = in.nextInt();
            for (int j = 0; j < M; j++) {
                hasCandies[in.nextInt() - 1] = true;
            }
        }
        int res = 0;
        for (boolean b : hasCandies) {
            if (!b) {
                res++;
            }
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 46620
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

const LL MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    string ds[2];
    cin >> ds[0] >> ds[1];
    LL last = 0;
    LL ans = 1;
    for (int i = 0; i < n; ) {
        if (ds[0][i] == ds[1][i]) {
            ans *= (3 - last);
            last = 1;
            i++;
        } else if (last == 0) {
            ans *= 6;
            last = 2;
            i+=2;
        } else if (last == 1) {
            ans *= 2;
            last = 2;
            i+=2;
        } else {
            ans *= 3;
            last = 2;
            i+=2;
        }
        ans %= MOD;
    }
    cout << ans << endl;
}


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

int main(void){
 
  char S[4];
  scanf("%s",S);
  if(strcmp("ABC", S) == 0){
    printf("ARC\n");
  }
  else if(strcmp("ARC", S) == 0){
    printf("ABC");
  }
  
  return 0;
}

Measured memory_bytes: 1732
n = int(input())
S = input()

l = [0]*n
wl = [0]*n
el = [0]*n

for i in range(n-1):
  if i == 0:
    wl[i+1] = S[i].count("W")
  else:
    wl[i+1] = S[i].count("W")+wl[i]

for i in reversed(range(1,n)):
  if i == n:
    el[i-1] = S[i].count("E")
  else:
    el[i-1] = S[i].count("E")+el[i]
    
for i in range(n):
  l[i] = wl[i] + el[i]
  
print(min(l))

Measured memory_bytes: 38904
N, M = [int(x) for x in input().split()]
MOD = 10**9+7

if max(N, M) - min(N, M) > 1:
    print(0)
    exit()


def floor(n):
    result = n
    for i in range(n-1, 0, -1):
        result *= i
        result %= MOD

    return result


r = floor(max(N, M))
t = floor(min(N, M))

if r == t:
    result = (r * t * 2) % MOD
else:
    result = (r * t) % MOD

print(result)


Measured memory_bytes: 9096
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#include<queue>
#define ll long long
int main()
{
	int n,k,h=0;
	cin>>n>>k;
	int num[n+1];         //n个数据  
	for(int i=1;i<=n;i++)//接受值 
	{
		cin>>num[i];
	}
	for(int i=1;k+i<=n;i++)
	{
		if(num[i]<num[k+i])
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 4400
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int a[N];
int main(void)
{   int n;
    while(scanf("%d",&n)!=EOF)
    {
        for(int i = 1;i <= n;i++)
            scanf("%d",&a[i]);
        int cn = 0;
        for(int i = 1;i < n;i++)
            if(a[i] == i)
            swap(a[i],a[i+1]),cn++;
        if(a[n]==n)
            cn++;
        printf("%d\n",cn);
    }
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int main(int argc, char const *argv[])
{
	int n;
	scanf("%d",&n);

	char str[n];
	scanf("%s",str);

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

	for (int i = 0; i < n; ++i)
	{
		if (str[i]==str[a-1])
		{
			/* code */
		}else{
			str[i]='*';
		}
	}
	printf("%s\n", str);
	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

import static java.util.Comparator.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ======================================================================
	public void solve() {
		int N = ni();
		int M = ni();
		int ans = 0;
		for (int i = 1; i * i <= M; i++) {
			if(M % i == 0) {
				if(i <= M / N)		ans = Math.max(ans, i);
				if(M/i <= M / N)	ans = Math.max(ans, M/i);
			}
		}
		out.println(ans);
    }
    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return sc.nextInt();
    }
    public long nl() {
    	return sc.nextLong();
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] nddi(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll=long long;
using P = pair<int,int>;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(b-a==c-b)cout << "YES" << endl;
    else cout << "NO" << endl;
}


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

 ll dp[1000000];

 //a^n (mod m)
 const long long mod = 1e9+7;
 long long modpow(long long a, long long n) {
     long long res = 1;
     while (n > 0) {
         if (n & 1) res = res * a % mod;
         a = a * a % mod;
         n >>= 1;
     }
     return res;
 }
 
 //mod mでの a の逆元を求める
 long long modinv(long long a) {
     long long b = mod, u = 1, v = 0;
     while (b) {
         long long t = a / b;
         a -= t * b; swap(a, b);
         u -= t * v; swap(u, v);
     }
     u %= mod; 
     if (u < 0) u += mod;
     return u;
 }

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

    ll n,k;
    cin>>n>>k;
    cout << modpow(k,n)<<endl;

}


Measured memory_bytes: 3212
n = int(input())
d = list(map(int , input().split()))
max_d = 0
cnt = [0] * 10**5
for i in d:
    cnt[i] += 1
    max_d = max(i, max_d)
if cnt[0] != 1 or d[0] != 0:
    ans = 0
else:
    ans = 1
    for i in range(1, max_d + 1):
        if cnt[i] == 0:
            ans = 0
            break
        ans *= cnt[i-1] ** cnt[i]
print(ans % 998244353)




Measured memory_bytes: 14396
#include<iostream>
#include<string>
 using namespace std;
     
int main()
{
  string s;
  cin >> s;
     
  if(s.find("AC") == -1)
  {
    cout << "No" << endl;
  }
  else
  {
    cout << "Yes" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a[3];
  int count=0;
  for(int i=0;i<3;i++)
    scanf("%d",&a[i]);
  for(int i=0;i<3;i++){
    for(int j=i+1;j<3;j++){
      if(a[i]==a[j])
        count++;
    }
  }
  if(count==1)
    printf("Yes");
  else
    printf("No");
}


Measured memory_bytes: 1712
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
#define N 1000009
#define LL long long
LL le[N], prime[N];
void init() {
	memset(prime, -1, sizeof(int) * N);
	prime[0] = 0, prime[1] = 0;
	long long j;
	for(long long i = 2;i < N;i++){
		if (!prime[i])
			continue;
		for (j = i * i;j < N;j += i)
			prime[j] = 0;
	}
}
//int solve(long long n, int i) {
//
//}
int main() {
	std::ios::sync_with_stdio(0); std::cin.tie(0);
	long long n, temp;
	LL ans = 0;
	cin >> n;
	temp = n;
	memset(le, 0, sizeof(int) * N);
	//init();
	long long a = sqrt(n), b;
	for (long long i = 2;i * i <= n;i++) {
		//if (n % i == 0 && prime[i] == -1) {
		if (n % i == 0) {
			//b = i;
			while (n % i == 0) {
				le[i]++;
				//b *= i;
				n /= i;
			}
		}
	}
	LL j = 1, t, count = 0;
	for (LL i = 2;i <= a;i++) {
		//if (!prime[i])
		//	continue;
		t = 0, count = 0;
		for (j = 1;j <= le[i];j++) {
			t += j;
			if (t > le[i])
				break;
			count++;
		}
		ans += count;
	}
	if (n != 1)
		ans++;
	cout << ans;
	return 0;
}

Measured memory_bytes: 7100
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
int main()
{
    int a,b,c,n,i;
    scanf("%d",&n);
    for (i=1;i<=n;i++)
    {
        scanf("%d %d %d",&a,&b,&c);
        if ((a*a+b*b==c*c)||(a*a+c*c==b*b)||(b*b+c*c==a*a))
            printf("%s","YES\n");
        else
            printf("%s","NO\n");
    }
    return 0;
}

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

const int MAX_N = (int)110;

int n, t[MAX_N], v[MAX_N];
int up[400 * 100 + 10] = {};
int dp[400 * 100 + 10] = {};

int main(void) {
    // Here your code !
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
      scanf("%d", &t[i]);
    }

    int ind = 0;
    for (int i = 0; i < n; ++i) {
      scanf("%d", &v[i]);
      for (int j = 0; j < 2 * t[i]; ++j) {
        up[ind] = v[i] * 2;
        ind++;
      }
    }

    int tmp;
    for (int i = 0; i < 210; ++i) {
      for (int j = 1; j < ind + 1; ++j) {
        tmp = min({dp[j - 1], dp[j + 1], up[j] - 1, up[j - 1] - 1});
        if (dp[j] <= tmp) dp[j]++;
      }
    }

    double whole = 0;
    for (int i = 0; i < ind + 1; ++i) {
      whole += (dp[i] + dp[i + 1]) * 0.5;
    }

    printf("%f\n", whole * 0.25);

    return 0;
}


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a>b)
        swap(a, b);
    if (a > c)
        swap(a, c);
    if (b > c)
        swap(b, c);
    cout <<a << " " << b <<  " " << c <<endl;
    return 0;
}


Measured memory_bytes: 3132
N, K = map(int, input().split()[:2])
arr = list(map(int, input().split()[:N]))


def pos(X):
    sum = 0
    for i in arr:
        sum += int(i/X)
        if i % X == 0:
            sum -= 1
    return sum <= K


low = 1
high = 10 ** 9
mid = 0
ans = 10**9

while low <= high:
    mid = int((low+high)/2)
    # print(low, mid, high)
    if pos(mid):
        ans = mid
        high = mid-1
    else:
        low = mid+1
    # print(pos(mid))
print(ans)


Measured memory_bytes: 30736
while True:
    a,b,c=input().split()
    a=int(a)
    c=int(c)
    
    if b=="+":
        print(a+c)
    elif b=="-":
        print(a-c)
    elif b=="*":
        print(a*c)
    elif b=="/":
        print(a//c)
    else:
        break


Measured memory_bytes: 5592
S = list(input())
A = list("AKIHABARA")
B = list("AKIHABARA")
j = 0
for i in range(9):
    if j == len(S):
        A[i] = "A"
    elif S[j] == A[i]:
        j += 1
    else:
        A[i] = "A"

if A == B and j == len(S):
    ans = "YES"
else:
    ans = "NO"
print(ans)


Measured memory_bytes: 9068
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC179B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            bool hantei = false;
            int zoro = 0;
            for(int i = 0; i < N; i++)
            {
                string[] DD = Console.ReadLine().Split(' ');
                if (DD[0] == DD[1]) zoro += 1;
                else zoro = 0;
                if (zoro == 3) hantei = true;
                
            }
            if (hantei) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int N;
  cin >> N;
  vector<long long> a(N);
  for (int i = 0; i < N; ++i) cin >> a[i];

  vector<long long> s(N + 1, 0);
  map<long long, long long> nums;
  for (int i = 0; i < N; ++i) s[i + 1] = s[i] + a[i];
  for (int i = 0; i < N + 1; ++i) nums[s[i]]++;

  long long res = 0;
  for (auto it : nums) {
    long long num = it.second;
    res += num * (num - 1) / 2;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 305;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
char s[MAXN];
int n, m, ans, dp[MAXN][MAXN][MAXN];
int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1), read(m);
	for (int i = 1; i <= n; i++)
	for (int j = i; j <= n; j++)
	for (int k = 0; k <= n; k++)
		dp[i][j][k] = m + 1;
	dp[1][n][0] = 0;
	for (int i = 1; i <= n; i++)
	for (int j = n; j >= i; j--)
	for (int k = 0; k <= n; k++) {
		int tmp = dp[i][j][k];
		if (tmp == m + 1) continue;
		chkmin(dp[i + 1][j][k], tmp);
		chkmin(dp[i][j - 1][k], tmp);
		if (i == j) chkmax(ans, 2 * k + 1);
		else {
			int cost = s[i] != s[j];
			if (cost + tmp <= m) {
				chkmin(dp[i + 1][j - 1][k + 1], tmp + cost);
				chkmax(ans, 2 * k + 2);
			}
		}
	}
	writeln(ans);
	return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2> 
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main(){
	int n, gw;
	cin >>n >>gw;
	VI v(n), w(n);
	rep(i, n) cin >>v[i] >>w[i];
	
	VI dp( gw+ 50, -1);
	dp[0] = 0;
	rep(i,n) repr(j, gw, 0) if(dp[j] >=0){
		if(j + w[i] <= gw)  dp[j+w[i]] = max(dp[j+w[i]], dp[j] + v[i]);
	}

	int ans = *max_element(all(dp));
	cout << ans <<"\n";
	//for(auto x :dp) printf("%d, ",x); puts("");
	return 0;
}




Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);
#define mp make_pair
#define pb push_back

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

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template< typename S, typename T >
inline void chmax(S &a, const T &b) { if(a < b) a = b; }
 
template< typename S, typename T >
inline void chmin(S &a, const T &b) { if(a > b) a = b; }
 

//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
ll modinv(ll a, ll m) {
	if(m==0)return (ll)1;
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


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

int main() {

ll n;
cin>>n;

vector<P> vec{};
vector<P> vec2{};
rep(i,n){
	ll a,b;
	cin>>a>>b;
	vec.push_back(mp(a,b));
	vec2.pb(mp(-(b),a));
}

sort(ALL(vec));
sort(ALL(vec2));

ll ans=0;
ll t1=0;
ll f1=0;
ll t2=0;
ll f2=0;
if(n%2==1){t2=-1; f2=-1;
t1=vec[n/2].first;
f1=vec2[n/2].first;
f1=-f1;
cout<<f1-t1+1<<endl;
return 0;
}

else{
	t1=vec[n/2-1].first;
f1=vec2[n/2-1].first;
f1=-f1;
t2=vec[n/2].first;
f2=vec2[n/2].first;
f2=-f2;
ans=f1+f2-t1-t2;
ans=ans+1;
cout<<ans<<endl;
return 0;
}



}




Measured memory_bytes: 9836