akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	int n, h;
	cin >> n;
	int post_h = 0;
	for(int i = 0; i < n; ++i)
	{
		cin >> h;
		if (post_h > h)
		{
			cout << "No";
			return;
		}
		post_h = max(post_h, h - 1);
		//cout << post_h << " ";
	}
	cout << "Yes";
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
const ll INF=1e9;
const ll IINF=1e18;

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 main(){
    ll N,M;
    cin >> N >> M;
    vector<ll> S(N),T(M);
    rep(i,N){
        cin >> S[i];
    }
    rep(i,M){
        cin >> T[i];
    }
    vector<vector<ll>> dp(N+1,vector<ll>(M+1,0));
    vector<vector<ll>> sum(N+1,vector<ll>(M+1,0));
    dp[0][0]=sum[0][0]=1;
    rep(i,N){
        sum[i+1][0]=1;
    }
    rep(i,M){
        sum[0][i+1]=1;
    }
    rep(i,N){
        rep(j,M){
            if (S[i]==T[j]){
                dp[i+1][j+1]=sum[i][j];
            }
            sum[i+1][j+1]=sum[i][j+1]+sum[i+1][j]-sum[i][j]+dp[i+1][j+1];
            if (sum[i+1][j+1]<0){
                sum[i+1][j+1]+=MOD;
            }
            sum[i+1][j+1]%=MOD;
        }
    }
    cout << sum[N][M] << endl;
}

Measured memory_bytes: 62976
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;

int H, W; 
void paint(string s[], vector<vector<int>> &num_w, set<pii> &C,int color){
  set<pii> passed;
  queue<pii> q;
  for (auto p : C){
    int Ch = p.first, Cw = p.second;
    passed.insert({Ch,Cw});
    q.push({Ch,Cw});
    num_w[Ch][Cw] = color;
  }
  C.clear();

  int to_r[4] = {0,0,1,-1}, to_c[4] = {1,-1,0,0};
  while (!q.empty()){
    auto now = q.front(); q.pop();
    int r = now.first, c = now.second;

    rep(i,4) {
      int row = r + to_r[i], col = c + to_c[i];
      if (row<0 || row>=H || col<0 || col>=W) continue;

      if (s[row][col]=='.' && num_w[row][col]==-1) {
        num_w[row][col] = color;
        passed.insert({row,col});
        q.push({row,col});
      }
    }
  }

  for (auto now : passed){
    int r = now.first, c = now.second;
    for (int dr=-2;dr<=2;dr++) {
      for (int dc=-2;dc<=2;dc++){
        if (dr==0 && dc==0) continue;
        if (r+dr<0 || r+dr>=H || c+dc<0 || c+dc>=W) continue;

        if (s[r+dr][c+dc]=='.' && num_w[r+dr][c+dc]==-1){
          C.insert({r+dr,c+dc});
        }

      }
    }
  }

  return;
}



int main(){
  cin >> H >> W;
  int Ch, Cw; cin >> Ch >> Cw;
  Ch--, Cw--;
  int Dh, Dw; cin >> Dh >> Dw;
  Dh--, Dw--;
  string s[H];
  rep(row,H) cin >> s[row];

  vector<vector<int>> num_w(H,vector<int>(W,-1));
  int color = 0;
  set<pii> C;
  C.insert({Ch,Cw});

  while (1){
    paint(s,num_w,C,color);

    if (C.empty()) break;
    color++;    
  }
  cout << num_w[Dh][Dw] << endl;
  /*
  rep(r,H) rep(c,W){
    if (s[r][c]=='.') cout << num_w[r][c];
    else cout << 0;

    if (c==W-1) cout << endl;
  }*/

  // cout << fixed << setprecision(10);
  
  return 0;
}

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

int main(void)
{
	int m, f, r;
	cin >> m >> f >> r;
	while (m != -1 || f != -1 || r != -1){
		int s = m + f;
		if (m==-1 || f==-1) cout << "F\n";
		else if(80 <= s)  cout << "A\n";
		else if(65 <= s && s< 80)  cout << "B\n";
		else if(50 <= s && s< 65)  cout << "C\n";
		else if(30 <= s && s< 50)
			if (50 <= r) cout << "C\n";
			else cout << "D\n";
		else if(s< 30)  cout << "F\n";
		cin >> m >> f >> r;
	}
	return 0;
}

