akhauriyash/Code-Regression huggingface dataset:
def solve(N, T, A, H):
  best = (T - A) / 0.006
  index = -1
  diff = -1
  for i in range(N):
    d = abs(best - H[i])
    if diff == -1 or d < diff:
      diff = d
      index = i
  return index + 1

# receive inputs
N = int(input())
T, A = list(map(int, input().split()))
H = list(map(int, input().split()))

# print outputs
print(solve(N, T, A, H))


Measured memory_bytes: 3060
# coding: utf-8
# Your code here!
def insert_sort(A:list) -> list:
    for i in range(1, len(A)):
        print(" ".join(list(map(str,A))))
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
    return A


if __name__ == '__main__':
    n = int(input())
    A = list(map(int, input().rstrip().split()))
    print(" ".join(list(map(str,insert_sort(A)))))


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

struct edge
{
	int s,t,w,n;
} e[1000000];

int n,h[1000000],fac[1000000],ifac[1000000],vis[1000000],f[1000000],siz[1000000],ecnt,cnt,S,p,ans,res;

int ksm(int a,int b)
{
	int x=a;
	a=1;
	while(b)
	{
		if(b&1)
			a=1ll*a*x%1000000007;
		x=1ll*x*x%1000000007,b>>=1;
	}
	return a;
}

int C(int n,int m)
{
	return 1ll*fac[n]*ifac[m]%1000000007*ifac[n-m]%1000000007;
}

void dfs(int x,int fa)
{
	vis[x]=1,cnt++;
	for(int i=h[x],y; y=e[i].t,i; ecnt++,i=e[i].n)
		if(!vis[y])
			f[y]=i,dfs(y,x);
		else if((y!=fa)&&(!S)) 
			S=i;
}

void dfs2(int x,int fe)
{
	siz[x]=0,f[x]=1;
	for(int i=h[x],y; y=e[i].t,i; i=e[i].n)
		if((i!=fe)&&((i^p)>1))
		{
			dfs2(y,i^1);
			if(e[i].w>e[fe].w)
				res=1ll*res*ifac[siz[y]]%1000000007*f[y]%1000000007;
			else
				siz[x]+=siz[y],f[x]=1ll*f[x]*f[y]%1000000007*C(siz[x],siz[y])%1000000007;
		}
	siz[x]++;
}

