akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			//			solveA();
			solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		int a = nextInt();
		int b = nextInt();
		int t = nextInt();

		int res = 0;

		double time = 0;
		while (time <= t + 0.5) {
			time += a;
			if (time <= t + 0.5) {
				res += b;
			}
		}

		out.println(res);
	}

	private void solveB() {
		int numN = nextInt();
		int[] v = IntStream.range(0, numN).map(i -> nextInt()).toArray();
		int[] x = IntStream.range(0, numN).map(i -> nextInt()).toArray();

		long res = 0;
		for (int i = 0; i < numN; i++) {
			if (v[i] > x[i]) {
				res += (v[i] - x[i]);
			}
		}

		out.println(res);
	}

	private void solveC() {
		int numN = nextInt();

		out.println("");
	}

	private void solveD() {
		int numN = nextInt();

		out.println("");
	}

	private void solveE() {
		int numN = nextInt();

		out.println("");
	}

	private void solveF() {
		int numN = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

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

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

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

int main()
{
 int N;cin>>N;
  vector<int> X(N);
  vector<long long int> SUM(100);
  for(int i=0;i<N;i++)
  {
  cin>>X[i];
  }
  for(int i=0;i<100;i++)
  {
    for(int j=0;j<N;j++)
    {
     SUM[i]=SUM[i]+pow((X[j]-i+1),2);
    }
  }
  sort(SUM.begin(),SUM.end());
  cout<<SUM[0]<<endl;
}

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

const int H = 8;
const int W = 8;
const int di[8] = {0,1,1,1,0,-1,-1,-1};
const int dj[8] = {1,1,0,-1,-1,-1,0,1};
vector<string> G(H);

int check(int i, int j, int di, int dj, char c) {
  int length = 0;
  while(1) {
    i += di;
    j += dj;
    if(i < 0 || i >= H) return 0;
    if(j < 0 || j >= W) return 0;
    if(G[i][j] == c) return length;
    if(G[i][j] == '.') return 0;
    ++length;
  }
}

int canPut(int i, int j, char c) {
  if(G[i][j] != '.') return 0;
  int res = 0;
  for(int k = 0; k < 8; ++k) {
    res += check(i, j, di[k], dj[k], c);
  }
  return res;
}

void reverse(int i, int j, int di, int dj, char c) {
  while(1) {
    i += di;
    j += dj;
    if(G[i][j] == c) return;
    G[i][j] = c;
  }
}

void put(int i, int j, char c) {
  G[i][j] = c;
  for(int k = 0; k < 8; ++k) {
    if(!check(i, j, di[k], dj[k], c)) continue;
    reverse(i, j, di[k], dj[k], c);
  }
}

int main() {
  for(int i = 0; i < H; ++i) cin >> G[i];
  while(1) {
    int pass = 0;
    {
      int maxi = 0, pi, pj;
      for(int i = 0; i < H; ++i) {
        for(int j = 0; j < W; ++j) {
          int tmp = canPut(i, j, 'o');
          if(tmp > maxi) {
            maxi = tmp;
            pi = i; pj = j;
          }
        }
      }
      if(maxi) put(pi, pj, 'o');
      else ++pass;
    }
    {
      int maxi = 0, pi, pj;
      for(int i = H-1; i >= 0; --i) {
        for(int j = W-1; j >= 0; --j) {
          int tmp = canPut(i, j, 'x');
          if(tmp > maxi) {
            maxi = tmp;
            pi = i; pj = j;
          }
        }
      }
      if(maxi) put(pi, pj, 'x');
      else ++pass;
    }
    if(pass == 2) break;
  }
  for(int i = 0; i < H; ++i) cout << G[i] << endl;
  return 0;
}

Measured memory_bytes: 1188
#include<iostream>
using namespace std;
int main(){

	int N,M,X,Y,tmp,a=0;
	int x[210]={0},y[210]={0};
	cin>>N>>M>>X>>Y;
	for(int i=0;i<N;i++)
		cin>>x[i];
	for(int i=0;i<M;i++)
		cin>>y[i];
	
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			if(x[i]>x[j]){
				tmp=x[i];
				x[i]=x[j];
				x[j]=tmp;
	}	}	}
	for(int i=0;i<M;i++){
		for(int j=i+1;j<M;j++){
			if(y[i]>y[j]){
				tmp=y[i];
				y[i]=y[j];
				y[j]=tmp;
	}	}	}
	if(x[N-1]>=y[0]){
		a=1;
		cout<<"War"<<endl;
	}
	else{
		for(int i=x[N-1]+1;i<=y[0];i++){
			if(X<i && i<=Y){
				cout<<"No War"<<endl;
				a=1;
				break;
			}
	}	}
	if(a==0)
		cout<<"War"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#nが総数
n = int(input ())
#print(n)