Measured memory_bytes: 1124
#include<bits/stdc++.h>
using namespace std;
int N,Q;
int S[1000009];
vector<int>sre;
vector<int>led;
int search(int c){
	int res=0;
	vector<int>be,en;
	if((int)led.size()==0)return N;
	//printf("search(%d)\n",c);
	for(int i=0;i<(int)led.size();i++){
		int ledpoint=led[i];
		//[ledpoint-c,ledpoint]
		be.push_back(lower_bound(sre.begin(),sre.end(),ledpoint-c)-sre.begin());
		en.push_back(upper_bound(sre.begin(),sre.end(),ledpoint)-sre.begin()-1);
	}
	sort(be.begin(),be.end());
	sort(en.begin(),en.end());
	for(int i=0;i<(int)led.size();i++){
		//printf("%d %d\n",be[i],en[i]);
	}
	int end=en[0];int beg=be[0];
	for(int i=1;i<(int)en.size();i++){
		if(end>=be[i]){
			end=en[i];
		}
		else{
			res+=(end-beg+1);
			beg=be[i];end=en[i];
		}
	}
	res+=(end-beg+1);
	//printf("%d\n",N-res);
	//printf("\n");
	return N-res;
}
int main()
{
	scanf("%d%d",&N,&Q);
	for(int i=0;i<N;i++){
		scanf("%d",&S[i]);sre.push_back(S[i]);
	}
	sort(sre.begin(),sre.end());
	for(int i=0;i<Q;i++){
		string q;int x;
		cin >> q;scanf("%d",&x);
		if(q=="ADD"){
			x--;
			led.push_back(S[x]);
		}
		else if(q=="REMOVE"){
			x--;
			for(int i=0;i<(int)led.size();i++){
				if(led[i]==S[x]){
					led.erase(led.begin()+i);
					break;
				}
			}
		}
		else{
			int l=0;int r=1<<30;
			if(search(1<<30)>x){
				printf("NA\n");
				continue;
			}
			while(r-l>1){
				int c=(l+r)/2;
				int num=search(c);
				if(num>x)l=c;
				else r=c;
			}
			if(search(0)<=x)printf("%d\n",0);
			else printf("%d\n",r);
		}
	}
	return 0;
}

Measured memory_bytes: 9136
#if 1

#include <bits/stdc++.h>
using namespace std;
int ans;

int main()
{
    int a,b;
    cin >> a >> b;
    if(a > b)
    {
        ans += a;
        a--;
    }
    else
    {
        ans += b;
        b--;
    }
    if(a > b)
    {
        ans += a;
        a--;
    }
    else
    {
        ans += b;
        b--;
    }
    cout << ans;
}

#endif // 1++

Measured memory_bytes: 256
// #pragma GCC optimize("Ofast,unroll-all-loops")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define all(v) v.begin(), v.end()
#define len(v) ((int)(v).size())
#define pb push_back
#define kek pop_back
#define pii pair<int, int>
#define mp make_pair
#define int ll

#define debug(x) cout << #x << " = " << x << endl;

const int INF = (is_same<int, ll>::value ? 1e18 + 666 : 1e9 + 666);
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

// const int MEM_SIZE = 1e8;
// char mem[MEM_SIZE];
// int cur_mem_ptr = 0;

// void* operator new(size_t n) {
//     cur_mem_ptr += n;
//     return mem + cur_mem_ptr - n;
// }

// void operator delete(void*) noexcept {}
// void operator delete(void*, size_t) noexcept {}

