akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 5010;
const ll M = 210;
inline ll read()
{
  ll p=0; ll f=1; char ch=getchar();
  while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();}
  while(ch>='0' && ch<='9'){p=p*10+ch-'0'; ch=getchar();}
  return p*f;
}
ll a[N],b[N][M]; ll s[N]; ll top; ll sum[N][N]; ll l[N],r[N]; ll pre[N];
int main()
{
  ll n=read(),m=read();

  for(ll i=2;i<=n;i++) a[i] = read();
  for(ll i=1;i<=n;i++) for(ll j=1;j<=m;j++) b[i][j] = read();
  
  for(ll i=1;i<=m;i++)
  {
  	top = 0; s[top] = 0;
  	for(ll j=1;j<=n;j++) l[j] = r[j] = 0;
  	for(ll j=1;j<=n;j++)
  	{
  	  while(top && b[j][i] > b[s[top]][i]) top--;
  	  l[j] = s[top] + 1; s[++top] = j;
  	}

  	top = 0; s[top] = n+1;
  	for(ll j=n;j>=1;j--)
  	{
  	  while(top && b[j][i] > b[s[top]][i]) top--;
  	  r[j] = s[top] - 1; s[++top] = j;
  	}

  	for(ll j=1;j<=n;j++)
  	{
  	  // prllf("%d %d %d\n",i,l[j],r[j]);
  	  sum[l[j]][j] += b[j][i];
  	  sum[j+1][j] -= b[j][i] ;
  	  sum[l[j]][r[j]+1] -= b[j][i];
  	  sum[j+1][r[j]+1] += b[j][i];
  	}
  }

  for(ll i=2;i<=n;i++) pre[i] = pre[i-1] + a[i];

  ll maxx = 0;
  for(ll i=1;i<=n;i++) for(ll j=1;j<=n;j++)
  {
  	sum[i][j] = sum[i][j] + sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
 	  if(i<=j) maxx = max(maxx , sum[i][j] - pre[j] + pre[i]);
    // prllf("%d %d %d\n",i,j,sum[i][j]); 
  }

  return printf("%lld\n",maxx),0;
}

Measured memory_bytes: 204672
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
ll f(int x, vector<ll> a) {
    ll sum = 0, cost = 0;
    for (int i = 0; i < a.size(); i++) {
        sum += a[i];
        if (i % 2 == x) {
            if (sum <= 0) {
                cost += 1 - sum;
                sum = 1;
            }
        }
        else {
            if (sum >= 0) {
                cost += 1 + sum;
                sum = -1;
            }
        }
    }
    return cost;
}
/* main */
int main(){
    int N;
    cin >> N;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];


    // min(+-+-.... or -+-+....)
    cout << min(f(0, a), f(1, a)) << '\n';
}


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

using ll = long long;
using namespace std;

const int MAX { 100010 };
ll MOD { 1000000007 };

bitset<MAX> trap;
ll dp[MAX];

ll solve(int N) {
    //Casos bases
    dp[0] = 1;
    dp[1] = (trap[1] ? 0 : 1);

    for (int i = 2; i <= N; i++) {

        //Se o degrau estiver quebrado existem 0 maneiras de se chegar até ele
        if (trap[i]) {
            dp[i] = 0;
        } else {
            //Se não houver o armadilha a quantidade de maneiras de se chegar até 
            //a esse degrau é o total de maneiras vindo de dp[i-2] + dp[i-1]
            dp[i] = (dp[i-2] + dp[i-1]) % MOD;
        }
    }
    return dp[N];
}

int main(int argc, char const *argv[])
{
    int N, M, t;
    cin >> N >> M;

    for (int i = 0; i < M; i++) {
        cin >> t;
        trap[t] = true;
    }

    auto ans = solve(N);

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
	int N, A, B;

	cin >> N >> A >> B;
	int ans = 0, count;
	for (int i = 1; i <= N; i++) {
		int tmp = i;
		count = 0;
		while (tmp != 0) {
			count += tmp % 10;
			tmp /= 10;
		}
		if (A <= count && count <= B) ans += i;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

const double PI = acos(-1.0);

int main()
{
	double R;
	cin >> R;

	cout << 2.0 * PI * R << endl;

	return 0;
}

Measured memory_bytes: 3752
import java.util.Scanner;

public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int Q = sc.nextInt();
    	String S = sc.next();
    	
    	int[] count = new int[N+1];
    	boolean flag = false;
    	for( int i = 0; i < N; i++ ) {
    		if( S.charAt(i) == 'A' ) {
    			flag = true;
    			count[i+1] = count[i];
    		}
    		else if( flag == true && S.charAt(i) == 'C' ) {
    			flag = false;
    			count[i+1] = count[i] + 1;
    		}
    		else {
    			flag = false;
    			count[i+1] = count[i];
    		}
    	}

    	for( int i = 0; i < Q; i++ ) {
    		int l = sc.nextInt();
    		int r = sc.nextInt();
    		System.out.println( count[r] - count[l] );
    	}
    	
    	sc.close();
    }
}

Measured memory_bytes: 68928
import java.util.*;