d = [int(input()) for i in range(n)]
#print(d)

d2 = sorted(d)
#print(d2)

count=1
for i in range(n-1):
    if( d2[i] < d2[i+1] ):
        count += 1
        
print(count)

Measured memory_bytes: 3060
def resolve():
    #n=int(input())
    #a,b=map(int,input().split())
    #x=list(map(int,input().split()))
    #a=[list(map(lambda x:int(x)%2,input().split())) for _ in range(h)]
    n,k=map(int,input().split())
    MOD=998244353
    lr=[list(map(int,input().split())) for _ in range(k)]
    dp=[0]*(n+1)
    dpsum=[0]*(n+1)
    dp[1]=1
    dpsum[1]=1
    for i in range(2,n+1):
      for l,r in lr:
        li=i-r
        ri=i-l
        if r<0:continue
        li=max(1,li)
        dp[i]+=dpsum[ri]-dpsum[li-1]
      dpsum[i]=(dpsum[i-1]+dp[i])%MOD
    print(dp[n]%MOD)
    
if __name__ == '__main__':
    resolve()

Measured memory_bytes: 76700
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

ll cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
vector<pair<string,string>> fh;
vector<pair<string,string>> sh;
void rec(int now, string red, string blue, string s, int type){
    if(now >= s.size()){
        if(type == 0){
            reverse(all(blue));
            reverse(all(red));
            fh.push_back({red, blue});
        } else {
            sh.push_back({blue, red});
        }
        return;
    }

    rec(now + 1, red + s[now], blue, s, type);
    rec(now + 1, red, blue + s[now], s, type);
}
int main(void){
    int n;
    string s;
    cin >> n >> s;

    string firsth = s.substr(0, n);
    string secondh = s.substr(n, n);

    rec(0, "", "", firsth, 0);
    rec(0, "", "", secondh, 1);

    map<pair<string,string>, ll> mp;
    for(int i = 0; i < fh.size(); i++){
        //cout << fh[i].first << " " << fh[i].second << endl;
        mp[fh[i]]++;
    }
    //cout << "---" << endl;
    ll ans = 0;
    for(int i = 0; i < sh.size(); i++){
        //cout << sh[i].first << " " << sh[i].second << endl;
        ans += mp[sh[i]];
    }
    cout << ans << endl;
}

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

using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//
//using namespace __gnu_pbds;
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//class Timer {
//    clock_t start;
//    string name;
//public:
//    Timer() {name = "";start = clock();}
//    Timer(string s){name = s;start = clock();}
//    ~Timer() {fprintf(stderr, "%s: %.3gs\n", name.c_str(), 1.0*(clock() - start) / CLOCKS_PER_SEC);}
//};

//#define isValid(a, b) ((a) >= 0 && (a) < (b))
//int dr[]  =  {0, -1, -1, -1,  0,  1, 1, 1};
//int dc[]  =  {1,  1,  0, -1, -1, -1, 0, 1};

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define um unordered_map
#define us unordered_set
#define endl '\n'
#define what_is(x) cerr << fixed << setprecision(2) << boolalpha << #x << " = " << x << endl

const double EPS = 1e-9;
const double PI = acos(-1.0);

template<typename T> inline T sq(T a){return a*a;}
template<typename T1, typename T2> inline pair<T1, T2> mp(T1 a, T2 b){return make_pair(a, b);}
template<typename T1, typename T2> inline T1 safeMod(T1 a, T2 m){return (a%m + m)%m;}/*handling negative sign of remainder*/
template<typename T1, typename T2> inline bool isEq(T1 a, T2 b){return abs(a - b) < EPS;}
template<typename T1, typename T2, typename T3> inline bool isEq(T1 a, T2 b, T3 eps){return abs(a - b) < eps;}
template<typename T> inline bool isKthBitOn(T n, int k){assert(n <= numeric_limits<T>::max());assert(k<=numeric_limits<T>::digits);T ONE = 1;return bool((n & (ONE<<k)));}
template<typename T> inline void setKthBit(T& n, int k){assert(n <= numeric_limits<T>::max());assert(k<=numeric_limits<T>::digits);T ONE = 1;n = (n|(ONE<<k));}
//mt19937 rng((int)chrono::steady_clock::now().time_since_epoch().count());
//template<typename T> inline T nextRand(T lo, T hi){return uniform_int_distribution<T>(lo, hi)(rng);}

#define toRad(deg) ((deg)*PI/180.0)
#define toDeg(rad) ((rad)*180.0/PI)

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int oo = 0x3f3f3f3f;
const int MAX = 200010;
const int MOD = 1000000007;
const int precision = 10;

