akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define Reverse(x) reverse(all(x));
#define Sort(x) sort(all(x));
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli n, h, w;
    cin >> n >> h >> w;
    lli ans = 0;
    rep(i, n) {
        lli a, b;
        cin >>a >> b;
        if(a>=h&&b>=w)
        {
            ans++;
        }
    }
    out(ans);
}

Measured memory_bytes: 3604
n = int(input())
p = list(map(int, input().split()))
p.append(0)
for i in range(n): p[i] -= 1

ans = 0
for i in range(n):
    if p[i] == i:
        ans += 1
        p[i], p[i+1] = p[i+1], p[i]

print(ans)

Measured memory_bytes: 14008
#include<bits/stdc++.h> 
typedef long long int ll;
using namespace std;
const ll P = 1000000007;


ll solve(){

	ll n,x,t;
	cin>>n>>x>>t;

	ll  m = n/x + ((n%x != 0) ? 1 : 0);
	cout<<m*t<<"\n";

	return 0;
}

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

 	ll t = 1;
    // cin>>t;

    while(t--){
    	solve();
    }   

    return 0;
}	 

Measured memory_bytes: 3616
//marico el que lo lea
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <assert.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;

void fastIO() {
	std::ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
}

#define FOR(i,f,t) for(int i=f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=f; i>(int)t; i--)
#define FORE(i,c) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define all(obj) obj.begin(), obj.end()
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)

#define fst first
#define snd second