class Main {
   public static void main(String[] args)
   {
      Scanner scan = new Scanner(System.in);
      int     N    = Integer.parseInt(scan.next());

      int[] arr   = new int[N];
      int[] times = new int[N];

      for(int i = 0; i < N; i++){
          arr[i] = Integer.parseInt(scan.next());
          int n = 0;
          while(arr[i] % 2 == 0){
                arr[i] = arr[i] / 2;
                n++;
                }
          times[i] = n;
          }
      Arrays.sort(times);
      System.out.println(times[0]);
   }
}


Measured memory_bytes: 21844
#include <cstdio>
int A, B;

int solve() {
  if (B == 1) return 0;
  // (B - 2) = (B - A + (A - 1) - 1) [round up]
  return 1 + (B - 2) / (A - 1);
}

int main() {
  scanf(" %d%d", &A, &B);
  printf("%d\n", solve());
  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
//#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
//#define EXIST(s, e) ((s).find(e)!=(s).end())
//#define SORT(c) sort(begin(c),end(c))
//#define pb emplace_back
//#define MP make_pair
//#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007

//ここから編集する
class Dijkstra {
public:
    using T = long long int;
    typedef pair<T, int> P; //firstは最短距離、secondは頂点の番号
    const T inf = (T) 5e15;
    struct edge {
        int to;
        T cost;
    };

    int V;                  //超点数
    vector<vector<edge>> G; //グラフ,G[i]はiから出る辺の集合,G[i][j]はiから出る辺のj番目の辺
    vector<T> d;           //最短距離

    //0origin
    Dijkstra(int N) {
        V = N;
        G = vector<vector<edge >>(N);
        d = vector<T>(N);
    };

    void dijkstra(int s) {
        priority_queue<P, vector<P>, greater<P>> que;
        fill(d.begin(), d.end(), inf);
        d[s] = 0;
        que.push(P(0, s));

        while (!que.empty()) {
            P p = que.top();
            que.pop();
            int v = p.second;
            if (d[v] < p.first)
                continue;
            for (int i = 0; i < G[v].size(); i++) {
                edge e = G[v][i];
                if (d[e.to] > d[v] + e.cost && !(d[e.to] == inf && d[v] == inf)) {
                    d[e.to] = d[v] + e.cost;
                    que.push(P(d[e.to], e.to));
                }
            }
        }
    }

    /* 頂点fromに頂点toに達するコストcostの辺を貼る */
    void addEdge(int from, int to, T cost) {
        edge e;
        e.to = to;
        e.cost = cost;
        G[from].push_back(e);
    }

    T getDist(int v) {
        return d[v];
    }
};

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

    int n, m, r;
    cin >> n >> m >> r;
    Dijkstra dij(n);

    rep(i, 0, m) {
        int s, t, d;
        cin >> s >> t >> d;
        dij.addEdge(s, t, d);
    }
    dij.dijkstra(r);

    rep(i, 0, n) {
        ll res = dij.getDist(i);
        if (res == dij.inf) {
            cout << "INF" << endl;
        } else {
            cout << dij.getDist(i) << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 19424
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits>

long table[1000][10000+1]={};
long A[1000]={};
long B[1000]={};
long H,N;
void init(long As, long Bs)
{
    for(long i=0; i<=10000; i++){
        table[0][i]=Bs*(i/As);
        if(i%As!=0){
            table[0][i]+=Bs;
        }
    }
    for(long i=0; i<1000; i++){
        table[i][0]=0;
    }
}

long min3(long A1, long B1, long C1){
    return std::min(A1,std::min(B1,C1));
}

void solve(){
    for(long i=1; i<N; i++){
        for(long j=1;j<=H; j++){
            table[i][j]=min3(table[i-1][j],table[i-1][std::max((long)0,j-A[i])]+B[i],table[i][std::max((long)0,j-A[i])]+B[i]);
        }
    }
}

int main(){
    std::cin >> H >> N;
    for(long i=0; i<N; i++){
        std::cin >> A[i] >> B[i];
    }
    init(A[0],B[0]);
    solve();
    std::cout << table[N-1][H] << std::endl;
    return 0;
}

Measured memory_bytes: 81792
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll n, k, cnt = 0;
    string s;
    cin >> n >> k >> s;
    REP(i, n-1)if(s[i]==s[i-1])cnt++;
    cout << min(cnt+2*k, n-1) << endl;
}

Measured memory_bytes: 512
n,k=map(int,input().split())

r=list(map(int,input().split()))
MOD = 10**9+7
i=0
tentou=0
while i<n-1:
  j=i+1
  while j<n:
    if r[i]>r[j]:tentou+=1
    j=j+1
  i=i+1

tentou2=0
i=0
while i<n:
  j=0
  while j<n:
    if r[j]>r[i]:tentou2+=1
    j=j+1
  i=i+1

#print(tentou,tentou2)

temp1=(tentou*k)
#temp2=((tentou2*k*(k-1))/2)
temp3=((tentou2*k*(k-1))//2)
#print(temp2%MOD,temp3%MOD)
#浮動小数点型にしてはでかすぎるのでtemp2は近似値となってしまっている
print((temp1+temp3)% MOD)

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n,0);
    for(auto&& x: v){
        cin >> x;
    }
    for(int i=0; i<n; ++i){
        int x = v[i];
        int j=i-1;
        while( j>=0 and v[j]>x ){
            v[j+1]=v[j];
            --j;
        }
        v[j+1] = x;

        for(int i=0; i<n; ++i){
            if ( i>0 )
                cout << ' ';
            cout << v[i];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = 0;
		int[] kind = new int[m];
		for (int i = 0; i < n; i++) {
			k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				kind[sc.nextInt() - 1]++;
			}
		}
		int ans = 0;
		for (int i = 0; i < m; i++) {
			if (kind[i] == n)
				ans++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long

int main() {
  int a;
  cin >>a;
  
  cout << (a==5 ||a==3 || a==7?"YES":"NO") << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>
#include <cassert>
#include <unordered_map>
#include <fstream>
#include <random>
#include <cstring>
#include <bitset>
#include <functional>
#include <tuple>
#include <complex>
#include <chrono>
#include <climits>

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back

using namespace std;

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

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
// default_random_engine generator;
// mt19937 rnd(1);

const ll INF = 1e18;

const int MAXN = 200200;
const int MAXM = 62;


int cnt[MAXN];
int lnk[MAXM][MAXN];
ll len[MAXM][MAXN];

int last[MAXN];

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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

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

    for (int i = 0; i < n; ++i) {
        int u = last[a[i]];
        int v = (i + 1) % n;

        lnk[0][u] = v;
        len[0][u] = (u < i ? i - u + 1 : i + n - u + 1);

        last[a[i]] = i;
    }

    // for (int i = 0; i < n; ++i) {
    //     cout << lnk[0][i] << " " << len[0][i] << endl;
    // }

    for (int i = 1; i < MAXM; ++i) {
        for (int j = 0; j < n; ++j) {
            lnk[i][j] = lnk[i - 1][lnk[i - 1][j]];
            len[i][j] = min(INF, len[i -  1][j] + len[i - 1][lnk[i - 1][j]]);
        }
    }

    int pos = 0;
    ll cur = 0;

    for (int i = MAXM - 1; i >= 0; --i) {
        if (cur + len[i][pos] <= k * n) {
            cur += len[i][pos]; 
            pos = lnk[i][pos];
        }
    }

    vector<int> b;
    for (int i = n - (n * k - cur); i < n; ++i) {
        if (cnt[a[i]] > 0) {
            while (cnt[a[i]] > 0) {
                --cnt[b.back()];
                b.pop_back();
            }
        } else {
            ++cnt[a[i]];
            b.push_back(a[i]);
        }
    }

    // cout << n - pos << endl;

    for (int el : b) {
        cout << el << " ";
    }
    cout << endl;
}

Measured memory_bytes: 150260
#include<iostream>
#include<string>
#include<algorithm>
#include <math.h>
#define PI 3.14159265

int main(){
    double a,b,c;
    std::cin>>a>>b>>c;
    double d=sqrt(a*a+b*b-2*a*b*cos(c*PI/180));
    printf("%f\n", a*b*sin(c*PI/180)/2);
    printf("%f\n", a+b+d);
    printf("%f\n", b*sin(c*PI/180));
}



Measured memory_bytes: 3384
n, m = map(int, input().split())
grida = []
gridb = []
for i in range(n):
    grida.append(list(input()))
for i in range(m):
    gridb.append(list(input()))

ans = False
for i in range(n-m+1):
    for j in range(n-m+1):
        bad = False 
        for k in range(m):
            for l in range(m):
                if grida[k+i][l+j] != gridb[k][l]:
                    bad = True
        if not bad:
            ans = True

if ans:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 9180
n = gets.to_i
s = gets.split.map(&:to_i)
q = gets.to_i
t = gets.split.map(&:to_i)

count = 0
s.each do |x|
  t1 = t
  t.each do |y|
    if x == y
      count += 1
      t1 -= [y]
      break
    end
  end
  t = t1
end
puts count


Measured memory_bytes: 7124
Public Class Program
  Shared Sub Main()
    Dim nk As Long() = Cin.LngArr()
    Dim n As Long = nk(0)
    Dim k As Long = nk(1)
    Dim h As Long() = Cin.LngArr()
    Dim ans As Long = 0
    Array.Sort(h)
    For i As Long = 0 To n - 1 - k
      ans += h(i)
    Next
    Console.WriteLine(ans.ToString())
  End Sub
End Class

Public Class Cin
  Public Shared Function Str() As String
    Return Console.ReadLine().Trim()
  End Function
  Public Shared Function Int() As Integer
    Return Integer.Parse(Str())
  End Function
  Public Shared Function Lng() As Long
    Return Long.Parse(Str())
  End Function
  Public Shared Function Dbl() As Double
    Return Double.Parse(Str())
  End Function
  Public Shared Function StrArr(Optional separator As String = " ") As String()
    Return Str().Split(separator)
  End Function
  Public Shared Function IntArr(Optional separator As String = " ") As Integer()
    Return Array.ConvertAll(Of String, Integer)(StrArr(separator), AddressOf Integer.Parse)
  End Function
  Public Shared Function LngArr(Optional separator As String = " ") As Long()
    Return Array.ConvertAll(Of String, Long)(StrArr(separator), AddressOf Long.Parse)
  End Function
  Public Shared Function DblArr(Optional separator As String = " ") As Double()
    Return Array.ConvertAll(Of String, Double)(StrArr(separator), AddressOf Double.Parse)
  End Function
End Class

Measured memory_bytes: 36412
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
       int n=sc.nextInt();
       int  max,min;
       long sum;
       sum=0;
       max=-1000000;
       min=1000000;
       for(int i=1;i<=n;i++){
           int a=sc.nextInt();
           sum+=a;
           if(max<a)max=a;
           if(min>a)min=a;
       }
        System.out.println(min+" "+max+" "+sum); 
      
    }
}



Measured memory_bytes: 41528
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
template<typename T> inline void chkmin(T &a, const T &b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T &a, const T &b) { a = a > b ? a : b; }

const int MAXN = 200005, MOD = 1e9 + 7;
struct Data { int x, v; } dat[MAXN];
int sta[MAXN], val[MAXN], rgt[MAXN], lft[MAXN], f[MAXN], sum[MAXN], n, pw[MAXN];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d%d", &dat[i].x, &dat[i].v);
	sort(dat + 1, dat + 1 + n, [&](const Data &a, const Data &b) { return a.x < b.x; });
	int tp = 0;
	for (int i = 1; i <= n; i++) {
		while (tp > 0 && val[tp] > dat[i].v) --tp;
		++tp, sta[tp] = i, val[tp] = dat[i].v;
	}
	for (int i = 1; i <= n; i++) {
		int p = upper_bound(val + 1, val + 1 + tp, dat[i].v) - 1 - val;
		rgt[i] = sta[p];
	}
	
	memset(f, 0x3f, sizeof(f));
	tp = 0;
	for (int i = n; i > 0; i--) {
		while (tp > 0 && val[tp] < dat[i].v) --tp;
		++tp, sta[tp] = i, val[tp] = dat[i].v;
	}
	reverse(sta + 1, sta + 1 + tp);
	reverse(val + 1, val + 1 + tp);
	for (int i = 1; i <= n; i++) {
		int p = lower_bound(val + 1, val + 1 + tp, dat[i].v) - val;
		int l = sta[p];
		chkmax(lft[rgt[i]], l);
	}
	
	f[0] = sum[0] = 1;
	for (int i = 1; i <= n; i++) {
		if (lft[i]) {
			f[i] = (sum[i - 1] - (lft[i] > 1 ? sum[lft[i] - 2] : 0) + MOD) % MOD;
		} else f[i] = f[i - 1] * 2 % MOD;
		sum[i] = (sum[i - 1] + f[i]) % MOD;
	}
	printf("%d\n", f[n]);
	return 0;
}

Measured memory_bytes: 6528
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
using static ConsoleApplication.Utils;

namespace ConsoleApplication
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Solve();
            WriteLine(Result);
        }

        public static string Result { get; set; }

        private static void Solve()
        {
            var n = ReadInt();
            var k = ReadInt();
            var x = ReadInt();
            var y = ReadInt();
            var xCount = Min(n, k);
            var yCount = Max(0, n - k);
            Result = (x * xCount + y * yCount).ToString();
        }
    }

    public static class Utils
    {
        #region Extensions for IO

        public static int ReadInt()
            => ReadInts().First();

        public static IEnumerable<int> ReadInts()
            => ReadStrings().Select(int.Parse);

        public static IEnumerable<String> ReadStrings()
            => ReadLine().Split(' ');

        #endregion

        #region Extensions of int

        public static bool IsOdd(this int n)
            => !n.IsEven();

        public static bool IsEven(this int n)
            => n % 2 == 0;
        
        public static bool CanDivideWith(this int n, int divisor)
            => n % divisor == 0;

        #endregion

        #region Extensions of string

        public static int ToInt(this string str)
            => int.Parse(str);

        public static long ToLong(this string str)
            => long.Parse(str);

        public static bool IsNullOrEmpty(this string str)
            => string.IsNullOrEmpty(str);

        #endregion

        public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
        {
            foreach (var item in source)
            {
                action(item);
            }
        }
    }
}


