akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        long[] lucas = new long[n + 1];
        lucas[0] = 2;
        lucas[1] = 1;
        for (int i = 2; i <= n; i++) {
            lucas[i] = lucas[i - 1] + lucas[i - 2];
        }
        System.out.println(lucas[n]);
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;
inline int getint(){
  char c; int res = 0;
  for(c = getchar();c < '0' || c > '9';c = getchar());
  for(;c >= '0' && c <= '9';c = getchar()) res = res * 10 + (c - '0');
  return res;
}
deque <int> deq1,deq2,min1,min2,max1,max2;
int q;
void pushb2(int x){
  deq2.push_back(x);
  while(!min2.empty() && min2.back() > x) min2.pop_back();
  min2.push_back(x);
  while(!max2.empty() && max2.back() < x) max2.pop_back();
  max2.push_back(x);
}
int popf2(){
  int tmp = deq2.front();
  deq2.pop_front();
  if(!min2.empty() && min2.front() == tmp) min2.pop_front();
  if(!max2.empty() && max2.front() == tmp) max2.pop_front();
  return tmp;
}
void pushb1(int x){
  deq1.push_back(x);
  if(min1.empty() || min1.back() > x) min1.push_back(x);
  if(max1.empty() || max1.back() < x) max1.push_back(x);
}
int popb1(){
  int tmp = deq1.back();
  deq1.pop_back();
  if(!min1.empty() && min1.back() == tmp) min1.pop_back();
  if(!max1.empty() && max1.back() == tmp) max1.pop_back();
  return tmp;
}

//void print(deque <int> q){
//  for(int i = 0;i < (int)q.size();i++){
//    cout << q[i] << " ";
//  }
//  cout << endl;
//}

int main(){
  while((q = getint()) && q){
    deq1.clear(); min1.clear(); max1.clear();
    deq2.clear(); min2.clear(); max2.clear();
    int len = 0;
    while(q--){
      int fl = getint(), x = 0;
      if(fl == 0 || fl == 4 || fl == 5 || fl == 8 || fl == 9) x = getint();
      if(fl == 0){
        pushb2(x);
        len++;
        if(len & 1){
          int tmp = popf2();
          pushb1(tmp);
        }
      }else if(fl == 1){
        int tmp = popb1();
        printf("%d\n",tmp);
        len--;
        if(len & 1){
          tmp = popf2();
          pushb1(tmp);
        }
      }else if(fl == 2){
        printf("%d\n",min1.back());
      }else if(fl == 3){
        printf("%d\n",min2.front());
      }else if(fl == 4){
        printf("%d\n",min1.at(min1.size() - x));
      }else if(fl == 5){
        printf("%d\n",min2.at(x - 1));
      }else if(fl == 6){
        printf("%d\n",max1.back());
      }else if(fl == 7){
        printf("%d\n",max2.front());
      }else if(fl == 8){
        printf("%d\n",max1.at(max1.size() - x));
      }else if(fl == 9){
        printf("%d\n",max2.at(x - 1));
      }
    }
    puts("end");
  }
  return 0;
}



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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N,K;
    cin >> N >> K;
    cout << N-(K-1) << endl;
}

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

int main() {
  int n;
  cin>>n;
  int a[n];
  for (int i=0; i<n; i++) cin>>a[i];
  sort(a, a + n);
  long long sum = a[n-1];
  int cnt = n - 2;
  for (int i=n-2; i>=0 && cnt > 0; i--) {
    sum += min(2, cnt) * a[i];
    cnt -= 2;
  }
  cout<<sum<<endl;
}

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

#define int long long

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

  int n = s.size();
  for (int begin = 0; begin < n; begin++) {
    for (int end = 0; end <= n; end++) {
      string t = "";
      for (int k = 0; k < n; k++) {
        if (begin <= k && k < end) {
          continue;
        } else {
          t.push_back(s[k]);
        }
      }
      if (t == "keyence") {
        puts("YES");
        return 0;
      }
    }
  }

  puts("NO");

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>

using namespace std;

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

        int ans = 1;
        int minimum;
        cin >> minimum;
        for(int i = 1; i < n; i++) {
                int pi;
                cin >> pi;
                if(minimum >= pi) {
                        minimum = pi;
                        ans++;
                }
        }

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

Measured memory_bytes: 384
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}