int main()
{
	scanf("%d",&n),fac[0]=1;
	for(int i=1; i<=2*n; i++)
		fac[i]=1ll*fac[i-1]*i%1000000007;
	ifac[2*n]=ksm(fac[2*n],1000000007-2);
	for(int i=2*n; i; i--)
		ifac[i-1]=1ll*ifac[i]*i%1000000007;
	for(int i=1,x,y,tot=1; i<=2*n; i++)
	{
		scanf("%d %d",&x,&y),y+=n;
		e[++tot]=(edge)
		{
			x,y,x+y,h[x]
		};
		h[x]=tot;
		e[++tot]=(edge)
		{
			y,x,x+y,h[y]
		};
		h[y]=tot;
	}
	ans=fac[2*n];
	for(int i=1,s; i<=2*n; i++)
		if(!vis[i])
		{
			ecnt=cnt=S=s=0,dfs(i,0);
			if(cnt!=ecnt/2)
			{
				puts("0");
				return 0;
			}
			p=S;
			for(int j=S; e[j].s!=e[S].t; j=f[e[j].s])
				p=(e[p].w<e[j].w?j:p);
			res=1;
			dfs2(e[p].s,p);
			s+=1ll*ifac[siz[e[p].s]]*f[e[p].s]%1000000007*res%1000000007;
			res=1;
			dfs2(e[p].t,p);
			s+=1ll*ifac[siz[e[p].t]]*f[e[p].t]%1000000007*res%1000000007;
			ans=1ll*ans*s%1000000007;
		}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 30976
#include "bits/stdc++.h"
using namespace std;

////////////// Prewritten code follows. Look down for solution. ////////////////
#define x first
#define y second
#define len(x) ((int)(x).size())
using pii = pair<int, int>;
using ll = long long;
using llu = long long unsigned;
using ld = long double;

const ld EPS = 1e-9;
inline int cmp(ld x, ld y = 0, ld tol = EPS) {
	return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

const int MOD = 1;
inline int mod (ll x, int m = MOD) {
	return (int)(((x%m) + m)%m);
}

////////////////////////// Solution starts below. //////////////////////////////

const int INF = 1e9+100;

const int N = 1e5+10;

int n;
int a[N];
int dp[N];

int solve (int p) {
	if (p == n)
		return 0;
	else if (p > n)
		return INF;
	int &r = dp[p];
	if (r != -1) return r;
	return r = min (solve (p+1) + abs(a[p]-a[p+1]),
					solve (p+2) + abs(a[p]-a[p+2]));
}

int main () {
	memset (dp, -1, sizeof dp);
	scanf ("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf ("%d", &a[i]);
	printf ("%d\n", solve (1));

	return 0;
}


Measured memory_bytes: 2560
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T>
T GCD(T x, T y)
{
    if (x < y)
    {
        const T a = x;
        x = y;
        y = a;
    }
    T b = 100000;
    while (b)
    {
        b = x % y;
        x = y;
        y = b;
    }
    return x;
}

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll res = a[0];
    for (int i = 0; i < n; i++)
    {
        res = GCD(res, a[i]);
    }
    cout << res << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define num(a) a-'0'
#define charr(a) (a - 'A' + 1)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define maxs(a,b) if(b>a)a=b
#define mins(a,b) if(b<a)a=b
#define debug(x) cerr<<"["<<#x<<":"<<x<<"] "
#define debug2(a,b) debug(a);debug(b)
#define debug3(a,b,c) debug2(a,b);debug(c)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/(__gcd(a,b))
#define print(arr) for(auto it = arr.begin();it < arr.end();it ++){cout << *it << " ";}cout << ln;
#define all(a) (a).begin(), (a).end()
#define vi vector<long long>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
#define f first
// #define s second
#define ln "\n"
typedef long double ld;
typedef double d;
using namespace std;
int modF=1e9+7;
int INF=1e11;

void solve(){
	int n,x,m;
	cin>>n>>x>>m;
	if(x==0){
		cout<<0<<ln;
	}
	else{
		vi h;
		set<int> s;
		int curr=x;
		int len=0;
		int ans=0;
		while(len<n){
			if(s.find(curr)==s.end()){
				h.pb(curr);
				s.insert(curr);
				ans+=curr;
				curr=(curr*curr)%m;
				len++;
			}
			else{
				int rl=0;
				int sum=0;
				int in;
				for(int i=len-1;i>=0;i--){
					rl++;
					sum+=h[i];
					if(h[i]==curr){
						in=i;
						break;
					}
				}
				ans+=((n-len)/rl)*sum;
				int it=(n-len)%rl;
				for(int i=in;i<in+it;i++){
					ans+=h[i];
				}
				break;
			}
		}
		cout<<ans<<ln;
	}
}

signed main(){
	boost_io;
	solve();
	return 0;
}

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

int main(){
    int x,a=0,b=0,c=0; cin >>x;

    for(int i=1; i<=x; i++){a +=i;}

    for(int i=1; i<=x; i++)
    for(int j=1; j<=x-i; j++)
    {b +=gcd(i,j);}
    
    for(int i=1; i<=x; i++)
    for(int j=1; j<=x-i; j++)
    for(int k=1; k<=x-i-j; k++)
    {c +=gcd(i,gcd(j,k));}

    cout << a+6*b+6*c;

return 0;
}

Measured memory_bytes: 3684
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
        int[] a = new int[N];
        for(int i=0; i<N; i++){
          a[i] = sc.nextInt();
        }
        int min = 0;
        for(int i=0; i<N; i++){
          min += (a[i]-(-101)) * (a[i]-(-101));
        }
      
        for(int i=-100; i<=101; i++){
          int sum = 0;
          for(int j=0; j<N; j++){
            sum += (a[j]-i) * (a[j]-i);
          }
          if(sum < min){
            min = sum;
          }
        }

        System.out.println(min);
    }
}

Measured memory_bytes: 21716
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>

int main(){
  srand((unsigned int)time(NULL)); 
  int D,M=365*500;
  int c[30];
  int s[370][30];
  int t[370];
  int last[30];
  int ans=0;
  int ans_max=0;
  int old_t[370];
  
  scanf("%d",&D);
  for(int i=1;i<=26;i++)
    scanf("%d",c+i);
  for(int i=1;i<=D;i++)
   for(int j=1;j<=26;j++)
     scanf("%d",&s[i][j]);
  
  for(int i=1;i<=D;i++)
    t[i]=rand()%26+1;
  
  for(int i=1;i<=M;i++){
    ans=0;
    for(int r=1;r<=D;r++){
      old_t[r]=t[r];
      t[r]=rand()%26+1;
    }
    for(int k=1;k<=26;k++)
      last[k]=0;
    for(int d=1;d<=D;d++){
      ans+=s[d][t[d]];
      last[t[d]]=d;
      for(int j=1;j<=26;j++){
        ans-=c[j]*(d-last[j]);
      }
    }
    if(ans<ans_max){
      for(int r=1;r<=D;r++){
        t[r]=old_t[r];
      }
    }else{
      ans_max=ans;
    }
  }
  
  for(int i=1;i<=D;i++)
    printf("%d\n",t[i]);
  return 0;
}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
ll n, a, dp[55][55][2555];
vi x;

ll solve(int i, int used, int sum)
{
	if (i == n) return sum == used*a;
	if (dp[i][used][sum] >= 0) return dp[i][used][sum];
	ll res = 0;
	res = solve(i + 1, used + 1, sum + x[i]) + solve(i + 1, used, sum);
	return dp[i][used][sum] = res;
}

int main()
{
	cin.sync_with_stdio(false);
	MS(dp, -1);
	cin >> n >> a;
	x.resize(n);
	REP(i, n) cin >> x[i];
	cout << solve(0, 0, 0) - 1 << endl;
	return 0;
}

Measured memory_bytes: 60672
#include <vector>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

vector<string> split(string &str, const char *delim){
	vector<string> result;
	int cutAt;
	while( (cutAt = str.find_first_of(delim)) != str.npos ){
		if(cutAt > 0){
			result.push_back(str.substr(0, cutAt));
		}
		str = str.substr(cutAt + 1);
	}
	if(str.length() > 0){
		result.push_back(str);
	}
	return result;
}

void reversepoland(string &exp){
	vector<string> token = split(exp," ");
	vector<double> resolveNumber;
	vector<string> resolveString;
	for(int i=0;i<token.size();i++){
		char *p=NULL;
		double d=strtod(token[i].c_str(),&p);
		if(p-token[i].c_str()==token[i].size()){
			resolveNumber.push_back(d);
			resolveString.push_back(token[i]);
		}else{
			//if(resolveNumber.size()<2){printf("stack few\n");return;}
			double d2=resolveNumber[resolveNumber.size()-1],d1=resolveNumber[resolveNumber.size()-2];
			resolveNumber.pop_back(),resolveNumber.pop_back();
			string s2=resolveString[resolveString.size()-1],s1=resolveString[resolveString.size()-2];
			resolveString.pop_back(),resolveString.pop_back();
			double ret;

			if(token[i]=="+"){ret=d1+d2;}
			else if(token[i]=="-"){ret=d1-d2;}
			else if(token[i]=="*"){ret=d1*d2;}
			else if(token[i]=="/"){ret=d1/d2;}
			//else if(token[i]=="%"){ret=d1%d2;}
			//else if(token[i]=="**"){ret=pow(d1,d2);}
			//else{printf("unknown OP %s\n",token[i].c_str());return;}

			resolveNumber.push_back(ret);
			resolveString.push_back("("+s1+token[i]+s2+")"); //this won't emit "optimized" expression. full of parens.
		}
	}
	//if(resolveNumber.size()!=1){printf("result stack not 1");return;}
	printf("%f\n",resolveNumber[0]);
}
int main(){for(string str;getline(cin,str);reversepoland(str));}

Measured memory_bytes: 1276
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextInt();

		long[] a = new long[(int) N];
		long[] values = new long[(int) (N+1)];

		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			values[(int) a[i]]++;
		}
		sc.close();

		long sum = 0;
		for (long c : values) {
			if(c > 1) {
			sum += (c-1)*c/2;
			}
		}

		for (long c :a) {
			System.out.println(sum - (values[(int) c]-1));
		}

	}

}


