akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long n = sc.nextInt();
		long k = sc.nextLong();

		Map<Long, Long> oneCountMap = new HashMap<Long, Long>();

		long maxLength = 0;
		for(long i= 0; i < n; i++) {
			// 01 に変換する
			String s = Long.toBinaryString(sc.nextLong());

			char[] c = s.toCharArray();
			if(maxLength < c.length) {
				maxLength = c.length;
			}

			for(int j = c.length - 1; j >= 0; j--) {
				long key = c.length - j;
				if(c[j] == '1') {
					if(oneCountMap.containsKey(key)) {
						oneCountMap.put(key, oneCountMap.get(key) + 1);
					} else {
						oneCountMap.put(key, 1L);
					}
				}
			}
		}

		String s = Long.toBinaryString(k);
		long maxMapSize = Math.max(maxLength, s.length());

		long sumA = 0;
		Map<Long,Long> reversAmtMap = new HashMap<Long,Long>();
		for(long i = maxMapSize; i > 0; i--) {
			long amt = (long) Math.pow(2, i-1);
			long zeroCount = 0;
			long oneCount = 0;
			if(oneCountMap.containsKey(i)) {
				oneCount = oneCountMap.get(i);
			}
			zeroCount = n-oneCount;

			if(zeroCount > oneCount) {
				// ZEROを1にしてたしたい
				// 変えた時の差分
				reversAmtMap.put(amt, amt*zeroCount-amt * oneCount);
				sumA += amt * oneCount;
			} else {
				// そのままでいい
				sumA += amt * oneCount;
			}
		}

		// 足したら大きくなるほうから並び替え
		List<Entry<Long, Long>> reverseAmtDesc = new ArrayList<Entry<Long, Long>>(reversAmtMap.entrySet());
		Collections.sort(reverseAmtDesc, new Comparator<Entry<Long, Long>>() {
			public int compare(Entry<Long, Long> obj1, Entry<Long, Long> obj2) {
					return obj2.getValue().compareTo(obj1.getValue());
			}
		});

		long maxK = 0;
		for(Entry<Long, Long> e : reverseAmtDesc) {
			long amt = e.getValue();
			long key = e.getKey();
			if(k >= maxK + key) {
				// 1にする
				sumA += amt;
				maxK += key;
			}
		}


		System.out.println(sumA);

	}

}


Measured memory_bytes: 65652
def func():
    pass


def main():
    h, w = map(int, input().split())
    p = []
    for i in range(h):
        s = input()
        p.append(s)

    print("#" * (w + 2))
    for pi in p:
        print("#" + pi + "#")
    print("#" * (w + 2))



if __name__ == '__main__':
    main()


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