int main(void){
  int N, A, B, W, H;
  int c[3][3], a[3][2];
  rep(i, 3) rep(j, 3) cin >> c[i][j];
  rep(i, 3){
    a[i][0] = c[i][1] - c[i][0], a[i][1] =c[i][2] - c[i][1];
  }
  rep(j, 2) {
    if (a[0][j] != a[1][j] || a[1][j] != a[2][j]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


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

const int INF = 1e9;

int main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(N + 2);
    rep(i, N) cin >> A[i + 1];
    int ans = INF;
    auto solve = [&](int x) -> int {
        priority_queue<int> que;
        vector<int> P;
        rep(i, N + 2) if(A[i] < x) P.push_back(i);
        rep(i, P.size() - 1) {
            priority_queue<int, vector<int>, greater<int>> tmp;
            for(int j = P[i] + 1; j < P[i + 1]; ++j) tmp.push(A[j]);
            while(tmp.size() >= K) que.push(tmp.top()), tmp.pop();
        }
        int mx = 0;
        if(que.size() < Q) return INF;
        while(que.size() > Q) que.pop();
        return que.top() - x;
    };
    for(int i = 1; i < N + 1; ++i) ans = min(ans, solve(A[i]));
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3608
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
using namespace std;
//int bz[1000];
typedef long long ll;
ll mypow(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)
		ans*=a;
			a*=a;
		b/=2;
	}
	return ans;
}
int main()
{
	int x;
	cin>>x;
	ll ans=0;
	ll t;
	for(int i=1;i<=50;i++){
		for(int j=2;j<=50;j++){
			
			if(mypow(i,j)<=x)
			{
				ans=max(ans,mypow(i,j));
			}
			else
				break;
		}
	}
	cout<<ans<<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++)

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

    return 0;
}

Measured memory_bytes: 256
import java.lang.*;
import java.util.*;

public class Main
{
    
    public static void main(String args[])
    {
	int[] num = new int[11];
	int[] a_i = new int[21];
	Scanner sc = new Scanner(System.in);
	int i,j,t;
	
	int in,l,c;

	while(true){
	    in = sc.nextInt();
	    l = sc.nextInt();
	    if(in == 0 && l == 0)break;
	    for(i=0; i<l; i++){
		num[i] = 0;
	    }
	    c=0;
	    
	    while(true){
		 
		if(c==0){
		    a_i[c]=in;
		    c++;
		}else{
		    for(i=0; i<10; i++){
			num[i] = 0;
		    }
		    int max=0, min=0;
		    			
		    for(i=0; i<l; i++){
		
			if(in<0){
			    num[0] += 1;
			}else{
			    num[in%10] += 1;
			    in /= 10;
			}
		    }
		    		     
		    for(t=l, i=9; t>0 ; i--){
			if(num[i] == 0) continue;
			while(num[i] > 0){
			    max += i;
			    if(--t <= 0) break;
			    max *= 10;
			    num[i]--;
			    
			}
		    }
		    
		    in = max;
		    for(t=0; t<l ;t++){
				if(in%10 == 0){
				    in/=10;
				}else{
				    min += in%10;
				    min *= 10;
				    in/=10;
				}			
		    }
		    min/=10;
		    		    
		    boolean f= false;
		    
		    for(i=0;i<c;i++){
			if(a_i[i]==(max - min)){
			    System.out.println( i + " " + a_i[i] + " " + (c-i) );
			    f=true;
			}
			
		    }
		    if(f) break;
		    
		    a_i[c++] = max - min;
		    in = max-min;
		}
		
	    }
	    
	}
    }
}

    

Measured memory_bytes: 20348
from collections import deque
n,q=map(int,input().split())
K=[[]for _ in range(n)]
P=[0]*n
V=[False]*n
for i in range(n-1):
   a,b=map(int,input().split())
   K[a-1].append(b-1)
   K[b-1].append(a-1)
for i in range(q):
   p,x=map(int,input().split())
   P[p-1]+=x
que=deque([0])
while que:
   s=que.popleft()
   V[s]=True
   for ni in K[s]:
      if V[ni]==False:
         P[ni]+=P[s]
         que.append(ni)
print(*P)

Measured memory_bytes: 105236
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>
#include <functional>

using namespace std;
using ll = long long;
using ld = double;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll, ll>;
const ll INF = 1e17;
const ld eps = 1e-10;
const ll MOD = 1e9 + 7;

const double pi = acos(-1.0);


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll k;
	string s;
	cin >> s;
	k = s.size();
	ll win = 0;
	for (int i = 0;i < s.size();i++)
		if (s[i] == 'o')
			win++;
	win += 15 - k;
	if (win >= 8)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T>T read(){
	T x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())x=(x<<3)+(x<<1)+(c^48);
	return x*f;
}
/*struct Edge{
	int be[maxn],tot;
	int to[maxn],ne[maxn];
	void add(int u,int v){
		to[++tot]=v;
		ne[tot]=be[u];
		be[u]=tot;
	}
}G;*/
const int maxn=2e5+10; 
vector<int> G[maxn];