Measured memory_bytes: 100604
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<list>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const ll p=924844033;
const ll g=5;
ll fp(ll a,ll b)
{
	ll s=1;
	while(b)
	{
		if(b&1)
			s=s*a%p;
		a=a*a%p;
		b>>=1;
	}
	return s;
}
namespace ntt
{
	ll w1[1000010];
	ll w2[1000010];
	int rev[1000010];
	int n;
	void init()
	{
#ifdef DEBUG
		n=16;
#else
		n=524288;
#endif
		int i;
		for(i=1;i<=n;i<<=1)
		{
			w1[i]=fp(g,(p-1)/i);
			w2[i]=fp(w1[i],p-2);
		}
		rev[0]=0;
		for(i=1;i<n;i++)
			rev[i]=(rev[i>>1]>>1)|(i&1?n>>1:0);
	}
	void ntt(ll *a,int t)
	{
		int i,j,k;
		ll u,v,w,wn;
		for(i=0;i<n;i++)
			if(rev[i]<i)
				swap(a[i],a[rev[i]]);
		for(i=2;i<=n;i<<=1)
		{
			wn=(t==1?w1[i]:w2[i]);
			for(j=0;j<n;j+=i)
			{
				w=1;
				for(k=j;k<j+i/2;k++)
				{
					u=a[k];
					v=a[k+i/2]*w%p;
					a[k]=(u+v)%p;
					a[k+i/2]=(u-v)%p;
					w=w*wn%p;
				}
			}
		}
		if(t==-1)
		{
			ll inv=fp(n,p-2);
			for(i=0;i<n;i++)
				a[i]=a[i]*inv%p;
		}
	}
};
ll b[1000010];
ll c[1000010];
ll a[1000010];
ll inv[1000010];
ll fac[1000010];
ll ifac[1000010];
int s[1000010];
int n;
list<int> l[200010];
ll num[1000010];
void dfs(int x,int fa)
{
	s[x]=1;
	for(auto v:l[x])
		if(v!=fa)
		{
			dfs(v,x);
			s[x]+=s[v];
			num[s[v]]--;
			num[n-s[v]]--;
		}
}
int main()
{
#ifdef DEBUG
	freopen("b.in","r",stdin);
	freopen("b.out","w",stdout);
#endif
	scanf("%d",&n);
	int i,x,y;
	for(i=1;i<=n-1;i++)
	{
		scanf("%d%d",&x,&y);
		l[x].push_back(y);
		l[y].push_back(x);
	}
	inv[0]=inv[1]=fac[0]=fac[1]=ifac[0]=ifac[1]=1;
	for(i=2;i<=n;i++)
	{
		inv[i]=-(p/i)*inv[p%i]%p;
		fac[i]=fac[i-1]*i%p;
		ifac[i]=ifac[i-1]*inv[i]%p;
	}
	dfs(1,0);
	num[n]=n;
	for(i=0;i<=n;i++)
		b[i]=num[n-i]*fac[n-i]%p;
	for(i=0;i<=n;i++)
		c[i]=ifac[i];
	ntt::init();
	ntt::ntt(b,1);
	ntt::ntt(c,1);
	for(i=0;i<ntt::n;i++)
		a[i]=b[i]*c[i]%p;
	ntt::ntt(a,-1);
	for(i=1;i<=n;i++)
	{
		ll ans=a[n-i]*ifac[i]%p;
		ans=(ans+p)%p;
		printf("%lld\n",ans);
	}
	return 0;
}


Measured memory_bytes: 78080
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    n = int(input())
    a = list(map(int, input().split()))
    s = sum(a)
    t = list(itertools.accumulate(a))
    print(min(abs(s-2*t[i]) for i in range(0, n-1)))


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000
#define LLINF 1e18

void solve_abc_a() {
	ll n, m;
	ll x, y;
	ll a, b, d;
	ll c;
	//char c;
	ll h, w;
	ll k;
	string s, t;
	ll l_ans = 0;
	string s_ans = "NG";
	ll l, r;

	cin >> x;

	if (x >= 30) {
		s_ans = "Yes";
	}
	else {
		s_ans = "No";
	}

	cout << s_ans << "\n";

	return;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(7);

	solve_abc_a();

	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define ll long long int
#define F first
#define S second
#define pb push_back
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y);
#define sdl(x) scanf("%lld",&x)
#define sd2l(x,y) scanf("%lld%lld",&x,&y);
#define sz(x) (int)(x.size())
#define nax 100010
#define inf 1001000100
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define mp make_pair
#define pc pair<char ,int>
#define pi pair<int ,int>
#define pii pair <int,pi>
#define ull unsigned long long int
using namespace std;
int arr[nax];
int siz[nax];
vector< ll > ans;
vector< pi > v;