bool bfs(int x)
{
    queue<int>q;
    bool vis[MAX] = {false};
    q.push(x);
    vis[x] = 1;
    while(!q.empty()){
        int u = q.front();
        q.pop();
        if(u == 0)return true;
        for(int i = 100; i <= 105; i++){
            int v = u-i;
            if(v == 0)return true;
            if(v > 0 && !vis[v]){
                vis[v] = 1;
                q.push(v);
            }
        }
    }
    return false;
}

int main()
{
    //assert(freopen("in.txt", "r", stdin));
    //assert(freopen("out.txt", "w", stdout));
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    //cout << fixed << setprecision(precision);
    int x;
    cin >> x;
    cout << bfs(x) << endl;
    return 0;
}


Measured memory_bytes: 512
import heapq

N = int(input())
A = list(map(int, input().split()))
n1 = A[:N]
s1 = [sum(n1)]
heapq.heapify(n1)
for i in range(N):
    heapq.heappush(n1,A[N+i])
    p = heapq.heappop(n1)
    s1.append(s1[-1]-p+A[N+i])

n3 = [-a for a in A[-N:]]
s3 = [(sum(n3))]
heapq.heapify(n3)
for i in range(N):
    heapq.heappush(n3,-A[-N-i-1])
    p = heapq.heappop(n3)
    s3.append(s3[-1]-p-A[-N-i-1])
M = -10**15
# print(s3)
for i,j in zip(s1,s3[::-1]):
    # print(i,j)
    M = max(M,i+j)

print(M)