int main() {
    int A,B;
    cin >> A >> B;
    int K = 0;
    if ((A + B) % 2 == 0) {
        cout << (A+B)/2 << endl;
    }
    else {
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n;
  cin >> n;
  map<string, ll> mp;
  REP(i, n){
    string s;
    cin >> s;
    mp[s]++;
  }
  printf("AC x %lld\n", mp["AC"]);
  printf("WA x %lld\n", mp["WA"]);
  printf("TLE x %lld\n", mp["TLE"]);
  printf("RE x %lld\n", mp["RE"]);
  return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int S;cin>>S;vector<long long>D(S+6);
  D[0]=0;D[1]=0;D[2]=1;D[3]=1;D[4]=1;
  for(int X=5;X<S;X++){
    D[X]=(D[X-3]+D[X-1])%1000000007;
  }
  cout<<D[S-1]<<endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define N 200010
int a[N],b[N],cnt[N];
int main(){
	int n,m,i;
	scanf("%d%d",&n,&m);
	int ans=n;
	for (i=1;i<=n;i++){
		scanf("%d",&a[i]);
		cnt[a[i]]++;
		int tmp=a[i]-cnt[a[i]]+1;
		if (tmp>0){
			if (!b[tmp]) ans--;
			b[tmp]++;
		}
	}
	for (i=1;i<=m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		int tmp=a[x]-cnt[a[x]]+1;
		if (tmp>0){
			if (b[tmp]==1) ans++;
			b[tmp]--;
		}
		cnt[a[x]]--;
		cnt[y]++;
		a[x]=y;
		tmp=y-cnt[y]+1;
		if (tmp>0){
			if (!b[tmp]) ans--;
			b[tmp]++;
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

bool f(int x){
    int keta = 0;
    while (x){
        keta++;
        x /=10;
    }
    return keta%2==1;
}

int main(){
    int n;
    cin >> n;
    int ans=0;
    for (int i=1; i<=n; i++){
        if (f(i)) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#define rep(i,n) for(int i=0;, i < n; i++)
#define rep_2(i,n) for(int i=n, i > 0; i--)
using namespace std;
using ln = long long;

int main()
{
    int N,R;
    cin >> N >> R;
    if(N>=10)
        cout << R << endl;
    else
        cout << R + 100 * (10 - N) << endl;
}

Measured memory_bytes: 3588
#include<stdio.h>
#include<string.h>
int main(){
	char r[128],m,s;
	int i,k=0;
	scanf("%s",r);
	m='A';
	for(i=0;i<strlen(r);i++){
		s=r[i];
		if(s-m<=0){
			k++;
		}
		m=s;
	}
	printf("%d\n",k);
    return 0;
}

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

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;
int main() {
    int N;
    cin>>N;
    vector<float> A(N);
    rep(i,N){
        cin>>A[i];
    }
    float ans = 0;
    rep(i,N){
        ans += 1.0/A[i];
    }
    ans = 1 / ans;
    cout << setprecision(15)<<ans<<endl;

}

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

using namespace std;

bool isPrime(int n) {
	if (n == 1) return false;
	for (int i = 2; i*i <= n; ++i) {
		if (n % i == 0) return false;
	}
	return true;
}

//bool f[10000000] = {0};
int main() {
	int N, p;
	while ( cin >> N >> p, N != -1 || p != -1 ) {
//		fill(&f[0], &f[0]+10000000, false);
		int b = -1;
		vector<int> v;
		for (int i = N+1; ; ++i) {
			if (isPrime(i)) {
				v.push_back(i);
				if (v.size() > p+1) break;
			}
		}
		vector<int> a;
		for (int i = 0; i < v.size(); ++i) {
			for (int j = i; j < v.size(); ++j) {
//				if (!f[v[i]+v[j]]) {
					a.push_back(v[i]+v[j]);
//					f[v[i]+v[j]] = true;
//				}
			}
		}
		sort( a.begin(), a.end() );
//		a.erase( unique(a.begin(), a.end()), a.end() );
		cout << a[p-1] << endl;
	}
}

Measured memory_bytes: 1276
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint extgcd(lint a, lint b, lint &x, lint &y) {
  lint g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
lint invMod(lint a, lint m) {
  lint x, y;
  if (extgcd(a, m, x, y) == 1) return (x + m) % m;return 0;
}
lint zyo[1000100],rz[1000100];
lint mo=998244353;
lint co(int a,int b){
	if(a<0 || b<0 || a-b<0) return 0;
	return ((zyo[a]*rz[b])%mo*rz[a-b])%mo;
}
int main()
{
	zyo[0]=1;rep(i,1000010) zyo[i+1]=(zyo[i]*(i+1))%mo;
	rep(i,1000010) rz[i]=invMod(zyo[i],mo);
	int n,k;lint out=0;
	cin>>n>>k;
	rep(i,k+1){
		int j=k-i;
		if(j>i || i<n) continue;
		if(i==j){
			out+=co(k-1,i)-co(k-1,n-2);
		}
		else{
			out+=co(k,i)-co(k,j-1-(i-n));
		}
		out%=mo;
	}
	out+=mo;out%=mo;cout<<out<<endl;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	string s;
	int k; cin >> s >> k;
	
	int n = s.size();
	vector<vi> dp(2, vi(k + 1));
	dp[0][0] = 1;
	rep(i, n){
		vector<vi> next(2, vi(k + 1));
		rep(f, 2) rep(j, k + 1) if(dp[f][j]) rep(d, 10){
			
			if(!f && s[i] - '0' < d) continue;
			int nf = f || s[i] - '0'> d;
			int nj = j + (d > 0);
			if(nj > k) continue;
			next[nf][nj] += dp[f][j];
		}
		dp = next;
	}
	cout << dp[0][k] + dp[1][k] << endl;
	
	return 0;
}

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

int main() {
  
  int a,b,c,d,x;
  long long la,lb;
  double da,db;
  string s,ss,sss;
  
  int ans = 0;
  string anss = "";
  
  cin >> a >> b;
  
  int ab [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  int result3 = std::max({a, b, c});
//--------------------------------------------------------------------------------

  //if(a > 9 || b > 9) ans = -1;
  //else ans = a*b;

  cout << 6-a-b << endl;

}

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

int main() {
    double n,m,a,b,c,sum=0,flag=0;
	string s;
	cin>>a>>b;
	if(a+b==15){
	    cout<<'+'<<'\n';
	}
	else if(a*b==15){
	    cout<<'*'<<'\n';
	}
	else{
	    cout<<'x'<<'\n';
	}
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define has(c,i) 		((c).find(i) != end(c))
#define has_str(s, c)	((s).find(c) != string::npos)
typedef long long ll;

int main() {
#ifdef LOCAL
    //freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, c;
    cin >> n >> c;
    vector<ll> dp(c+1);
    for(int i = 0; i < n; ++i) {
        int w, v;
        cin >> w >> v;
        for(int j = c; j >= w; --j) {
            dp[j] = max(dp[j], dp[j - w] + v);
        }
    }
    cout << dp[c];
    return 0;
}

Measured memory_bytes: 3944
let a_s = Array.init 3 @@ fun _ -> Scanf.scanf " %d" (+) 0
let ans = ref 500
let f i j k = ans := min !ans @@ abs (a_s.(i) - a_s.(j)) + abs (a_s.(j) - a_s.(k))
let _ =
  f 0 1 2; f 0 2 1; f 1 0 2; f 1 2 0; f 2 0 1; f 2 1 0;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
vector<int>g[110000];
int L[110000];
int R[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a-1;i++){
		int p,q;scanf("%d%d",&p,&q);p--;q--;
		g[p].push_back(q);g[q].push_back(p);
	}
	for(int i=0;i<a;i++)L[i]=R[i]=-1;
	L[0]=0;R[a-1]=0;
	queue<int>Q;Q.push(0);
	while(Q.size()){
		int at=Q.front();Q.pop();
		for(int i=0;i<g[at].size();i++){
			int to=g[at][i];if(L[to]==-1){
				L[to]=L[at]+1;Q.push(to);
			}
		}
	}
	Q.push(a-1);
	while(Q.size()){
		int at=Q.front();Q.pop();
		for(int i=0;i<g[at].size();i++){
			int to=g[at][i];if(R[to]==-1){
				R[to]=R[at]+1;Q.push(to);
			}
		}
	}
	int B=0;int W=0;
	for(int i=0;i<a;i++){
		if(L[i]<=R[i])B++;
		else W++;
	}
	if(W>=B)printf("Snuke\n");else printf("Fennec\n");
}


Measured memory_bytes: 6912
from collections import defaultdict, deque

V, E = map(int, input().split())
# 隣接リストはdefaultdictで管理すると楽
G = defaultdict(lambda: [])

for i in range(E):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

INF = 10 ** 18
dist = [INF] * V
parent = [-1] * V  # 親ノード
q = deque()

dist[0] = 0
q.append(0)
while q:
    now = q.popleft()  # v: 探索起点
    for to in G[now]:  # u: 隣接リストの接続先
        if dist[to] != INF:  # uをすでに探索していたらINFではない。
            continue
        dist[to] = dist[now] + 1  # 距離の更新
        parent[to] = now
        q.append(to)

print("Yes")
for i in range(1, V):
    print(parent[i] + 1)


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

using namespace std;

int main(){

    int N;
    cin >> N;

    vector<int> vec(N, 0);

    for(int i = 0; i < N; i++){
	int a;
	cin >> a;
	vec.at(i) = a;
    }

    vector<bool> pushed(N, false);
    int pt = 1;
    int sum = 0;
    for(;;){
	int npt = vec.at(pt-1);
	sum++;
	if(npt == 2){
	    cout << sum << endl;
	    break;
	}else if(pushed.at(npt-1)){ // loop
	    cout << -1 << endl;
	    break;
	}
	pushed.at(npt-1) = true;
	pt = npt;
    }
    
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << N); ++bit)

int main()
{
    string S;
    cin >> S;
    ll N = S.length() - 1, sum = 0;
    repb(bit, N, 0)
    {
        ll s = 0, cnt = 1;
        repi(i, N, 0)
        {
            if (bit & (1 << i))
            {
                s += stoll(S.substr(S.length() - 1 - i, cnt));
                cnt = 1;
            }
            else
            {
                cnt++;
            }
        }
        s += stoll(S.substr(0, cnt));
        sum += s;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

    Scanner cin = new Scanner(System.in);
    int A = cin.nextInt();
    int B = cin.nextInt();
    int C = cin.nextInt();
    cin.close();

    int maxv = (int)Math.pow(10,8);
    int tmp = 101;
    String result = "NO";

    for(int i=0;i<maxv;i++){
        tmp = (i*A-C)%B;
          if(tmp==0){
            result = "YES";
            break;
          }
    }
    System.out.println(result);
  }
}

Measured memory_bytes: 23764
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  int N, a, b;
  string s;

  cin >> N >> a >> b ;
  cin >> s;

  int ac = 0;
  int o = 0;

  for (const char c : s) {
    bool f = false;
    if (c == 'b') ++o;

    if (c == 'a') {
      f = (ac < a+b);
    } else if (c == 'b') {
      f = (ac < a+b && o <= b);
    }

    if (f) {
      cout << "Yes" << endl;
      ++ac;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}



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

int main() {
	// your code goes here
	int a,b; cin >> a >> b;
	if(a==b) cout << a+b << endl;
	if(a>b) cout << 2*a-1 << endl;
	if(a<b) cout << 2*b-1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl;

typedef long long ll;
const ll INF = 99999999999999;
const ll MOD = 1000000007;

using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    ll ans = 0;
    rep(i, 3)
    {
        if (s[i] == t[i])
            ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 764
def abc042_c():
    price, len_hate_set = map(int, input().split())
    hate_set = set([int(i) for i in input().split()])

    usable_list = list(set(range(0, 10)) - hate_set)

    ans = 0

    while True:
        if all(map(lambda x: int(x) in usable_list, [int(str(ans)[i]) for i in range(len(str(ans)))])) and ans >= price:
            return ans

        ans += 1


if __name__ == '__main__':
    print(abc042_c())


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

const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

int main() {
	
	//vector<int> a(n);  sort(a.begin(),a.end());
	//cout << "test" << "\n";
	cin.tie(0);
	ios::sync_with_stdio(false);
	//string ans="YES";
	
//////////////////////////////////////////////
	
	
	string ans="Yes";
	
	int n;
	cin >> n;
	
	vector<int> a(n);
	rep(i,n) cin >> a[n-1-i];
	
	
	bool f=1;
	
	rep(i,n-1){
		if(a[i]<a[i+1]){
			if(a[i]==a[i+1]-1) a[i+1]--;
			else {
				ans="No";
				break;
			}
		}
	}
		

	cout << ans << "\n";
	
	
	return 0;
}


//g++ -o a a.cpp

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pl;
typedef pair<int,int> pi;
typedef pair<ll,pl> pp;
const ll MOD = 1e9+7;
const ll MAX = 1e18*2;

ll dp[111][111111];
int main(){
  ll n,k;
  cin>>n>>k;
  ll w[111111],v[111111];
  for(int i=0;i<n;i++)cin>>w[i]>>v[i];
  for(int i=0;i<n;i++){
    for(int j=0;j<=k;j++){
	 dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
	 if(j+w[i]>k)continue;
	 int nj=j+w[i];
	 dp[i+1][nj]=max(dp[i+1][nj],dp[i][j]+v[i]);
    }
  }
  ll ma=0;
  for(int i=0;i<=k;i++)ma=max(ma,dp[n][i]);
  cout<<ma<<endl;
  return 0;
}


Measured memory_bytes: 87424
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
const ll INF = INT_MAX;

typedef ll Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int main() {
  ll N,M;cin >> N >> M;
  Graph g(N);
  repeat(i,M){
    ll L,R;
    Weight D;
    cin >> L >> R >> D;
    L--;R--;
    g[L].emplace_back(L,R,D);
    g[R].emplace_back(R,L,-D);
  }
  vector<bool> isused(N,false);
  vector<ll> x(N,0);
  bool isok=true;
  repeat(i,N){
    if(isused[i]) continue;
    queue<int> Q;
    x[i]=0;
    Q.push(i);
    while(!Q.empty()){
      int u = Q.front();
      Q.pop();
      if(isused[u]) continue;
      isused[u] = true;
      for(auto e:g[u]){
        if(!isused[e.dst]){
          Q.push(e.dst);
          x[e.dst] = x[u]+e.weight;
        }else if(x[e.dst] != x[u]+e.weight){
          isok = false;
        }
      }
    }
  }
  cout << (isok? "Yes":"No") << endl;

  return 0;
}


Measured memory_bytes: 14080
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(n-1):
    if a[i]+a[i+1]>x:
        d=a[i+1]+a[i]-x
        if d<=a[i+1]:
            ans+=d
            a[i+1]-=d
        else:
            ans+=a[i+1]
            a[i+1]=0
            d=a[i]-x
            ans+=d
            a[i]-=d
print(ans)



Measured memory_bytes: 85480
#include <iostream>
using namespace std;
void solve(long long n){
	int cnt[2] ={0,0};
	for(long long i = 1; i <=n; i++){
		long long t = i;
		while(!(t % 2)){
			t /= 2;
			cnt[0]++;
		}
		while(!(t % 5)){
			t /= 5;
			cnt[1]++;
		}
	}
	cout << min(cnt[0], cnt[1]) << endl;
}
int main(){
	long long n;
	while(cin >> n, n){
		solve(n);
	}
	return 0;
}

Measured memory_bytes: 1160
A,V=map(int, input().split())
B,W=map(int, input().split())
T=int(input())

if W>=V:
    print('NO')
    exit(0)

if A*B<0:
    if (abs(A)+abs(B))/(V-W)<=T:
        print('YES')
    else:
        print('NO')
else:
    if abs(abs(A)-abs(B))/(V-W)<=T:
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 9036
#include<bits/stdc++.h>
using namespace std;
int N;
 int A [ 101010 ];

int V [ 101010 ];
 int num [ 101010 ];

void solve(){
	 int i,j,k,l,r,x,y; string s;
	
	
	cin >> N;
	multiset < int > M;
	for (int i=1;i<=N;i++){
		cin >> x;
		auto it = M.lower_bound(x);
		 if(it!= M.begin())M.erase(--it);
		M.insert(x);
	}
	cout << M.size()<< endl;
	
}

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

Measured memory_bytes: 4992
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,t = na()
a = na()
b = [0]
c = a[0]
for i in range(1,n):
    b.append(a[i]-c)
    c = min(c,a[i])

print(b.count(max(b)))

Measured memory_bytes: 14756
N, M = map(int, input().split())
q = [list(map(int, input().split())) for i in range(M)]

ans = -1
if N == 1:
  s = 0
else:
  s = 10 ** (N - 1)
for i in range(s, 10 ** N + 1):

  flag = True
  for j in range(M):
    try:
      if str(i)[q[j][0] - 1] != str(q[j][1]):
        flag = False
    except:
      flag = False
      break
      
  if flag:
    ans = i
    break
    
print(ans)


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

//  Utility method to convert integer into string
string toString(int n)
{
    string str;
    stringstream ss;
    ss << n;
    ss >> str;
    return str;
}

// Method to convert n to base negBase
string toNegativeBase(int n, int negBase)
{
    //  If n is zero then in any base it will be 0 only
    if (n == 0)
        return "0";

    string converted = "";
    while (n != 0)
    {
        // Get remainder by negative base, it can be
        // negative also
        int remainder = n % negBase;
        n /= negBase;

        // if remainder is negative, add abs(base) to
        // it and add 1 to n
        if (remainder < 0)
        {
            remainder += (-negBase);
            n += 1;
        }

        // convert remainder to string add into the result
        converted = toString(remainder) + converted;
    }

    return converted;
}

//  Driver code to test above methods
int main()
{
    int n ;
    cin>>n ;
    int negBase = -2;

    cout << toNegativeBase(n, negBase);

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>

#define int long long
#define rr register

#define MAXN 200010
#define inf 1e18

using namespace std;

inline int read(int &T) {
    int s = 0, f = 0;
    char ch = getchar();
    while (!isdigit(ch)) {f |= ch == '-'; ch = getchar();}
    while (isdigit(ch)) {s = s * 10 + (ch ^ 48); ch = getchar();}
    return T = f ? -s : s;
}

void print(int x) {
    if (x < 0) x = -x, putchar('-');
    if (x > 9) print(x / 10);
    putchar(x % 10 + '0');
}

int n,m,to[MAXN];

int cnt,head[MAXN];

int vis[MAXN],dis[MAXN];

struct Edge {
    int next, to;
}pth[MAXN<<2];

std::queue<int> q;

void add(int from,int to) {
    pth[++cnt].to=to,pth[cnt].next=head[from];
    head[from]=cnt;
}

signed main() {
    memset(dis,0x3f,sizeof dis);
    n = read(n), m = read(m);
    for (rr int i = 1; i <= m; ++i) {
        int u = read(u),v = read(v);
        add(u,v),add(v,u);
    }
    q.push(1);
    dis[1] = 0;
    while (!q.empty()) {
        int u = q.front();q.pop();
        for (rr int i = head[u]; i; i = pth[i].next) {
            int v = pth[i].to;
            if(dis[v] > dis[u] + 1) {
                dis[v] = dis[u]+1;
                to[v] = u;
            }
            if(!vis[v]) {
                q.push(v);
                vis[v] = 1;
            }
        }
    }
    for(int i=2;i<=n;++i) {
        if(dis[i]==inf) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    for(int i=2;i<=n;++i) {
        printf("%d\n",to[i]);
    }
    return 0;
}

Measured memory_bytes: 14088
//Battlefield control establishing...
#include <iostream>
#include <cstdio>
//#include <bits/stdc++.h>
#include <iomanip>
#include <cstring>
#include <cmath>
//#include <minmax.h>
#include<queue>
#define MCV main
#define lldin(a) scanf("%lld",&a)
#define din(a) scanf("%d",&a)
#define reset(a,b) memset(a,b,sizeof(a))
const int INF=0x3f3f3f3f;
using namespace std;
typedef long long ll;
//Get ready? LET'S ROCK!
int MCV()
{
  int a,b,k;
  cin>>a>>b>>k;
  int tmp=min(a,b);
  int cnt=0,ans;
  for(int i=tmp;i>=1;i--)
  {
     if(a%i==0&&b%i==0)
      {
         cnt++;
         if(cnt==k)
         {
            ans=i;
            break;
         }
      }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>


using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

vector<bool> d(10, true);

bool isOK(int cur) {

	while(cur > 0) {
		if (d[cur % 10] == false) {
			return false;
		}
		cur /= 10;
	}
	return true;

}

int main() {
	int n, k;

	cin >> n >> k;

	
	for (int i = 0; i < k; i++) {
		int temp_d;
		cin >> temp_d;
		d[temp_d] = false;
	}

	for (int i = n; i < 100000; i++) {
		if (isOK(i)) {
			cout << i << endl;
			return 0;
		}
	}


	
	return 0;
}

Measured memory_bytes: 256
macro_rules! scan {
    ( $( $x:ident ),*; $t:ty ) => {
        let mut buf = String::new();
        let mut itr = {
            while buf.trim().len() == 0 {
                buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
            }
            buf.split_whitespace().map(|n| n.parse::<$t>().unwrap())
        };
        $(
            let $x = itr.next().unwrap();
        )*
    };
}

fn main() {
    scan!(n; u64);
    if n % 2 == 1 {
        println!("0");
        return;
    }

    let mut m:u64 = 0;
    let mut t = 5;
    while t <= n {
        let u = n / t;
        m += u/2;
        t *= 5;
    }

    println!("{}", m);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <iomanip>
#include <stack>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
const ll INF = 1LL << 50;

int solve();

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

int solve() {

	int a = 0;
	for (int i = 0; i < 3; i++) {
		int j;
		cin >> j;
		a *= 10;
		a += j;
	}

	if (a % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
// Input macros
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%lld",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
// Useful constants
#define INF                         (int)1e9
#define EPS                         1e-9
// Useful hardware instructions
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
// Useful container manipulation / traversal macros
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
// Some common useful functions
#define maX(a,b)                     ( (a) > (b) ? (a) : (b))
#define miN(a,b)                     ( (a) < (b) ? (a) : (b))
#define checkbit(n,b)                ( (n >> b) & 1)
#define DREP(a)                      sort(all(a)); a.erase(unique(all(a)),a.end())
#define INDEX(arr,ind)               (lower_bound(all(arr),ind)-arr.begin())
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int x[100010];
int N, X;

int main()
{
    int last, ans;
    cin>>N>>X;
    forall(i,0,N){
        cin>>x[i];
        if (i == 0){
            ans = x[i] - X;
        } else {
            ans = gcd(ans, x[i] - X);
        }
    }
    cout<<abs(ans);
    return 0;
}


Measured memory_bytes: 640
/**
*
* Author: MARC
* Lang: GNU C++14
*
**/

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

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >

typedef unsigned long long ull;
typedef long double ldbl;
typedef long long ll;
typedef double dbl;

const ldbl E = 2.71828182845904523536;
const ldbl pi = acos(-1);
const dbl eps = 1e-9;
const ll mod = 1e9+7;
const ll inf = 1LL<<30;

/** /////////// ** Code ** /////////// **/

const int N=100100;

int main()
{
    string s; cin>>s;
    if(s[0] == s[2]) cout<<"Yes";
    else cout<<"No";
    return 0;
}


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

using namespace std;

int main(void)
{
    int row,col;
    scanf("%d%d",&row,&col);
    string str[row+3];
    for(int i=0;i<row;i++)cin>>str[i];
    for(int i=0;i<row;i++)cout<<str[i]<<"\n"<<str[i]<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    bool a = false, b = false, c = false;
    for(int i = 0; i < 3; i++){
        if(s[i] == 'a'){
            a = true;
        }
        if(s[i] == 'b'){
            b = true;
        }
        if(s[i] == 'c'){
            c = true;
        }
    }
    if(a == true && b == true && c == true){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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 (a>b) { a=b; return 1; } return 0; }

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

    int N,A,B; cin >> N >> A >> B;
    vei p(N); rep(i,N) cin >> p[i];

    int cnt1 = 0, cnt2 = 0, cnt3 = 0;
    rep(i,N) {
        if(p[i] <= A) cnt1++;
        if(A + 1 <= p[i] and p[i] <= B) cnt2++;
        if(p[i] >= B+1) cnt3++;
    }
    cout << min(cnt1, min(cnt2, cnt3)) << endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long int ll;
const int64_t MOD = 1e9+7;

int main(){
    ll N; cin >> N;
    vector<int64_t> A(N+1);
    int64_t res = 0;
    rep(i,N) cin >> A[i];
    rep(k,60){
        int64_t n0=0, n1=0;
        rep(i,N){
            if(A[i]&((int64_t)1<<k) ) n1++;
            else n0++;
        }
        int64_t num = (n0 * n1) % MOD;
        int64_t p = pow(2,k); p %= MOD;
        res += (p * num);
        res %= MOD;
    }
    cout << res << endl;
}

Measured memory_bytes: 2560
fn main() {
    let mut buf = String::new();
    let _ = std::io::stdin().read_line(&mut buf);
    let mut iter = buf
        .trim()
        .split_whitespace()
        .map(|x| x.parse::<u32>().unwrap());
    let n = iter.next().unwrap();
    let k = iter.next().unwrap();
    let mut i = 0.0;
    for x in 1..(n + 1) {
        let mut c = x;
        for y in 0.. {
            if k <= c {
                c = y;
                break;
            } else {
                c *= 2;
            }
        }
        i += (0.5f64).powf(c as f64);
    }
    println!("{}", i / n as f64);
}


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

int main(){
  int N;
  cin >> N;
  vector<int> card(N);
  rep(i,N)
    cin >> card.at(i);
  stable_sort(card.begin(),card.end(),greater<int>());
  int A=0,B=0;
  rep(i,N){
    if(i%2==0)
      A += card.at(i);
    if(i%2==1)
      B += card.at(i);
  }
  cout << A-B << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    string s;
    cin >> s;

    int count = 0;
    char current = 'a';
    for(char c : s){
        if(c != current){
            current = c;
            count++;
        }
    }

    p(count-1);
    
    return 0;
}

Measured memory_bytes: 512
N = int(input())

Alist = []
Blist = []

for _ in range(N):
    a, b = map(int, input().split())
    Alist.append(a)
    Blist.append(b)

Alist.sort()
Blist.sort()

if N%2==1:
    center_A = Alist[(N-1)//2]
    center_B = Blist[(N-1)//2]
    print(int(center_B - center_A + 1))

else:
    center_A = (Alist[N//2 - 1] + Alist[N//2]) / 2
    center_B = (Blist[N//2 - 1] + Blist[N//2]) / 2
    print(int(center_B * 2 - center_A * 2 + 1))

Measured memory_bytes: 25408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	ll cnt=0;
	for(ll i=1;i<=n;i++){
		ll now=n/i;
		cnt+=now;
		if(n%i==0){
			cnt--;
		}
		//cout << cnt<<endl;
	}
	cout <<cnt;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3668
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int psize;
int prime[2000000];
bool bprime[2000000];

int main() {
  MEMSET(bprime, true);
  bprime[0] = bprime[1] = false;
  REP(i, 2000000) {
    if (!bprime[i]) { continue; }
    prime[psize++] = i;
    for (int j = i + i; j < 2000000; j += i) {
      bprime[j] = false;
    }
  }
  int n;
  while (scanf("%d", &n), n) {
    if (bprime[n]) { puts("0"); }
    else {
      int upper = *upper_bound(prime, prime + psize, n);
      int lower = *(upper_bound(prime, prime + psize, n) - 1);
      cout << upper - lower << endl;
    }
  }
}

Measured memory_bytes: 0
#include <stdio.h>

static const int N = 100;

int min(int a, int b){

  return a < b ? a : b;

}


int main(){

  int i,j,k,l,v,n,X[N+1],Y[N+1][N+1];
  
  scanf("%d",&n);
  
  for(i=1;i<=n;i++){
    scanf("%d%d",&X[i-1],&X[i]);
  }

  for(i=1;i<=n;i++){
    Y[i][i] = 0;
  }
  
  for(l=2;l<=n;l++){
    for(i=0;i<=n-l+1;i++){
      j = i + l -1;

      Y[i][j] = (1<<21);
      
      for(k=i;k<=j-1;k++){
        Y[i][j] = min(Y[i][j],Y[i][k] + Y[k+1][j] + X[i-1]*X[k]*X[j]);
        v = Y[i][k] + Y[k+1][j] + X[i-1]*X[k]*X[j];

        //printf("m[%d,%d] + m[%d,%d] + p[%d]p[%d]p[%d] = %d\n",i,k,k+1,j,i-1,k,j,v);
      }
    }
  }

  /*for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      
      printf("%4d",Y[i][j]);
    }
    
    printf("\n");
    }*/

  
  printf("%d\n",Y[1][n]);

  return 0;

}


Measured memory_bytes: 2056
#include <stdio.h>
int main(void){
	int i,j,N,M,K,tmp,count=0;

	scanf("%d %d",&N,&M);
	int A[M];

	for(j=0;j<M;j++){
		A[j] = 0;
	}

	for(i=0;i<N;i++){
		scanf("%d",&K);
		for(j=0;j<K;j++){
			scanf("%d",&tmp);
			A[tmp-1]++;
		}
	}
	for(i=0;i<M;i++){
		if(A[i] == N){
			count++;
		}
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 128
using static System.Math;
using System.Linq;
using System.Collections.Generic;
using System;

public class P
{
    public int p1 { get; set; }
    public int p2 { get; set; }
}

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var s = getArray(a);
        var t = getArray(b);
        var q = int.Parse(line[2]);
        for (int i = 0; i < q; i++)
        {
            var x = long.Parse(Console.ReadLine().Trim());
            var ss = getPos(s, a, x);
            var tt = getPos(t, b, x);
            Console.WriteLine(getAns(ss.p1, ss.p2, tt.p1, tt.p2, x, s, t));
        }
    }
    static long getAns(long a1, long a2, long b1, long b2, long x, long[] s, long[] t)
    {
        var ans = new List<long>();
        ans.Add(Abs(s[a1] - x) + Abs(s[a1] - t[b1]));
        ans.Add(Abs(s[a1] - x) + Abs(s[a1] - t[b2]));
        ans.Add(Abs(s[a2] - x) + Abs(s[a2] - t[b1]));
        ans.Add(Abs(s[a2] - x) + Abs(s[a2] - t[b2]));
        ans.Add(Abs(t[b1] - x) + Abs(t[b1] - s[a1]));
        ans.Add(Abs(t[b1] - x) + Abs(t[b1] - s[a2]));
        ans.Add(Abs(t[b2] - x) + Abs(t[b2] - s[a1]));
        ans.Add(Abs(t[b2] - x) + Abs(t[b2] - s[a2]));
        return ans.Min();
    }
    static P getPos(long[] a, int aL, long x)
    {
        var ans = new P();
        var p = LowerBound(a, x);
        if (p == 0)
        {
            if (x < a[0]) { ans.p1 = 0; ans.p2 = 0; }
            else { ans.p1 = 0; ans.p2 = 1; }
        }
        else if (p == aL) { ans.p1 = aL - 1; ans.p2 = aL - 1; }
        else { ans.p1 = p - 1; ans.p2 = p; }
        return ans;
    }
    static long[] getArray(int n)
    {
        var ans = new long[n];
        for (int i = 0; i < n; i++) ans[i] = long.Parse(Console.ReadLine().Trim());
        return ans;
    }
    public static int LowerBound<T>(T[] arr, int start, int end, T value, IComparer<T> comparer)
    {
        int low = start;
        int high = end;
        int mid;
        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (comparer.Compare(arr[mid], value) < 0)
                low = mid + 1;
            else
                high = mid;
        }
        return low;
    }
    public static int LowerBound<T>(T[] arr, T value) where T : IComparable
    {
        return LowerBound(arr, 0, arr.Length, value, Comparer<T>.Default);
    }
}

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

using namespace std ;

int main () {

    long long n , m,ans=0 ,i,j ,k=0,p ;

    string s;

    cin >> s;

    for (i=0;i<s.size();i++){
        if (s[i]=='x')
            k++ ;
    }

    if (15-k>=8)
        cout << "YES\n" ;
    else
        cout << "NO\n" ;





    return 0 ;
}


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

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

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();

            double X = N / 1.08;

            if ((int) (Math.floor(X) * 1.08) == N) {
                out.println((int) Math.floor(X));
            } else if ((int) (Math.ceil(X) * 1.08) == N) {
                out.println((int) Math.ceil(X));
            } else {
                out.println(":(");
            }
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

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

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

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
struct tpl {
    int s,t,x;
};
int n,q,s[200001],t[200001],x[200001],p1;
long long ans[200001];
vector<tpl> road[400001];
vector<int> comp;
multiset<pair<int,int> > ppl;
map<int,int> m;
int main() {
    cin>>n>>q;
    for (int i=0; i<n; i++) {
        cin>>s[i]>>t[i]>>x[i];
        comp.push_back(x[i]);
    }
    sort(comp.begin(),comp.end()); comp.erase(unique(comp.begin(),comp.end()),comp.end());
    for (int i=0; i<comp.size(); i++) m[comp[i]]=i+1;
    for (int i=0; i<n; i++) {
        road[m[x[i]]].push_back({s[i],t[i],x[i]});
    }
    for (int i=0; i<q; i++) {cin>>p1; ppl.insert({p1,i});}
    memset(ans,-1,sizeof(ans));
    for (int i=1; i<=comp.size(); i++) {
        for (int j=0; j<road[i].size(); j++) {
            int l=road[i][j].s,r=road[i][j].t;
            auto it=ppl.lower_bound(make_pair(l-road[i][j].x,-1));
            auto it2=ppl.lower_bound(make_pair(r-road[i][j].x,-1));
            for (it; it!=it2; it++) {
                ans[it->second]=road[i][j].x;
            }
            it=ppl.lower_bound(make_pair(l-road[i][j].x,-1));
            ppl.erase(it,it2);
        }
    }
    for (int i=0; i<q; i++) cout<<ans[i]<<'\n';
}

Measured memory_bytes: 42320
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto K = RD;
	auto s = RD!string;

	string ans = s[0..K-1];
	if (s[K-1] == 'A')
		ans ~= "a";
	else if (s[K-1] == 'B')
		ans ~= "b";
	else
		ans ~= "c";
	ans ~= s[K..$];

	writeln(ans);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    String A = sc.next();
    if(N < A.length()){
      String tmpS = A.substring(0, N) + "...";
      System.out.println(tmpS);
    }else{
      System.out.println(A);
    }


  }
}




Measured memory_bytes: 38496
// C - Flip,Flip, and Flip......

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	ll N, M;
	cin >> N >> M;

	ll ans;

	if (N == 1 && M == 1) {
		ans = 1;
	} else if (N == 1) {
		ans = M - 2;
	} else if (M == 1) {
		ans = N - 2;
	} else {
		ans = (N - 2) * (M - 2);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main(){
	int N,A,B;
	cin >> N >> A >> B;
	
	int ans=0;
	int total;
	for(int n=1;n<=N;n++){
		total = n%10 + (n%100-n%10)/10 + (n%1000-n%100)/100 + (n%10000-n%1000)/1000 + (n%100000-n%10000)/10000;
		if(total>=A && total<=B){
			ans+=n;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  long long ans=0;
  rep(i,N-1){
    // A*B = i+1
    int count=0;
    for(int k=1; k*k<=i+1; k++){
      if (k*k==i+1) count++;
      else{
        if ((i+1)%k==0) count+=2;
      }
    }
    ans += count;
  }

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

Measured memory_bytes: 3620