template<class t1, class t2>
bool cmin(t1 &a, const t2 &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class t1, class t2>
bool cmax(t1 &a, const t2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int bpow(int a, int b, int mod) {
    int res = 1;
    for (; b; b >>= 1) {
        if (b & 1) {
            res *= a;
            res %= mod;
        }
        a *= a;
        a %= mod;
    }
    return res;
}

#ifndef LOCAL
void UseFiles(const string &s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}
#else
void UseFiles(const string&) {}
#endif

void run();

signed main() {
    // UseFiles("squads");
    iostream::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    run();
}


void run() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        g[u].pb(v);
        g[v].pb(u);
    }
    vector<int> prv(n, -1);
    queue<int> q;
    prv[0] = -2;
    q.push(0);
    while (len(q)) {
        int v = q.front();
        q.pop();
        for (auto &x : g[v]) {
            if (prv[x] == -1) {
                prv[x] = v;
                q.push(x);
            }
        }
    }
    for (auto &x : prv) {
        if (x == -1) {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
    for (int i = 1; i < n; ++i) {
        cout << prv[i] + 1 << " ";
    }
    cout << endl;
}

Measured memory_bytes: 12972
import kotlin.math.*
import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.*


private var fs = BufferedReader(InputStreamReader(System.`in`))
private fun readLn() = fs.readLine()!! // string line
private fun readStrings() = readLn().split(" ") // list of strings
private fun readLong() = readLn().toLong()
private fun readLongs() = readStrings().map { it.toLong() } // list of ints
private fun readInt() = readLn().toInt() // single int
private fun readInts() = readStrings().map { it.toInt() } // list of ints

fun main() {
    solveAtc()
}
fun solveAtc() {
    var (A,B,H,M) = readStrings().map{it.toDouble()}
    var angle = max(H + M/60.0,M/5.0)*30 - min(H + M/60.0,M/5.0)*30
    var rest = 2*A*B*cos(angle * (2*PI/360.0))
    println(sqrt(A.pow(2) + B.pow(2) - rest))
}


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

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

  string s, t, u;
  int a, b;

  cin >> s >> t >> a >> b >> u;

  if (u == s) cout << a-1 << " " << b << '\n';
  else cout << a << " " << b-1 << '\n';

  return (0);
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i =0; i < n ;i++)
using namespace std;


int main(){
    int a=0;
    char c;
    rep(i, 4){
        cin >> c;
        if(c=='+') a++;
        else a--;
    }

    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define loop(i, a, b) for(int i = a; i < b; i++) 
#define rep(i, a) loop(i, 0, a)
using namespace std;
const int MOD = 1000000007;
const int inf = 1e8;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
using vvs = vector <vs>;
//g++ -std==c++14
//setprecision(10)
int n;
vi a;
long long int pow_mod(long long int pm_n, long long int pm_p){
    if(pm_p == 0)
        return 1;
    else if(pm_p % 2 == 0){
        long long int va = pow_mod(pm_n, pm_p / 2);
        return (va * va) % MOD;
    }
    else if(pm_p % 2 == 1)
        return (pow_mod(pm_n, pm_p - 1) * pm_n) % MOD;
}

int main(){
    cin >> n;
    a = vi (n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    rep(i, n){
        if(!i && n % 2){
            if(a[i] != 0){
                cout << 0 << endl;
                return 0;
            }
            continue;
        }
        else if(a[i] != i + 1 || a[i + 1] != i + 1){
            cout << 0 << endl;
            return 0;
        }
        i++;
    }
    cout << pow_mod(2, n / 2) << endl;
}

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


int main() {
	long int a,b;
	cin>>a>>b;
	if(a==b && a==1)
	  {
	  	cout<<1;
	  }
	else if(min(a,b)==1)
	  cout<<max(a,b)-2<<" ";
	 else if(min(a,b)==2)
	   cout<<0<<" ";
	else   
	  cout<<a*1ll*b-2*1ll*(a+b-2)<<" ";
	// your code goes here
	return 0;
}

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

int main(void){
    int a,l;
	while(cin >> a >> l,a+l!=0){
        string s = to_string(a);
        int used[1000001];
        memset(used,-1,sizeof(used));
        int i = 0;
        used[a] = 0;
        while(true){
            i++;
            for(;s.size()<l;s += '0'){}
            sort(s.begin(),s.end());
            string t = s;
            reverse(t.begin(),t.end());
            
           // cout << s << " " << t << endl;
            int n = stoi(t) - stoi(s);
           // cout << n << endl;
            s = to_string(n);

            if(used[n] != -1){
                cout << used[n] << " " << n << " " << i-used[n] << endl;
                break;
            }
            used[n] = i;
        }
    }
	return 0;
}

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

using namespace std;

#define MAXN 100005
vector<int> a,b,c;

int memo[MAXN][3];
int calculate(int choice_prec, int currDay) {
    //cout<<"Calling "<<choice_prec<<" "<<currDay<<endl;
    if(memo[currDay][choice_prec] != -1)
        return memo[currDay][choice_prec];
    if(currDay == a.size())
        return 0;
    if(currDay == 0) {
        int tempMax = calculate(0, 1) + a[0];
        tempMax = max(tempMax, calculate(1, 1) + b[0]);
        tempMax = max(tempMax, calculate(2, 1) + c[0]);

        return tempMax;
    }
    if(choice_prec == 0) {
        int tempMax = calculate(1, currDay+1) + b[currDay];
        tempMax = max(tempMax, calculate(2, currDay+1) + c[currDay]);

        return memo[currDay][choice_prec] = tempMax;
    }
    if(choice_prec == 1) {
        int tempMax = calculate(0, currDay+1) + a[currDay];
        tempMax = max(tempMax, calculate(2, currDay+1) + c[currDay]);

        return memo[currDay][choice_prec] = tempMax;
    }
    if(choice_prec == 2) {
        int tempMax = calculate(0, currDay+1) + a[currDay];
        tempMax = max(tempMax, calculate(1, currDay+1) + b[currDay]);

        return memo[currDay][choice_prec] = tempMax;
    }
    return 0;
}
int main() {
    int N;
	cin>>N;
	int tempa, tempb, tempc;
	for(int i = 0; i < N; i++) {
		cin>>tempa>>tempb>>tempc;
		a.push_back(tempa);
		b.push_back(tempb);
		c.push_back(tempc);
	}
	memset(memo,-1,sizeof memo);
	cout<<calculate(0,0);
}

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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

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

int main() {
    ll i, j, k;
    ll N;
    cin >> N;
    ll v_all = 0;
    for(i = 1; i <= N; i++) {
        v_all += i * (N - i + 1);
    }
    ll e_all = 0;
    for(i = 0; i < N - 1; i++) {
        ll u, v;
        cin >> u >> v;
        e_all += min(u, v) * (N - max(u, v) + 1);
    }
    cout << v_all - e_all << endl;

    return 0;
}


Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#include <climits>
#include <memory>
#include <numeric>
#include <utility>


#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
#define PI 3.14159265358979323846264338327950L;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;



int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int D;
ll G;
vector<ll> P, C;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string a;
	ll k;

	cin >> a >> k;
	rep(i, 0, min((ll)a.size(), k)) {
		if (a[i] >= '2') {
			cout << a[i] << endl;
			return 0;
		}

	}

	cout << 1 << endl;


	

}
	

Measured memory_bytes: 256
N = gets.chomp.to_i
NUM_CHARS = %w{3 5 7}

def dfs(num_str)
  return 0 if num_str.to_i > N

  is_ngs = NUM_CHARS.all? { |n| num_str.include? n }
  NUM_CHARS.inject(is_ngs ? 1 : 0) do |sum, n|
    sum + dfs(num_str + n)
  end
end

puts dfs("")


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
using namespace std;

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

int main(){

    int N;
    cin >> N;
    string S;
    cin >> S;

    int left = 0, right = 0;
    for(int i = 0; i < S.length(); i++){
        if(S[i] == '(') right++;
        else{
            if(right == 0) left++;
            else right--;
        }
    }

    for(int i = 0; i < left; i++) cout << "(";
    cout << S;
    for(int i = 0; i < right; i++) cout << ")";
    cout << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}
double pi = 3.14159265359;
void solve()
{
  // ll n; cin >> n;
  ll a, b, h, m; cin >> a >> b >> h >> m;
  double thh, thm, hx, hy, mx, my, l;
  thh = 2 * pi * (h + m / 60.0) / 12.0;
  thm = 2 * pi * m / 60.0;
  hx = a * sin(thh);
  hy = a * cos(thh);
  mx = b * sin(thm);
  my = b * cos(thm);
  l = sqrt((hx - mx)*(hx-mx) + (hy-my)*(hy-my));
  printf("%.13f\n", l);
  
}


int main(void)
{
  // ll t; cin >> t; REP(i, t)
  solve();
}


Measured memory_bytes: 4064
import java.util.Scanner;

public class Main {

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

		int a = scan.nextInt();
		int b = scan.nextInt();
		
		int sum[] = new int[1000];
		sum[0] = 1;
		for(int i = 1; i < 1000; i++) {
			sum[i] += sum[i - 1] + (i + 1);
		}
		
		int diff = b - a;
		int ans = 0;
		for(int i = 1; i < 1000; i++) {
			if(diff == sum[i] - sum[i - 1]) {
				ans = sum[i - 1] - a;
				break;
			}
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  int n;
  int ans =0;
  cin >> n;
  for(int i=1;i<=n;i++){
    int x;
    cin >> x;
    if(i%2 && x%2)ans++;
  }
  cout<<ans<<endl;


return 0;
}
///....


Measured memory_bytes: 3648
from math import gcd
n = int(input())
a = list(map(int, input().split()))
g = a[0]
lcm = 0
for i in range(1, n):
    tmp = gcd(g, a[i])
    lcm = g * a[i] // tmp
    g = lcm
    tmp = lcm
print(lcm)


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

int main(){
    long long N; cin >> N;
    vector<string> S(N);
    unordered_map<string, long long>MP;
    for(int i = 0; i < N; i++ ) cin >> S[i];
    for(int i = 0; i < N; i++){
        sort(S[i].begin(), S[i].end());
        MP[S[i]]++;
    }
    long long ans = 0;
    for(auto e: MP){
        ans += e.second * (e.second-1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 17700
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
struct UnionFind {
    vector<int> par, w;
    
    UnionFind(int n) : par(n, -1), w(n, 0) { }
    void init(int n) { par.assign(n, -1); w.assign(n, 0); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) {
            ++w[x];
            return false;
        }
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        w[x] += w[y];
        ++w[x];
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
 
    int wei(int x) {
        return w[root(x)];
    }
};

void _main()
{
    int N;
    cin >> N;
    UnionFind uf(N + 1);
    vector<bool> exists(N + 1, false);
    int max = 0;
    rep(i, 0, N)
    {
        int P;
        cin >> P;
        exists[P] = true;

        if (exists[P - 1])
        {
            uf.merge(P - 1, P);
        }

        chmax(max, uf.size(P));
    }

    cout << N - max << endl;
}


Measured memory_bytes: 1920
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,x,y;
int a[105],b[105];
int main()
{
	scanf("%d %d %d %d",&n,&m,&x,&y);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=m;i++)
		scanf("%d",&b[i]);
	sort(a+1,a+n+1);
	sort(b+1,b+m+1);
	for(int i=x+1;i<=y;i++)
		if(a[n]<i&&b[1]>=i)
		{
			printf("No War\n");
			return 0;
		}
	printf("War\n");
}

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

int main() {
  int N,K;
  cin >> N >> K;
  string S;
  cin >> S;
  
  if(S.at(K-1)=='A'){
    S.at(K-1)='a';
  }else if(S.at(K-1)=='B'){
    S.at(K-1)='b';
  }else{
    S.at(K-1)='c';
  }
  cout << S << endl;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
l=[0]*k
ans=0
for i in range(1,n+1):
    l[i%k]+=1
for j in range(k):
    bj=(-j)%k
    cj=(-j)%k 
    if (bj+cj)%k==0:
        ans+=(l[j]*l[bj]*l[cj])
        
print(ans)


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

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

int main(){
    int n;
    cin >> n;
    long long t[n];
    for(int i=0;i<n;i++){
        cin>>t[i];
    }
    long long lcm=t[0];
    for(int i=0;i<n;i++){
        lcm=t[i]/gcd(t[i],lcm)*lcm;
    }

    cout<<lcm<<endl;

    return 0;
}


Measured memory_bytes: 256
S = input()
T = input()

Nmax = len(T)
for i in range(len(S)-len(T)+1):
    diff = 0
    for j in range(len(T)):
        if(S[i+j] != T[j]):
            diff += 1

    Nmax = min(diff, Nmax)

print(Nmax)


Measured memory_bytes: 9068
#include <bits/stdc++.h>
     
    #define         ll      long long
     
    using namespace std;
     
    ll func(ll x)
    {
    	if(x==0 or x==1) return x;
     
    	if(x%2==0)
    	{
    		if(x%4==0) return x;
    		else return x+1;
    	}
    	else return func(x-1)^x;
    }
     
    int main()
    {
    	ll a, b;
     
    	cin >> a >> b;
     
    	cout << (func(a-1)^func(b)) << endl;
     
    	return 0;
    }

Measured memory_bytes: 256
a = input().split()
N = int(a[0])
D = int(a[1])
#print('N=', N, 'D=', D)

b = []
X = []
Y = []

for i in range(N):
  b = input().split()
  X.append(int(b[0]))
  Y.append(int(b[1]))
  b.clear()

#print('X=', X)
#print('Y=', Y)

count = 0

for i in range(N):
  if (X[i]**2+Y[i]**2)**0.5 <= D:
    count = count + 1

print(count)








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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MIN(a,b) ((a) < (b) ? (a) : (b))

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

    int* B;
    NEW(B,N-1);
    for(int i=0;i<N-1;i++){
        scanf("%d\n", &B[i]);
    }

    long ans;
    ans=B[0]; //A[0]=B[0]
    for(int i=1;i<N-1;i++){
        ans+=MIN(B[i-1],B[i]); //A[i]=min(B[i-1],B[i])
    }
    ans+=B[N-2]; //A[N-1]=B[N-2];

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

    return 0;
}

//300点
//解法の肝はコメント部分、実際に紙に書いてA[i]を求めて仕組みを探すこと

Measured memory_bytes: 128
// https://atcoder.jp/contests/abc085/tasks/abc085_c

#include <iostream>
using namespace std;

void bad() {
    cout << -1 << " " << -1 << " " << -1 << endl;
}
int main() {
    int N, Y;
    cin >> N >> Y;
    int a{}, b{}, c{};
    // a + b + c == N
    // 10000a + 5000b + 1000c == Y
    // 9000a + 4000b == Y - 1000N
    if (Y - 1000*N < 0) {
        bad();
        return 0;
    }
    // 9a + 4b == Y/1000 - N
    auto n = (Y/1000 - N) % 4;
    // 4a'+n = a
    auto l = Y/1000 - N - 9*n;
    // 9 4 a' + 4 b = l
    if (l < 0 || l % 4 != 0) {
        bad();
        return 0;
    }
    auto m = l / 4;
    //
    // 9a'+b = m
    auto p = m % 9;
    // b = 9b' + p
    // 9a'+9b' = m - p
    auto q = m - p;
    if (q < 0 || q % 9 != 0) {
        bad();
        return 0;
    }
    auto r = q / 9;
    // a' + b' = r
    for (int i=0; i <= r; ++i) {
        // a' = i
        a = 4 * i + n;
        b = 9*(r - i) + p;
        c = N - b - a;
        if (a >= 0 && b >= 0 && c >= 0) {
            cout << a << " " << b << " " << c << endl;
            return 0;
        }
    }
    bad();
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>

typedef long long ll;

using namespace std;

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;
    cout << a*b/gcd(a,b);
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        class Food
        {
            public int A;
            public int B;
            public Food(int[] args)
            {
                this.A = args[0];
                this.B = args[1];
            }
        }

        static int Solve(int N, int T, Food[] foods)
        {
            var dp = new Tuple<int, bool>[N + 1][];
            dp[0] = Enumerable.Repeat(new Tuple<int, bool>(0, false), T).ToArray();
            for (int i = 0; i < N; ++i)
            {
                dp[i + 1] = new Tuple<int, bool>[T];
                for (int j = 0; j < T; ++j)
                {
                    dp[i + 1][j] = new Tuple<int, bool>(dp[i][j].Item1, false);
                }
                for (int j = 0; j + foods[i].A < T; ++j)
                {
                    if (dp[i][j].Item1 + foods[i].B > dp[i + 1][j + foods[i].A].Item1)
                    {
                        dp[i + 1][j + foods[i].A] = new Tuple<int, bool>(dp[i][j].Item1 + foods[i].B, true);
                    }
                }
            }
            int t = T - 1;
            var set = new HashSet<int>(Enumerable.Range(0, N));
            for (int i = N - 1; i >= 0; --i)
            {
                if (dp[i + 1][t].Item2)
                {
                    t -= foods[i].A;
                    set.Remove(i);
                }
            }
            int b = (set.Count > 0) ? set.Max(i => foods[i].B) : 0;
            return dp[N][T - 1].Item1 + b;
        }

        static void Main(string[] args)
        {
            int[] V = ReadInts();
            int N = V[0], T = V[1];
            var foods = new Food[N];
            for (int i = 0; i < N; ++i) { foods[i] = new Food(ReadInts()); }
            Console.WriteLine(Solve(N, T, foods));
        }
    }
}


Measured memory_bytes: 306116
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c[10001],s=0;
    cin>>a>>b;
    for(int i=0;i<a;i++)
    {
        cin>>c[i];
    }
    sort(c,c+a);
    reverse(c,c+a);
    for(int i=0;i<b;i++)
    {
        s=s+c[i];
    }
    cout<<s<<endl;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
   
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define deb(x) cout << #x << "=" << x << endl
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define vi vector<int>
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define mod 1000000007
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define int long long

const int N=(int)1e5+5;

int dp[N][5];
int a[N];
int b[N];
int c[N];
int n,k;
int solve(int idx,int type)
{
    int i=idx;
    if(i==n+1)return 0;
    
    int &ans=dp[i][type];
    if(ans!=-1)return ans;
    
    
    int op1=0,op2=0,op3=0;
    if(type==0)
    {
        op1=solve(i+1,1)+a[i];
        op2=solve(i+1,2)+b[i];
        op3=solve(i+1,3)+c[i];
        
    }
    else
    {
        for(int ind=1;ind<=3;ind++)
        {
            if(ind==type)continue;
            if(ind==1)
            {
               op1=solve(i+1,1)+a[i];
            }
            if(ind==2)
            {
                op2=solve(i+1,2)+b[i];
            }
            if(ind==3)
            {
                 op3=solve(i+1,3)+c[i];
            }
            
        }
    }
    
    return ans=max({op1,op2,op3});
    
    
}
	
void solve()
{
   
    memset(dp,-1,sizeof dp);
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i]>>b[i]>>c[i];
    
    
    
    
    int ans=solve(1,0);
    cout<<ans;
}

int32_t main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    
	int t=1;
	//cin>>t;
	while(t--)solve();
	    
   
}

Measured memory_bytes: 16116
def main():
    from bisect import bisect_left
    from collections import namedtuple
    from operator import attrgetter
    import sys

    input = sys.stdin.readline
    Event = namedtuple('Event', 'pos start end')

    N, Q = map(int, input().split())

    events = []
    for _ in range(N):
        s, t, x = map(int, input().split())
        e = Event(pos=x, start=s - x, end=t - x)  # 時間[s-x,t-x)にpos=0にいるとpos=xで工事中
        events.append(e)
    events.sort(key=attrgetter('pos'))

    D = [int(input()) for _ in range(Q)]

    ans = [-1] * Q
    see = [-1] * Q
    for e in events:
        left = bisect_left(D, e.start)
        right = bisect_left(D, e.end)
        # Dの要素で index が [left,right) 内のものは e.pos で工事中
        # e.pos 昇順ソートしているので, ans[idx] には工事中の最小のposが入る
        idx = left
        while idx < right:
            if ~ans[idx]:
                idx = see[idx]
                continue
            ans[idx] = e.pos
            see[idx] = right
            idx += 1
            
    print(*ans, sep='\n')


if __name__ == '__main__':
    main()


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

using namespace std;

int main(void)
{
    int N, M;
    cin >> N;
    vector<int> T(N);
    int s = 0;
    for(auto& e : T)
    {
        cin >> e;
        s += e;
    }

    cin >> M;
    vector<pair<int, int>> P(M);
    for(auto& e : P)
        cin >> e.first >> e.second;

    for(const auto& e : P)
    {
        cout << s - T[e.first - 1] + e.second << endl;
    }

    return 0;
}

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

#define INF INT_MAX>>1 //要climits#includ
#define SIZE 100001
#define MOD 1000000007

typedef long long ll;

using namespace std;

int main(void){
	int n; cin >> n;
	int a[SIZE];
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	sort(a, a+n);

	int ans = a[n/2] - a[n/2-1];
	cout << ans << endl;


}


/*
int main(void){
	int n; cin >> n;
	int a[100];
	for(int i=0; i<n; i++){
		cin >> a[i];
	}

	int ans = 0;
	for(int i=1; i<n-1; i++){
		int ma = max(a[i-1], max(a[i], a[i+1]));
		int mi = min(a[i-1], min(a[i], a[i+1]));
		if(a[i] != ma && a[i] != mi) ans++;
	}
	
	cout << ans << endl;
}
*/





/*
int main(void){
	string str;
	cin >> str;
	char ch1=NULL, ch2=NULL;
	for(int i=0; i<str.length(); i++){
		if(str[i] != ch1){
			if(ch1 == NULL){
				ch1 = str[i];
			}else if(str[i] != ch2){
				if(ch2 != NULL){
					cout << "No" << endl;
					return 0;
				} else ch2 = str[i];
			}
		}
	}
	if(ch2 == NULL) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}
*/

Measured memory_bytes: 640
n = int(raw_input())
if n < 10:
    print(n)
elif n >= 10 and n < 100:
    print(9)
elif n >=100 and n < 1000:
    print((n-100) + 10)#n-90
elif n >=1000 and n < 10000:
    print(909)
elif n >= 10000 and n < 100000:
    print((n-10000) + 910)
elif n == 100000:
    print(90909)

Measured memory_bytes: 2568
n,k,q=map(int,input().split())
answer_number = [int(input()) for _ in range(q)]
points=[int(k)]*n

for i in answer_number:
    points[i-1]=points[i-1]+int(1)
for p in range (n):
    if points[p]>q:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 56024
n=int(input())
li=[list(map(int,input().split())) for i in range(n-1)]

#色の情報を記録する配列を作る。0が白で、1が黒
col=[-1]*(n+1) #最初は全ての頂点が情報なし。
col[1]=0 #頂点1の色は白。

#2点間の距離の情報を記録する配列を作る…と思ったがO(n^2)やわこれ
#ついでにグラフも作る。距離の情報はグラフに入れることにしよう
graph = [[] for _ in range(n+1)]

for x,y,z in li:
  graph[x].append([y,z])
  graph[y].append([x,z])

def dfs(v):
    dist = [-1] * (n+1)
    stack = [v]
    dist[v] = 0
    while stack:
        v = stack.pop()
        dw = dist[v] + 1
        for w,z in graph[v]: #頂点vに接続してる点についての調査
            if dist[w] >= 0: #0以上であれば既に調査済み
                continue
            dist[w] = dw #調査済みでない場合は、distに現在の深さを記録。
            if z%2:
              col[w]=col[v]^1
            else:
              col[w]=col[v]
            stack.append(w)
    return col
print(*dfs(1)[1:], sep="\n")

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

int main(void){
  string s; cin>>s;
  rep(i,s.size()-1){
    if(s.at(i) == s.at(i+1)){
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
  return 0;
}


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

int main(void) {
    int N;
    int *array;
    int S1, S2, ans=1000;

    scanf("%d", &N);

    array = malloc(N*sizeof(int));

    // scanf("%d", &array[0]);
    for(int i=0; i < N; i++) {
        scanf("%d", &array[i]);
    }

    for(int i=0; i < N-1; i++) {
        // S1とS2の初期化
        S1 = 0;
        S2 = 0;
        // S1とS2を求める
        for(int j=0; j < i+1; j++) {
            S1 += array[j];
        }
        for(int k=i+1; k < N; k++) {
            S2 += array[k];
        }

        // ansの更新
        if(ans >= abs(S1-S2)) {
            ans = abs(S1-S2);
            // printf("%dに更新！S1:%d S2:%d\n", i, S1, S2);
        }
    }

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

    return 0;
}


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

int main() {
    int N; cin >> N;
    vector<long long> L(N);
    for (int i = 0; i < N; ++i) cin >> L[i];
    sort(L.begin(), L.end());

    long long res = 0;
    
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            int k = lower_bound(L.begin(), L.end(), L[i] + L[j]) - L.begin();

            res += max(k - (j+1), 0);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
using namespace std;
#define max_n 7368791
int prime[max_n];
bool is_prime[max_n+1];
int m,n,i,j;
int sieve(){
	int p=0;
	for(i=m;p<n+1;i++){
		if(is_prime[i]){
			prime[p]=i;
			p++;
			for(j=2*i; j<=max_n; j+=i){
				is_prime[j] = false;
			}
		}
	}
    return p;
}

int main() {
while(cin>>m>>n){
	for(i=0;i<max_n+1;i++){
		is_prime[i]=true;
		prime[i]=0;
}
	if(m==0 && n==0){break;}
	int k=sieve();
	cout<<prime[n]<<endl;
}
	return 0;
}

Measured memory_bytes: 39052
N, x = map(int, input().split())
A = [int(i) for i in input().split()]

ans = 0
for i in range(1, N):
    if A[i-1]+A[i] > x:
        e = A[i-1]+A[i]-x
        ans += e
        if A[i] >= e:
            A[i] -= e
        else:
            A[i] = 0
print(ans)


Measured memory_bytes: 14132
#include <iostream>
#include <vector>
using namespace std;
const int mod = 1e9+7;

int main(){
  string K;
  int D;
  cin >> K >> D;
  vector< vector<int> > dp(D, vector<int>(2,0));
  dp[0][1] = 1;
  for(size_t i = 0; i < K.length(); ++i){
    vector< vector<int> > dp_(D, vector<int>(2,0));
    for(int j = 0; j < 10; ++j){
      for(int k = 0; k < D; ++k){
        dp_[(k+j)%D][0] += dp[k][0];
        dp_[(k+j)%D][0] %= mod;
        if('0'+j > K[i]) continue;
        if('0'+j < K[i]){
          dp_[(k+j)%D][0] += dp[k][1];
          dp_[(k+j)%D][0] %= mod;
        }else{
          dp_[(k+j)%D][1] += dp[k][1];
          dp_[(k+j)%D][1] %= mod;
        }
      }
    }
    dp = dp_;
  }
  cout << (dp[0][0] + dp[0][1] + mod - 1)%mod << endl;
}


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

int cnt(string x, string y)
{
    vector<bool> a(26, 0), b(26, 0);
    for (int i = 0; i < x.size(); i++) a[x[i]-'a'] = 1;
    for (int i = 0; i < y.size(); i++) b[y[i]-'a'] = 1;
    
    int cnt = 0;
    for (int i = 0; i < 26; i++)
        if (a[i] and b[i]) cnt++;
    
    return cnt;
}

int main() {
    int n;
    string s;
    cin >> n >> s;
    
    int ans = 0;
    for (int i = 1; i < n; i++)
        ans = max(ans, cnt(s.substr(0, i), s.substr(i, n)));
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
const int N=200005;
const int mod=1e9+7;
const double eps=1e-8;
const double PI = acos(-1.0);
#define lowbit(x) (x&(-x))
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll qpow(ll a,ll b){ll res=1;while(b){if(b&1) res=res*a%mod;a=a*a%mod;b>>=1;}return res;}
ll inv(ll a,ll p){return qpow(a,p-2);}
int main()
{
    std::ios::sync_with_stdio(false);
    ll n;
    while(cin>>n)
    {
        ll ans=1;
        for(int i=1;i<=n;i++)
            ans=ans*i%mod;
        cout<<ans<<endl;
    }
    return 0;
}


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

using namespace std;

inline int divisor(int n) {
    int count = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            count++;
            if (i * i != n)
                count++;
        }
    }
    
    return count;
}


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

    /*
    for(int a=1 ; a<=n ; a++){
        for(int b=1 ; b<=n ; b++){
            if(a*b > n)
                break;
            for(int c=1 ; c<=n ; c++){
                if(a*b+c==n){
                    count++;
                }
            }
        }

    }
    */

    int count = 0;
    for(int c=1 ; c<=n ; c++){
        int r = n-c;
        count += divisor(r);
    }

    cout << count << endl;



    
    return 0;
}

Measured memory_bytes: 3616
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    N = int(inputs[0])
    lucas_numbers = [2, 1]
    for i in range(2, N+1):
        lucas_numbers.append(lucas_numbers[i-2] + lucas_numbers[-1])
    return lucas_numbers[-1]


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


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

int main(){
    int a,b,c;
    cin >>a>>b>>c;
    int buy=-1;
    if(a*c<=b){
        cout << c << endl;
        return 0;
    }
    else{
        while(b>=0){
            buy += 1;
            b -= a;
        }
        cout << buy << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
 
int main() {
 int N;
 cin>>N;
 vector<int>a(N);
 int count=0;
 for(int i=0;i<N;i++){
     cin>>a[i];a[i]--;
 }
 int k=0;
 for(int i=0;i<N;i++){
     if(k==1){cout<<count<<endl;return 0;}
     k=a[k];
     count++;
 }
 cout<<-1<<endl;
 return 0;}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

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

const int MOD = 1e9 + 7;

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

    int n;
    cin >> n;

    rep(i, 1000){
        if(i >= n && i % 111 == 0){
            cout << i << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())
X = list(map(int, input().split()))

Y = sorted(X)
for i in range(N):
    if X[i] < Y[N // 2]:
        print(Y[N // 2])
    else:
        print(Y[N // 2 - 1])


Measured memory_bytes: 26792
import java.io.PrintWriter;
import java.util.Scanner;

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

		String S = stdin.next();
		String Sc[] = new String[S.length()+1];
		String sc1;
		String sc2;
		int cnt=0;
		
		for(int i=0;i<S.length();i++) {
			Sc[i] = S.substring(i,i+1);
		}
		
		for(int i=0,j=S.length()-1;j>=0;i++,j--) {
			sc1 = Sc[i];
			sc2 = Sc[j];
			if(!(sc1.equals(sc2))) {
				cnt++;
				Sc[i] = Sc[j];
			}
		}

		
		out.println(cnt);
		out.flush();
	}

}


Measured memory_bytes: 22612
from math import *
PI = 3.1415926535898
while True:
    try:
        n = raw_input()
        res = []
        for x in n:
            res.append(int(x))
        while len(res) > 1:
            t = []
            for i in range(1, len(res)):
                t.append((res[i]+res[i-1])%10)
            res = t
        print res[0]
    except EOFError:
        break

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

int main() {
  int n, d;
  cin >> n >> d;
  int ans = 0;
  if (n%(2*d + 1) ==0)
    ans = n/(2*d +1);
  else
    ans = n/(2*d +1) + 1;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n,v[51],s[51],u;M(int*a){return*a-*1[&a];}D(i,V,c){for(c=V+1,u--;--i;)v[i]>=c|s[i]||(c=v[i],s[i]=3,V-c?D(i,V-c):S(n),s[i]=0);u++;}S(i){for(u||main(puts("YES"));s[i];i--)s[i]&1&&(s[i]^=1,D(i,v[i]),s[i]^=1);}main(i){for(;scanf("%d",&n),n;qsort(v+1,n,4,M),memset(s,0,204),s[n]=3,S(n),puts("NO"))for(i=n;i;u=n-1)scanf("%d",v+i--);exit(0);}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
using namespace std;
typedef long long ll;
const ll INF = 1e15;
int main() {
  ll n, K;
  cin >> n >> K;
  vector<ll> h(n), dp(n + 200, INF);
  REP(i, n) cin >> h[i];
  dp[0] = 0;
  REP(i, n - 1) {
    FOR(j, 1, K + 1) {
      dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
    }
  }
  cout << dp[n - 1] << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#define MAX_NUM 200000
#define INFTY 1000000001

unsigned long count = 0;

void merge(int a[],int left,int mid,int right){
    int n1 = mid-left;
    int n2 = right-mid;
    int l[n1+1];
    int r[n2+1];
    for(int i=0;i<n1;i++){
        l[i] = a[left+i];
    }
    for(int i=0;i<n2;i++){
        r[i] = a[mid+i];
    }
    l[n1] = INFTY;
    r[n2] = INFTY;
    int i=0,j=0;
    for(int k=left;k<right;k++){
        if(l[i] < r[j]){
            a[k] = l[i];
            i++;
        }else{
            a[k] = r[j];
            count += (n1-i);
            j++;
        }
    }
}

void mergeSort(int a[],int left,int right){
    if(left+1<right){
        int mid = (left+right)/2;
        mergeSort(a,left,mid);
        mergeSort(a,mid,right);
        merge(a,left,mid,right);
        //std::cout << count << '\n';
    }
}

int main(){
    int a[MAX_NUM] = {};
    int n;
    std::cin >> n;
    for(int i=0;i<n;i++){
        std::cin >> a[i];
    }
    
    mergeSort(a,0,n);
    
    /*std::cout << a[0] ;
    for(int i=1;i<n;i++){
        std::cout << ' ' << a[i];
    }
    std::cout << '\n';*/
    std::cout << count << '\n';
    return 0;
}



Measured memory_bytes: 4624