int root(int x)
{
	while(arr[x] != x)
	{
		 x = arr[x];
		 arr[x] = arr[arr[x]];
	}
	return x;
}

ll unite(int a, int b)
{
	a = root(a);
	b = root(b);
	ll ret = siz[a] * 1ll * siz[b];
	if(siz[a] > siz[b])
	{
		arr[b] = a;
		siz[a] += siz[b];
	}
	else
	{
		arr[a] = b;
		siz[b] += siz[a];
	}
	return ret;
}


int main() {

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int a, b, c;
    cin >> a >> b >> c;
    int ma = a * c ;
    int ctr = 0;
    for(int i = 1; i <= min(ma, b); i++)
    {
    	if(i % a == 0)
    		++ctr;
    }
    cout << ctr << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define NMAX 100000
int compare(const void *a, const void *b);
int main(void)
{
  int i, n, prex, xlevel = 0, aflag = 0, ans = 0, a[NMAX], x[NMAX][2];
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    x[i][0] = a[i];
    x[i][1] = i;
  }
  qsort(x, n ,sizeof(int) * 2, compare);
  prex = x[0][0];
  for (i = 0; i < n; i++) {
    if (prex != x[i][0]) {
      xlevel++;
      prex = x[i][0];
    }
    a[x[i][1]] = xlevel;
  }
  memset(x, 0, sizeof(x));
  for (i = 0; i < n; i++) {
    x[a[i]][0]++;
    if (x[a[i]][0] == 1) ans++;
    else if (x[a[i]][0] == 0) ans--;
    x[a[n-1-i]][0]--;
    if (x[a[n-1-i]][0] == -1) ans++;
    else if (x[a[n-1-i]][0] == 0) ans--;
    if (!ans) {
      if (aflag) printf(" ");
      aflag = 1;
      printf("%d", i + 1);
    }
  }
  printf("\n");
}

int compare(const void *a, const void *b)
{
  int *ta = *(int(*)[2])a, *tb = *(int(*)[2])b;
  return ta[0] - tb[0];
}



Measured memory_bytes: 3428
#include <stdio.h>

void BuildStairs(int& N, int heights[])
{
    if (N == 1)
    {
        printf("Yes\n");
        return;
    }

    for (int i = 1; i < N; i++)
    {
        if (heights[i] < heights[i-1])
        {
            printf("No\n");
            return;
        }
        else if (heights[i] > heights[i-1]) heights[i]--;
    }

    printf("Yes\n");
}

int main()
{
    int N;

    scanf("%d", &N);

    int heights[N];

    for (int i = 0; i < N; i++) scanf("%d", &heights[i]);

    BuildStairs(N, heights);

    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

int main(){
	int dp[100001];
	int N, K; cin >> N >> K;
	vector<int> h;
	h.resize(N);

	for(int i = 0; i < N; ++i) cin >> h[i];

	dp[0] = 0;
	for(int i = 1; i < N; ++i){
		int mindp = 1000000000; // INF
		for(int j = i-K; j < i; ++j){
			if(j < 0) continue;
			int dur = dp[j] + abs(h[i]-h[j]);
			if(dur < mindp) mindp = dur;
		}
		dp[i] = mindp;
		// cout << "i:" << i << ", dp:" << dp[i] << endl;
	}

	cout << dp[N-1] << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,a[505],b[505],c[250005];
bool cmp(int x,int y)
{
	return a[x]<a[y];
}
void biu()
{
	puts("No");
	exit(0);
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		b[i]=i;c[a[i]]=i;
	}
	sort(b+1,b+n+1,cmp);
	int now=1;
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<b[i];j++)
		{
			while(c[now])now++;
			c[now]=b[i];
		}
		if (now>a[b[i]]) biu();
	}
	now=n*n;
	for (int i=n;i>=1;i--)
	{
		for (int j=b[i]+1;j<=n;j++)
		{
			while(c[now])now--;
			c[now]=b[i];
		}
		if (now<a[b[i]]) biu();
	}
	puts("Yes");
	for (int i=1;i<=n*n;i++)
		printf("%d ",c[i]);
}

Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>

struct Graph
{
std::size_t sz;
std::vector<std::vector<int>> elist;
// set avoids duplicates

Graph(int n) : sz(n), elist(n)
{}
void add_edge(int i,int j)
{
	elist[i].push_back(j);
	elist[j].push_back(i);
}
std::size_t size()
{
	return sz;
}


unsigned connected_components(std::vector<int>& components)
{	unsigned int num = 0;
	std::vector<bool> visited(sz,false);
	for(unsigned v = 0; v < sz; ++v)
	{		
		if(visited.at(v)== false)
		{	
			std::vector<int> nb;
			std::vector<int> nb2;
			components.push_back(0);
			visited.at(v) = true;	
			++components.at(num);
			for(auto & e : elist[v])
			{
				if(visited.at(e)== false)
				{
				nb.push_back(e);
				++components.at(num);
				visited.at(e) = true;			
				}			
			}
			while(!nb.empty())
			{
				for(auto & n : nb)
				{
					for(auto &e : elist.at(n))
					{	if(!visited.at(e))	
						{	nb2.push_back(e);
							++components.at(num);
							visited.at(e) = true;
						}					
					}
				}
				std::swap(nb, nb2);
				nb2.clear();
			}
			++num; 
		}
		
	}
	return num;
}


};