int b[maxn],n,p[maxn];

//#define Eor(i,u) for(int i=G.be[u];i;i=G.ne[i])

const int mod=1e9+7,inv2=mod+1>>1;
int pow2=1,ans,tot;

struct data{
	int z0,z1,z2;
};

data operator + (data a,data b){
	data c;
	c.z0=1ll*a.z0*b.z0%mod;
    c.z1=(1ll*a.z0*b.z1+1ll*a.z1*b.z0)%mod;
    c.z2=(1ll*a.z0*b.z2+1ll*a.z2*b.z0+1ll*a.z1*b.z1+1ll*a.z2*b.z2+1ll*a.z1*b.z2+1ll*a.z2*b.z1)%mod;
    return c;
}

vector<data> a[maxn];

void merge(int &x,int y){
	if(a[x].size()<a[y].size())swap(x,y);
	
	for(int i=0;i<a[y].size();++i){
		//a[x][a[x].size()-i-1]
		a[x][a[x].size()-i-1]=a[x][a[x].size()-i-1]+a[y][a[y].size()-i-1];
	}
	
}

void solve(){
	n=read<int>()+1;
	for(int i=2;i<=n;++i){
		p[i]=read<int>()+1;
		//cerr<<p[i]<<endl;
		G[p[i]].push_back(i);
		//G.add(p[i],i);
	}
	for(int i=n;i;--i){
		int mx=0;
		if(G[i].size()==0){
			//cerr<<i<<endl;
			a[b[i]=++tot].push_back((data){inv2,inv2,0});
		}
		else{
			b[i]=b[G[i][0]];
			for(int j=1;j<G[i].size();++j){
				int v=b[G[i][j]];
				mx=max(mx,(int)min(a[b[i]].size(),a[v].size()));
				merge(b[i],v);
			}
			a[b[i]].push_back((data){inv2,inv2,0});
		}
		for(int j=(int)a[b[i]].size()-1-1;j>=(int)a[b[i]].size()-mx-1;--j)
			a[b[i]][j].z0+=a[b[i]][j].z2,a[b[i]][j].z2=0;
		pow2=(pow2<<1)%mod;
	}
	
	for(int i=0;i<a[b[1]].size();++i){
		//cerr<<a[b[1]][i].z1<<endl;
		(ans+=a[b[1]][i].z1)%=mod;
		//cerr<<ans<<endl;
	}
	//cerr<<ans<<" "<<pow2<<endl;
	cout<<1ll*ans*pow2%mod<<endl;
}
int main(){
	solve();
	
	return 0;
} 

Measured memory_bytes: 21236
import * as fs from 'fs';

//in
// 2
// ABCXYZ
//out
// CDEZAB
const main = (inp: string) => {
    const n: number = parseInt(inp.split('\n')[0]);
    let ans: string[] = inp.split('\n')[1].split('');

    // 65 - 90
    for (let i: number = 0; i < ans.length; i++) {
        let code: number = ans[i].charCodeAt(0) + n;
        if (code > 90) {
            code = 65 + (code - 91);
        }
        ans[i] = String.fromCharCode(code);
    }
    console.log(ans.join(''));
};

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


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

#define ll long long
#define ld long long
#define pi 3.14159265359