Measured memory_bytes: 38148
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000003;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
string stakoma;
int n;
vector<vector<int>>go;
map<pair<int,int>,tuple<llint,llint,int>>memo;
tuple<llint,llint,int>dfs(int ter,int per){
	if(memo.count(mp(ter,per))){return memo[mp(ter,per)];}
	llint dai=0,ugo=0;int koma=stakoma[ter]-'0';
	for(auto it:go[ter]){
		if(it==per){continue;}
		llint Sy,Su;int Sk;
		tie(Sy,Su,Sk)=dfs(it,ter);
		Sy+=Sk;Su+=Sk;
		ugo+=Su;
		maxeq(dai,Sy+Su);
		koma+=Sk;
		
	}
	llint yori=max(ugo%2,dai-ugo);
	memo[mp(ter,per)]=mt(yori,ugo,koma);
	return mt(yori,ugo,koma);
}
int main(void){
	cin.tie(0);ios::sync_with_stdio(false);
	int i;
	cin>>n>>stakoma;
	go.res(n);
	for(i=1;i<n;i++){
		int a,b;cin>>a>>b;a--;b--;
		go[a].pub(b);
		go[b].pub(a);
	}
	llint ans=big;
	for(i=0;i<n;i++){
		auto ret=dfs(i,-1);
		//cerr<<"y="<<get<0>(ret)<<"u="<<get<1>(ret)<<"k="<<get<2>(ret)<<endl;
		if(get<0>(ret)==0){mineq(ans,get<1>(ret)/2);}
	}
	if(ans==big){ans=-1;}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1152
#include<iostream> 
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const double pi=acos(-1.0);
int main()
{
	int a,b,h,m;cin>>a>>b>>h>>m;
	double theta1=(h*60+m)/720.0*2*pi;
	double theta2=(m)/60.0*2*pi;
	double theta=fabs(theta1-theta2);
	printf("%.20f\n",sqrt(a*a+b*b-2.0*a*b*cos(theta)));
	return 0;
	
}


Measured memory_bytes: 3432
#include "bits/stdc++.h"

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

void solve(){
	int a,b,c;
	cin >> a >> b >> c;
	map<int,int> m;
	m[a]++;
	m[b]++;
	m[c]++;
	P(m.size());
}

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


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

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> v(N);
	vector<int> c(N);

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

	int result = 0;
	for(int i = 0; i < N; i++) {
		if(v[i] > c[i])
			result += v[i] - c[i];
	}

	cout << result << endl;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int W, H, N;
    cin >> W >> H >> N;

    int ax, ay, bx, by;
    ax = ay = 0;
    bx = W, by = H;

    rep(i, N) {
        int X, Y, A;
        cin >> X >> Y >> A;

        switch (A) {
        case 1:
            ax = max(ax, X);
            break;
        case 2:
            bx = min(bx, X);
            break;
        case 3:
            ay = max(ay, Y);
            break;
        case 4:
            by = min(by, Y);
            break;
        }
    }

    if (bx - ax <= 0 || by - ay <= 0) cout << 0 << endl;
    else cout << (bx - ax) * (by - ay) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int k,t;
  scanf("%d %d", &k, &t);
  int a[t];
  for (int i = 0; i < t; i++) {
    scanf("%d", &a[i]);
  }
  int max = 0;
  for (int i = 0; i < t; i++) {
    if (a[i] > max) {
      max = a[i];
    }
  }
  int answer = max-1-(k-max);
  if (answer < 0) {
    answer = 0;
  }
  printf("%d\n", answer);

  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MAX (2000000)
#define INF (1145141919)
using namespace std;

int dp[MAX + 1];

int main()
{
	for (int i = 1000000; i >= 0; i--){
		dp[i] = i;
	}
	
	for (int i = 1000000; i >= 0; i--){
		for (int y = 0; y <= 1000; y++){
			dp[i + y * y] = min(dp[i + y * y], dp[i] + y);
		}
	}
	
	for (int i = 1000000; i >= 0; i--){
		for (int z = 0; z <= 100; z++){
			dp[i + z * z * z] = min(dp[i + z * z * z], dp[i] + z);
		}
	}
	
	int e;
	while (scanf("%d", &e), e){
		printf("%d\n", dp[e]);
	}
	
	return 0;
}

Measured memory_bytes: 8840
from collections import Counter
n=input()[::-1]

A=[0]
num,point=0,1
for i in n:
    num +=int(i)*point
    num %=2019
    A.append(num)
    point *=10
    point %=2019

count=Counter(A)
ans=0
for i,j in count.items():
    if j>=2:ans +=j*(j-1)//2
print(ans)

Measured memory_bytes: 83920
#include<stdio.h>
int fun(int c)
{
    int t,d=0;
    t=c;
    while(t>0)
    {
       d=d*10+t%10;
       t=t/10;
    }
    if(c==d)
        return 1;
    else
        return 0;
}
int main()
{
    int a,b,i,n=0;
    scanf("%d%d",&a,&b);
    for(i=a;i<=b;i++)
    {
        if(fun(i))
            n++;
    }
    printf("%d\n",n);
    return 0;
}

Measured memory_bytes: 128
import bisect
from collections import deque

N = int(input())
A = deque([-1])

for i in range(N):
  a = int(input())
  idx = bisect.bisect_left(A, a)
  if idx == 0:
    A.appendleft(a)
  
  else:
    A[idx-1] = a

print(len(A))

Measured memory_bytes: 7668
n,m = map(int,input().split())
h = list(map(int,input().split()))
H = set(range(n))
for i in range(m):
    a,b = map(int,input().split())
    if h[a-1] <= h[b-1]:
        H.discard(a-1)
    if h[a-1] >= h[b-1]:
        H.discard(b-1)

print(len(H))

Measured memory_bytes: 22452
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n;
	cin >> n;
	vector<vll> v(0);
	if (n % 2 == 0) {
		for (ll i = 1; i <= n / 2; i++) {
			v.push_back({i, n - i + 1});
		}
	}
	else {
		for (ll i = 1; i <= (n - 1) / 2; i++) {
			v.push_back({i, n - i});
		}
		v.push_back({n});
	}

	set<vll> ans;
	for (ll i = 0; i < v.size() - 1; i++) {
		for (ll j = 0; j < v[i].size(); j++) {
			for (ll k = 0; k < v[i + 1].size(); k++) {
				ll a = min(v[i][j], v[i + 1][k]), b = max(v[i][j], v[i + 1][k]);
				ans.insert({a, b});
			}
		}
	}
	ll i = v.size() - 1;
	for (ll j = 0; j < v[i].size(); j++) {
		for (ll k = 0; k < v[0].size(); k++) {
			ll a = min(v[i][j], v[0][k]), b = max(v[i][j], v[0][k]);
			ans.insert({a, b});
		}
	}

	cout << ans.size() << endl;
	for (auto i : ans) {
		cout << i[0] << " " << i[1] << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<cctype>
#include<cstring>
using namespace std;
int main(){
  char cc[1000];
  cin.getline(cc,1000);
    for(int i=0;i<strlen(cc);i++){
      if(cc[i]=='a'&&cc[i+1]=='p'&&cc[i+2]=='p'&&cc[i+3]=='l'&&cc[i+4]=='e'){
	cc[i] = 'p';
	cc[i+1] = 'e';
	cc[i+2] = 'a';
	cc[i+3] = 'c';
	cc[i+4] = 'h';
      }
      else if(cc[i]=='p'&&cc[i+1]=='e'&&cc[i+2]=='a'&&cc[i+3]=='c'&&cc[i+4]=='h'){
	cc[i] = 'a';
	cc[i+1] = 'p';
	cc[i+2] = 'p';
	cc[i+3] = 'l';
	cc[i+4] = 'e';
     }
      cout << cc[i];
    }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1120
var lines = []; var result = Infinity;
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
})

rl.on('close', function () {
    var D = Number(lines[0]);

    if (D === 25) { console.log('Christmas') }
    else if (D === 24) { console.log('Christmas Eve') }
    else if (D === 23) { console.log('Christmas Eve Eve') }
    else { console.log('Christmas Eve Eve Eve') }
});

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

#define For(i, j, k) for (int i = j; i <= k; i++)

using namespace std;

const int N = 2e5 + 10;

int n;
int A[N];

int main() {

	scanf("%d", &n);
	For(i, 1, n) scanf("%d", &A[i]), A[i] -= i;
	sort(A + 1, A + n + 1);

	int b = A[(n + 1) / 2];
	long long sum = 0;
	For(i, 1, n) sum += abs(b - A[i]);
	printf("%lld\n", sum);

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <limits.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define INF 2e9 + 7
#define DIV 1000000007
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define pi 3.14159265
#define MAX 400000

using namespace std;

int n;
vector<ll> p, m;
ll x, y;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x >> y;
		p.pb(x + y);
		m.pb(x - y);
	}
	sort(all(p));
	sort(all(m));
	cout << max(p.back() - p[0], m.back() - m[0]);
	return 0;
}

