akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600
#define long long long

int main(){
  int h,w;
  while(cin>>h>>w, h|w){
    int n; cin>>n;
    vector<vector<int> > vec(h, vector<int>(w, 0));
    rep(i,n){
      int x,y;
      scanf("%d %d", &x, &y);
      x--;y--;
      vec[x][y] = -1;
    }
    vec[0][0]=1;
    repl(i,1,w) if(vec[0][i]!=-1) vec[0][i] = vec[0][i-1];
    repl(i,1,h) if(vec[i][0]!=-1) vec[i][0] = vec[i-1][0];

    repl(i,1,h) repl(j,1,w) if(vec[i][j]!=-1){
      if(vec[i-1][j]!=-1) vec[i][j] += vec[i-1][j];
      if(vec[i][j-1]!=-1) vec[i][j] += vec[i][j-1];
    }
    cout<<vec[h-1][w-1]<<endl;
  }

  return 0;
}

Measured memory_bytes: 3260
char s[111];
n,ans,cnt[26],now;
main(){
  scanf("%d%s",&n,s);
  for(int i=1;i<n;i++){
    for(int j=0;j<26;j++)cnt[j]=0;
    for(int j=0;j<i;j++)cnt[s[j]-'a']++;
    now=0;
    for(int j=i;j<n;j++)now+=!!cnt[s[j]-'a'],cnt[s[j]-'a']=0;
    ans=fmax(ans,now);
  }
  printf("%d",ans);
}

Measured memory_bytes: 128
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10;

int main() {
	fast_cin();
	int a, b, m;
	cin >> a >> b >> m;
	vector<int> rfg(a), mcw(b);
	for (auto& i : rfg) {
		cin >> i;
	}
	for (auto& i : mcw) {
		cin >> i;
	}
	int ans = *min_element(rfg.begin(), rfg.end()) + *min_element(mcw.begin(), mcw.end());
	while (m--) {
		int x, y, c;
		cin >> x >> y >> c;
		ans = min(ans, rfg[x - 1] + mcw[y - 1] - c);
	}
	cout << ans << endl;
}

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

int n, m;
string res = "No";

int main(){
  cin >> n >> m;
  if(m == n){
    res = "Yes";
  }
  
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int main()
{
	ios::sync_with_stdio(false);
	int a,b,c;cin>>a>>b>>c;
	int k;cin>>k;
	int ans=0;
	while(b<=a)
	{
		b*=2;ans++;
	}
	while(c<=b)
	{
		c*=2;
		ans++;
	}
	if(ans<=k)
		cout<<"Yes";
	else
	cout<<"No";
	return 0;

    
}


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

int x[100001], y[3][100001], z[100001];

void no() { printf("No\n"), exit(0); }

int main(){
	int n;
	scanf("%d", &n);
	f(i, 0, 3)f(j, 1, n + 1)scanf("%d", y[i] + j);
	f(i, 1, n + 1){
		int k = (y[0][i] - 1) / 3;
		if (k + 1 & 1 ^ i & 1)no();
		f(j, 1, 3)if ((y[j][i] - 1) / 3 != k)no();
		if (y[1][i] > y[0][i] && y[2][i] > y[1][i])x[i] = k + 1;
		else if (y[1][i] < y[0][i] && y[2][i] < y[1][i]) x[i] = -(k + 1);
		else no();
		z[abs(x[i])] = i;
	}
	f(i, 1, n + 1)if (z[i] != i){
		int l = i, r = z[i];
		x[r - 1] = -x[r - 1];
		x[l] = -x[l];
		x[r] = -x[r];
		swap(z[i], z[abs(x[l])]);
		swap(x[l], x[r]);
	}
	f(i, 1, n - 2)if (x[i] < 0)f(j, i, i + 4)x[j] = -x[j];
	if (x[n] > 0 && x[n - 1] > 0 && x[n - 2] > 0 || x[n] < 0 && x[n - 1] > 0 && x[n - 2] < 0)printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#include <math.h>
#include <iostream>
#include <list>
#include <cmath>
#include <queue>
using namespace std;
#define fo(i, n) for (ll i = 0; i < n; ++i)
#define ll long long
void sor(vector<ll> &x)
{
    sort(x.begin(), x.end());
}

void rev(vector<ll> &x)
{
    reverse(x.begin(), x.end());
}

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

list<ll> a[5];
void bfs(int src)
{
    queue<int> q;
    bool *vis = new bool[5 + 1]{0};
    q.push(src);
    vis[src] = true;
    while (!q.empty())
    {
        int node = q.front();
        cout << node << " ";
        q.pop();
        for (int n : a[node])
        {
            if (!vis[n])
            {
                q.push(n);
                vis[n] = true;
            }
        }
    }
}

ll max(ll x, ll y)
{
    if (x > y)
    {
        return x;
    }
    else
    {
        return y;
    }
}

ll min(ll x, ll y)
{
    if (x > y)
    {
        return y;
    }
    else
    {
        return x;
    }
}

void primeFactors(ll n, vector<ll> &vec)
{

    while (n % 2 == 0)
    {
        vec.push_back(2);
        n = n / 2;
    }

    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            vec.push_back(i);
            n = n / i;
        }
    }

    if (n > 2)
        vec.push_back(n);
}

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