int main()
{
	std::ios::sync_with_stdio(false);
	int n, m;
	std::cin >> n >> m;
	Graph g(n);

	for(int l = 0 ; l < m ; ++l)
	{
		int i, j;
		std::cin >> i >> j;
		g.add_edge(i-1,j-1);
	}
	std::vector<int> components;
	int num = g.connected_components(components);
	if(num == 1)
	{
		std::cout << g.size() ;
		return 0;
	}
	int groups = 0;
	for(auto & m : components)
	{
		if(m > groups)
		groups = m; 
	}
	
	std::cout << groups << std::endl;
}





Measured memory_bytes: 15016
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  long double l;cin>>l;
  cout << std::fixed << std::setprecision(8) <<l*l*l/27  << endl;
}

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

using namespace std;

typedef struct{
    string str;
    int len;
}Music;

int main(int, char**) {
    int N;
    vector<Music> playList;

    cin >> N;
    playList.reserve(N);

    for(int i=0;i<N;++i){
        Music m;
        cin >> m.str >> m.len;
        playList.emplace_back(m);
    }

    string last;
    cin >> last;

    auto it = begin(playList);
    for(;it!=end(playList)&&it->str!=last;++it);
    int sum = 0;
    for(++it;it!=end(playList);++it){
        sum += it->len;
    }
    cout << sum << "\n";
}


Measured memory_bytes: 256
import numpy as np
ans=0
D=int(input())
C=np.array(list(map(int,input().split())))
last_day=np.array([-1 for _ in range(26)])
score=np.array([list(map(int,input().split())) for _ in range(D)])

for day in range(D):
    today_point=C*(day-last_day)
    S_today=sum(today_point)
    for k in range(26):
        today_point[k]=score[day][k]-S_today+today_point[k]

    if day!=D-1:
        max_score=-1*float("inf")
        for k in range(26):
            nday_point=C*((day+1)-last_day)
            S_nday=sum(nday_point)-C[k]*(day-last_day[k])
            
            for i in range(26):
                if k!=i:
                    nday_point[i]=score[day+1][i]-S_nday+nday_point[i]
                else:
                    nday_point[i]=score[day+1][i]-S_nday+C[i]

                if today_point[k]+nday_point[i]>max_score:
                    max_score=today_point[k]+nday_point[i]
                    idx=k
    else:
        idx=np.argmax(today_point)

    last_day[idx]=day
    print(idx+1)


Measured memory_bytes: 27448
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

lo n,m,b,a[li],k,flag;
lo cev;
string s;
vector<lo> v;

void YES(lo xxxxxxx){
	if(xxxxxxx==1){cout<<"YES\n";exit(0);}
	printf("YES\n");
	exit(0);
}

void NO(lo xxxxxxx){
	if(xxxxxxx==1){cout<<"NO\n";exit(0);}
	printf("NO\n");
	exit(0);
}