Measured memory_bytes: 2904
#include<stdio.h>

int main(void){
  char a,b,c,d;
  scanf("%c%c%c%c",&a,&b,&c,&d);
  if(a==b ||  b==c || c==d)
  {
    printf("Bad\n");
  }else{
    printf("Good\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	
	int n,i,temp;
	char str[10];
	while(1){
		int top=1,yoko[4]={2,3,5,4},soko=6,total=1;
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<n;i++){
			scanf("%s",str);
			switch(str[0]){
				case 'N':
					temp=top;
					top=yoko[0];
					yoko[0]=soko;
					soko=yoko[2];
					yoko[2]=temp;
					break;
				case 'E':
					temp=top;
					top=yoko[3];
					yoko[3]=soko;
					soko=yoko[1];
					yoko[1]=temp;
					break;
				case 'S':
					temp=top;
					top=yoko[2];
					yoko[2]=soko;
					soko=yoko[0];
					yoko[0]=temp;
					break;
				case 'W':
					temp=top;
					top=yoko[1];
					yoko[1]=soko;
					soko=yoko[3];
					yoko[3]=temp;
					break;
				case 'R':
					temp=yoko[0];
					yoko[0]=yoko[1];
					yoko[1]=yoko[2];
					yoko[2]=yoko[3];
					yoko[3]=temp;
					break;
				case 'L':
					temp=yoko[0];
					yoko[0]=yoko[3];
					yoko[3]=yoko[2];
					yoko[2]=yoko[1];
					yoko[1]=temp;
					break;
				default :
					break;
			}
			total+=top;
		}
		printf("%d\n",total);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
    int N;
    string S;
    
    cin >> N;
    cin >> S;
    
    int count = 0;
    for(int i=0; i<N-2; i++){
        if(S[i] == 'A'){
            if(S[i+1] == 'B'){
                if(S[i+2] == 'C'){
                    count++;
                }
            }
        }
    }
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  ll A,B,K;
  cin>>A>>B>>K;

  ll rest=max(0ll,K-A);
  ll C=max(0ll,A-K);
  ll D=max(0ll,B-rest);
  cout<<C<<" "<<D<<endl;

  return 0;
}


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

q = []
for x in range(N):
    q.append(x+1)

i = 0
c = 0
ans = "NO"
while(i < N):
    if p[i] != q[i]:
        c += 1
    if c > 2:
        break
    i += 1

if (c == 2) or (c == 0):
    ans = "YES"

print(ans)

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

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}

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

int a[10];
signed main(void)
{
    int m;
    cin >> m;

    cout << 24 + (24-m) << endl;

    return 0;
}


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

void countingSort(vector<int>& A, vector<int>& B, int k)
{
	vector<int> C(10005, 0);

	for (int i = 0; i < A.size(); i++) C.at(A.at(i))++;

	for (int i = 1; i <= k; i++) C.at(i) = C.at(i) + C.at(i - 1);

	for (int i = A.size() - 1; i >= 0; i--)
	{
		B.at(C.at(A.at(i)) - 1) = A.at(i);
		C.at(A.at(i))--;
	}
}

int main(void)
{

	int N;
	cin >> N;
	vector<int> A(N), B(N);

	for (int i = 0; i < N; i++) cin >> A.at(i);

	countingSort(A, B, 10000);

	for (int i = 0; i < B.size(); i++)
	{
		if (i) cout << " ";
		cout << B.at(i);
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 18336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<pair<int, int> > ans;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  if (k == 0) {
    for (int i = 1; i <= n; ++ i) {
      for (int j = i + 1; j <= n; ++ j) {
        ans.push_back({i, j});
      }
    }
    cout << ans.size() << endl;
    for (auto &p : ans) {
      cout << p.first << " " << p.second << endl;
    }
    return 0;
  }
  else if (n == 2 || (n - 1) * (n - 2) / 2 < k) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 1; i < n; ++ i) {
    ans.push_back({i, n});
  }
  int sum = 0;
  for (int i = 1; i < n - 1; ++ i) {
    for (int j = i + 1; j < n; ++ j) {
      sum ++;
      if (sum > k) {
        ans.push_back({i, j});
      }
    }
  }
  cout << ans.size() << endl;
  for (auto &p : ans) {
    cout << p.first << " " << p.second << endl;
  }
  return 0;
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define MAX_V 10000

typedef pair<ll, ll> P;
set<int> st;
int point;


int main(){
    int n, ans = 0;
    string s;
    cin >> n >> s;
    REP(i, n-2) {
        if(s[i] == 'A') {
            if(s[i+1] == 'B') {
                if(s[i+2] == 'C') {
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define all(c) c.begin(), c.end()

using namespace std;

typedef long long int ll;
typedef long double ld;

const ll mod = 1e9 + 7;
const ld PI = 3.141592653589793;

void solve () {
	ll a,b,c;
	cin>>a>>b>>c;
	cout<<c-min(a-b,c);
}
main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    
    solve();
    return 0;
    }


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout<<fixed<<setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	ll n;
	while ((n = in()) != 0) {
		vector<ll>t(n);
		REP(i, n)t[i] = in();
		sort(ALL(t));
		ll ans = 0;
		REP(i, n) {
			ans += t[i] * (n - 1 - i);
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3228
r, c = gets.split.map(&:to_i)
list = Array.new
r.times do
  a = gets.split.map(&:to_i)
  list << a + [a.inject(:+)]
end
list << list.transpose.map {|a| a.inject(:+) }
list.map {|a| puts a.join(" ") }

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

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long long llong;
typedef long double ld;

using namespace std;

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
        cerr << (*i) << " ";
    }
    cerr << "\n";
}

int was[120000];
int dis[120000];
int a[120000];
int b[120000];
int n;
int p[120000];
vector<int> vva;
vector<int> vvb;
int xa, xb;
set<int> ss;
map<int, vector<int>>  go;
map<int, int> lst;

int get(int a) {
    if (p[a] == a)
        return a;
    return p[a] = get(p[a]);
}

void un(int a, int b) {
    a = get(a);
    b = get(b);
    if (a == b)
        return;
    p[a] = b;
}

void dfs1(int v, int k) {
    was[v] = 1;
    un(v, k);
    int g = go[a[v]].back();
    go[a[v]].pop_back();
    if (!was[g])
        dfs1(g, k);
}

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i], vva.push_back(a[i]), xa ^= a[i];
    for (int i = 0; i < n; ++i)
        cin >> b[i], vvb.push_back(b[i]), xb ^= b[i];
    vva.push_back(xa);
    vvb.push_back(xb);
    sort(vva.begin(), vva.end());
    sort(vvb.begin(), vvb.end());
    for (int i = 0; i < vva.size(); ++i) {
        if (vva[i] != vvb[i]) {
            cout << -1 << "\n";
            return 0;
        }
    }
    int cnt = n;
    for (int i = 0; i < n; ++i)
        if (a[i] == b[i]) {
            dis[i] = 1;
            --cnt;
        }
    int fl = 0;
    for (int i = 0; i < n; ++i) {
        if (!dis[i] && a[i] == xb) {
            fl = 1;
            swap(xa, a[i]);
            break;
        }
    }
    for (int i = 0; i < n; ++i)
        if (!dis[i])
            go[b[i]].push_back(i);
    for (int i = 0; i < n; ++i)
        p[i] = i;
    for (int i = 0; i < n; ++i) {
        if (!dis[i] && !was[i])
            dfs1(i, i);
    }
    for (int i = 0; i < n; ++i) {
        if (!dis[i]) {
            if (lst.count(a[i]))
                un(lst[a[i]], i);
            lst[a[i]] = i;
        }
    }
    for (int i = 0; i < n; ++i)
        if (!dis[i])
            ss.insert(get(i));
    cout << cnt + (int)ss.size() - fl << "\n";
    return 0;
}




Measured memory_bytes: 20600
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
x = 0
y = 0
for i in range(N):
    if A[i]>B[i]:
        x += A[i]-B[i]
    else:
        y += (B[i]-A[i])//2
if y>=x:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 40432
#include <bits/stdc++.h>
#include<string.h>
#define ll long long
#define pb push_back
#define vi vector<int>
#define nl endl
#define tc    \
    ll t;     \
    cin >> t; \
    while (t--)
#define fastio                       \
    ios_base::sync_with_stdio(NULL); \
    cin.tie(NULL);                   \
    cout.tie(NULL);
using namespace std;
int main()
{
    fastio;
    ll i,n,s=0;
    cin>>n;
    ll m=3*n;
    ll a[m];
    for(i=0;i<m;i++){
        cin>>a[i];
    }
    sort(a,a+m);
    for(i=n;i<m;i=i+2){
        s+=a[i];
    }
    cout<<s;
}

Measured memory_bytes: 6004
#include <bits/stdc++.h>
using namespace std;
int main() {
	int h, w;
	cin >> h >> w;
	long long int n;
	cin >> n;
	vector<int> arr(n);
	vector< vector<int> > v(h, vector<int> (w));
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
	}

	int num = 1;
	for(int i = 0; i < h; i++) {
		if(i % 2) {
			for(int j = w - 1; 0 <= j; j--) {
				v[i][j] = num;
				arr[num - 1]--;
				if(arr[num - 1] == 0) num++;
			}
		} else {
			for(int j = 0; j < w; j++) {
				v[i][j] = num;
				arr[num - 1]--;
				if(arr[num - 1] == 0) num++;
			}
		}
	}

	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			cout << v[i][j];
			if(j != w - 1) cout << " ";
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

struct Point {
    double x, y;
};

double len(Point p1, Point p2) {
    return sqrt((p1.x - p2.x)*(p1.x - p2.x) + (p1.y - p2.y)*(p1.y - p2.y));
}

double area(Point *points) {
    double a = len(points[0], points[1]);
    double b = len(points[1], points[2]);
    double c = len(points[2], points[0]);
    double s = (a + b + c) / 2;
    return sqrt(s*(s - a)*(s - b)*(s - c));
}

int is_in(Point *points, Point search) {
    double src = area(points);
    double a, b, c;
    
    swap(points[0], search);
    a = area(points);
    swap(points[0], search);

    swap(points[1], search);
    b = area(points);
    swap(points[1], search);

    swap(points[2], search);
    c = area(points);
    swap(points[2], search);

    if (src - 1e-5 < a + b + c && a + b + c < src + 1e-5) {
        return 1;
    }
    else {
        return 0;
    }
}

int main() {
    while (1) {
        Point points[3];
        Point search;

        for (int i = 0; i < 3; i++) {
            if (!(cin >> points[i].x >> points[i].y)) {
                return 0;
            }
        }
        cin >> search.x >> search.y;
    
        if (is_in(points, search) == 1) {
            cout << "YES\n";
        }
        else {
            cout << "NO\n";
        }
    }
    
    return 0;
}

Measured memory_bytes: 1188
N,T = (int(i) for i in input().split())
c = list(0 for i in range(N))
t = list(0 for i in range(N))
for i in range(N):
    c[i], t[i] = (int(i) for i in input().split())
c_min=0
for i in range(N):
    if c_min > c[i] or c_min == 0:
        if t[i] <= T:
            c_min = c[i]
if c_min == 0:
    print("TLE")
else:
    print(c_min) 

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

using namespace std;

int arr[100002], pref[100002], suf[100002];

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

int main(){

    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    //freopen("input.txt", "r", stdin);

    int n;

    cin >> n;

    int cur = -1;

    for(int i = 0; i < n; ++i){
        cin >> arr[i];
        if(i == 0){
            cur = arr[i];
        } else {
            cur = GCD(cur, arr[i]);
        }
        pref[i] = cur;
    }

    cur = -1;

    for(int i = n - 1; i > -1; --i){
        if(i == n - 1){
            cur = arr[i];
        } else {
            cur = GCD(cur, arr[i]);
        }
        suf[i] = cur;
    }

    int best = 1;

    for(int i = 0; i < n; ++i){
        if(i == 0){
            cur = suf[i + 1];
        } else if(i == n - 1){
            cur = pref[i - 1];
        } else {
            cur = GCD(suf[i + 1], pref[i - 1]);
        }
        best = max(best, cur);
    }

    cout << best;

    return 0;
}


Measured memory_bytes: 1408
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n, q; rd(n, q);
  auto tree=new SquareRootDecomposition(n);
  while(q--){
    auto args=readln.split.to!(int[]);
    if(args[0]==0){
      tree.add(args[1]-1, args[2], args[3]);
    }else{
      writeln(tree.sum(args[1]-1, args[2]));
    }
  }
}

class SquareRootDecomposition{ // starry
  import std.algorithm;
  int D=1, nil=-1;
  long[] val, buc, star;
  this(int n){
    while(D*D<n) D++;
    val.length=D*D;
    buc.length=star.length=D;
  }

  void add(int ql, int qr, long x){
    foreach(k; 0..D){
      int l=k*D, r=(k+1)*D;
      if(r<=ql || qr<=l){
        // 
      }else if(ql<=l && r<=qr){
        star[k]+=x;
      }else{
        int s=max(l, ql), t=min(r, qr);
        buc[k]+=x*(t-s);
        val[s..t]+=x;
      }
    }
  }

  long sum(int ql, int qr){
    long ret=0;
    foreach(k; 0..D){
      int l=k*D, r=(k+1)*D;
      if(r<=ql || qr<=l){
        // 
      }else if(ql<=l && r<=qr){
        ret+=(buc[k]+star[k]*D);
      }else{
        int s=max(l, ql), t=min(r, qr);
        ret+=star[k]*(t-s);
        ret+=reduce!"a+b"(0L, val[s..t]);
      }
    }
    return ret;
  }
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}


Measured memory_bytes: 3960
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;
const int m=1000000000;

int main(){
	string s;
	cin>>s;
	string t(s);
	int l=s.length();
	int c=0;
	FOR(i,0,l/2){
		if(s[i]==s[l-1-i]){

		}else{
			c++;
		}
	}
	cout<<c<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
	int i,N,L,ans=0;
	cin>>N>>L;
	for(i=0;i<N;i++){
		ans+=L+i;
	}
	if(L>=0){
		ans-=L;
	}else if(L+N-1<0){
		ans-=L+N-1;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: i64, k: i64,
    }
    let mut tot: i64 = 0;
    for b in k + 1..n + 1 {
        // How many possible a's are there?
        let s = n / b;
        let t = n % b;
        tot -= s * k + min(t + 1, k);
        tot += n + if k == 0 { 0 } else { 1 };
        debugln!("{} {}", b, tot);
    }
    puts!("{}\n", tot);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

int graph[101][101];
int main(){
  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
    int u,k,v; cin>>u>>k;
    for(int j=1;j<=k;j++){
      cin>>v;
      graph[u][v]=1;
    }
  }

  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      if(j-1) cout<<" ";
      cout<<graph[i][j];
    }
    cout<<"\n";
  }
}



Measured memory_bytes: 3112
#

#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

def main():
    n = int(input())
    al = [int(input()) for _ in range(n)]

    lsbs = deque()
    for a in al:
        pos = bisect.bisect_left(lsbs, a)
        if pos == 0:
            lsbs.appendleft(a)
        else:
            if pos == len(lsbs):
                lsbs[-1] = a
            else:
                lsbs[pos-1] = a
        # print(lsbs)
    print(len(lsbs))


if __name__ == '__main__':
    main()


Measured memory_bytes: 54488
import sys
readline = sys.stdin.readline
write = sys.stdout.write
N, M = map(int, readline().split())
P = []
while 1:
    s, t, e = map(int, readline().split())
    if e == 0:
        break
    P.append((s-1, t-1, e))
L = int(readline())
B = [list(map(int, readline().split())) for i in range(L)]
C = [[0]*N for i in range(L)]
for k in range(L):
    ck = C[k]; bk = B[k]
    for s, t, e in P:
        ck[s] += bk[t] * e
    write(' '.join(map(str, ck)))
    write('\n')



Measured memory_bytes: 84100
N, M = map(int, input().split())
H = list(map(int, input().split()))
yoi = [1] * N

for _ in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    if H[A] > H[B]:
        yoi[B] = 0
    elif H[B] > H[A]:
        yoi[A] = 0
    else:
        yoi[A] = 0
        yoi[B] = 0

print(sum(yoi))

Measured memory_bytes: 84780
#include<stdio.h>
#define INFTY 2001

int prim();

int n,m[100][100];


int main(){
  int i,j,a;

  scanf("%d",&n);

  for(i=0;i<=n-1;i++){
    for(j=0;j<=n-1;j++){
      scanf("%d",&a);
      if(a==-1)a=INFTY;
      m[i][j]=a;
    }
  }

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

  return 0;
}


int prim(){
  int sum=0,i,j,u,mincost,d[100],p[100],c[100];
  for(i=0;i<=n-1;i++){
    d[i]=INFTY;
    p[i]=-1;
    c[i]=-1;
  }

  d[0]=0;

  while(1){
    mincost=INFTY;
    u=-1;

    for(i=0;i<=n-1;i++){
      if(mincost>d[i]&&c[i]!=1){
	u=i;
	mincost=d[i];
      }
    }
    
    if(u==-1)break;

    c[u]=1;

    for(j=0;j<=n-1;j++){
      if(c[j]!=1&&m[u][j]!=INFTY&&d[j]>m[u][j]){
	d[j]=m[u][j];
	p[j]=u;
	c[j]=0;
      }
    }
  }

  for(i=0;i<=n-1;i++){
    if(p[i]!=-1)sum+=m[i][p[i]];
  }

  return sum;
}

  

    

    

    



Measured memory_bytes: 2076
n, l = map(int, input().split())
sorted = [input()]

for i in range(n-1):
  s = input()
  for j in range(len(sorted)):
    if s < sorted[j]:
      sorted.insert(j, s)
      break
    if j == len(sorted)-1:
      sorted.append(s)
ans = ""
for x in sorted:
  ans = ans + x
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N, H, W; cin >> N >> H >> W;
	int res = (N - H + 1)*(N - W + 1);

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
        long b = 1;
        for(long i=1;i<=Math.sqrt(a);i++){if(a%i==0){b=i;
                                                   }                            
                                        }
		System.out.println(b+a/b-2);
	}
}