ll g(ll x)
{
    for (ll i = 2; i <= sqrt(x); i++)
    {
        if (x % i == 0)
        {
            return i;
        }
    }
    return 0;
}

ll countDivisors(ll n)
{
    ll cnt = 0;
    for (ll i = 1; i <= sqrt(n); i++)
    {
        if (n % i == 0)
        {
            if (n / i == i)
                cnt++;

            else
                cnt = cnt + 2;
        }
    }
    return cnt;
}

void solve()
{
    ll n;
    cin >> n;
    ll ans = 0;
    vector<vector<ll>> a;
    for (ll i = 1; i < n; i++)
    {
        for (ll j = 1; j <= n - i; j++)
        {
            if (i * j < n)
            {
                ans++;
            }
            else
            {
                break;
            }
        }
    }
    cout << ans;
}

int main()
{

    int t;
    t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}

//0 3 1 0 5 2 6
//0 0 1 2 3 5 6

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

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(){
    int A,B;
    cin >> A >> B;
    if (B%A == 0) PRINTD(A+B);
    else PRINTD(B-A);


}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program
{      
    
    public void Slove()
    {
        var inputs = Console.ReadLine().Split();
        int n = int.Parse(inputs[0]);
        int limit = int.Parse(inputs[1]);
        int[] candies = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int bef = 0;
        long count = 0;
        foreach(int i in Enumerable.Range(0, n))
        {
            int temp = limit - bef;
            if(temp < candies[i])
            {
                count += candies[i] - temp;
                candies[i] = temp;
            }
            bef = candies[i];
        }
        System.Console.WriteLine(count);
    }
    
    static void Main(string[] args)
    {
        new Program().Slove();
    }
}


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

a=[[0 for j in range(N-1)] for i in range(N)]
for i in range(N):
  line=list(map(int,input().split()))
  for j in range(N-1):
    a[i][j]=line[j]-1

id=[[0 for j in range(N)] for i in range(N)]
v=0
for i in range(N-1):
  for j in range(i+1,N):
    id[i][j]=v
    v+=1

def toId(i,j):
  if i>j:
    i,j=j,i
  return id[i][j]

to=[[] for i in range(v)]
inner=[0 for i in range(v)]
for i in range(N):
  for j in range(N-1):
    a[i][j]=toId(i,a[i][j])
  for j in range(N-2):
    to[a[i][j]].append(a[i][j+1])
    inner[a[i][j+1]]+=1

stack=[]
isstarted=[False for i in range(v)]
dist=[0 for i in range(v)]
for i in range(v):
  if inner[i]==0:
    stack.append([i,1])

while stack:
  node=stack.pop()
  e=node[0]
  d=node[1]
  if d>dist[e]:
    dist[e]=d
  inner[e]-=1
  if inner[e]<=0 and not isstarted[e]:
    isstarted[e]=True
    children=to[e]
    for child in children:
      stack.append([child,dist[e]+1])
for i in range(len(isstarted)):
  if not isstarted[i]:
    print(-1)
    break
else:
  ans=0
  for i in range(len(dist)):
    if dist[i]>ans:
      ans=dist[i]
  print(ans)

Measured memory_bytes: 165232
N = int(input())
x = []
y = []
for i in range(N):
    a, b = map(int, input().split())
    x.append(a)
    y.append(b)

if N == 1:
    ans = 1
