akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
using namespace std;

const int Max = 45;

int FibArray[Max];

int fib(int n){
    if(n == 0) return 1;
    if(n == 1) return 1;
    
    if(FibArray[n] != 0) return FibArray[n];
    else{
        int val = fib(n-1) + fib(n-2);
        FibArray[n] = val;
        return val;
    }
}

int main(){
    int index;
    scanf("%d", &index);

    printf("%d\n", fib(index));
    return 0;
}


Measured memory_bytes: 3232
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner tan = new Scanner(System.in);
        int n,a=0,p=0;
        n = tan.nextInt();
        while(n!=0){
            a=n%10;
            n=n/10;
            if(a==7){
                p++;
                break;
            }
        }
        if(p==0)
            System.out.println("No");
        else
            System.out.println("Yes");
    }
}


Measured memory_bytes: 35772
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int ar[200005];
int pre[200005];
int32_t main(){
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		cin>>ar[i];
		pre[i]=pre[i-1]+ar[i];
	}
	int ans = 1e14;
	for(int i=1;i<=n;i++){
		ans = min(ans,abs(pre[n]-pre[i]-pre[i]));
	}
	cout<<ans;
}


Measured memory_bytes: 3328
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var k = int.Parse(Console.ReadLine());

        var s = "";
        for (int i = 0; i < k; ++i)
        {
            s += "ACL";
        }

        Console.WriteLine(s);
    }
}