Measured memory_bytes: 23892
import java.util.*;
import java.math.*;

class Main {
    private static long[] grades = new long[200000 + 5];

    public static void main(String[] args) {
	Scanner s = new Scanner(System.in);
	int n = s.nextInt();
	int k = s.nextInt();

	for (int i = 0; i < n; i++) {
	    grades[i] = s.nextLong();
	}

	int i = k;

	for (; i < n; i++) {
	    if (grades[i - k] < grades[i]) {
		System.out.println("Yes");
	    } else {
		System.out.println("No");
	    }
	}
    }
}


Measured memory_bytes: 71784
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

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

int main(){

  int t; cin>> t;
  while(t--){
    int p, q; cin>> p>> q;
    int cnt=0;
    for(int m=-200; m<=200; m++)for(int n=-200; n<=200; n++){
      int sq=n*n+m*m;
      if(sq==0) continue;
      if((m*p+n*q)%sq==0 and (m*q-n*p)%sq==0){
        cnt++;
      }
    }
    if(cnt==8) cout<< "P"<< endl;
    else cout<< "C"<< endl;
  }

  return 0;
}


Measured memory_bytes: 3092
#include<iostream>
#include<iomanip>
#include<vector>
using namespace std;
int N,M;
vector<int>G[666];
double dp[666];
double x[666][666];
main()
{
	cin>>N>>M;
	for(int i=0;i<M;i++)
	{
		int s,t;cin>>s>>t;
		s--,t--;
		G[s].push_back(t);
	}
	dp[N-1]=0;
	x[N-1][N-1]=1;
	for(int i=N-2;i>=0;i--)
	{
		double sum=0;
		for(int v:G[i])
		{
			sum+=dp[v];
			for(int j=0;j<N;j++)x[i][j]+=x[v][j]/G[i].size();
		}
		x[i][i]=1;
		dp[i]=sum/G[i].size()+1;
	}
	double ans=dp[0];
	for(int i=0;i<N-1;i++)
	{
		if(G[i].size()==1)continue;
		double sum=0,m=0;
		for(int v:G[i])
		{
			sum+=dp[v];
			m=max(m,dp[v]);
		}
		double ch=(sum-m)/(G[i].size()-1)+1-dp[i];
		ans=min(ans,dp[0]+ch*x[0][i]);
	}
	cout<<fixed<<setprecision(16)<<ans<<endl;
}