int main(void){
	scanf("%lld %lld %lld",&n,&m,&k);
	cev=min(n+m,m+k);
	cev=min(cev,n+k);
	printf("%lld\n",cev);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
using namespace std;
int main(){
	int n,q;
	cin>>n>>q;
	queue<int>que[n];
	while(q--){
		int command,t;
		cin>>command>>t;
		if(command==0){
			int x;
			cin>>x;
			que[t].push(x);
		}
		else if(command==1){
			if(!que[t].empty())	
				cout<<que[t].front()<<endl;
		}

		else if(command==2){
			if(!que[t].empty())	
				que[t].pop();
		}

	}
	return 0;
}


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

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef vector<LL> 		VL;
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"
#define DRT() int t; si(t); while(t--)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//# define M_PI           3.14159265358979323846264338327950288
// DSU
void IO(){
	#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
	srand(chrono::steady_clock::now().time_since_epoch().count());
	off;
}
LL gcd(LL a, LL b){
	return b == 0 ? a : gcd(b, a % b);
}
int main(){
	IO();
	LL a,b,c,d;
	cin>>a>>b>>c>>d;
	a--;
	if(d > c)
		swap(c,d);
	LL g = gcd(c,d);
	LL l = (c*d)/g;
	LL ans = b/c - a/c + b/d - a/d - b/(l) + a/(l);
	ans = (b-a) - ans;
	cout<<ans; 
	return 0;
}

Measured memory_bytes: 3672
#include <stdio.h>

int main(void)
{
	char s[20] = "\0";
	int i = 0;
	scanf("%s",s);
	for(i = 0;i < 4;i++)
		printf("%c",s[i]);
	printf(" ");
	for(i = 4;i < 12;i++)
		printf("%c",s[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>

using namespace std;

int graph_p[9][9];

int dfs(int v, int n, int visited[9]) {
	int res = 1;
	for (int i = 0; i < n; i++) {
		if (visited[i] == 0) {
			res = 0;
		}
	}

	if (res == 1)
		return 1;

	int cnt = 0;

	for (int i = 0; i < n; i++) {
		if (graph_p[v][i] == 1 && visited[i]==0) {
			visited[i] = 1;
			cnt += dfs(i, n, visited);
			visited[i] = 0;
		}
	}

	return cnt;
}


int main()
{
	int n, m;
	int visited[9];

	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		graph_p[a-1][b-1] = 1;
		graph_p[b-1][a-1] = 1;
	}

	for (int i = 0; i < n; i++) {
		visited[i] = 0;
	}

	visited[0] = 1;

	cout << dfs(0, n, visited) << endl;


    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,a1,a2;
  long long miti[100001]={};
  cin >> n >> m;
  for(int i=0;i<m;i++){
    cin >> a2;
    if(i == 0) a1 = a2;
    for(int j=min(a1,a2);j<max(a1,a2);j++) miti[j]++;
    a1 = a2;
  }
  long long a,b,c;
  long long ans = 0;
  for(int i=1;i<n;i++){
    cin >> a >> b >> c;
    ans += min(miti[i]*a,miti[i]*b+c);
  }
  cout << ans << endl;
  return (0);
}

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

int main() {
	int p, q;
	while (~scanf("%d%d", &p, &q)) {
		map<int, int>mp;
		string s;
		for (int i = 1; p; i++) {
			if (mp[p])break;
			mp[p] = i;
			p *= 10;
			s += to_string(p / q);
			p %= q;
		}
		cout << s << endl;
		if (p) {
			bool flag = false;
			rep(i, s.size()) {
				if (i+1 == mp[p])flag = true;
				if (flag)cout << '^';
				else cout << ' ';
			}
			cout << endl;
		}
	}
}

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

using ll = long long;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)

int main(){
	int s;
	cin >> s;
	int b = s / 100;
	int a = s % 100;
	if((a == 0 || a > 13) && (b == 0 || b > 13))cout << "NA" << endl;
	else if(a == 0 || a > 13){
		cout << "MMYY" << endl;
	}
	else if(a != 0 && a <= 12 && b != 0 && b <= 12){
		cout << "AMBIGUOUS" << endl;
	}	
	else{
		cout << "YYMM" << endl;
	}
	return 0; 
}


Measured memory_bytes: 256
//============================================================================
//Everyone has a different way of thinking, so God Created us
//   Hope You Respect My Way..,Thank You ):
// Author      : Murad
// Name        : Codeforces.cpp & Atcoder.cpp
// Description : Problem name
//============================================================================
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define ULL unsigned long long
#define MP make_pair
#define SZ(c) int(c.size())
#define ff first
#define ss second
#define INF INT32_MAX
#define _INF INT32_MIN
#define PQ priority_queue
#define MM multimap
#define PB push_back
#define vii vector<int>
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define MAXN 100004
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
char alphz[27] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
int main() {
	El3zba;
	int a,b,k;
	cin>>a>>b>>k;
	int cnt=0;
	for(int i=a;i>=0;i--)
	{
		if(a%i==0&&b%i==0)
			cnt++;
		if(cnt==k)
			return cout<<i<<endl,0;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
int main(){
  string str;
  int n;
  cin >> n;
  str = to_string(n);
  int ans=0;
  rep(i,4){
    if(str[i]=='2'){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,i,j,y,x,m;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    int a=0;
    int d[102][2]={{0}};
    for(i=0;i<n*2;i++){
      scanf("%d",&d[i%n][i/n]);
    }
    m=1000;
    for(i=0;i<2;i++){
      y=0;
      x=i;
      a=0;
      int c[102][2]={{0}};
      for(j=0;1;j++){
	while((d[y][x]==1)&&d[y+1][x]==1)y++;
	while(d[y][x]==2)y--;//printf("%d %d\n",y,x);
	if(c[y][x]==1)break;
	if(y>n-2){
	  a=1;//printf("j:%d\n",j);
	  break;
	}
	c[y][x]=1;
	y+=2;
	if(x)x=0;
	else x=1;
      }
      if(m>j&&a)m=j;//printf("m:%d\n",m);
    }
    if(a)printf("%d\n",m);
    else printf("NA\n");
  }
  return 0;
}

Measured memory_bytes: 612
#include <cmath>
#include <iostream>

using namespace std;
using ll = long long;
int m = 1e9;

int main() {
  ll S, x2{m}, x3, y2{1}, y3;
  cin >> S;
  y3 = 1 + (S - 1) / m;
  x3 = m - (S - 1) % m - 1;
  cout << "0 0 " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
}


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

int cost[] = {0,2,5,5,4,5,6,3,7,6};
bool d[10] = {};
int main() {
    int n, m;
    cin >> n >> m;
    for (int i=0; i<m; i++) {
        int a;
        cin >> a;
        d[a] = 1;
    }

    vector<string> dp(n+1, "");
    for (int j=0; j<=n; j++) {
        for (int i=1; i<10; i++) {
            if ( !d[i] ) continue;
            if ( j+cost[i]>n ) continue;
            if ( j && dp[j]=="" ) continue;
            string s=dp[j]+(char)(i+'0');
            if ( s.length()==dp[j+cost[i]].length() ) {
                dp[j+cost[i]]=max(s, dp[j+cost[i]]);
            } else if ( s.length()>dp[j+cost[i]].length() ) {
                dp[j+cost[i]]=s;
            }
        }
    }

    cout << dp[n] << '\n';
    return 0;
}

Measured memory_bytes: 43776
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		String s = scan.nextLine();
		String p = scan.nextLine();

		String ss = s + s;
		if (ss.matches(".*" + p + ".*")) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

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

int main(){
    int i;
    std::string buff;

    getline(std::cin, buff);

    for(i=0;i<buff.size();i++){

        if('a'<=buff[i]&&buff[i]<='z'){
            buff[i]-=0x20;
        }else if('A'<=buff[i]&&buff[i]<='Z'){
            buff[i]+=0x20;
        }else{
            buff[i]=buff[i];
        }    
    }

    std::cout<<buff<<std::endl;

    return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;} 



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

int N, Q; string S;
cin >> N >> S >> Q;

vector<set<int>> pos(26, set<int>({1<<30}));
rep(i, 0, N) {
    pos[S[i] - 'a'].insert(i);
}

while(Q--){
    int q; cin >> q;
    if (q == 1){
        int i; char c; cin >> i >> c;
        pos[S[i-1] - 'a'].erase(i-1);
        pos[c - 'a'].insert(i-1);
        S[i-1] = c;
    }
    else {
        int l, r; cin >> l >> r;
        int c = 0;
        rep(i, 0, 26){
            if (pos[i].empty()) continue;
            if (*pos[i].lower_bound(l-1) < *pos[i].lower_bound(r)) ++c;
        }

        cout << c << "\n";
    }
}

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 24220
#include "stdio.h"
#include "string.h"
long long N[4001];
int f[4001];
int main(){
    int x,i,j,c=0;
    long long p,n;
    scanf("%d",&i);
    while(i!=0){
        c=0;
	memset(N,0,sizeof(N));
	memset(f,0,sizeof(f));
        for(j=0;j<i;j++){
            scanf("%d%lld%lld",&x,&n,&p);
            if(N[x]>=0&&(N[x]+=n*p)>=1000000L){
                f[c]=x;
                c++;
                N[x]=-100L;
            }
        }
        if(c<1){
            printf("NA\n");
        }else{
            for(j=0;j<c;j++)printf("%d\n",f[j]);
        }
        scanf("%d",&i);
    }
    return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
		// 1行目個数、2行目の複数の数字を配列に格納
		//   3
		//   1 2 3
		int N = Integer.parseInt(br.readLine());
		String[] ss0 = br.readLine().trim().split(" ", 0);
		Integer[] ii0 = new Integer[N];
		for(int i = 0; i < N; i++){
			ii0[i] = Integer.parseInt(ss0[i]);
		}
		
		
			//入力値確認
			for(int i=0; i < N; i++){
				//dp(ii0[i]);
			}

		if (N%2==0) {
			// 偶数個の場合、4::   1,3
			for(int i=0; i < N; i++){
				ii0[i] = (ii0[i] + 1) / 2;
			}
		} else {
			// 奇数個の場合、5:: 0,2,4
			for(int i=0; i < N; i++){
				ii0[i] = (ii0[i]) / 2;
			}
		}

		Arrays.sort(ii0);
			//入力値確認
			for(int i=0; i < N; i++){
				dp(ii0[i]);
			}
	
		
		boolean b = true;
		int j=0;
		for(int i=0; i < N; i++){
			if (N%2==0) {
				j = (i+2)/2;
			} else {
				j = (i+1)/2;
			}
				dp(j);
			b = (ii0[i] == j);
			if (b == false) { System.out.println(0); return; }
		}
		
		//
		j = (N/2);
		double d = 0;
		
		d = 1;
		for(int i=0; i < (N/2); i++){
			d = (d * 2) % (Math.pow(10d, 9d)+7);
		}

		//System.out.println((int)((Math.pow(2d, d)) % (Math.pow(10d, 9d)+7)));
		System.out.println((int)d);

        return;
    }
    // Debug.Print
    static void dp(String s) {
		//System.out.println(s);
	}
    static void dp(StringBuilder s) { dp(s.toString()); }
    static void dp(int i) { dp(String.valueOf(i)); }
    static void dp(long i) { dp(String.valueOf(i)); }

}

Measured memory_bytes: 29328
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] str = br.readLine().split(" ");
		int a = Integer.parseInt(str[0]);
		int b = Integer.parseInt(str[1]);
		int d = a / b;
		int r = a % b;
		double f = (double)a / b;
		System.out.printf("%d %d %.5f\n", d, r, f);
	}

}

Measured memory_bytes: 24792
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
long long a[100001];
vector<long long> v;

int go(int x) { // 7 6 4   6가 나왔다. 
	int l = 0;
	int r = v.size() - 1; 
	while (l <= r) {
		int mid = (l + r) / 2; 
		if (v[mid] < x) {
			r = mid - 1;
		}
		else {
			l = mid + 1;
		}
	}
	return l;
}
int main() { // 34        
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	} 
	v.push_back(a[0]);
	for (int i = 1; i < n; i++) {
		if (v[v.size() - 1] >= a[i]) {
			v.push_back(a[i]);
		}
		else {
			int j = go(a[i]);
			v[j] = a[i];
		}
	}
	cout << v.size() << '\n';


}