Measured memory_bytes: 6192
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;

int main(){
    int n; cin >> n;
    string s, ans="Yes"; cin >> s;
    if(!(n%2)){
        REP(i, n/2){
            if(s[i] != s[i + n/2]) ans = "No";
        } 
    }
    else ans = "No";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int a,b; cin>>a>>b;
  string s[100];
  rep(i,100){
    rep(j,100){
      if(i<50) s[i].PB('.');
      else s[i].PB('#');
    }
  }

  int cnt = 0;
  for(int i=0; i<50; i+=2){
    if(cnt==b-1) break;
    for(int j=0; j<100; j+=2){
      if(cnt==b-1) break;
      s[i][j] = '#'; cnt++;
    }
  }
  cnt = 0;
  for(int i=51; i<100; i+=2){
    if(cnt==a-1) break;
    for(int j=0; j<100; j+=2){
      if(cnt==a-1) break;
      s[i][j] = '.'; cnt++;
    }
  }

  cout << 100 SP 100 << endl;
  rep(i,100) cout << s[i] << endl;

  return 0;
}


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

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

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

	for (int i = 0; i < q; i++) {
		int c, a, n;
		int ans = 0;
		cin >> c >> a >> n;

		while (1) {
			if (c <= 0)break;
			if (a > 0 && n > 0) {
				c--, a--, n--;
				ans++;
			}
			else if (c >= 2 && a > 0 && n <= 0) {
				a--, c-=2;
				ans++;
			}
			else if (c >= 3) {
				c -= 3;
				ans ++;
			}
			else
				break;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
 
priority_queue<ll> ret;
void divisor(long long n)
{
 
    for (long long i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push(i);
            if (i * i != n)
                ret.push(n / i);
        }
    }
    // sort(ret.begin(), ret.end()); // 昇順に並べる
}
 
int main()
{
    //最大公約数を求める。
    ll n, m;
    cin >> n >> m;
    divisor(m);
    ll k = 0;
    ll u=ret.size();
   /* while (1)//計算量1をn回
    {
      if (ret.top() < n){
      	break;
      }
        k = ret.top();
        ret.pop();//計算量logn
    }*/
	rep(i,u){
    
      if (ret.top()<n){
      break;
      }
       k = ret.top();
      ret.pop();
    }
    cout << m/k  << endl;
    //公約数のうち、N以上となるもののうち最小値になるものを選択すれば良い。
    //Mが大きすぎるのでfor分で回すと死ぬ。
    //公約数と成り得る数をqueに格納していけば絶対にできる。(どうやる？)
}


Measured memory_bytes: 256
def count_primes(n)
  primes = (n + 1).times.map { 1 }
  primes[0] = primes[1] = 0
 
  count = 0
 
  for p in (2..n)
    if (primes[p] != 0)
      count += 1
      (p * p).step(n, p) do |q|
        #puts "q = #{q}"
        primes[q] = 0
      end
    end
  end
 
  return count
end
 
while (line = gets)
  n = line.chop.to_i
  puts count_primes(n)
end


Measured memory_bytes: 86112
N = int(input())
Ai = list(map(int, input().split()))

m = max(Ai)
idx = Ai.index(m)
del Ai[idx]

target = m // 2
nearest = 1000000000
use_value = -1
for a in Ai:
    d = abs(a - target)
    if nearest > d:
        nearest = d
        use_value = a

print(m, use_value)



Measured memory_bytes: 14428
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector< pair<long, long> > ab(n);
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        ab[i] = make_pair(a, b);
    }

    sort(ab.begin(), ab.end());

    long ans = 0;

    while (m) {
        for (int i = 0; i < n; ++i) {
            if (ab[i].second <= m) {
                ans += ab[i].first * ab[i].second;
                m -= ab[i].second;
            } else {
                ans += ab[i].first * m;
                m = 0;
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

const int INF = 1e9;


void updTrans(vector<int> &a, vector<int> &b, char bc) {
    b[0] = min(b[0], min(a[0], a[1]));
    b[1] = min(b[1], min(a[0] + 1, a[1]));
    b[bc == '.' ? 1 : 0] = INF;
}

int main () {
    int n, m;
    while (scanf("%d %d", &n, &m) == 2) {
        vector<string> g(n, string(m, 0));
        for (int i = 0; i < n; i++) {
            char s[110];
            scanf("%s", s);
            g[i] = string(s);
        }

        vector<vector<vector<int>>> dp(n, vector<vector<int>>(m, vector<int>(2, INF)));
        dp[0][0][0] = g[0][0] == '.' ? 0 : INF;
        dp[0][0][1] = g[0][0] == '.' ? INF : 1;
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++) {
                if (i) updTrans(dp[i - 1][j], dp[i][j],  g[i][j]);
                if (j) updTrans(dp[i][j - 1], dp[i][j],  g[i][j]);
            }

        int res = min(dp[n - 1][m - 1][0], dp[n - 1][m - 1][1]);
        printf("%d\n", res);
    }
}



Measured memory_bytes: 768
// C - String Transformation
#include <bits/stdc++.h>
using namespace std;

int main(){
	string S, T; cin>>S>>T;
	vector<int> st(26, -1), ts(26, -1);//st:S->T, ts:T->S
	for(int i=0; i<S.size(); ++i){
		int s = S[i]-'a', t = T[i]-'a';
		if(st[s] > -1 || ts[t] > -1){
			if(st[s] != t || ts[t] != s){ puts("No"); return 0; }
		}
		st[s] = t, ts[t] = s;
	}
	puts("Yes");
}

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

using namespace std;

#define INF 1001001001  //int32_t
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int a,b;
    cin >>a>>b;

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << max(max(a+b,a-b),a*b) << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

using namespace std;

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

    string s,t;
    cin >> s >> t;
    string d[t.size()+1];
    string last="";
    string temp;

    for(int i=s.size()-1;i>=0;i--)
    {
        for(int j=t.size()-1;j>=0;j--)
        {
            if(s[i]==t[j])
            {
                temp=s[i]+d[j+1];
            }
            else
            {
                if(last.size()<d[j].size()) temp=d[j];
                else temp=last;
            }
            d[j+1]=last;
            last=temp;
        }
        d[0]=last;
        last="";
    }

    cout << d[0] << endl;
}


Measured memory_bytes: 4992
#include<iostream>

using namespace std;

int main() {
  int x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  int distanceY = y2 - y1;
  int distanceX = x2 - x1;

  cout << x2 - distanceY << " " << y2 + distanceX << " ";
  cout << x1 - distanceY << " " << y1 + distanceX << endl;
  return 0;
}

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

const int mod = 1000000007;
int main(){
    int n,k;
    cin >> n >> k;
    ve<int> a(n);
    rep(i,n) cin >> a[i];
    ve<ll> dp(100005);
    dp[0] = 1;
    rep(i,n){
        ve<ll> p(100005);
        swap(p,dp);
        rep(j,k) (p[j+1] += p[j]) %= mod;
        rep(j,k+1){
            int l = j-a[i]-1;
            dp[j] = p[j];
            if(l>=0) dp[j]-=p[l];
            if(dp[j]<0) dp[j]+=mod;
        }
    }
    cout << dp[k] << endl;
    return 0;
}

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

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

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

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

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

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

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

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

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

int main()
{
	ll n,car=0,tmp=0;
	cin >> n;
	while(car<n){
		tmp++;
		car+=tmp;
	}
	cout << tmp << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*
import java.math.*
import java.lang.Math.*

private val readString: ()->String = {readLine()!!}
private val readInt: ()->Int = {readLine()!!.toInt()}
private val readLong: ()->Long = {readLine()!!.toLong()}
private val readIntArray: ()->IntArray = {readLine()!!.split(' ').map{it.toInt()}.toIntArray()}
private val readLongArray: ()->LongArray = {readLine()!!.split(' ').map{it.toLong()}.toLongArray()}
private val errPrintln: (String)->Unit = {msg -> System.err.println(msg)}
private val MOD = 1e9.toLong()+7
private val INF = Int.MAX_VALUE/2
private val LINF = Long.MAX_VALUE/2


data class PairInt(val first: Int, val second: Int)
fun greedyBitFS(item: Array<PairInt>, bonus: IntArray, LowLimit: Int): Int {
    val N = item.size
    var res = Int.MAX_VALUE;
    for (p in 0 until (0b01 shl N)) {
        var ptn = p
        var scr = 0
        var cnt = 0
        var lv = -1
        for(i in 0 until N) {
            val vi = item[i].first
            val ci = item[i].second
            if ((ptn and 0b01) == 1) {
                scr += vi * ci + bonus[i]
                cnt += ci;
                if (scr >= LowLimit) {
                    res = min(res, cnt)
                }
            } else {
                lv = max(lv, i)
            }
            ptn = ptn shr 1
        }
        if (scr < LowLimit) {
            if (lv >= 0) {
                val v = item[lv].first
                val c = item[lv].second
                val dc = min((LowLimit - scr + v - 1) / v, c - 1)
                if (scr + v*dc >= LowLimit) {
                    res = min(res, cnt + dc)
                }
            }
        }
    }
    return res
}


fun solveC(G: Int, P: IntArray, C: IntArray): Int {
    val D = P.size
    val items = Array<PairInt>(D){PairInt(0,0)}
    for (i in 0 until D) {
        items[i] = PairInt(100*(i+1), P[i])
    }

    return greedyBitFS(items, C, G)
}


fun main(args: Array<String>) {
    val (D,G) = readIntArray()
    val P = IntArray(D){0}
    val C = IntArray(D){0}
    for(i in 0 until D) {
        val (p, c) = readIntArray()
        P[i] = p; C[i] = c
    }

    val ans = solveC(G, P, C)

    println(ans)
}


Measured memory_bytes: 38300
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<memory.h>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i,n)cin >> a[i];
  ll ans=0;
  rep(i,n){
    ans+=a[i]/2;
  }
  rep(i,n){
    if(i<n && a[i]%2>0){
      i++;
      while(i<n && a[i]>0 && a[i]%2==0){
        i++;
      }
      if(i<n && a[i]%2>0){
        ans++;
      }
    }
  }
  cout << ans << endl;
return 0;}


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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