Measured memory_bytes: 4608
/********************/
/* K B G D E L T A */
/*     DA-IICT      */
/********************/
 
#include<bits/stdc++.h>
using namespace std;
using   ll=long long;
using   ld=long double;
#define fast           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl           "\n"
#define F(i,n)         for(ll i=0;i<n;i++)
#define rep(i,a,b,c)   for(ll i=a;i<b;i+=c)
#define repp(i,a,b)    for(ll i=a;i>=b;i--)
#define pb             push_back
#define mp             make_pair
#define vll            vector<ll>
#define f              first
#define s              second
#define pll            pair<ll,ll>
#define ALL(v)         v.begin(),v.end()
#define ALLR(v)        v.rbegin(),v.rend()
#define pii            3.14159265358979323
 
void solve()
{
	ll n;
	
	string s,t;
	
	cin>>n>>s>>t;
	
	for(int i=0;i<n;i++)
	{
		cout<<s[i]<<t[i];
	}
}

 
signed main(){
 
    fast;
 
    ll t;
    
    t=1;
    
    while(t--)
    {
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
#define pb push_back
#define ff first
#define ss second
#define all(s) (s).begin(), (s).end()

int main()
{
    int n;
    cin >> n;
    vi arr(n - 1), ans(n, 0);
    for (auto &it : arr)
        cin >> it, it--, ans[it]++;
    for (auto it : ans)
        cout << it << "\n";
    return 0;
}

Measured memory_bytes: 6424