int main() {
    int N; cin >> N;
    ll ans = 0;
    for (int i = 1; i < N + 1; i++ ) {
        if (i % 3 != 0 && i % 5 != 0) {
            ans += i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n;
    string s;
    cin>>n>>s;
    int ans = 0;
    for(int i=1;i<s.size();i++){
        int now = 0;
        set<char> sc1,sc2;
        for(int j=0;j<i;j++){
            sc1.insert(s[j]);
        }
        for(int j=i;j<s.size();j++){
            sc2.insert(s[j]);
        }
        for(auto u : sc1){
            if(sc2.find(u)!=sc2.end()) now++;
        }
        ans = max(ans,now);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input());A = list(map(int,input().split(' ')))
x = [0]*100001
for a in A:
    if a != 0:
        x[a-1]+=1;x[a]+=1;x[a+1]+=1
    else:
        x[a]+=1;x[a+1]+=1
print(max(x))

Measured memory_bytes: 14004
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

int N; LL M;
std::vector<LL> A;

LL Count(LL v) {
  LL count = 0;
  for (const LL Ax : A) {
    LL Ay = v - Ax;
    int idx = std::lower_bound(A.begin(), A.end(), Ay) - A.begin();
    count += N - idx;
  }
  return count;
}

LL Sum(int v) {
  std::vector<LL> As = A;
  for (int i = N-2; i >= 0; --i) As[i] += As[i + 1];

  LL sum = 0;
  for (const LL Ax : A) {
    LL Ay = v - Ax;
    int idx = std::lower_bound(A.begin(), A.end(), Ay) - A.begin();
    LL cnt = N - idx;
    if (cnt == 0) continue;

    sum += Ax * cnt;
    sum += As[idx];
  }
  return sum;
}

int main() {
  std::cin >> N >> M;
  A.resize(N);
  for(int i = 0; i < N; ++i) std::cin >> A[i];
  std::sort(A.begin(), A.end());

  LL l = 0, r = 2 * A[N-1] + 1;
  while (l + 1 != r) {
    LL mid = (l + r) / 2;
    if (M <= Count(mid)) l = mid;
    else r = mid;
  }

  LL ans = (M - Count(l + 1)) * l + Sum(l + 1);
  std::cout << ans << std::endl;
}


Measured memory_bytes: 1792
N, X, Y = gets.split(" ").map(&:to_i)
ans = Array.new(N - 1, 0)

(N - 1).times do |i|
    j = i + 1
    while j < N do
        if X < i + 1 && j + 1 < Y
            min = (((2 * i - X + Y - 2 * j + 1) >= 0) ? (j - i - 1) : (- X + Y + i - j))
            ans[min] += 1
        elsif X < i + 1 && j + 1 >= Y
            min = (((2 * i - X - Y + 3) >= 0) ? (j - i - 1) : (i + j - X - Y + 2))
            ans[min] += 1
        elsif X >= i + 1 && Y >= j + 1
            min = (((X + Y - 2 * j - 1) >= 0) ? (j - i - 1) : (X + Y - i - j - 2))
            ans[min] += 1
        elsif X >= i + 1 && Y < j + 1
            ans[X - Y - i + j] += 1
        end
        j += 1
    end
end

puts ans

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

int main() {
    int N, C, K;
    cin >> N >> C >> K;
    vector<int> T(N);
    rep(i, N) cin >> T[i];
    sort(T.begin(), T.end());
    int ans = 0;
    rep(i, N) {
        int j = i;
        while(j < N && j - i + 1 < C && T[j + 1] - T[i] <= K) {
            ++j;
        }
        if(j == N) --j;
        i = j;
        ++ans;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c=1,d;
    cin>>a>>b;
    d=(a*2)-1;
    for(int i=0; i<d; i++){
        cout<<b-(a-c)<<" ";
        c++;
    }
    cout<<'\n';
    return(0);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    while(cin >> S) {
        int x = 0, y = sz(S), z = 0;
        each(c, S) {
            if(c == 'p')--x;
        }
        rep(i, sz(S)) {
            if(z + 1 <= y - 1)++x, --y, ++z;
        }
        cout << x << endl;
    }
}

Measured memory_bytes: 512
#include "math.h"
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <functional>
#include <numeric>
#include <cmath>
using namespace std;

int t;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int l, r, d;
	cin >> l >> r >> d;
	int ans = floor(r*1.0 / d) - floor(l*1.0/d);
	if (l%d == 0 && r % d == 0) ans++;
	cout << ans;
	return 0;
}


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

int main(){
  int k,x;
  cin >> k >> x;
  for(int i=x-k+1;i<k+x;i++){
    if(i<-10000000) continue;
    if(i>10000000) break;
    cout << i;
    if(i!=x+k-1 && i!=10000000) cout << " ";
  }
  return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
signed main() {
	int n; cin >> n;
	int a[123456]; for (int i = 0; i < n; i++)cin >> a[i]; sort(a, a + n);
	cout << a[n / 2] - a[n / 2 - 1]<<endl;
	cin >> n;
}

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

using ll = long long;

int main() {
    int x;
    cin >> x;
    if(x == 7 || x == 5 || x == 3)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
typedef long long int ll;
void swap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
ll asc(const void *a,const void *b){return *(ll*)a-*(ll*)b;}
ll desc(const void *a,const void *b){return *(ll*)b-*(ll*)a;}
ll max(ll x,ll y){return x>y?x:y;}
ll min(ll x,ll y){return x>y?y:x;}

int main(){
    int n,p[40];
    scanf("%d",&n);

    int cnt=0;
    for(int i=0;i<n;i++)scanf("%d",&p[i]);
    for(int i=1;i<n-1;i++){
        if(p[i-1]<p[i]&&p[i]<p[i+1])cnt++;
        else if(p[i-1]>p[i]&&p[i]>p[i+1])cnt++;
    }
    printf("%d\n",cnt);
    return 0;

}

Measured memory_bytes: 128
N = int(input())
flg = False
for i in range(N//4+1):
    for j in range(N//7+1):
        if 4*i + 7*j == N:
            flg = True
        if 4*i + 7*j > N:
            break
if flg:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
N, Y = map(int,input().split())

for i in range(N+1):
  for j in range(N+1):
    k = N-i-j
    if k >= 0:
      if 10000*i+5000*j+1000*k == Y:
        print(i, j, k)
        exit()
print(-1, -1, -1)

Measured memory_bytes: 2940
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
const int N = 1000000;
const int mod = 1000000007;
const int INF = 1 << 30;
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define vin(v,n) rep(i,n)cin>>v[i];
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define sz size()
#define fi first
#define se second
#define pb push_back
#define prqueue priority_queue<ll,vector<ll>,greater<ll>>
string YN(bool b) { return(b ? "YES" : "NO"); }
string yn(bool b) { return(b ? "Yes" : "No"); }
ll n,sums[300010],sums2[300010],ans=INF;
string s;
int main() {
	cin >> n >> s;
	rep(i, n) {
		if (s[i] == 'W'&&i < n - 1)sums[i + 1] = sums[i] + 1;
		else sums[i + 1] = sums[i];
	}
	for (ll i = n - 1; i >= 0; --i) {
		if (s[i] == 'E'&&i > 1)sums2[i - 1] = sums2[i] + 1;
		else sums2[i - 1] = sums2[i];
	}
	rep(i, n)ans = min(ans, sums[i] + sums2[i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5380
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define Cin cin>>a;

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
ll combination(ll n, ll r) {
	if (r * 2 > n) r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (unsigned int i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int main(void){
	int a, b;
	cin >> a >> b;
	cout << a - b + 1 << endl;

}


Measured memory_bytes: 256
L, R = map(int, input().split())

if R - L >= 2019 - 1:
    print(0)
    exit()

ans = 2020
for i in range(L, R):
    for j in range(i+1, R+1):
        ans = min(ans, (i*j) % 2019)
        
print(ans)


Measured memory_bytes: 3060
m = 2019
C = [0]*m
C[0] = 1
s = list(input())
now = 0
cnt = 0
while s:
  now += pow(10, cnt, m) * int(s.pop())
  now %= m
  C[now] += 1
  cnt += 1
ans = 0
for c in C:
  ans += c*(c-1)//2
print(ans)

Measured memory_bytes: 79032
import math
from collections import deque
from collections import defaultdict
import itertools as it

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

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

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

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

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

x = readInts()

for i in range(1,6):
	if x[i-1]!=i:
		print(i)

Measured memory_bytes: 9644
#include <bits/stdc++.h>
using namespace std;
int main(){
  int k;
  string s;
  cin >> s >> k;
  int one = 0;
  char second = '1';
  for(int i = 0;i < s.size();i++){
    if(s[i] != '1'){
      one = i;
      second = s[i];
      break;
    }
  }
  if(k <= one) cout << 1 << endl;
  else cout << second << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <limits>
#include <queue>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(3 * n);
  for (int i = 0; i < a.size(); i++) {
    cin >> a[i];
  }

  vector<int64_t> left(n + 1);
  {
    priority_queue<int64_t, vector<int64_t>, greater<int64_t>> q;
    for (int i = 0; i < n; i++) {
      left[0] += a[i];
      q.push(a[i]);
    }
    for (int k = n; k < 2 * n; k++) {
      q.push(a[k]);
      left[k + 1 - n] = left[k - n] + a[k] - q.top();
      q.pop();
    }
  }

  vector<int64_t> right(n + 1);
  {
    priority_queue<int64_t, vector<int64_t>> q;
    for (int i = 3 * n - 1; i >= 2 * n; i--) {
      right[n] += a[i];
      q.push(a[i]);
    }
    for (int k = 2 * n - 1; k >= n; k--) {
      q.push(a[k]);
      right[k - n] = right[k + 1 - n] + a[k] - q.top();
      q.pop();
    }
  }

  int64_t ans = numeric_limits<int64_t>::min();
  for (int i = 0; i <= n; i++) {
    ans = max(ans, left[i] - right[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4840
#include <cstdio>
#include <cstddef>
#include <vector>
#include <algorithm>

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

  std::vector<int> A(M);
  for (int i=0; i<M; ++i) {
    scanf("%d", &A[i]);
  }

  if (X <= A[0] || A[M-1] <= X)
    return !printf("0\n");

  auto ub=std::upper_bound(A.begin(), A.end(), X);

  ptrdiff_t res=std::min<int>(ub-A.begin(), A.end()-ub);
  printf("%td\n", res);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    #define ll long long
    #define f   first
    #define s   second
    #define pb          push_back
    #define mod         1000000007
    #define hell        998244353
    #define inf         1000000000000000000LL
    using namespace std;
    ll n,k,m,l,mx,sum,q;

    void solve()
    {   ll a,b,x,y;
        string s;
        cin>>s;
        map<ll,ll> hm;
        hm[0]++;
        ll rem=0;
        ll p=1;
        n=s.size();
        for(int i=n-1;i>=0;i--)
        {
            rem=((s[i]-'0')*p +rem)%2019;
            p=(p*10)%2019;
            //cout<<rem<<" ";
            hm[rem]++;
        }
        ll ans=0;
        for(auto x:hm)
        {
            ll y=x.s;
            ans+=(y*(y-1))/2;
        }
        cout<<ans;


    }    
    int main()
    {  
        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
        //cout<<primes.size();
        
        ll t=1;
        //cin>>t;
        while(t--)
            solve();

    }


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

int main() {
  string a, b;
  cin >> a >> b;
  if(a[0] == b[2] && a[1] == b[1] && a[2] == b[0]){cout << "YES" << endl;}
  else{cout << "NO" << endl;}

}


Measured memory_bytes: 3600
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))
    ans = 10**5
    for i in range(1, N):
        s1 = sum(A[:i])
        s2 = sum(A[i:])
        ans = min(ans, abs(s1 - s2))
    return ans

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


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
n = int(input())
A = list(map(int, input().split(' ')))

even_ans, odd_ans = 0, 0

s = 0
for i, a in enumerate(A):
    s += a

    if i % 2 == 0:
        if s > 0:
            pass
        else:
            even_ans += 1 - s
            s = 1
    else:
        if s < 0:
            pass
        else:
            pass
            even_ans += s + 1
            s = -1



s = 0
for i, a in enumerate(A):
    s += a

    if i % 2 == 1:
        if s > 0:
            pass
        else:
            odd_ans += 1 - s
            s = 1
    else:
        if s < 0:
            pass
        else:
            pass
            odd_ans += s + 1
            s = -1


print(min(even_ans, odd_ans))


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

int main() {
 string a,b;
 cin >> a >> b;
 int n=a.size();
 //文字列a,bは問題文の操作をn回繰り返すことで元に戻り、
 //その途中でa==bとなればいい。
bool ok=false;
 for(int i=0;i<n;i++){
   if(a==b){
     ok=true;
   }
   a=a.back()+a.substr(0,n-1);
 }
 
   if(ok){
 cout <<"Yes" << endl;
 }
 else{
 cout <<"No" << endl;

  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n, m;
  cin >> n >> m;
  int count = 0, sum = 0;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  for (int i = 0; i < n; i++) {
    if (a[i] >= sum * 1.0 / (4 * m)) count++;
  }
  cout << (count >= m ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a, b;
	int tapcount = 1; //タップ数
	
	scanf("%d %d", &a, &b);
	
	if(b == 1){
		//タップ不要
		tapcount = 0;
	}else if(b <= a){
		//タップ1つでよし
		tapcount = 1;
	}else{
		while(1){
			if(b <= ((a - 1) * (tapcount - 1)) + a){
				break;
			}else{
				tapcount++;
			}
		}
	}
	
	printf("%d" , tapcount);
  
    return 0;
}

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

int main(){
	string s;
	cin >> s;
	string prev;
	prev = s[0];
	int count = 1;
	string current="";
	for(int i=1;i<(int) s.length(); i++){
		current += s[i];
		if (current != prev) {
			count++;
			prev = current;
			current = "";
		}
	}
	cout << count;
		
	
 }


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const LL MOD = 1e9 + 7;

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()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  LL n, k;
  cin >> n >> k;
  VLL a(n+1);
  REP2(i, 1, n+1) cin >> a[i];
  VVLL dp(n+1, VLL(k+1, 0)), Sum(n+1, VLL(k+1, 0));
  // dp[i][j]: i人目までにj個の飴を分ける方法の総数
  // Sum[i][j]: dp[i][0] ~ dp[i][j] までの総和
  // dp[i][j] = Σ[k=0->a[i]](dp[i-1][j-k]) = Sum[i-1][j] - Sum[i-1][j-a[i]-1]
  dp[0][0] = 1;
  LL candy = 0;
  REP2(i, 1, n+1)
  {
    candy += a[i];
    Sum[i-1][0] = dp[i-1][0];
    REP2(j, 1, k+1)
    {
      Sum[i-1][j] = Sum[i-1][j-1] + dp[i-1][j];
      Sum[i-1][j] %= MOD;
    }
    REP(j, k+1)
    {
      if (j > candy) break;
      dp[i][j] = Sum[i-1][j];
      if (j-a[i]-1 >= 0) dp[i][j] -= Sum[i-1][j-a[i]-1];
      if (dp[i][j] < 0) dp[i][j] += MOD;
      else if (dp[i][j] >= MOD) dp[i][j] -= MOD;
    }
  }
  cout << dp[n][k] << endl;

  return 0;
}

Measured memory_bytes: 159088
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), c
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;

  vll csum(n+1, 0);
  rep(i, n){
    ll a;
    cin >> a;
    csum[i+1] += csum[i] + a;
  }
  ll ans = INF;
  repLRE(i, 1, n-1) {
    chmin(ans, abs(2*csum[i] - csum[n]));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4756
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int h, w;
    cin >> h >> w;
    VVI a(h, VI(w, 0));
    REP(i, h) {
        REP(j, w) {
            char c;
            cin >> c;
            if (c == '#') {
                a[i][j] = 1;
            }
        }
    }

    int x=0,y=0;
    a[0][0]=0;
    while(x!=h-1 ||  y!=w-1){
        if(x<h-1){
            if(a[x+1][y]==1){
                a[x+1][y]=0;
                x++;
                continue;
            }
        }
        if(y<w-1){
            if(a[x][y+1]==1){
                a[x][y+1]=0;
                y++;
                continue;
            }
        }
        cout << "Impossible" << endl;
        return 0;
    }

    REP(i, h) {
        REP(j, w) {
            char c;
            if (a[i][j] == 1) {
                cout << "Impossible" << endl;
                return 0;
            }
        }
    }

    cout << "Possible" << endl;


    return 0;
}

Measured memory_bytes: 636
// Apna Time Aayega...
#include <bits/stdc++.h>
using namespace std;

#define MOD 1000000007
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define ll long long
#define inf 100000000000000000
int addMod(int x, int y)
{
    x += y;
    while(x >= MOD) x -= MOD;
    while(x < 0) x += MOD;
    return x;
}

int mulMod(int x, int y)
{
    return (x * 1ll * y) % MOD;
}

int binpow(int x, int y)
{
    int z = 1;
    while(y)
    {
        if(y & 1) z = mulMod(z, x);
        x = mulMod(x, x);
        y >>= 1;
    }
    return z;
}

int inv(int x)
{
    return binpow(x, MOD - 2);
}

int divide(int x, int y)
{
    return mulMod(x, inv(y));
}

ll gcd(int a, int b) 
{   if (a == 0) return b; 
    if (b == 0) return a;  
    if (a == b) return a; 
    if (a > b)  return gcd(a-b, b); 
    return gcd(a, b-a); 
} 

ll lcm(ll a, ll b){
    return (a*b)/gcd(a, b);
}

ll h(ll* A, int N){
    ll pro = 1;
    for(int i=0; i<N; ++i) pro = mulMod(A[i], pro);
    return pro;
}

ll f(ll* A, int N){
    int alpha = A[0];
    for(int i=1; i<N; ++i){
        alpha = gcd(alpha, A[i])%MOD;
    }
    return alpha;
}

void generateNormal(string ans, int N, int charUsed){
    if(N==0) {cout<<ans<<endl; return;}
    for(int i=0; i<charUsed+1; ++i){
        char currentChar = 'a' + i;
        generateNormal(ans+currentChar, N-1, i+1);
    }
    return;
}
int N, X;
int A[100005];
vector <int> adj[100005];
int dfs(int u, int p){
    int sum = A[u];
    for(auto &i:adj[u]){
        if(i!=p){
            sum += dfs(i, u);
        }
    }
    return max(sum, -X);
}

void cl()
{
    for(int i=1;i<=N;i++)
        adj[i].clear();
}

unsigned long long int counting(int a, int b){
    unsigned long long int count = 1;
    while(a>0 || b>0){
        if(a&1 && b&1){
            count = mulMod(2, count);
        }
        a = a>>1;
        b = b>>1;
    }
    return count;
}

int main(){
    FIO
    int k, n; cin>>k>>n;
    int arr[n];
    for(int i=0; i<n; ++i) cin>>arr[i];
    sort(arr, arr+n);
    int arr1[n];
    for(int i=1; i<n; ++i){
        arr1[i-1] = arr[i] - arr[i-1];
    }
    arr1[n-1] = k-arr[n-1]+arr[0];
    sort(arr1, arr1+n);
    int sum = 0;
    for(int i=0; i<n-1; i++) sum+=arr1[i];
    cout<<sum<<endl;
}


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

int main() {
	int a, b, k;
	cin >> a >> b >> k;
	int cnt = 0;
	for(int i = min(a, b); ; i--) {
		if(a%i == 0 && b%i == 0){
			cnt++;
		}
		if(cnt == k) {
			cout << i << endl;
			return 0;
		}
	}
	
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	string s;
	cin >> s;
	if(s=="AAA"||s=="BBB") cout << "No\n";
	else cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
void solve(){
    string s;
    cin >> s;
    int num;
    int cnt = 0;
    if(s.size() % 2 == 0){
        num = s.size() / 2;
    }
    else{
        num = (s.size() - 1) / 2;
    }
    for(int i = 0; i < num; i++){
        if(s.at(i) != s.at(s.size() - 1 - i)){
            cnt++;
        }
    }
    cout << cnt << endl;
}
int main(){
    solve();
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef double db;
#define inf 0x3f3f3f3f
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int ll
int a[2123];
signed main() {
	int n, i, t, j;
	cin >> n;
	for (i = 0; i < n; ++i)cin >> a[i];
	sort(a, a + n);
	a[n] = inf;
	int ans = 0;
	for (i = 0; i < n; ++i) {
		for (j = i+1; j < n; ++j) {
			int* tt = lower_bound(a + j + 1, a + n + 1, a[i] + a[j]);
			int t = tt - a;
			ans += (t - j - 1);
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 998244353

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast;
    ll n, k;
    cin >> n >> k;
    ld ans = 0;
    REP(i, 1, n+1) {
        ld p = (ld)k / i;
        ll x = log2(p);
        if (pow(2, x) < p)
            x++;
        x = max(0ll , x);
        ans += (ld) 1.0 / (ld)pow(2, x);
    }
    cout << setprecision(36) << ans * (1.0)/n << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b;
    char op;
    while (1) {
        cin >> a >> op >> b;
        if (op == '?') {
            break;
        }
        switch (op) {
            case '+':
                cout << a + b << "\n";
                break;
            case '-':
                cout << a - b << "\n";
                break;
            case '*':
                cout << a * b << "\n";
                break;
            case '/':
                cout << a / b << "\n";
                break;
        }
    }

    return 0;
}

Measured memory_bytes: 1192
M = 1000000000 + 7

N = int(input())

primes = set()
factorCounter = [0] * (N + 1)

for i in range(2, N + 1):
    n = i
    isPrime = True
    for prime in primes:
        while n > 0 and n % prime == 0:
            n //= prime
            factorCounter[prime] += 1
            isPrime = False

    if isPrime:
        factorCounter[i] += 1
        primes.add(i)
        

ans = 1
for prime in primes:
    ans *= factorCounter[prime] + 1
    ans %= M

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int N=S.size();
  vector<int> p(26,0);
  vector<int> q(26,-1);
  for(int i=0;i<N;i++){
    int a=S[i]-'a';
    p[a]=max(p[a],i-q[a]-1);
    q[a]=i;
  }
  int Z=N;
  for(int i=0;i<26;i++){
    p[i]=max(p[i],N-1-q[i]);
    Z=min(Z,p[i]);
  }
  cout<<Z<<endl;
  
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, LL> II;

const int N = (int) 1e5 + 10;
int n, a, b, h[N];
LL r[N];

bool Check(int T) {
	for (int i = 1; i <= n; ++i) r[i] = h[i] - (LL) T * b;
	int delta = a - b;
	LL sum = 0;
	for (int i = 1; i <= n; ++i)
		if (r[i] > 0) sum += (r[i] + delta - 1) / delta;
	return sum <= T;
}

int main() {
	scanf("%d%d%d", &n, &a, &b);
	for (int i = 1; i <= n; ++i) scanf("%d", &h[i]);

	int l = 0, r = (int) 1e9, f = r;
	while (l <= r) {
		int mid = (l + r) >> 1;
		if (Check(mid)) {
			f = mid;
			r = mid - 1;
		}
		else l = mid + 1;
	}
	printf("%d", f);
	return 0;
}

Measured memory_bytes: 1408