struct Level {
    ll pate, ban, total;
};

const Level ban = {0, 1, 1},
        pate = {1, 0, 1};

vector<Level> searchBound(int depth, vector<Level> &levels, ll n, ll x) {
    Level l = levels[n - depth];
    if (l.total < x) return {l};
    else if (n - depth == 0) return {pate};
    else {
        Level next = levels[n - depth - 1];
        // ban, next, pate, next, ban

        vector<Level> res;
        ll sum = 0;
        if (x == 0) return res;
        sum += 1;
        res.push_back(ban);
        if (x == sum) return res;
        if (sum + next.total >= x) {
            vector<Level> k = searchBound(depth + 1, levels, n, x - sum);
            for (Level m : k) res.push_back(m);
            return res;
        } else {
            sum += next.total;
            res.push_back(next);
        }
        sum++;
        res.push_back(pate);
        if (x == sum) return res;
        if (sum + next.total >= x) {
            vector<Level> k = searchBound(depth + 1, levels, n, x - sum);
            for (Level m : k) res.push_back(m);
            return res;
        } else {
            sum += next.total;
            res.push_back(next);
        }
        sum++;
        res.push_back(ban);
        if (x == sum) return res;

        __throw_runtime_error("konai");
    }
}

int main() {
    ll n, x;
    cin >> n >> x;

    vector<Level> levels(n + 1);
    levels[0].ban = 0;
    levels[0].pate = 1;
    levels[0].total = 1;
    for (int i = 1; i <= n; i++) {
        levels[i].pate = 1 + levels[i - 1].pate + levels[i - 1].pate;
        levels[i].ban = 2 + levels[i - 1].ban + levels[i - 1].ban;
        levels[i].total = levels[i].pate + levels[i].ban;
    }

    vector<Level> res = searchBound(0, levels, n, x);
    ll ans = 0;
    for (Level r : res) {
        ans += r.pate;
//        printf("%lld %lld %lld\n", r.pate, r.ban, r.total);
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		try(Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			int[] dp = new int[n+1];
			int[] c  = new int[m];
			for(int i=0; i<m; i++) {
				c[i] = sc.nextInt();
			}
			for(int i=0; i<n+1; i++) {
				dp[i] = Integer.MAX_VALUE;
			}
			dp[0] = 0;
			
			for(int i=0; i<=n; i++) {
				for(int j=0; j<m; j++) {
					if(c[j] <= i) {
						dp[i] = Math.min(dp[i], dp[i-c[j]]+1);
					}
				}
			}
			System.out.println(dp[n]);
		}
	}

}