Measured memory_bytes: 27324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<tuple<int, int, int>> data(M);
    rep(0, i, M)
    {
        int p, y;
        cin >> p >> y;
        data[i] = make_tuple(y, p, i);
    }
    sort(all(data));
    vector<int> city(N);
    vector<P> pair(M);
    rep(0, i, M)
    {
        int y, p, idx;
        tie(y, p, idx) = data[i];
        city[p]++;
        pair[idx] = make_pair(p, city[p]);
    }
    for (int i = 0; i < M; ++i)
    {
        // setwで文字数、setfillで埋める文字を指定
        cout << setw(6) << setfill('0') << pair[i].first;
        cout << setw(6) << setfill('0') << pair[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 3840
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>

int main() {
  char buf[262144];
  scanf("%s", buf);
  std::string s=buf;
  scanf("%s", buf);
  std::string t=buf;

  std::vector<std::vector<int>> vs(26), vt(26);
  for (size_t i=0; i<s.size(); ++i) {
    vs[s[i]-'a'].push_back(i);
    vt[t[i]-'a'].push_back(i);
  }

  std::sort(vs.begin(), vs.end());
  std::sort(vt.begin(), vt.end());

  // for (size_t i=0; i<26; ++i)
  //   for (size_t j=0; j<vs[i].size(); ++j)
  //     fprintf(stderr, "%d%c", vs[i][j], j+1<vs[i].size()? ' ':'\n');

  printf("%s\n", vs==vt? "Yes":"No");
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
#define fi first
#define se second
#define upb upper_bound
#define lwb lower_bound
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y){
    if(y<=0) return 1;
    ll ans = 1;
    x %= mod;
    while(y){
        if(y&1)
            ans = (x * ans) % mod;
        x = (x * x) % mod;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = (a - b); if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = (a + b); if(c >= mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

//------------------------------------------------------------------------------------------

const ll N = 2e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

ll n, k;
ll a[N];

bool f(ll x){
	int c=0;
	for(int i=0;i<n;i++){
		if(a[i]%x==0){
			c+=a[i]/x-1;
		}
		else c+=a[i]/x;
	}
	return c<=k;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<<fixed<<setprecision(10);

	
	cin>>n>>k;
	ll ma=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		ma=max(ma, a[i]);
	}
	ll l=1, r=ma;
	ll ans=0;
	while(l<=r){
		ll m = l+(r-l)/2;
		if(f(m)){
			ans = m;
			r = m-1;
		}
		else l = m+1;
	}
	cout<<ans;

    return 0;
}


Measured memory_bytes: 5172
n = int(input())
p = list(map(int,input().split()))
q = list(range(1, n+1)) #正しい昇順リスト
c = 0

if p == q:
  print("YES")

else:
  for i in range(n): #違う箇所の数を探す
    if p[i] != q[i]: #違ったら
      c = c + 1 #cを+1
    if c > 2: #違う箇所が2を超えたら見込みがないので抜ける
      break
  if c == 2: #2なら入れ替え1回で直る
    print("YES")
  else: #それ以外なら無理
    print("NO")

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

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef long long ll;
typedef pair<long long, long long> l4;
typedef vector<long long> vll;
typedef double db;
typedef vector<double> vdb;
typedef pair<double, double> dd;
typedef set<int> si;
typedef set<long long> sll;
#define fi first
#define se second
#define matrix(a) vector< vector<a> >
#define sz(a) int((a).size()) 
#define lop(i,a,b) for (int i=a; i<=b; i++)
#define vlop(i,v) lop(i,0,sz(v)-1)
#define vlop1(i,v) lop(i,1,sz(v)-1)
#define rlop(i,a,b) for (int i=b; i>=a; i--)
#define vrlop(i,v) rlop(i,0,sz(v)-1)
#define vrlop1(i,v) rlop(i,1,sz(v)-1)
#define printv(i,v) vlop(i,v)cout<<v[i]<<" "
#define printv1(i,v) vlop1(i,v)cout<<v[i]<<" "
#define all(s) (s).begin(),(s).end()
#define pb push_back
#define enter cout<<'\n'
#define lb(i,v) int(lower_bound(all(v),i)-v.begin())
#define ub(i,v) int(upper_bound(all(v),i)-v.begin())

int main() {
	ll n=1;
	string ans;
	while(n<=1e9){
		cout<<"? "<<n<<'\n';
		fflush(stdout);
		cin>>ans;
		if(ans[0]=='N')break;
		n*=10;
	}
	if(n==1e10){
		n=1;
		while(n<=1e9){
		cout<<"? "<<n+1<<'\n';
		fflush(stdout);
		cin>>ans;
		if(ans[0]=='Y')break;
		n*=10;
	}
	cout<<"! "<<n;
	}
	else{
	    ll l=n/10+1,u=n-1,med;
	    while(l<u){
	    	med=(l+u)/2;
	    	cout<<"? "<<med*10<<'\n';
	    	fflush(stdout);
	    	cin>>ans;
	    	if(ans[0]=='Y')u=med;
	    	else l=med+1;
	    }
	    cout<<"! "<<l;
	}
	return 0;
}

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

int main () {
  int H , W ;
  cin >> H >> W ;
  
  for (int i = 0 ; i < W+2 ; i++) {
    cout << "#" ;
  }
  cout << endl;
  
  for (int k = 0 ; k<H ; k++){
    string vec;
    cout << "#" ;
    cin >> vec ;
    cout << vec ;
  cout << "#" << endl;  
  }
  
  for (int i = 0 ; i < W+2 ; i++) {
    cout << "#" ;
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
#define ll long long
//---------------------------

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int N;cin>>N;
  int a = N % 3;
  P((N-a) / 3);
  return 0;
}


Measured memory_bytes: 256
function main(input) {
  input = input.split('\n');
  var tmp = input[0].split(' ');

  var N = Number(tmp[0]);
  var A = Number(tmp[1]);

  var x = [0];
  x = x.concat(input[1].split(' ').map(Number));

  var dp = new Array(N + 1);
  for (var i = 0; i <= N; ++i) {
    dp[i] = new Array(N + 1);
    for (var j = 0; j <= N; ++j) {
      dp[i][j] = new Array(A * N + 1).fill(0);
    }
  }

  for (var i = 0; i < N; ++i) dp[i][0][0] = 1;

  for (var i = 1; i <= N; ++i) {
    for (var j = 1; j <= i; ++j) {
      for (var k = 1; k <= A * N; ++k) {
        if (k < x[i]) {
          dp[i][j][k] = dp[i - 1][j][k];
        } else {
          dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]];
        }
      }
    }
  }

  var ans = 0;
  for (var j = 1; j <= N; ++j) {
    ans += dp[N][j][j * A];
  }

  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 102448
package main

import (
	"fmt"
	"math"
)

func main() {
	var x, a, b int
	fmt.Scan(&x, &a, &b)
	da := int(math.Abs(float64(x - a)))
	db := int(math.Abs(float64(x - b)))
	if da < db {
		fmt.Println("A")
	} else {
		fmt.Println("B")
	}
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

int main() {
  int N;
  intmax_t A, B;
  scanf("%d %jd %jd", &N, &A, &B);

  std::vector<intmax_t> X(N);
  for (int i=0; i<N; ++i)
    scanf("%jd", &X[i]);

  intmax_t res=0;
  for (int i=1; i<N; ++i)
    res += std::min((X[i]-X[i-1])*A, B);

  printf("%jd\n", res); 
}


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

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define sz(s) (int)s.size()

int dp[55][3][3];
const int MOD = 1000000007;

int main() {
    int n;
    string s, f;
    cin >> n >> s >> f;
    int start = 1;
    if (s[0] == f[0]) {
        rep(i, 0, 3) dp[0][i][i] = 1;
    } else {
        rep(i, 0, 3) rep(j, 0, 3) if (i != j) dp[1][i][j] = 1;
        start = 2;
    }
    for (int i = start; i < n;) {
        if (s[i] == f[i]) {
            if (s[i - 1] == f[i - 1]) {
                rep(c1, 0, 3) rep(c2, 0, 3) if (c1 != c2) {
                    (dp[i][c1][c1] += dp[i - 1][c2][c2]) %= MOD;
                }
            } else {
                rep(c, 0, 3)
                rep(c1, 0, 3) rep(c2, 0, 3) if (c != c1 && c != c2 && c1 != c2)
                    (dp[i][c][c] += dp[i - 1][c1][c2]) %= MOD;
            }
            ++i;
        } else {
            if (s[i - 1] == f[i - 1]) {
                rep(c1, 0, 3) rep(c2, 0, 3) rep(c, 0, 3) if (c1 != c2 && c1 != c && c2 != c)
                    (dp[i + 1][c1][c2] += dp[i - 1][c][c]) %= MOD;
            } else {
                rep(c1, 0, 3) rep(c2, 0, 3)
                rep(p1, 0, 3) rep(p2, 0, 3)
                if (c1 != p1 && c2 != p2 && c1 != c2 && p1 != p2)
                    (dp[i + 1][c1][c2] += dp[i - 1][p1][p2]) %= MOD;
            }
            i += 2;
        }
    }
    int ans = 0;
    if (s[n - 1] == f[n - 1]) {
        rep(c, 0, 3) (ans += dp[n - 1][c][c]) %= MOD;
    } else {
        rep(c1, 0, 3) rep(c2, 0, 3) (ans += dp[n - 1][c1][c2]) %= MOD;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
k,x = map(int,input().split())
li = []

for i in range(k):
  li.append(x-k+i+1)
  
for i in range(1,k):
  li.append(x+i)
  
for i in range(len(li)-1):
  print(li[i],end=" ")

if len(li) == 1:
  print(x)
else:
  print(li[i+1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
// x^y≡x^(y%(p-1))mod p
// but there is a condition that x needs to be coprime to p
///assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set; */
typedef long long int ll;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
#define  pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define tests() int test_cases ; cin >> test_cases ; while(test_cases--)
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define MAXN 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define sp " "
#define nl '\n'
#define MS(x,y) fill_n(*x, sizeof x / sizeof **x, y);
#define mem(x,y) memset(x,y,sizeof(x));
#define INF 1000000000000000000
#define IO                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);
#define debug(x) cerr << (#x) << " is " << (x) << endl;

#ifndef ONLINE_JUDGE
#define cerr if(true)cerr
#endif

template<int D, typename T>
struct Vec : public vector<Vec<D - 1, T>> {
static_assert(D >= 1, "Vector dimension must be greater than zero!");
template<typename... Args>
	Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {
	}
};
template<typename T>
struct Vec<1, T> : public vector<T> {
	Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {
	}
};

ll power(ll x, ll y,ll p)
{
    ll res = 1;     // Initialize result
    x = x % p;
    if (y==0)return 1;
    if(x==0)return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; // y = y/2
        x = (x*x) % p;  // Change x to x^2
    }
    return res;
}
int gcd(int a, int b) { if (a == 0)return b;return gcd(b % a, a);}

ll inv(ll a,ll p){return power(a,p-2,p);}

ll p = 998244353;

void solve(){
    ll n,s;
    cin>>n>>s;
    vll a(n+1);
    f(i,0,n){
        cin>>a[i+1];
    }
    Vec<2,ll> dp(n+1,s+1,0);
    dp[0][0] = power(2,n,p);
    // deb(dp[0][0])
    ll x = inv(2,p);
    fo(i,1,n){
        fo(j,0,s){
            (dp[i][j]+=dp[i-1][j])%=p;
            if (j-a[i]>=0)
            {
                (dp[i][j]+=dp[i-1][j-a[i]]*x)%=p;
            }
        }
    }
    cout<<dp[n][s]<<endl;
    return ;
}
int main()

{
    IO;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    // #endif
    int T=1;
	// cin >> T;
	f(c,0,T){
		solve();
	}
    return 0;
}// make_pair make_tuple  tuple<int,int,int> continue resize insert count size else true isValid second first false erase double priority_queue


Measured memory_bytes: 73640
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in); 
		int a, b, c;
		int C = 0;
		
		a = scan.nextInt();
		b = scan.nextInt();
		c = scan.nextInt();
		
		for(int i = a; i <= b; i++){
			
			if(c % i == 0){
				C++;
			}
		}
			
	System.out.println(C);
		
	
	}

}

Measured memory_bytes: 26392
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std;

const int N=200010,mod=1e9+7;
int n,ans,cnt[27];
char s[N];

int main(){
	scanf("%d%s",&n,s+1); ans=1;
	rep(i,1,n) cnt[s[i]-'a']++;
	rep(i,0,25) ans=1ll*ans*(cnt[i]+1)%mod;
	printf("%d\n",(ans-1+mod)%mod);
	return 0;
}

Measured memory_bytes: 384
n = gets.chomp.to_i
list = []
n.times do
  list << gets.chomp
end
ac = list.count("AC")
wa = list.count("WA")
tle = list.count("TLE")
re = list.count("RE")
puts "AC x #{ac}"
puts "WA x #{wa}"
puts "TLE x #{tle}"
puts "RE x #{re}"


Measured memory_bytes: 20648
#include<stdio.h>

main(){
  int n1, count = 0;
  scanf("%d", &n1);

  int i, j, array1[n1];
  for( i = 0; i < n1; i++){
    scanf("%d", &array1[i]);
  }
  int n2;
  scanf("%d", &n2);
  int array2[n2+1];
  for( i = 0; i < n2; i++){
    scanf("%d", &array2[i]);
  }
  
  for( i = 0; i < n2; i++){
    for( j = 0; j < n1; j++){
      if( array2[i] == array1[j]){
	count++;
	break;
      }
    }
  }
  
  printf("%d\n", count);
  
  return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define nl cout<<"\n"
#define endl "\n"
#define ll long long
#define ld long double
#define all(c) (c).begin(),(c).end()
#define trav(a,x) for(auto a = x.begin() ; a != x.end() ; a++)
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define f first
#define s second

inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b) {if(b==0) return a; a%=b;return gcd(b,a);}
ll power(ll x, ll y){if(y == 0) return 1; ll a = power(x,y/2);if (y % 2 == 0) return a * a; else return x * a * a; }
ll powermod(ll x, ll ex , ll md) {ll ans = 1ll;while (ex > 0) {if (ex & 1ll) ans = (ans * x) % md; ex >>= 1ll;x = (x * x) % md;}return ans;}

const ll inf = 1e18 + 9;
const ll mod = 1e9 + 7;
const ld PI = acos(-1);
const ld eps = 1e-9;

const ll N = 2e5 + 1;
ll n , m ,k , pfx1[N] , pfx2[N];
vll d1;
void solve(){
    cin >> n >> m >> k;
    rep(i , n){
        ll x ;
        cin >> x;
        if(i == 0) pfx1[i] = x;
        else pfx1[i] = pfx1[i - 1] + x;
        d1.pb(pfx1[i]);
    }
    rep(i , m){
        ll x ;
        cin >> x;
        if(i == 0) pfx2[i] = x;
        else pfx2[i] = pfx2[i - 1] + x;
    }
    ll ans = 0;
    auto it = ub(all(d1) , k);
    if(it != d1.begin()){
        it--;
        ans = it - d1.begin() + 1;
    }
    for(ll i = 0 ; i < m ; i++){
        ll t1 = pfx2[i];
        t1 = k - pfx2[i];
        if(t1 >= 0){
            auto it = ub(all(d1) , t1);
            if(it != d1.begin()){
                it--;
                ans = max(ans , i + 1 + (it - d1.begin() + 1) );
            }
            else ans = max(ans , i + 1);
        }
    }
    cout << ans << endl;
}
int main(){
    IOS;
    cout << fixed << setprecision(20);
    ll NTC=1;
    // cin>>NTC;
    ll PTC=0;
    while(PTC++<NTC){
        // cout<<"Case #"<<PTC<<":"<<' ';
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 8172
def readinput():
    n=int(input())
    return n

def main(n):
    if n==2:
        return 2
    
    nmax=2*10**5
    isprime=[1]*(nmax)
    isprime[0]=0
    isprime[1]=0
    m=4
    while(m<nmax):
        isprime[m]=0
        m+=2
    
    for i in range(3,nmax,2):
        if isprime[i]==0:
            continue
        else:
            if i>=n:
                return i
        m=2*i
        while(m<nmax):
            isprime[m]=0
            m+=i
    return -1

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


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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int 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 all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int n;
vector<int> a;

signed main()
{
    cin >> n;
    a.resize(n);
    rep(i, n)
    {
        cin >> a[i];
    }
    deque<int> index;

    index.pb(a[0]);

    rep(i, n - 1)
    {
        if (index[0] >= a[i + 1])
        {
            index.push_front(a[i + 1]);
            continue;
        }

        auto itr = lower_bound(all(index), a[i + 1]);
        itr--;
        *itr = a[i + 1];
    }

    cout << index.size() << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > piii;
#define pb push_back
#define NeedForSpeed ios_base::sync_with_stdio(0), cin.tie(0)
#define PI acos(-1)
#define all(c) c.begin(), c.end()
#define SET(x, y) memset((x), y, sizeof(x))
const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const ll INF64 = 1e18;

template <typename T>
string to_string(const vector<T> &v) {
    string ret = "<";
    for (auto it : v) {
        ret += to_string(it) + ", ";
    }
    ret.pop_back(); ret.pop_back();
    ret += ">";
    return ret;
}

void debug_print() { cerr << endl; }

template <typename T, typename ...U>
void debug_print(T t, U... u) {
    cerr << " " << to_string(t);
    debug_print(u...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_print(__VA_ARGS__)
const int N = 1e5 + 5;

int main() {
    ll n, k;
    cin >> n >> k;
    n %= k;
    cout << min(n, k - n) << endl;
    return 0;
}

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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF 1<<30
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME (1ll<<61)-1

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

template<class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline void outmat(T& a, int y, int x) {
	for(int i=0; i<y; i++) {
		for(int j=0; j<x; j++) cout<<a[i][j]<<" ";
		cout<<endl;
	}
}

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

ll binpow(ll a, ll ex, ll p) { //繰り返し二乗法
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int N,M,K;
llvec A,B;

void input() {
	cin>>N>>M>>K;
	A.resize(N+1);
	A[0]=0ll;
	for(int i=1; i<=N; i++) {
		int a; cin>>a;
		A[i]=A[i-1]+a;
	}
	B.resize(M+1);
	B[0]=0;
	for(int i=1; i<=M; i++) {
		int b; cin>>b;
		B[i]=B[i-1]+b;
	}
}

void solve() {
	int res=0;
	int bpos=M;
	for(int i=0; i<=N && A[i]<=K; i++) {
		for(int j=bpos; j>=0; j--) {
			if(A[i]+B[j]>K) continue;
			else {
				bpos=j;
				chmax(res,i+j);
				break;
			}
		}
	}
	cout<<res<<endl;
}

int main() {
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 6408
n=int(input())
a=list(map(int,input().split()))
a.sort()
data=[]
lst=[a[0]]
num=1
for i in range(1,n):
    if a[i]==a[i-1]:
        num+=1
    else:
        data.append(num)
        lst.append(a[i])
        num=1
data.append(num)
if len(data)==3 and data[0]==data[1]==data[2]:
    if lst[0]^lst[1]==lst[2]:
        print("Yes")
    else:
        print("No")
else:
    if len(data)==1 and lst[0]==0:
        print("Yes")
    elif len(data)==2 and data[0]*2==data[1]:
        print("Yes")
    else:
        print("No")

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

int main()
{
    string s;
    cin >> s;
    int a = 0,b = 0,i;
    for(i = 0;i < s.size();++i){
        if(s.at(i) == '0'){
            ++a;
        }else{
            ++b;
        }
    }
    cout << 2*min(a,b) << endl;
    return 0;
}

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

using namespace std;
#define int long long
#define pb push_back
template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a, b;
	cin >> a >> b;
	int s = a + b;
	if (s % 2 == 1)
		cout << "IMPOSSIBLE";
	else
		cout << s / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N;
int A[1123][1123];

int main() {

	scanf("%d", &N);
	rep(i, N) rep(j, N - 1) {
		scanf("%d", &A[i][j]);
		A[i][j]--;
	}

	int cur[1123] = {};

	int cnt = N * (N - 1) / 2;
	int ans = 0;
	while (cnt > 0) {
		bool f = true;
		vector<int> addlist;
		rep(i, N) {
			if (cur[i] < N - 1) {
				int t = A[i][cur[i]];
				if (t > i && A[t][cur[t]] == i) {
					addlist.push_back(i);
					addlist.push_back(t);
					f = false;
					cnt--;
				}
			}
		}
		for (auto al : addlist) cur[al]++;
		ans++;
		if (f) {
			printf("-1\n");
			return 0;
		}
	}

	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 4608
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;

int n, l, r;
long long a[55];

long long c(int y, int x) {
	long long ans = 1LL;
	for(int i=y;i>x;i--) {
		ans = ans * i;
		ans = ans/(y-i+1);
	}
	return ans;
}

int main() {
	cin>>n>>l>>r;
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	
	long long s=0;
	for(int i=n-l;i<n;i++)
		s+=a[i];
	printf("%.10lf\n", 1.*s/l);
	fflush(stdout);
	
	int x = 1;
	for(int i=n-l+1;i<n && a[i]==a[i-1];i++) x++;
	int y = x;
	for(int i=n-l;i>0 && a[i]==a[i-1];i--) y++;
	
	long long ans = 0LL;
	if(a[n-1] != a[n-l]) ans = c(y, x);
	else {
		for(int i=x;i<=min(y, r);i++)
			ans += c(y, i);
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100000

int a,A[N];

int se(int rig,int A[],int k);
int main(){
 
  int b,bValue;
  int i,c=0;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&b);
  for(i=0;i<b;i++){
    scanf("%d",&bValue);
    if(se(a,A,bValue)==1)c++;
  }

  printf("%d\n",c);
  return 0;
}
int se(int rig,int A[],int k){
  int lef=0;
  int mid=0;
  while(lef<rig){
    mid=(lef+rig)/2;
    if(A[mid]>k)rig=mid;
    else if(A[mid]<k)lef=mid+1; 
    else return 1;
  }
  return 0;
}



Measured memory_bytes: 2084
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    ll n;cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    rep(i,n){
        a[i]-=(i+1);
    }
    sort(a.begin(),a.end());
    ll all=(n%2==0)? (a[n/2-1]+a[n/2])/2:a[n/2];
    ll res=0;
    rep(i,n){
        ll buf=abs(a[i]-all);
        res+=buf;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 1792
#[allow(dead_code)]
mod scanner {
    use std::io::StdinLock;
    use std::str::FromStr;
    use std::io::BufRead;
    pub struct Scanner<'a> {
        stdin: StdinLock<'a>,
        token: Vec<String>,
    }
    impl<'a> Scanner<'a> {
        pub fn new(stdin: StdinLock) -> Scanner {
            Scanner {
                stdin: stdin,
                token: vec![],
            }
        }
        pub fn read<T: FromStr>(&mut self) -> T {
            loop {
                if let Some(token) = self.token.pop() {
                    return token.parse().ok().expect("Scanner : Parse Error");
                }
                let mut s = String::new();
                self.stdin.read_line(&mut s).unwrap();
                self.token = s.trim().split_whitespace().rev().map(String::from).collect();
            }
        }
    }
}

fn main() {
    let stdin = std::io::stdin();
    let sc = scanner::Scanner::new(stdin.lock());
    run(sc);
}

use std::cmp::{min, max};

fn run(mut sc: scanner::Scanner) {
    let h: i64 = sc.read();
    let w: i64 = sc.read();
    if h % 3 == 0 || w % 3 == 0 {
        println!("0");
        return;
    }
    let mut ans = min(h, w);
    for &(h, w) in [(h, w), (w, h)].iter() {
        for i in 1..h {
            let a = w * i;
            let b = (w / 2) * (h - i);
            let c = h * w - a - b;
            ans = min(ans, max(a, max(b, c)) - min(a, min(b, c)));
        }
    }
    println!("{}", ans);
}


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

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

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

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

signed main() {
  int a, b, c;
  cin >> a >> b >> c;
  rep(i, 1, 1000) {
    if(a * i % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end());
#define MIN(vec) *std::min_element(vec.begin(), vec.end());
#define MAXI(vec)                                                              \
  std::distance(vec.begin(), *std::max_element(vec.begin(), vec.end()));
#define MINI(vec)                                                              \
  std::distance(vec.begin(), *std::min_element(vec.begin(), vec.end()));
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define MATMUL(a, b, c)                                                        \
  REP(i, a.size())                                                             \
  REP(j, b[0].size()) REP(k, a[0].size()) c[i][j] ^= a[i][k] & b[k][j];
#define CLA2(a) REP(i, a.size()) REP(j, a[0].size()) a[i][j] = 0;

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

int main() {
  ll N, K;
  vector<ll> A;
  cin >> N >> K;
  ll po = (N / K);
  if (K % 2 == 1) {
    cout << (po * po * po) << endl;
  } else if (N % K >= K / 2) {
    ll bo = po + 1;
    cout << (po * po * po) + (bo * bo * bo) << endl;
  } else {
    cout << 2 * (po * po * po) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int gets(){
  int res = 0;
  REP(i, 16){
    int c; cin>>c;
    res += c << i;
  }
  return res;
}


int main(){
  int N, C;
  while(cin>>N>>C && N){
    vector<int> a(N);
    vector<int> b(C);
    REP(i, N) a[i] = gets();
    REP(i, C) b[i] = gets();
    int dp[31][1<<16] = {};
    REP(i, 31)REP(j, 1<<16) dp[i][j] = -INF;
    dp[0][0] = 0;
    int ans = 0;
    REP(i, N)REP(S, 1<<16)if(dp[i][S] >= 0)REP(j, C){
      int S2 = S | a[i];
      int NS = S2 & (~b[j]);
      int pt = __builtin_popcount(S2 & b[j]);
      dp[i + 1][NS] = max(dp[i + 1][NS], dp[i][S] + pt);
      //printf("dp[%d][%d] <- %d + %d\n", i + 1, NS, dp[i][S], pt);
      ans = max(ans, dp[i + 1][NS]);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 9140
#include<bits/stdc++.h>
typedef long long ll;

using namespace std;
ll n, a, b, cnt;

int main(){
	cin >> n >> a >> b;
	if(a > b){
		cout << 0;
		return 0;
	}
	
	if(a < b && n == 1){
		cout << 0;
		return 0;
	}
	if(a == b){
		cout << 1;
		return 0;
	}
		cout << (b - a) * (n - 2ll) + 1;
return 0;
}


Measured memory_bytes: 256
N=int(input())
alist=list(map(int,input().split()))
#print(alist)

dic_a={}
for a in alist:
  if not a in dic_a:
    dic_a[a]=1
  else:
    dic_a[a]+=1
    
all_pair=0
for val in dic_a.values():
  all_pair+=val*(val-1)//2

#print(dic_a,all_pair)
dic_answer={}
for a in alist:
  if a in dic_answer:
    print(dic_answer[a])
    continue
  
  now=dic_a[a]
  kill=now*(now-1)//2-(now-1)*(now-2)//2
  answer=all_pair-kill
  
  print(answer)
  dic_answer[a]=answer  

Measured memory_bytes: 35576
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_a_genius = 0; ngtkana_is_a_genius < int(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (int i = int(begin); (i) < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

void err() { std::cout << "Impossible" << std::endl; exit(0); }
#define require(exp) do { if (!(exp)) { err(); } } while(false)

bool query(int a, int b) {
  std::cout << "? " << a << " " << b << std::endl;
  char c; std::cin >> c;
  return c == 'Y';
}

void answer(std::vector< int > ans) {
  std::cout << "!" << " ";
  for (int x : ans) std::cout << x;
  std::cout << std::endl;
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int A, B; std::cin >> A >> B;
  if (A <= B) err();
  int n = A + B;
  std::vector< int > chain;
  rep(i,0,n) {
    if (chain.empty()) {
      chain.emplace_back(i);
      continue;
    }
    bool res = query(chain.back(), i);
    if (res) {
      chain.emplace_back(i);
    } else {
      A--,B--;
      chain.pop_back();
    }
  }
  assert((B+1) <= (int)chain.size());
  int pivot = chain.back();
  std::vector< int > ans(n, true);
  rep(i,0,n) {
    if (i == pivot) continue;
    ans.at(i) = query(pivot, i);
  }
  answer(ans);
  return 0;
}

Measured memory_bytes: 724
a,b,c,x,y = gets.chomp.split.map(&:to_i)
ans = 10 ** 18
0.upto([x,y].max) do |i|
  sum = a * [x-i, 0].max + b * [y-i ,0].max + (c * i * 2)
  ans = sum if ans > sum
end

puts ans

Measured memory_bytes: 1916
#include <iostream>
#include <vector>
#include <set>

using namespace std;

#define REP(i,a,b) for (int i = a; i <= b; i++)

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    REP(i, 0, n-1) {
        cin >> v.at(i);
    }

    cout << '\n';
    
    bool flag=true;
    int ind=0;
    set<int> went{};

    while (flag) {

        int tmp;
        tmp = v.at(ind);
        if (went.count(tmp)) {
            cout << "-1";
            return 0;
        }
        went.insert(tmp);

        if (tmp == 2) {
            cout << went.size();
            return 0;
        }
        ind = tmp-1;
    }
}

Measured memory_bytes: 8160
import sys
input = lambda: sys.stdin.readline().rstrip()
 
h,w=map(int,input().split())
a=[]
for _ in range(h):
    a.append(list(map(int,input().split())))
ans = []
flag = 1
for i in range(h):
    if flag:
        for j in range(w):
            if j == w - 1:
                flag ^= 1
                if i != h - 1 and a[i][j] % 2 == 1: 
                    ans.append([i + 1, j + 1, i + 2, j + 1])
                    a[i + 1][j] += 1
            elif a[i][j] % 2 == 1:
                ans.append([i + 1, j + 1, i + 1, j + 2])
                a[i][j + 1] += 1
    else:
        for j in range(w - 1, -1, -1):
            if j == 0:
                flag ^= 1
                if i != h - 1 and a[i][j] % 2 == 1:
                    ans.append([i + 1, j + 1, i + 2, j + 1])
                    a[i + 1][j] += 1
            elif a[i][j] % 2 == 1:
                ans.append([i + 1, j + 1, i + 1, j])
                a[i][j - 1] += 1
print(len(ans))
for i in ans:
    print(*i)


Measured memory_bytes: 30276
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> void chmin(T& t, const U& u){if(t>u)t=u;}
template<typename T,typename U> void chmax(T& t, const U& u){if(t<u)t=u;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  int n;cin>>n;
  rep(i,0,100000){
      if(i*108/100==n){
          cout<<i<<endl;
          return 0;
      }
  }
  cout<<":("<<endl;

}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 256
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<29
lINF = 1<<35

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

def main():
    a,b = input().split()
    a = int(a)
    b = int(float(b)*1000)
    print(a*b//1000)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 9204
function Main(input) {
	input = input.split("\n");
    a = input[1].split(" ");

    const N = parseInt(input[0]);
    var n = 0;

    for (let i=1; i<(N+1) ; i++) {

        if(i%2 == 1) {

            var tmp = parseInt(a[i-1]);

            if (tmp%2 == 1) {

                n++;

            }
        }
    }

    console.log( '%d', n);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29672
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <math.h>
#include <unordered_map>
#include <numeric>
#include <sstream>
using namespace std;

int main()
{
	int a,b,c,ans=0;

	std::cin >> a >> b >> c;

	while(((a+b+1)>0 && c>0) || b>0){
		if(c>0){
			c--;
			ans++;
		}

		if(b>0){
			b--;
			ans++;
		}else{
			a--;
		}
	}

	std::cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"


int main() {
	int N; cin >> N;
	string starts;
	for (int i = 0; i < N; ++i) {
		int a; cin >> a;
		a--;
		starts.push_back(a + '0');
	}
	string goals; 
	for (int i = 0; i < N; ++i) {
		goals.push_back(i + '0');
	}
	vector < vector<string>>fromstarts(5);
	fromstarts[0].emplace_back(starts);
	vector< vector<string>>fromgoals(5);
	fromgoals[0].emplace_back(goals);
	for (int i = 0; i < 4; ++i) {
		vector<string>aset;
		for (auto v : fromstarts[i]) {
			for (int l = 0; l < N; ++l) {
				for (int r = l+2; r <= N; ++r) {
					string rev = v.substr(l, r - l);
					reverse(rev.begin(), rev.end());
					string next = v.substr(0, l) + rev + (v.substr(r, N - r));
					aset.emplace_back(next);
				}
			}
		}
		sort(aset.begin(), aset.end());
		aset.erase(unique(aset.begin(), aset.end()), aset.end());
		fromstarts[i + 1] = aset;
	}
	for (int i = 0; i < 4; ++i) {
		vector<string>aset;
		for (auto v : fromgoals[i]) {
			for (int l = 0; l < N; ++l) {
				for (int r = l + 2; r <= N; ++r) {
					string rev = v.substr(l, r - l);
					reverse(rev.begin(), rev.end());
					string next = v.substr(0, l) + rev + (v.substr(r, N - r));
					aset.emplace_back(next);
				}
			}
		}
		sort(aset.begin(), aset.end());
		aset.erase(unique(aset.begin(), aset.end()), aset.end());
		fromgoals[i + 1] = aset;
	}
	int ans = 9;
	for (int s = 0; s < 4; ++s) {
		for (int t = 0; t < 4; ++t) {
			vector<string>sames;
			set_intersection(fromstarts[s].begin(), fromstarts[s].end(), fromgoals[t].begin(), fromgoals[t].end(), inserter(sames, sames.end()));
			if (!sames.empty()) {
				ans = min(ans, s+t);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;

typedef struct{
	int index, num;
}data;

bool asc(const data &x, const data &y){
	return x.num < y.num;
}

int main(){
	int n; cin >> n;
	vector<data> d; int v[n];
	Rep(i, n){
		int t; cin >> t;
		d.pb((data){i, t});
	}
	sort(d.begin(), d.end(), asc);
	int a = d[(n/2)-1].num, b = d[n/2].num;
	Rep(i, n){
		if(i < (n/2)){
			v[d[i].index] = b;
		}else{
			v[d[i].index] = a;
		}
	}
	Rep(i, n){
		cout << v[i] << endl;
	}
	return 0;
}

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

int main(){
  int N,M,K;
  cin >> N >> M >> K;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=M;j++){
      if(i*(M-j)+j*(N-i)==K){cout << "Yes" << endl; return 0;}
    }
  }
  cout << "No" << endl;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

using ll = long long;
using P = pair<int, int>;

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

int main(int, char**)
{
    int n;
    cin >> n;

    vector<ll> a(n);
    rep(i,n) {
        cin >> a[i];
        if (a[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    ll ans = 1;
    rep(i,n) {
        if (ans > 1000000000000000000 / a[i]) {
            cout << -1 << endl;
            return 0;
        }
        ans *= a[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4052
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include <unordered_map>
#include<map>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n; ++i)
#define ALL(a) (a).begin(),(a).end()
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)

int main(){
    ll n, k;
    cin >> n >> k;
    double ans = 0.0;
    for(int i = 1; i <= n; ++i){
        int count = 0;
        double p = 1.0/n;
        while(i*pow(2, count++) < k)p*=0.5;
        ans += p;
    }
    printf("%.12f", ans);
}

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

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    ll minus = 0, zero = 0, plus = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i] < 0) minus++;
        else if (A[i] == 0) zero++;
        else plus++;
    }
    ll prod_minus = minus*plus, prod_plus = plus*(plus-1)/2+minus*(minus-1)/2, prod_zero = N*(N-1)/2-(prod_minus+prod_plus);
    if (prod_minus < K && prod_minus+prod_zero >= K) {
        cout << 0 << endl;
        return 0;
    }
    
    sort(A.begin(), A.end());
    
    if (K <= prod_minus) {
        ll l = -2e18, r = 0;
        while (r-l > 1) {
            ll c = (l+r)/2;
            ll cnt = 0;
            for (int i = 0; i < N; i++) {
                if (A[i] == 0) continue;
                if (A[i] < 0) {
                    ll T = abs(A[i]);
                    auto it = lower_bound(A.begin(), A.end(), (abs(c)+T-1)/T);
                    cnt += distance(it, A.end());
                }
                if (A[i] > 0) {
                    ll T = A[i];
                    auto it = upper_bound(A.begin(), A.end(), -((abs(c)+T-1)/T));
                    cnt += distance(A.begin(), it);
                }
            }
            if (cnt/2 >= K) r = c;
            else l = c;
        }
        cout << r << endl;
        return 0;
    }else {
        ll l = 0, r = 2e18;
        while (r-l > 1) {
            ll c = (l+r)/2;
            ll cnt = 0;
            for (int i = 0; i < N; i++) {
                if (A[i] == 0) {
                    cnt += (N-1);
                    continue;
                }
                if (A[i] < 0) {
                    ll T = abs(A[i]);
                    auto it = lower_bound(A.begin(), A.end(), -(c/T));
                    cnt += distance(it, A.end());
                }
                if (A[i] > 0) {
                    ll T = A[i];
                    auto it = upper_bound(A.begin(), A.end(),  c/T);
                    cnt += distance(A.begin(), it);
                }
                if (A[i]*A[i] <= c) cnt--;
            }
            if (cnt/2 >= K) r = c;
            else l = c;
        }
        cout << r << endl;
        return 0;
    }
    return 0;
}

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

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (1)
    {
        if ((c -= b) <= 0)
        {
            cout << "Yes" << endl;
            break;
        }
        if ((a -= d) <= 0)
        {
            cout << "No" << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
#include<assert.h>

typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int n;
	char s[101], t[101];

	scanf("%d\n%s %s", &n, s, t);
	for (size_t i = 0; i < n; i++)
	{
		putchar(s[i]);
		putchar(t[i]);
	}
}




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

const int MAX = 1e5+5;
int a[MAX];
int n, l, t;

int main() {
    cin >> n >> l >> t;
    int p = 0;
    for (int i = 0; i < n; ++i) {
        int x, w; cin >> x >> w;
        if (w == 2) w = -1;
        x = x + t*w;
        p += x / l;
        a[i] = x % l;
        if (a[i] < 0) --p, a[i] += l;
    } 
    sort(a, a+n);
    p %= n;
    for (int i = 0; i < n; ++i) cout << a[(i+p+n)%n] << endl;
    return 0;
}


Measured memory_bytes: 1536