Measured memory_bytes: 2168
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();

        String result = "";
        System.out.println(calc(result, N, 1));
        sc.close();

    }

    static String calc(String result, long N, int count) {
        if (N < 26) {
            return moji((int) N) + result;
        } else if (N == 26) {
            return moji(0) + result;
        }

        result = (moji((int) (N % 26))) + result;
        if (N % 26 != 0) {
            return calc(result, ((N - N % 26) / 26), count++);
        } else {
            return calc(result, ((N - 26) / 26), count++);
        }
    }

    static String moji(int N) {
        String moji = "";
        switch (N) {
            case 1:
                moji = "a";
                break;
            case 2:
                moji = "b";
                break;
            case 3:
                moji = "c";
                break;
            case 4:
                moji = "d";
                break;
            case 5:
                moji = "e";
                break;
            case 6:
                moji = "f";
                break;
            case 7:
                moji = "g";
                break;
            case 8:
                moji = "h";
                break;
            case 9:
                moji = "i";
                break;
            case 10:
                moji = "j";
                break;
            case 11:
                moji = "k";
                break;
            case 12:
                moji = "l";
                break;
            case 13:
                moji = "m";
                break;
            case 14:
                moji = "n";
                break;
            case 15:
                moji = "o";
                break;
            case 16:
                moji = "p";
                break;
            case 17:
                moji = "q";
                break;
            case 18:
                moji = "r";
                break;
            case 19:
                moji = "s";
                break;
            case 20:
                moji = "t";
                break;
            case 21:
                moji = "u";
                break;
            case 22:
                moji = "v";
                break;
            case 23:
                moji = "w";
                break;
            case 24:
                moji = "x";
                break;
            case 25:
                moji = "y";
                break;
            case 0:
                moji = "z";
                break;
        }
        return moji;
    }
}