Measured memory_bytes: 27268
N = int(input())
dict = {}
for i in range(1, N+1):
    n = float(i)
    cnt = 0
    while n/2>0.0:
        if n%2 == 0.0:
            cnt += 1
        n = n/2
    dict[i] = cnt

import numpy as np
print(list(dict.keys())[np.argmax(list(dict.values()))])

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

char lower(char c){
  if('a'<=c and c<='z'){
    return c;
  }else{
    return c-'A'+'a';
  }
}

int main(void){
  int n, k;
  std::string s;
  std::cin >> n >> k >> s;
  s[k-1] = lower(s[k-1]);
  std::cout << s << std::endl;
  return 0;
}






Measured memory_bytes: 256
n_str = input()
n = int(n_str)

d = len(n_str)
ans = 0
for i in range(1, d, 2):
    ans += 10 ** (i) - 10 ** (i - 1)
if d % 2 == 1:
    ans += n - 10 ** (d - 1) + 1
print(ans)

Measured memory_bytes: 3060
def main():
    H, W = [int(x) for x in input().strip().split()]
    tables = []
    white_count = 0
    for i in range(H):
        rows = [str(x) for x in list(input().strip())]
        white_count += rows.count(".")
        tables.append(rows)

    next_cells = [(0, 0, 1)]
    while(next_cells):
        _next_cells = []
        for next_cell in next_cells:
            y, x, step = next_cell
            if y == H-1 and x == W-1: #Goal
                tables[y][x] = str(min(step+1, int(tables[y][x])))
                continue

            if y != 0: # up OK
                if tables[y-1][x] != "#": # move OK
                    if tables[y-1][x] != ".": # 既に通った
                        if step+1 < int(tables[y-1][x]):
                            tables[y-1][x] = str(step+1)
                            _next_cells.append((y-1, x, step+1))
                    else: # 初めて通る
                        tables[y-1][x] = str(step+1)
                        _next_cells.append((y-1, x, step+1))

            if y != H-1: # down OK
                if tables[y+1][x] != "#": # move OK
                    if tables[y+1][x] != ".": # 既に通った
                        if step+1 < int(tables[y+1][x]):
                            tables[y+1][x] = str(step+1)
                            _next_cells.append((y+1, x, step+1))
                    else: # 初めて通る
                        tables[y+1][x] = str(step+1)
                        _next_cells.append((y+1, x, step+1))

            if x != 0: # left OK
                if tables[y][x-1] != "#": # move OK
                    if tables[y][x-1] != ".": # 既に通った
                        if step+1 < int(tables[y][x-1]):
                            tables[y][x-1] = str(step+1)
                            _next_cells.append((y, x-1, step+1))
                    else: # 初めて通る
                        tables[y][x-1] = str(step+1)
                        _next_cells.append((y, x-1, step+1))

            if x != W-1: # right OK
                if tables[y][x+1] != "#": # move OK
                    if tables[y][x+1] != ".": # 既に通った
                        if step+1 < int(tables[y][x+1]):
                            tables[y][x+1] = str(step+1)
                            _next_cells.append((y, x+1, step+1))
                    else: # 初めて通る
                        tables[y][x+1] = str(step+1)
                        _next_cells.append((y, x+1, step+1))
        # end for
        next_cells = list(set(_next_cells)) # 重複カット
    # end while
    if tables[H-1][W-1] == ".":
        return -1
    return white_count - int(tables[H-1][W-1])
    