else:
    ans = N
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            dx, dy = x[i] - x[j], y[i] - y[j]
            
            cnt = 0
            for k in range(N):
                for l in range(N):
                    if k == l:
                        continue
                    if (dx == x[k] - x[l]) and (dy == y[k] - y[l]):
                        cnt += 1
            
            ans = min(ans, N - cnt)

print(ans)

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

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

    int n;
    cin >> n;
    double ans = 0;
    for (int i = 1; i <= n; i++)
    {
        if (i % 2 == 1)
            ans += (double)1 / n;
    }
    cout << ans << endl;
}


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

#define f first
#define s second
#define mp make_pair

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

using namespace std;

typedef unsigned int uint;
typedef long long ll;


int main(){
  int n; cin>>n;
  int cc = 0;
  while(n --> 0){
    int  b[9][9];
    bool f[9][9];
    if(cc++ != 0) puts("");
    REP(i,9) REP(j,9){
      cin>>b[i][j];
      f[i][j] = true;
    }
    for(int y = 0; y<9; y+=3){
      for(int x = 0; x<9; x+=3){
        int cnt[10] = {0};
        REP(i,3) REP(j,3)
          cnt[b[y+i][x+j]]++;
        REP(i,3) REP(j,3)
          if(cnt[b[y+i][x+j]] != 1){
            f[y+i][x+j] = false;
          }
      }
    }
    REP(y,9){
      int cnt[10] = {0};
      REP(x,9)
        cnt[b[y][x]]++;
      REP(x,9)
        if(cnt[b[y][x]] != 1)
          f[y][x] = false;
    }
    REP(x,9){
      int cnt[10] = {0};
      REP(y,9)
        cnt[b[y][x]]++;
      REP(y,9)
        if(cnt[b[y][x]] != 1)
          f[y][x] = false;
    }

    REP(i,9){
      REP(j,9)
        printf("%c%d",(f[i][j]?' ':'*'),b[i][j]);
      puts("");
    }
  }
  return 0;
}

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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  each(x,vec) is >> x;
  return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
  rep(i,vec.size()) {
    if (i) os << " ";
    os << vec[i];
  }
  return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
  rep(i,vec.size()) {
    if (i) os << endl;
    os << vec[i];
  }
  return os;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, m; cin >> n >> m;
  vector<ll> x(n); cin >> x;
  sort(all(x));
  ll ans = linf;
  rep(i, n) {
    ll l = i;
    ll r = i + m - 1;
    if (r >= n) continue;
    if (x[l] * x[r] >= 0) {
      chmin(ans, max(abs(x[l]), abs(x[r])));
    }
    else {
      chmin(ans, min(abs(x[l]), abs(x[r])) + abs(x[l]) + abs(x[r]));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k,b,ans;cin>>n>>k;
  map<int,int> a;
  ans=0;
  for(int i=0;i<n;i++){
  	cin>>b;
    if(a.count(b)){
    	a.at(b)++;
    }else{
    	a[b]=1;
    }
  }
  if(a.size()<=k){
    cout<<0<<endl;
  }else{
    vector<int> aa(a.size());
    int i=0;
  	for (auto p : a) {
  		aa.at(i) = p.second;
      	i++;
  	}
    sort(aa.begin(),aa.end());
    for(int j=0;j<a.size()-k;j++){
    	ans+=aa.at(j);
    }
    cout<<ans<<endl;
  }
  
}

Measured memory_bytes: 10368
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
#define INF 100000
using namespace std;
typedef long long ll;
#include <cstring>

struct edge {
  int to, cap, rev;
};

vector<edge> g[10010];
bool used[10010];

void add_edge(int from, int to, int cap) {
  g[from].push_back((edge){to, cap, (int)g[to].size()});
  g[to].push_back((edge){from, 0, (int)g[from].size() - 1});
}

int dfs(int v, int t, int f) {
  if (v == t) {
    return f;
  }
  used[v] = true;
  for (int i = 0; i < g[v].size(); i++) {
    edge &e = g[v][i];
    if (!used[e.to] && e.cap > 0) {
      int d = dfs(e.to, t, min(f, e.cap));
      if (d > 0) {
        e.cap -= d;
        g[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int max_flow(int s, int t) {
  int flow = 0;
  for (;;) {
    memset(used, 0, sizeof(used));
    int f = dfs(s, t, INF);
    if (f == 0) return flow;
    flow += f;
  }
}

int main() {
  int n, m;
  string s[100];
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s[i][j] == '.' && (i + j) % 2) {
        add_edge(0, i * m + j + 1, 1);
      } else if (s[i][j] == '.') {
        add_edge(i * m + j + 1, 10001, 1);
      }
      if (i != n - 1 && s[i][j] == '.' && s[i + 1][j] == '.') {
        if ((i + j) % 2) {
          add_edge(i * m + j + 1, (i + 1) * m + j + 1, 1);
        } else {
          add_edge((i + 1) * m + j + 1, (i)*m + j + 1, 1);
        }
      }
      if (j != m - 1 && s[i][j] == '.' && s[i][j + 1] == '.') {
        if ((i + j) % 2) {
          add_edge(i * m + j + 1, (i)*m + j + 1 + 1, 1);
        } else {
          add_edge((i)*m + j + 1 + 1, (i)*m + j + 1, 1);
        }
      }
    }
  }
  int ans = max_flow(0, 10001);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if ((i + j) % 2) {
        int x = i * m + j + 1;
        for (int k = 0; k < g[x].size(); k++) {
          if (g[x][k].to != 0 && g[x][k].cap == 0) {
            int y = x - g[x][k].to;
            if (m != 1 && y == 1) {
              s[i][j] = '<';
              s[i][j - 1] = '>';
            } else if (m != 1 & y == -1) {
              s[i][j] = '>';
              s[i][j + 1] = '<';
            } else if (y == -m) {
              s[i][j] = 'v';
              s[i + 1][j] = '^';
            } else if (y == m) {
              s[i][j] = '^';
              s[i - 1][j] = 'v';
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
  for (int i = 0; i < n; i++) {
    cout << s[i] << endl;
  }
}

Measured memory_bytes: 5540
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

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

    READV(N);
    READV(M);
    READV(K);
    cout<<max(0LL,N-K)<<" "<<max(0LL,M-max(0LL,K-N))<<endl;

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


    
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/agc024/tasks/agc024_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  cin >> N;

  VL ps(N);
  rep(i, N) cin >> ps[i];

  // sort_length[num]: num の位置から後方に続く num-1
  // 以下を無視したソート列の長さ
  VL sort_length(N + 1);

  {
    repr(i, N) {
      if (ps[i] == N) {
        sort_length[N] = 1;
      } else {
        sort_length[ps[i]] = sort_length[ps[i] + 1] + 1;
      }
    }
  }

  ll res = N;

  // num を先頭に持ってくる場合の数.
  // num が 0 -> 何も先頭に持ってこない
  // num が N -> 何も後方に持ってこない
  rep(num, N + 1) {
    ll _res = 0;
    _res += num;  // num と、num 未満の数全てを先頭に持ってくる
    // 残りは、 （残り - num+1 以上のソート配列）を後方に持ってくる
    if (num < N) {
      _res += (N - num - sort_length[num + 1]);
    }

    chmin(res, _res);
  }

  cout << res << endl;
}

void solve2() {
  ll N;
  cin >> N;

  VL ps(N);
  rep(i, N) cin >> ps[i];

  // sort_length[num]: num の位置から後方に続く num-1
  // 以下を無視したソート列の長さ
  VL sort_length(N + 1);

  ll max_sort_length = 0;
  {
    repr(i, N) {
      if (ps[i] == N) {
        sort_length[N] = 1;
      } else {
        sort_length[ps[i]] = sort_length[ps[i] + 1] + 1;
      }

      chmax(max_sort_length, sort_length[ps[i]]);
    }
  }

  // 最長ソート列以外の数を移動すれば答えとなる
  ll res = N - max_sort_length;

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve2();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
#define Int int64_t
#define ll long long
#define pb push_back
using namespace std;
const Int MAXN=200005;
const int ALPHA=26;

Int N,K,M;
Int X,Y,Z;Int C;
vector<Int> ID;
vector<Int> SZ;
string S;
int find(int x){
    if(ID[x]==x) return x;
    return find(ID[x]);
}
void Union(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(SZ[x]>SZ[y]){
        ID[y]=x;
        SZ[x]+=SZ[y];
    }
    else{
        ID[x]=y;
        SZ[y]+=SZ[x];
    }
    return;
}
string common_prefix(string s,string t){
    string ans="";
    for(int i=0;i<min(s.length(),t.length());++i){
        if(s[i]==t[i]) ans.pb(s[i]);
        else break;
    }
    return ans;
}
string LCP(vector<string> A,int l,int r){
    if(l>r) return "";
    if(l==r) return A[l];
    int mid=(l+r)/2;
    string left=LCP(A,l,mid);
    string right=LCP(A,mid+1,r);
    return common_prefix(left,right);
}

long long ModExpo(long long x,unsigned long long y,long long M){
    Int ans=1;
    ans=(long long)ans;
    
    while(y>0){
        if(y&1) ans=((ans%M)*(x%M))%M;
        y>>=1LL;
        x=((x%M)*(x%M))%M;
    }
    return ans%M;
}
Int LCM(Int x,Int y){
    return (x*y)/__gcd(x,y);
}

using D=long double;
vector<Int> A,B;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
    int t;
    t=1;
    while(t--){
        cin>>N>>M;
        Int ans=0;
        for(int i=0;i<N;++i){
            cin>>X>>Y;
            ans+=((X*X+Y*Y)<=(M*M));
        }
        cout<<ans<<"\n";
    
    }
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstring>

using namespace std;

int main(){
  int h1,m1,h2,m2,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int h = h2 - h1;
  int min = m2 - m1;
  if(min < 0){
    h --;
    min = 60 + min;
  } 
  int time = h * 60 + min;
  cout << time - k << endl;

  return 0;
}

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

long long n, k;

long long solve(long long x){
    long long res = 0;
    res += (n/x)*(x-k);
    res += max(0LL, n%x - k + 1);
    return res;
}

int main(){
    long long ans = 0;
    cin >> n >> k;
    for(long long b=k+1; b<=n; b++){
        ans += solve(b);
    }
    if(k==0) ans -= n;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    constexpr int A = 50;
    int n, a; cin >> n >> a;
    
    vector<int> x(n);
    REP(i, n) cin >> x[i];

    auto dp = make_v(n + 1, n + 1, A * n + 1, 0LL);
    
    dp[0][0][0] = 1LL;
    
    REP(i, n)REP(j, n + 1)REP(k, A * n + 1) {
        if (k + x[i] <= A * n && j < n) {
            dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
        }

        dp[i + 1][j][k] += dp[i][j][k];
    }

    ll ans = 0;
    FOR(i, 1, n + 1) ans += dp[n][i][i * a];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 52224
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

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

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, N);
    CIN(int, x);
    CINS(int, a, N);

    ll count = 0;

    for (int i = 1; i < N; i++) {
        if ( a[i] + a[i-1] > x ) {
            count += max(a[i] + a[i-1] - x,0);
            a[i] = a[i] - (a[i] + a[i - 1] - x);

            if ( a[i] < 0 ) {
                a[i-1] += a[i];
                a[i] = 0;
            }
        }
    }

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

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

int main() {
	long long N, K;
	std::cin >> N >> K;
	std::vector<long long> V(N);
	std::for_each(std::begin(V), std::end(V), [](long long& elem) {
		std::cin >> elem;
	});
	std::nth_element(std::begin(V), std::begin(V) + std::min(K, N), std::end(V), [](long long& elem1, long long& elem2) {
		return elem1 > elem2;
	});
	long long sum = 0;
	for (int i = K; i < N; i++) {
		sum += V[i];
	}
	std::cout << sum << std::endl;
	return 0;
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS

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

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

ll N, C, x[112345], v[112345];

int main() {

	scanf("%lld %lld", &N, &C);

	rep(i, N) scanf("%lld %lld", &x[i], &v[i]);

	vector<ll> right(N), left(N), right_back(N), left_back(N);// , rds(N), lds(N);
	rep(i, N) {
		if (i) right[i] = right[i - 1] + v[i] + x[i - 1] - x[i];
		else right[i] = v[i] - x[i];
		right_back[i] = right[i] - x[i];
	}
	rep(i, N) {
		if (i) left[N - 1 - i] = left[N - i] + v[N - 1 - i] + (C - x[N - i]) - (C - x[N - 1 - i]);
		else left[N - 1 - i] = v[N - 1 - i] - (C - x[N - 1 - i]);
		left_back[N - 1 - i] = left[N - 1 - i] - (C - x[N - 1 - i]);
	}
	ll c = 0;
	vector<ll> right_max(N), left_max(N), right_back_max(N), left_back_max(N);
	rep(i, N) {
		if (i) right_max[i] = max(right_max[i - 1], right[i]);
		else right_max[i] = right[i];
		if (i) right_back_max[i] = max(right_back_max[i - 1], right_back[i]);
		else right_back_max[i] = right_back[i];
	}
	rep(i, N) {
		if (i) left_max[N - 1 - i] = max(left_max[N - i], left[N - 1 - i]);
		else left_max[N - 1 - i] = left[N - 1 - i];
		if (i) left_back_max[N - 1 - i] = max(left_back_max[N - i], left_back[N - 1 - i]);
		else left_back_max[N - 1 - i] = left_back[N - 1 - i];
	}

	c = max(c, right_max[N - 1]);
	c = max(c, left_max[0]);
	rep(i, N - 1) {
		c = max(c, right_back_max[i] + left[i + 1]);
		c = max(c, left_back_max[i + 1] + right[i]);
	}

	printf("%lld\n", c);

	return 0;
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = 1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

void solve() {
    int n, m, k; cin >> n >> m >> k;
    FOR(i, 0, n + 1) FOR(j, 0, m + 1) {
        if (i * j + (n - i) * (m - j) == k) {
            cout << "Yes\n";
            return;
        }
    }
    cout << "No\n";
}

int main() {
    int JUDGE_ONLINE = 1;
    if (fopen("in.txt", "r")) {
        JUDGE_ONLINE = 0;
        assert(freopen("in.txt", "r", stdin));
        //assert(freopen("out.txt", "w", stdout));
    }
    else {
        ios_base::sync_with_stdio(0), cin.tie(0);
    }
    solve();
    if (!JUDGE_ONLINE) {
        //cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    }
    return 0;
}

Measured memory_bytes: 256
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

S,T=input(),input()
C=[-1]*26
D=set(list(range(26)))
ans=True
for i in range(len(S)):
    s,t=ston(S[i]),ston(T[i])
    if C[s]!=t:
        if C[s]!=-1 or t not in D:
            ans=False
            break
        D.remove(t)
        C[s]=t
judge(ans)

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

#define int long long int
#define ff first
#define ss second
#define pb push_back


int bexp(int a, int b, int mod)
{
    int res = 1;

    while (b)
    {
        if (b & 1) res = (res * a) % mod;

        a = (a * a) % mod; 
        b >>= 1;
    }
    return res;
}

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

#define N 100010
#define MOD 1000000007

struct comp {
    bool operator() (const pair<int, int> a, const pair<int, int> b) const
    {
        return a.ss > b.ss;
    }
};

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);

   
    int n;
    cin >> n;

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

    for (int i = 1; i < n; ++i)
    {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), i > 1 ? dp[i - 2] + abs(h[i] - h[i - 2]): INT_MAX);
    }

    cout << dp[n - 1];
    return 0;
}

Measured memory_bytes: 5180
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = 0;
		if(N % 2 == 0) {
			M = N / 2;
		}else {
			M = N / 2 + 1;
		}

		int counter = 0;
		for(int i = 1; i < M; i++) {
			if( (N - i) != i) {
				counter++;
			}else {

			}
		}
		System.out.println(counter);
	}

}


Measured memory_bytes: 21204
# https://atcoder.jp/contests/agc005/tasks/agc005_a
#
# Stackでやる

from collections import deque

stack = deque([])
X = input()

for ch in X:
    if ch == 'S':
        stack.append(ch)
    elif ch == 'T':
        if len(stack) == 0:
            stack.append(ch)
        elif stack[-1] == 'T':
            stack.append(ch)
        elif stack[-1] == 'S':
            stack.pop()

print(len(stack))

Measured memory_bytes: 44768
N = int(input())
MOD = 10 ** 9 + 7

dp = [0] * (N + 1)
dp[0] = 1
for i in range(N + 1):
    for v in range(3, N + 1):
        if i - v >= 0:
            dp[i] += dp[i - v]
            dp[i] %= MOD

print(dp[-1] % MOD)


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

int main() {
  int n, m;
  cin >> n;
  int t[n];
  rep(i, n) cin >> t[i];
  cin >> m;
  int p[m], x[m];
  rep(i, m) {
    cin >> p[i];
    cin >> x[i];
  }

  rep(i, m) {
    int sum = 0;
    rep(j, n) {
      if ((j + 1) == p[i])
        sum += x[i];
      else
        sum += t[j];
    }
    cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 256
/**

   Author : sea_26

**/


#pragma GCC optimize("03")
#include <bits/stdc++.h>

using namespace std;

const int M = 1000000007;
const double PI = acos(-1.0);

// const double pi = atan2(0, -1);
// const double PI = 4 * atan(1);
// const double pi = 2*cos(0.0);

typedef long long ll;
typedef long double ld;

const int iinf = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ln(x) (int)x.size()

#define bp(n)  __builtin_popcount(n)
#define bclz(n) __builtin_clzll(n)
#define bctz(n) __builtin_ctzll(n)
#define bip(n) __builtin_parity(n)

#define vsort(v) sort(v.begin(),v.end())
#define rvsort(v) sort(v.begin(),v.end(),greater<int>())

#define rep(n) for(int i=0; i<n; i++)
#define rrep(n) for(int i=n; i>=1; i--)
#define lrep(p,q) for(int i=p; i<=q; i++)
#define prep(n) for(int i=1; i*i<=n; i++)
#define it(a, x)  for(auto &a : x)
#define yes cout << "YES" << endl
#define no cout << "NO" << endl

priority_queue<int> pq;

#define fs   ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

template< typename T> inline T lcm(T a, T b){ return (a / gcd(a,b)) * b; }
template< typename T> inline T MAX(T a, T b){ return a ^ ((a ^ b) & -(a < b)); }
template< typename T> inline T MIN(T a, T b){ return b ^ ((a ^ b) & -(a < b)); }
template< typename T> void tpns(T n){ rrep(30){ if(n & (1 << i)) pq.push(1 << i); } }
template< typename T> void SWAP(T &a, T &b){ a = ((a) ^= (b)),  b = ((b) ^= (a)),  a = ((a) ^= (b)); }
template< typename T> inline T ABS(T a){ int x = a >> sizeof(int) * CHAR_BIT - 1; return (a + x) ^ x; }
template< typename T> inline T mod(T a, T b){ return a >= b ? a % b : a; }
template< typename T> inline T gcd(T a, T b){ while (b) b ^= a ^= b ^= a %= b; return a; }

ll gcdextd(ll a, ll b, ll& x, ll& y) {
    if (!a) { x = 0; y = 1; return b; }
    ll y1,d;
    d = gcdextd(b % a, a, y, y1);
    x = y1 - (b / a) * y;
    return d;
}



double WT() {
	return double(clock()) / CLOCKS_PER_SEC;
}

void ReT(){

	cout << "\nTime = " << fixed << setprecision(3) << WT()  << " Sec"<< endl;

exit(0);
}


int n,cnt;

int main(){

        fs;
        cin >> n;
        vector<ll> v(n);
        rep(n){
            cin >> v[i];
            if(v[i] < 0){
                v[i] = - v[i];
                cnt++;
            }
        }
        vsort(v);
        ll res = cnt%2 ? -2*v[0] : 0;
        rep(n)
            res += v[i];

        cout << res << endl;

     //   ReT();

}


Measured memory_bytes: 1024
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
          Copyright                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz(a) int((a).size())
#define rep(i,x,y) for(int i=x;i<y;i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 400010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return (pwur * pwur) % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int a[101],cp[101];

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);
    int n,m;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i],cp[i]=a[i];
    cin>>m;
    for(int i=0;i<m;i++){
        int p,x;
        cin>>p>>x;
        cp[p]=x;
        int ans=0;
        for(int j=1;j<=n;j++)ans+=cp[j];
        for(int j=1;j<=n;j++)cp[j]=a[j];
        cout<<ans<<endl;
    }
    return 0;
}


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

int main(){
    int n, alice=0, bob=0, odd=0;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    for (int i=n-1; i>-1; i--) {
        if (odd==0) {
            alice += a.at(i);
            odd = 1;
        }
        else {
            bob += a.at(i);
            odd = 0;
        }
    }
    cout << alice - bob << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(0,n):
    ans += b[a[i]-1]
    if i != 0 and a[i-1]+1 == a[i]:
        ans += c[a[i-1]-1]
print(ans)


Measured memory_bytes: 38384
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    N = int(input().strip())
    happy_list = [[int(i) for i in input().strip().split()] for _ in range(N)]
    dp = [[None, None, None] for _ in range(N)]

    dp[0] = happy_list[0]

    for i in range(1, N):
        dp[i][0] = happy_list[i][0] + max(dp[i - 1][1], dp[i - 1][2])
        dp[i][1] = happy_list[i][1] + max(dp[i - 1][0], dp[i - 1][2])
        dp[i][2] = happy_list[i][2] + max(dp[i - 1][0], dp[i - 1][1])

    return max(dp[-1])


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


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

/*
int main() {
    int a;
    string s;
    std::cin >> a >> s;
    if(a<3200){
        std::cout << "red" <<std::endl;
    }
    else{
        std::cout << s << std::endl;
    }
    return 0;
}
 */

/*
int main(){
    int N;
    std::cin >> N;
    double A[N];
    double A_sum = 0;
    double A_prod = 1;
    double ans;
    for(int i=0; i<N; i++){
        std::cin >> A[i];
    }
    for(int i=0; i<N; i++){
        A_prod *= A[i];
    }
    for(int i=0; i<N; i++){
        A_sum += (A_prod/A[i]);
    }
    ans = A_prod/ A_sum;
    std::cout << ans << std::endl;
    return 0;

}
*/

int main(){
    int N;
    std::cin >> N;
    double A[N];
    double means;
    double ans;
    for(int i=0; i<N; i++){
        std::cin >> A[i];
    }
    sort(A, A+N);
    means = A[0];
    for(int i=1; i<N; i++){
        means = (means+A[i])/2;
    }
    std::cout << means << std::endl;
    return 0;

}

Measured memory_bytes: 256
mod = 1000000007

def binary(n):
    if n == 0:
        return [0]
    else:
        b = []
        while n > 0:
            b = [n%2] + b
            n = n//2
        return b

def power(m,n):
    nbi = binary(n)
    l = len(nbi)
    s = 1
    for i in range(0,l):
        if nbi[l-i-1] != 0:
            p = m
            for j in range(0,i):
                p = (p*p) %mod
            s = s * p
            s = s %mod
    return s

M,N = map(int,input().strip().split(" "))
print(power(M,N))



Measured memory_bytes: 5600
#include<stdio.h>

int gcd(int a, int b);

int main() {
	int a, b, k, i;
	scanf("%d%d%d", &a, &b, &k);
	a = gcd(a, b);
	b = 0;
	for (i = a; i > 0; i--) {
		if (a % i == 0) {
			b++;
		}
		if (b == k) {
			a = i;
			break;
		}
	}
	printf("%d", a);
}

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

Measured memory_bytes: 128
// /*
// power code taken from geeks for geeks
// */
// cout << setprecision (2) << fixed << 1.2;

#include <bits/stdc++.h>
#define MODD 1000000007LL
#define MAX_SIZE 100000000
#define MAX_N 1000001LL
#define INF 1000000000LL
using namespace std;
typedef long long ll;
typedef long double ld;

ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
double max(double a,double b){return a>b?a:b;}
double min(double a,double b){return a<b?a:b;}

ll modd(ll a){if(a<0LL) return a*-1LL;return a;}
double modd(double a){if(a<0.0) return a*-1.0;return a;}

ll modulo(ll a){return a % MODD; }

ll power(ll k, ll p){
    if (p == 0)
    return 1LL;

    ll P = power(k, p/2LL);
    P = (P * P) % MODD;

    if (p % 2 == 1)
    P = (P * k) % MODD;

return P;
}


struct p_str{
    ll a, b;
};


void solve(){
    ll n, k;
    cin>>n>>k;
    ll a[n];
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }

    ll cost[n];
    memset(cost, 0, sizeof(cost));
    cost[0]=0;
    for(ll i=1;i<n;i++){
        ll t=INF;
        for(ll j=1;j<=k;j++){
            if(i-j>=0){
                t=min(t, modd(a[i-j]-a[i])+cost[i-j]);
            }
        }
        cost[i]=t;
    }

    cout<<cost[n-1]<<endl;
}



int main(){

  

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t=1;

    // init();

    // cin>>t;

    while(t--){

        solve();
    }
    return 0;
}


Measured memory_bytes: 5132
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


N = int(input())
MAX = 10 ** 5 + 1
while True:
    if is_prime(N):
        print(N)
        exit()
    else:
        N += 1


Measured memory_bytes: 3064