template<typename T, typename U> inline void mnze(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void mxze(T &x, U y) { if(x < y) x = y; }

void _scan( int &x ) { scanf("%d",&x); }
void _scan( long long &x ) { scanf("%lld",&x); }
void _scan( double &x ) { scanf("%lf",&x); }
void _scan( char &x ) { scanf(" %c",&x); }
void _scan( char *x ) { scanf("%s",x); }
void scan() {}
template<typename T, typename... U>
void scan( T& head, U&... tail ) { _scan(head); scan(tail...);}

template<typename T> void _dbg(const char* sdbg, T h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename T, typename... U> void _dbg(const char* sdbg, T h, U... t) {
	while(*sdbg != ',')cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(_i, (x)) cerr <<*_i <<", "; cerr <<"\n"; }}
#define debuga(x, sz) {{cerr <<#x <<" = "; FOR(_i, 0, sz) cerr << x[_i] <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debuga(x, sz)
#define cerr if(0)cout
#endif

///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////

const int MAXN = 2e5+5;

int n, a[MAXN];

int main(){
	scan(n);
	FOR(i,0,n) scan(a[i]);
	ll x=a[0], y=0;
	FOR(i,1,n) y+=a[i];
	ll ans = abs(x-y);
	FOR(i,1,n-1){
		x+=a[i];
		y-=a[i];
		mnze(ans, abs(x-y));
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;


int main(){
  string s; cin >> s;
  int i = 0;
  while(i < s.size()){
    if(s[i] == ',') cout << ' ';
    else cout << s[i];
    i++;
  }
  cout << endl;
}


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

const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n = 1) : n(n), f(n + 1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i * i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x; }
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main() {
  int n;
  cin >> n;
  Sieve sieve(n + 1);
  map<int, int> mp;
  for (int i = 1; i <= n; i++) {
    auto f = sieve.factor(i);
    for (auto x : f) mp[x.first] += x.second;
  }
  mint ans = 1;
  for (auto x : mp) ans *= (x.second + 1);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;

ll n,k;
vector<ll> vec(200001);

ll calc(ll x,ll y){
  ll ans = x / y;
  if(x % y != 0){
    ans++;
  }
  return ans-1;
}

bool solve(ll x){
  //cout << x << endl;
  ll sum = 0;
  rep(i,n){
    sum += calc(vec[i],x);
  }
  //cout << x << " " << sum << endl;
  return sum <= k;
}

int main(){
  cin >> n >> k;
  rep(i,n){
    cin >> vec[i];
  }
  ll ok = 1000000000;
  ll ng = 0;
  while(abs(ok-ng) > 1){
    ll mid = (ok + ng) / 2;
    if(solve(mid)){
      ok = mid;
    }else{
      ng = mid;
    }
  }
  ll ans = ok;
  cout << ans << endl;
}

Measured memory_bytes: 4692
#include<iostream>
using namespace std;
int main()
{
    int a[100000]={},n,j,max=0;
    char b[100000];
    cin>>n;
    for(j=1;j<n+1;j++)
        cin>>b[j];
    for(j=1;j<n+1;j++)
        if(b[j]=='I')
            a[j]=a[j-1]+1;
        else
            a[j]=a[j-1]-1;
    for(j=0;j<n+1;j++)
        if(a[j]>max)
            max=a[j];
    cout<<max<<endl;
    return 0;
}

Measured memory_bytes: 640
fun main(args: Array<String>) {
    val (k, n) = readLine()!!.split(' ').map(String::toLong)
    val aList = readLine()!!.split(' ').map(String::toLong)
    var max = Long.MIN_VALUE
    (1 until n.toInt()).forEach {
        max = Math.max(max, aList[it] - aList[it - 1])
    }
    max = Math.max(max, aList.first() + (k - aList.last()))
    println(k-max)
}


Measured memory_bytes: 82840
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <iterator>
#pragma warning(disable:4996)

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

long a[100];
long b[100];
long c[100];
long d[100];

int main(int argc, char* argv[])
{
    long n, m;
    scanf("%ld %ld", &n, &m);
    
    if(n==1 && m==1) {
        printf("1\n");
    }
    else if(n==1) {
        printf("%ld\n", m-2);
    }
    else if(m==1) {
        printf("%ld\n", n-2);
    }
    else {
        printf("%lld\n", (ll)(n-2)*(m-2) );
    }

    return 0;
}


Measured memory_bytes: 128
lines = readlines.map{|line| line.split(' ')}
a=lines[1][0].to_i
b=lines[1][1].to_i
if lines[0][0]==lines[2][0] then
  puts [a-1,b].join(' ')
elsif lines[0][1]==lines[2][0] then
  puts [a,b-1].join(' ')
end

Measured memory_bytes: 1788
#include <stdio.h>

int main(){
    int a, b, c, k;
    scanf ("%d%d%d", &a, &b, &c);
    scanf("%d", &k);
    
    if (a >= b && a >= c){
        for (int i = 0; i < k; i++)
        {
            a *= 2;
        }
        printf ("%d\n", a+b+c);     
    } else if (b >= a && b >= c){
        for (int i = 0; i < k; i++)
        {
            b *= 2;
        }
        printf ("%d\n", a+b+c);
    } else if (c >= a && c >= b){
        for (int i = 0; i < k; i++)
        {
            c *= 2;
        }
        printf ("%d\n", a+b+c);        
    }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define int long long
const int INF=1e18;
typedef pair<int,int> P;
vector<int> G[100001];
int dp[100001];
int dfs(int v){
    if(dp[v]!=-1){return dp[v];}
    dp[v]=0;
    for(auto x:G[v]){
        dp[v]=max(dp[v],1+dfs(x));
    }
    return dp[v];
}
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m,a,b,longest=0;
    cin>>n>>m;
    rep(i,0,m){
        cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
    }
    rep(i,0,n){
        dp[i]=-1;
    }
    rep(i,0,n){
        longest=max(longest,dfs(i));
    }
    cout<<longest;
}

Measured memory_bytes: 7936
/* This code is written by Nemlit */
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define debug printf("Now is Line : %d\n",__LINE__)
#define file(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define rep(i, a, b) for(re int i = (a); i <= (b); ++ i)
#define drep(i, a, b) for(re int i = (b); i >= (a); -- i)
#define Next(i, u) for(re int i = head[u]; i; i = e[i].next)
#define mem(k, p) memset(k, p, sizeof(k))
#define int long long
#define D double
#define inf 1023456789
#define mod 1000000007
#define lb(x) (x)&(-(x))
il int read() {
    re int x = 0, f = 1; re char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
il int Mul(int a, int b) { return 1ll * a * b % mod; }
il int Inc(int a, int b) { return (a += b) >= mod ? a - mod : a; }
il int Dec(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
il int qpow(int a, int b) { int r = 1; while(b) { if(b & 1) r = Mul(r, a); a = Mul(a, a), b >>= 1; } return r; }
#define maxn 200005
namespace Graph {
	int head[maxn], cnt;
	struct edge { int v, next; }e[maxn << 1];
	il void add(int u, int v) { e[++ cnt] = (edge){v, head[u]}, head[u] = cnt; }
}
//using namespace Graph;
int n, m, sum[maxn * 44], rt, a[maxn], cnt, L = -200000, R = (1e9) + 200000, ls[maxn * 44], rs[maxn * 44];
il void insert(int &k, int l, int r, int ll) {
	if(!k) k = ++ cnt; ++ sum[k];
	if(l == r) return;
	int mid = (l + r) >> 1;
	if(ll <= mid) insert(ls[k], l, mid, ll);
	else insert(rs[k], mid + 1, r, ll);
}
il int query(int k, int l, int r, int ll) {
	if(l == r) return sum[k];
	int mid = (l + r) >> 1;
	if(ll <= mid) return query(ls[k], l, mid, ll);
	else return query(rs[k], mid + 1, r, ll);
}
signed main() {
	n = read();
	rep(i, 1, n) a[i] = read();
	rep(i, 1, n) {
		m += query(1, L, R, i - a[i]);
		insert(rt, L, R, i + a[i]);
	}
	cout << m;
	return 0;
}


Measured memory_bytes: 45936
#include<iostream>
using namespace std;
#define ll long long
#include<cmath>
int main()
{
    ll n,ans=0;
    cin>>n;
    ll u=1ll*floor(sqrt(n-1));
    for(ll i=1;i<=u;i++)
    ans+=(n-1)/i;
    cout<<ans*2-u*u<<endl;
    
    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>

using namespace std;
using pii = pair<int,int>;
int p[100010],y[100010];
vector<pair<pii,int>> v;
string s[100010];

string solve(int a){
	int k = a,d = 0;
	string t;
	while(k>0){
		int x = k%10;
		if(x==0) t.push_back('0');
		if(x==1) t.push_back('1');
		if(x==2) t.push_back('2');
		if(x==3) t.push_back('3');
		if(x==4) t.push_back('4');
		if(x==5) t.push_back('5');
		if(x==6) t.push_back('6');
		if(x==7) t.push_back('7');
		if(x==8) t.push_back('8');
		if(x==9) t.push_back('9');
		k /= 10;
		d++;
	}
	string s;
	for(int i=0;i<6-d;i++){
		s.push_back('0');
	}
	for(int i=0;i<t.size();i++){
		s.push_back(t[t.size()-1-i]);
	}
	return s;
}
	
int main(){
	int i,n,m;
	cin >> n >> m;
	for(i=0;i<m;i++){
		cin >> p[i] >> y[i];
		v.push_back({{p[i],y[i]},i});
	}
	sort(v.begin(),v.end());
	int now = v[0].first.first,x = 1;
	for(i=0;i<m;i++){
		if(now!=v[i].first.first){
			x = 1;
		}
		now = v[i].first.first;
		s[v[i].second] = solve(now) + solve(x);
		x++;
	}
	for(i=0;i<m;i++){
		cout << s[i] << endl;
	}
}

Measured memory_bytes: 11380
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int[] n = new int[51];
        Arrays.fill(n,0);
        for(int a = 0;a < 10;a++){
            for(int b = 0;b < 10;b++){
                for(int c = 0;c < 10;c++){
                    for(int d = 0;d < 10;d++){
                        n[a+b+c+d]++;
                    }
                }
            }
        }
        try{
            String st ="";
            while((st = br.readLine())!= null)
            System.out.println(n[Integer.parseInt(st)]);
        }catch(IOException ex){            
        }
    }
}

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

int main(){
  int x, y;
  int s1[] = {1,3,5,7,8,10,12};
  int s2[] = {4,6,9,11};
  cin >> x >> y;
  int flag = 0;
  for(int i = 0; i < 7; i++) if(s1[i] == x || s1[i] == y) flag++;
  if(flag == 2){
    cout << "Yes" << endl;
    return 0;
  }else{
    flag = 0;
    for(int i = 0; i < 4; i++) if(s2[i] == x || s2[i] == y) flag++;
    if(flag == 2){
      cout << "Yes" << endl;
      return 0;
    }
    if(x == 2 && y == 2){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;
typedef long long LL;
LL x, a, b;

int main() {
	scanf("%lld%lld%lld", &x, &a, &b);
	if(x > b) printf("delicious\n");
	else if(x + a >= b) printf("safe\n");
	else printf("dangerous\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  int a,b,c;
  cin>>a>>b>>c;
  int d=100*a+10*b+c;
  if(d%4==0){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}


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

using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ll = long long int;
using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>;
using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using cdouble = complex<double>;

const double eps = 1e-7;
const double INFD = numeric_limits<double>::infinity();
#define Loop(i, n) for(int i = 0; i < int(n); i++)
#define Loopll(i, n) for(ll i = 0; i < ll(n); i++)
#define Loop1(i, n) for(int i = 1; i <= int(n); i++)
#define Loopll1(i, n) for(ll i = 1; i <= ll(n); i++)
#define Loopr(i, n) for(int i = int(n) - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = ll(n) - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = int(n); i >= 1; i--)
#define Looprll1(i, n) for(ll i = ll(n); i >= 1; i--)
#define Foreach(buf, container) for(auto buf : container)
#define Loopdiag(i, j, h, w, sum) for(int i = ((sum) >= (h) ? (h) - 1 : (sum)), j = (sum) - i; i >= 0 && j < (w); i--, j++)
#define Loopdiagr(i, j, h, w, sum) for(int j = ((sum) >= (w) ? (w) - 1 : (sum)), i = (sum) - j; j >= 0 && i < (h); j--, i++)
#define Loopdiagsym(i, j, h, w, gap) for (int i = ((gap) >= 0 ? (gap) : 0), j = i - (gap); i < (h) && j < (w); i++, j++)
#define Loopdiagsymr(i, j, h, w, gap) for (int i = ((gap) > (h) - (w) - 1 ? (h) - 1 : (w) - 1 + (gap)), j = i - (gap); i >= 0 && j >= 0; i--, j--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(ex_i, vector.size()) { cout << vector[ex_i] << " "; } cout << endl;
#define printmx(matrix) Loop(ex_i, matrix.size()) { Loop(ex_j, matrix[ex_i].size()) { cout << matrix[ex_i][ex_j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
#define Comp(type_t) bool operator<(const type_t &another) const
#define fst first
#define snd second
#define INF INFINITY
bool feq(double x, double y) { return abs(x - y) <= eps; }
bool fge(double x, double y) { return x >= y - eps; }
double fsqrt(double x) { return feq(x, 0) ? 0 : sqrt(x); }
bool inrange(ll x, ll t) { return x >= 0 && x < t; }
bool inrange(vll xs, ll t) { Foreach(x, xs) if (!(x >= 0 && x < t)) return false; return true; }
int ceillog2(ll x) { int ret = 0;	x--; while (x > 0) { ret++; x >>= 1; } return ret; }
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (m * m <= x ? 0 : -1); }
ll ceilsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }

/*******************************************************/

int main() {
	ll a, b; cin >> a >> b;
	if (a >= 13) {
		cout << b << endl;
	}
	else if (a >= 6) {
		cout << b / 2 << endl;
	}
	else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
ans = 0
for i in range(N) :
    Ai = A[i]
    ans += B[Ai-1]
    if i != N-1 and A[i]+1 == A[i+1] :
        ans += C[Ai-1]
print(ans)

Measured memory_bytes: 9204
S = raw_input()
K = int(raw_input())
list_S = list(S)
for i in range(0,len(list_S)):
        if list_S[i] == "1":
                if i == (K-1):
                        del list_S[:]
                        list_S = ["1"]
                        break
        elif list_S[i] != "1":
                break

for i in range(0,len(list_S)):
        if list_S[i] != "1":
               print list_S[i]
               break
        if i == len(list_S)-1:
                print "1"



Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
long double PI= 3.141592653589793238463;
const int N = 1e5+5;
const int MOD = 1e9+7;

ll a[100005];
ll dp[100005][4];
int n;

void D(int x)
{
    for(int i=x;i<n;i++){
        dp[i][0]=(abs(a[i]-a[i-1])+min(dp[i-1][0],dp[i-1][1]) );
        dp[i][1]=(abs(a[i]-a[i-2])+min(dp[i-2][0],dp[i-2][1]) );
    }
}

int main()
{
//int t; cin>>t;

//while(t--){
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) {
        dp[i][0]=N*N;
        dp[i][1]=N*N;
    }
    dp[0][0]=0;
    dp[1][0]=(abs(a[0]-a[1]));
    D(2);

    cout<<min( dp[n-1][0] , dp[n-1][1] );

//}


    return 0;
}



Measured memory_bytes: 7512
#include <iostream>

using namespace std;

int main()
{
	int a,b;
	cin >> a >> b;
	
	int x = (a + b) / 2.0;
	
	if ((a + b) % 2 == 0)
	{
		cout << x << endl;
	}
	else
	{
		cout << x + 1 << endl;
	}
	
	return 0;
}

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

typedef long long weight;
typedef pair<weight, int> P;

struct edge {
  int to;
  int cap;
  weight cost;
  int rev;
  edge(int to_, int cap_, weight cost_, int rev_):to(to_), cap(cap_), cost(cost_), rev(rev_) {}
};

constexpr weight INF = (1ll << 55);

vector<vector<edge>> G;

void init(int V) {
  G.assign(V, vector<edge>());
}

void add_edge(int from, int to, int cap, weight cost) {
  G[from].emplace_back(to, cap, cost, G[to].size());
  G[to].emplace_back(from, 0, -cost, G[from].size() - 1);
}

weight min_cost_flow(int s, int t, int f) {
  const int n = G.size();
  weight res = 0;
  vector<int> prevv(n), preve(n);
  vector<weight> h(n, 0);

  while(f > 0) {
    priority_queue<P, vector<P>, greater<P>> que;
    vector<weight> dist(n, INF);
    dist[s] = 0;
    que.push({0, s});

    while(!que.empty()) {
      const auto d = que.top().first;
      const auto v = que.top().second;
      que.pop();

      if(dist[v] < d) continue;

      for(unsigned i = 0; i < G[v].size(); ++i) {
	const edge &e = G[v][i];
	if(e.cap > 0 && dist[e.to] > d + e.cost + h[v] - h[e.to]) {
	  dist[e.to] = d + e.cost + h[v] - h[e.to];
	  prevv[e.to] = v;
	  preve[e.to] = i;
	  que.push({dist[e.to], e.to});
	}
      }
    }

    if(dist[t] == INF) return -1;

    for(int v = 0; v < n; ++v) {
      h[v] += dist[v];
    }

    int d = f;
    for(int v = t; v != s; v = prevv[v]) {
      d = min(d, G[prevv[v]][preve[v]].cap);
    }

    f -= d;
    res += d * h[t];
    for(int v = t; v != s; v = prevv[v]) {
      edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }

  return res;
}

constexpr weight DD = 1000000;
constexpr weight DS = 1000;
constexpr weight SS = 1;

inline void input(vector<vector<int>> &like, int v) {
  int l;
  cin >> l;

  for(int i = 0; i < l; ++i) {
    int a, b;
    cin >> a >> b;
    like[a][b] = v;
  }
}

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

  vector<vector<int>> like_m(n, vector<int>(m, 0));
  vector<vector<int>> like_f(m, vector<int>(n, 0));

  input(like_m, 2);
  input(like_m, 1);
  input(like_f, 2);
  input(like_f, 1);

  const int source = n + m;
  const int sink = source + 1;
  init(sink + 1);

  for(int i = 0; i < n; ++i) {
    add_edge(source, i, 1, 0);
  }

  for(int i = 0; i < m; ++i) {
    add_edge(i + n, sink, 1, 0);
  }

  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < m; ++j) {
      if(like_m[i][j] && like_f[j][i]) {
	const int sum = like_m[i][j] + like_f[j][i];
	switch(sum) {
	case 4: add_edge(i, j + n, 1, -DD); break;
	case 3: add_edge(i, j + n, 1, -DS); break;
	case 2: add_edge(i, j + n, 1, -SS); break;
	default: assert(false);
	}
      }
      else {
	add_edge(i, j + n, 1, 0);
      }
    }
  }

  const weight ans = -min_cost_flow(source, sink, min(n, m));
  const long long dd = ans / DD;
  const long long ds = ans % DD / DS;
  const long long ss = ans % DS;

  cout << dd << " " << ds << " " << ss << endl;

  return EXIT_SUCCESS;
}


Measured memory_bytes: 1944
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
	ll n,i,ans=1,m=1000000007;
	cin>>n;
	for(i=1;i<=n;i++)ans=ans*i%m;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
N, x = map(int, input().split())
a = list(map(int, input().split()))

i = 0
while len(a) > 0:
    if min(a) > x:
        break
    else:
        x -= min(a)
        a.remove(min(a))
        i += 1
if len(a) == 0:
    if x > 0:
        i -= 1
print(i)

Measured memory_bytes: 38384
let split str delim =
  let rec doit s acc =
    match
      try Some (String.index s delim)
      with _ -> None
    with
    | None -> List.rev (s :: acc)
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s2 (s1 :: acc)
  in
  doit str []

let print_result = List.iter (fun (s, t) -> Printf.printf "%s %d\n" s t)

let () =
  match List.map int_of_string (split (read_line ()) ' ') with
  | [] | [_] -> exit 1
  | n :: q :: _ -> begin
      let que = Queue.create () in
      let rec read i =
        if i >= n then ()
        else begin
          match split (read_line ()) ' ' with
          | [] | [_] -> exit 1
          | s :: t :: _ -> (Queue.add (s, int_of_string t) que; read (i + 1))
        end
      in
      read 0;
      let rec doit cnt ret =
        if Queue.is_empty que then List.rev ret
        else begin
          let (s, t) = Queue.take que in
          let rest = t - q in
          if rest > 0 then (Queue.add (s, rest) que; doit (cnt + q) ret)
          else let x = cnt + t in doit x ((s, x) :: ret)
        end
      in
      print_result (doit 0 [])
    end

Measured memory_bytes: 16300
CARDS = [input() for i in range(3)]
ABC = 'abc'
own = 0
while True:
  d = CARDS[own][0]
  CARDS[own] = CARDS[own][1:]
#  print(ABC[own],d,CARDS)
  own = ABC.index(d)
  if CARDS[own] == '':
    break
print(d.upper())

Measured memory_bytes: 3060
def main():
    import sys
    from collections import deque
    input = sys.stdin.readline

    # adj = [[], [(to, cost), (to, cost), ...], [(to, cost), (to, cost), ...], ...]
    def BellmanFord(adj, start):
        N = len(adj) - 1
        inf = 10**13
        dist = [inf] * (N + 1)
        dist[start] = 0
        neg_loop_flg = 0
        for i in range(N):
            updated = 0
            for fr in range(1, N + 1):
                if dist[fr] == inf:
                    continue
                for to, cost in adj[fr]:
                    if dist[fr] + cost < dist[to]:
                        dist[to] = dist[fr] + cost
                        updated = 1
            if not updated:
                break
            if i == N - 1:
                if updated:
                    neg_loop_flg = 1

        return dist, neg_loop_flg

    N, M = map(int, input().split())
    adj = [[] for _ in range(N+1)]
    for _ in range(M):
        a, b, c = map(int, input().split())
        adj[b].append((a, -c))

    adj_new = [[] for _ in range(N+1)]
    que = deque()
    que.append(N)
    seen = [0] * (N+1)
    seen[N] = 1
    while que:
        v = que.pop()
        for u, cost in adj[v]:
            if not seen[u]:
                seen[u] = 1
                que.append(u)
            adj_new[u].append((v, cost))

    dist, flg = BellmanFord(adj_new, 1)
    if flg:
        print('inf')
    else:
        print(-dist[N])


if __name__ == '__main__':
    main()


Measured memory_bytes: 43116
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

cnt = 0
f = [False]*n
f[0] = True
now = 0
for i in range(n):
    if  now == 1:
        break

    cnt += 1
    f[a[now]-1] = True
    now = a[now]-1

print(cnt if f[1] else -1)


Measured memory_bytes: 7888
/* 
* ID: juryc
* PROG: Papers, Please
* LANG: C++
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
int n; cin>>n;
vector<int> v(n);
for(int& i: v) cin>>i;
for(int i=0;i<n;i++) if(v[i]%2==0) if(v[i]%3&&v[i]%5) {cout<<"DENIED"<<endl; return 0 ; }
cout<<"APPROVED"<<endl;
}

Measured memory_bytes: 3612
#include<iostream>
using namespace std;
#define INF 1000001

void quickSort(int* Array,int left,int right){
    if(left < right){
        int i=left,j=right;
        int pivot;

        pivot = Array[(left+right)/2];
        while(1){
            while(Array[i]<pivot)
                i++;
            while(Array[j]>pivot)
                j--;
            if(i>=j)break;
            swap(Array[i],Array[j]);
            i++;j--;
        }
        quickSort(Array,left,i-1);
        quickSort(Array,j+1,right);
    }
}
int absolute(int x){
    if(x>=0)return x;
    else return -1*x;
}
int main(){
    int n;
    while(true){
        cin>>n;
        if(n==0)break;
        int grades[n];
        int minimum = INF;
        for(int i=0;i<n;i++)
            cin>>grades[i];
        quickSort(grades,0,n-1);
        for(int i=0;i<n-1;i++){
            int sub = grades[i+1] - grades[i];
            if(minimum > absolute(sub))minimum = absolute(sub);
        }
        cout<<minimum<<endl;
    }
    return 0;
}


Measured memory_bytes: 3124
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define P pair<int, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void ioup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	int h, w;
	string s;
	cin >> h >> w;
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			cin >> s;
			if (s == "snuke") {
				cout << (char)(j - 1 + 'A') << i << endl;
				return 0;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <ctime>
using namespace std;
typedef long long ll;
const int N = 262200;
const ll INF = 1e18;

int main() {
	int a[3];
	while(~scanf("%d %d %d", &a[0], &a[1], &a[2])) {
		sort(a, a+3);
		printf("%d\n", a[2] - a[0]);
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

class UnionFind {
  vector<int> par, rank, potential;
public:
  UnionFind(int n) {
    par.resize(n, -1);
    rank.resize(n, 0);
    potential.resize(n, 0);
  }
  int root(int x) {
    if (par[x] < 0)
      return x;
    int r = root(par[x]);
    potential[x] += potential[par[x]];
    return par[x] = r;
  }
  int size(int x) {
    return -par[root(x)];
  }
  int weight(int x) {
    root(x);
    return potential[x];
  }
  bool isSame(int x, int y) {
    return root(x) == root(y);
  }
  bool unite(int x, int y, int w = 0) {
    w += weight(x);
    w -= weight(y);
    x = root(x);
    y = root(y);
    if(x == y) {
      return false;
    }
    if(rank[x] < rank[y]) {
      swap(x, y);
      w = -w;
    }
    if(rank[x] == rank[y])
      rank[x]++;
    par[x] += par[y];
    par[y] = x;
    potential[y] = w;
    return true;
  }
  int diff(int x, int y) {
    return weight(y) - weight(x);
  }
};

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A(M), B(M);
  rep(i, M) {
    cin >> A[i] >> B[i];
    A[i]--; B[i]--;
  }
  UnionFind uf(N);
  vector<ll> res(M);
  res[M-1] = (ll)N*(N-1)/2;
  for(int i=M-1; i>0; i--) {
    ll sa = uf.size(A[i]), sb = uf.size(B[i]);
    if(uf.unite(A[i], B[i]))
      res[i-1] = res[i]-sa*sb;
    else
      res[i-1] = res[i];
  }
  rep(i, M)
    cout << res[i] << endl;
  return 0;
}

Measured memory_bytes: 4096
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)

int count(int N)
{
        int ans = 0;
        while (N)
        {
                ans++;
                N /= 10;
        }
        return ans;
}

int main()
{
        int S;
        cin >> S;
        int ans = 0;

        for (int i = 1; i < S + 1; i += 2)
        {
                int cnt = 0;
                for (int j = 1; j < S + 1; j += 2)
                {
                        if (i % j == 0)
                        {
                                cnt++;
                        }
                }
                if (cnt == 8)
                {
                        ans++;
                }
        }

        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

#define PI 3.14159265358979323846264338327950L

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

    double N;
    cin >> N;
    vector<double> ans(N + 1, 0);

    for (double z = 1; z * z < N; z++)
    {
        //double x = 1,y = 1,z=1;
        for (double y = 1; y * y < N; y++)
        {

            for (double x = 1; x * x < N; x++)
            {
                double n = pow(x + y, 2) + pow(y + z, 2) + pow(z + x, 2);
                //cout << "(" << x << "," << y << "," << z << ")" << endl;
                //cout << n/2 << endl;
                if (n < 2 * (N + 1))
                {
                    ans[n / 2 - 1] += 1;
                }
            }
        }
    }
    //cout << "" << endl;
    for (double i = 0; i < N; i++)
    {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const int vx[]={1,0,-1,0}, vy[]={0,1,0,-1};
const int sqrtN = 512;
const ll LINF=1e18;
const ld PI=abs(acos(-1));

struct Node{
	int data;
	
	Node(int data) : data(data) {};
	
	Node operator*(const Node r) const{
		return data + r.data;
	}
} e(0);

struct SqrtDecomposition{
	vector<Node> data;
	vector<Node> bucket;
	int N, K;

	SqrtDecomposition(int n) : N(n){
		K = (N + sqrtN - 1) / sqrtN;
		data.assign(K * sqrtN, e);
		bucket.assign(K, e);
	}
	
	void add(int a, int b, int x){
		for(int k = 0; k < K; k++){
			int l = k * sqrtN, r = (k + 1) * sqrtN;
			
			if(b<=l||r<=a) continue;
			if(a<=l&&r<=b) bucket[k] = bucket[k] * x;
			else{
				for(int i = max(a, l); i < min(b, r); i++){
					data[i] = data[i] * x;
				}
			}
		}
	}
	
	int get(int x){
		int k = x / sqrtN;
		
		return (data[x] * bucket[k]).data;
	}
};

int main(){
	int n,q; cin >> n >> q;
	SqrtDecomposition data(n);
	REP(i,0,q){
		int f; cin >> f;
		
		if(f == 0){
			int a,b,c; cin >> a >> b >> c;
			data.add(a, b + 1, c);
		}else if(f == 1){
			int a; cin >> a;
			cout << data.get(a) << endl;
		}
	}
	
	return 0;
}



Measured memory_bytes: 3344
using System;

namespace ReversingNumbers
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			Console.ReadLine();

			string input = Console.ReadLine ();
			char[] CharSeparators = new char[] { ' ' };
			string[] array = input.Split (CharSeparators);

			Array.Reverse(array);
			Console.WriteLine(string.Join(" ",array));

		}
	}
}

Measured memory_bytes: 5328
#109B
N=int(input())
W=[]
flag=0
for i in range(N):
    W.append(input())
for i in range(N-1):
    if W[i][-1]!=W[i+1][0]:
        flag=1
        break
if len(set(W))!=N:
    flag=1
if flag==1:
    print('No')
else:
    print('Yes')

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

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<#a<<':'<<a<<endl

const ll INF = 1e9+7;

template<typename T>inline T digit(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  vector<int> l(n);rep(i,n)cin>>l[i];
  sort(all(l));reverse(all(l));
  ll ans = 0;

  rep(i,n){
    for(int j = i+1;j < n;++j){
      for(int k = j+1;k < n;++k){
        if(l[i]-l[j]-l[k] >= 0)break;
        ++ans;
      }
    }
  }
  print(ans);
  return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch SequenceDecomposing | diff SequenceDecomposing.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address SequenceDecomposing.cpp && ./a.out

/*
 
 7/20/2019
 
 5:37-
 
 */

const int MAX_N=1e6+1;
LL A[MAX_N];
int N;

void solve() {
  multiset<int> S;
  REP(i,N) {
    if(S.empty()) S.emplace(A[i]);
    else {
      auto it=S.lower_bound(A[i]);
      if(it==S.begin()) {
        S.emplace(A[i]);
      } else {
        --it;
        assert(*it<A[i]);
        S.erase(it),S.emplace(A[i]);
      }
    }
  }
  cout<<SZ(S)<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  REP(i,N) cin>>A[i];
  solve();
  
  return 0;
}


Measured memory_bytes: 5760
function main(input) {
  input = input.trim().split("\n");
  const n = Number(input[0]);
  const p = input[1].split(" ").map(n => Number(n));
  let result = 0;
  for (let i = 0; i < n-2; i++) {
    const num1 = p[i];
    const num2 = p[i+1];
    const num3 = p[i+2];
    const max = Math.max(...[num1, num2,num3]);
    const min = Math.min(...[num1, num2, num3]);
    if (num2 !== max && num2 !== min) result++;
  }
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
import numpy as np
N = int(input())
As=input().split()
A = np.array([int(s) for s in As])
del(As)

min2A = A[A.argsort()[1]]
minA = np.amin(A)
if np.sum((A%min2A)==0)>=N-1:
    print(min2A)
elif np.sum((A%minA)==0)>=N-1:
    print(minA)
else:
    for i in range(2,min2A+1):
        if (min2A%i == 0) or (minA%i == 0):
            if(min2A%i == 0):
                j = int(min2A/i)
            elif(minA%i == 0):
                j=int(minA/i)
            if np.sum((A%j)==0)>=N-1:
                print(j)
                break


Measured memory_bytes: 23884
gets;
cards = Array.new;
while s = gets do
  a = s.split(" ");
  i = a[1].to_i - 1;
  if s[0] == "S" then
    cards << i;
  elsif s[0] == "H" then
    cards << 13 + i;
  elsif s[0] == "C" then
    cards << 26 + i;
  elsif s[0] == "D" then
    cards << 39 + i;
  end
end

cards.sort!;

52.times{|i|
  unless cards.include?(i) then
    if i >= 39 then
      puts "D " + (i % 13 + 1).to_s;
    elsif i >= 13 * 2 then
      puts "C " + (i % 13 + 1).to_s;
    elsif i >= 13 then
      puts "H " + (i % 13 + 1).to_s;
    else
      puts "S " + (i + 1).to_s;
    end
  end
}

Measured memory_bytes: 8692
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

vector<int> price;
vector<int> count;
int main() {
    int p, c;
    int dc = 0; // data set count
    char dm;    // dummy char
    while (cin >> p >> dm >> c) {
        price.push_back(p);
        count.push_back(c);
        dc++;
    }
    int sum = 0;
    for (int i = 0; i < dc; i++) 
        sum += price[i] * count[i];

    int sum_of_count = 0;
    for (int i = 0; i < dc; i++) 
        sum_of_count += count[i];
    double average = round( (double)sum_of_count / dc );

    cout << sum << endl << average << endl;
    return 0;
}

Measured memory_bytes: 0
#ifdef LOCAL
//#define _GLIBCXX_DEBUG
#endif
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<char> Vc;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;
typedef vector<vector<char>> VVc;
typedef vector<vector<vector<ll>>> VVV;
typedef vector<vector<vector<vector<ll>>>> VVVV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define rEach(i, mp) for (auto i = mp.rbegin(); i != mp.rend(); ++i)
#ifdef LOCAL
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgset(st) cerr << #st << ":"<<endl; for (auto i = st.begin(); i != st.end(); ++i) { cerr << *i <<" ";}cerr<<endl;
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#else
#define dbg(...)
#define dbgmap(...)
#define dbgset(...)
#define dbgarr(...)
#define dbgdp(...)
#endif
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int solve(){
    string s;
    cin>>s;
    Yes(s[0]==s[2]);
    return  0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);
    solve();
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 100

void push(int);
int pop(void);
int stack[MAX];
int top = 0;



void initialize(){
  top = 0;
}

int isEmpty(){
  return top == 0;
}


int main(){
  int x;
  char s[MAX];
  int a=0,b=0;

  while(scanf("%s",s) != EOF){

    if(s[0] == '+'){
      a=pop();
      b=pop();
      push(a+b);

    }

    else if(s[0] == '-'){
      a=pop();
      b=pop();
      push(b-a);

    }

    else if(s[0] == '*'){
      a=pop();
      b=pop();
      push(a*b);

    }

    else {
      x = atoi(s);
      push(x);

    }

  }

  printf("%d\n",pop());

  return 0;
}



void push(int x){
    top++;
    stack[top] = x;
}



int pop(){
   top--;
    return stack[top+1];

}




Measured memory_bytes: 2104