if __name__ == '__main__':
    print(main())

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

using namespace std;

int main(){
  double n,t,a,h; cin >> n >> t >> a;
  pair<double,int> ans=make_pair(1000000,0);
  for(int i=1;i<=n;++i){
    cin >> h;
    if(ans.first>abs(a-(t-h*0.006))) ans=make_pair(abs(a-(t-h*0.006)),i);
  }
  cout << ans.second << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint dp[310][310][310];
vector<pint> q[310];
int main()
{
	int n,m,l,r,x;
	cin>>n>>m;
	rep(i,m){
		cin>>l>>r>>x;
		q[r].pb(mp(l,x));
	}
	lint out=0,mo=1000000007;
	memset(dp,0,sizeof(dp));dp[1][0][0]=3;
	REP(i,1,n+1) rep(j,i+1) rep(k,i+1){
		//cout<<i<<' '<<j<<' '<<k<<' '<<dp[i][j][k]<<endl;
		rep(I,q[i].size()){
			l=q[i][I].fi;x=q[i][I].se;
			if(x==3 && k<l) dp[i][j][k]=0;
			if(x==2 && (k>=l || j<l)) dp[i][j][k]=0;
			if(x==1 && j>=l) dp[i][j][k]=0;
		}
		if(dp[i][j][k]==0) continue;
		dp[i][j][k]%=mo;
		//cout<<i<<' '<<j<<' '<<k<<' '<<dp[i][j][k]<<endl;
		if(i==n){
			out+=dp[i][j][k];out%=mo;continue;
		}
		dp[i+1][j][k]+=dp[i][j][k];
		//if(j<1) dp[i+1][i][k]+=dp[i][j][k]*2;
		dp[i+1][i][k]+=dp[i][j][k];
		dp[i+1][i][j]+=dp[i][j][k];
	}
	cout<<out<<endl;
}


Measured memory_bytes: 233088