Measured memory_bytes: 39356
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::iter::Iterator;
use std::collections::HashSet;
use std::cmp::*;
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }
  
  #[allow(unused_macros)]
  macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
    n: i64,
    k: i64,
    }

    let mut res = n;

    let amari = n % k;
    let shou = n /k;
    let over = ((shou + 1) * k) - n ;

    if amari < over {
      println!("{}", amari);
    }else{
      println!("{}", over);
    }

}


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

#define pb push_back
#define vi vector < int >
#define ii pair < int, int >
#define vii vector < pair < int, int > >
#define vvi vector < vector < int > >
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define FOR( i, lo, hi ) for( int i = (lo);i < (hi);i++ )
#define DFOR( i, hi, lo ) for( int i = (hi);i >= (lo);i-- )
#define pqueue priority_queue

using namespace std;

const long long int MOD = 1e9 + 7;

ll REM( ll a )
{
	a %= MOD;
	if ( a < 0 )
	   a += MOD;
	return a;
}

ll ADD( ll a, ll b )
{
	return REM( REM( a ) + REM( b ) );
}

ll SUB( ll a, ll b )
{
	return REM( REM( a ) - REM( b ) );
}

ll MUL( ll a, ll b )
{
	return REM( REM( a ) * REM( b ) );
}

ll POT( ll n, ll k )
{
	if ( k == 0 )
		return 1;

	ll ret = POT( n, k / 2 );
	ret = MUL( ret, ret );

	if ( k % 2 )
		return MUL( ret, n );
	return ret;
}

ll DIV( ll a, ll b )
{
	return MUL( a, POT( b, MOD - 2 ) );
}

bool isPrime( ll x )
{
	for ( ll i = 2;i <= sqrt( x ); i++ )
		if ( x % i == 0 )
			return false;
	return true;
}

int a, b, c;

int main()
{
	cin >> a >> b >> c;
	if ( ( a + b + c ) >= 22 )
		cout << "bust\n";
	else
		cout << "win\n";
	return 0;
}


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

/* Name of the class has to be "Main" only if the class is public. */
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
//class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		BufferedReader stdReader =
            new BufferedReader(new InputStreamReader(System.in));
        String line = stdReader.readLine();
        
        int a = Integer.parseInt(line);
        
        System.out.println( (a / 3600) + ":" + ( (a / 60) % 60 ) +":" + (a % 60) );
	}
}

Measured memory_bytes: 16864
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
  Scanner sc = new Scanner(System.in);
 
  public static void main(String[] args) {
    new Main().run();
  }


  void run() {
   int n=sc.nextInt();
   int k=sc.nextInt();
   int result=0;
   result=((int)Math.pow(k-1, n-1))*k;
   System.out.println(result);
   
   
  }
 

 
  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }
}

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

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())
#define pb(x) push_back(x)

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

const int MAXN = 1e5 + 5;
const ll inf = 1e16;

ll n, k;
ll a[MAXN], pref[MAXN], suf[MAXN], sol;
ll pravi[MAXN];

ll calc(int x, int y){
  if(x) return pravi[y] - pravi[x - 1];
  return pravi[y];
}

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

  cin >> n >> k;
  REP(i, n)
    cin >> a[i];
  pref[0] = max(a[0], 0LL);
  pravi[0] = a[0];
  FOR(i, 1, n){
    pref[i] = pref[i - 1] + (a[i] > 0 ? a[i] : 0);
    pravi[i] = pravi[i - 1] + a[i];
  }
  suf[n - 1] = max(a[n - 1], 0LL);
  for(int i = n - 2; i >= 0; --i)
    suf[i] = suf[i + 1] + (a[i] > 0 ? a[i] : 0);

  REP(i, n - k + 1)
    sol = max(sol, (i > 0 ? pref[i - 1] : 0LL) + suf[i + k] + max(0LL, calc(i, i + k - 1)));
  cout << sol;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
#define INF 2000'000'000

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	//freopen("in", "r", stdin);
	int n, ans = 0;
	string s;
	cin >> n >> s;
	for(int i = 0, j = n-1; i < j; i++){
		if(s[i] == 'W'){
			while(s[j] == 'W' && j > i)
				j--;
			if(s[j] == 'R')
				swap(s[i], s[j]), ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3768
#include <stdio.h>

int main(void)
{
	int n,sum=1,i;
	char c,d;
	
	scanf("%d",&n);
	c=getchar();
	c=getchar();
	for(i=0;i<n-1;i++){
		d=getchar();
		
/*printf("\n%d %d %c %c",i,i+1,c,d);*/
		if(c==d){}else{sum=sum+1;
		
/*printf(" ! %d\n",sum);*/
		}
		c=d;
	}
	printf("%d\n",sum);
	return 0;
}

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

int main() {
  
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int L = 0;
  int R = 0;
  
  L = A + B;
  R = C + D ;
  
  if (L > R){
    cout << "Left" << endl;
  }
  else if (L == R){
    cout << "Balanced" << endl;
  }
  else{
	cout << "Right" << endl;
  }

 }

Measured memory_bytes: 3624
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

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


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  string s;

  cin >> s;

  if(s.size() >= 4 && s.substr(0,4) == "YAKI"){
    puts("Yes");
  }else{
    puts("No");
  }
  
  return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ");
//#define double long double

template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int MAX = 200060;
const double pi = acos(-1);
const ll INF = 1e18;



void solve() {
	int N; cin >> N;
	string S; cin >> S;
	S += '.';
	ll ans = 0;
	FOR(i, 1, N + 1) {
		if (S[i] != S[i - 1])ans++;
	}
	print(ans);
}


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

	solve();
}

Measured memory_bytes: 512