akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
 
using namespace std;
 
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
 
const int INF=1<<29;
const double EPS=1e-9;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};


class card {
public:
	char c;
	int d;
	int id;
};

template<typename T>
int partition(std::vector<T> &A, int p, int r, bool (*f)(T, T) ) {
	T x = A[r];
	int i = p - 1;
	for (int j = p; j < r; ++j) {
		if (f(A[j], x)) {
			i++;
			swap(A[i], A[j]);
		}
	}
	swap(A[i + 1], A[r]);
	return i + 1;
}

template<typename T>
void quicksort(std::vector<T> &A, int p, int r, bool (*f)(T, T) ) {
	if (p >= r) return;
	int q = partition(A, p, r, f);
	quicksort(A, p, q - 1, f);
	quicksort(A, q + 1, r, f);
}


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

	std::vector<card> array;
	for (int i = 0; i < N; ++i) {
		char c;
		int d;
		cin >> c >> d;
		array.push_back((card){c, d, i});
	}

	quicksort<card>(array, 0, N - 1, 
		[](card a, card b){
			return a.d <= b.d;
		}
	);

	bool stable = true;
	for (int i = 0; i < N - 1; ++i) {
		if (array[i].d == array[i + 1].d && array[i].id > array[i + 1].id) {
			stable = false;
		}
	}
	if (stable) {
		cout << "Stable" << endl;
	} else {
		cout << "Not stable" << endl;
	}
	for (int i = 0; i < N; ++i) {
		cout << array[i].c << " " << array[i].d << endl;
	}
	return 0;
}

Measured memory_bytes: 2724
#include<bits/stdc++.h>
#define pi 3.141592653589793238
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        ll n;
        cin >> n;
        deque<ll> q;
        for(i = 0; i < n; i++){
            ll x;
            cin >> x;
            if(i % 2 == 0){
                q.pb(x);
            }
            else{
                q.push_front(x);
            }
        }
        while(!q.empty()){
            if(n % 2 == 0){
                cout << q.front() << " ";
                q.pop_front();
            }
            else{
                cout << q.back() << " ";
                q.pop_back();
            }
        }
    }
    return 0;
}

Measured memory_bytes: 5164
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include "set"
#include "map"
#include "unordered_map"
#include <string>
#include <iomanip>
#include <numeric>
#include "cmath"

using namespace std;
#define double long double
#define int long long
#define all(a) a.begin(), a.end()
const int N = 51;
const int M = 51 * 51;
int ldp[N][M];
int rdp[N][M];
int poww[N];

int binpow(int b) {
	return poww[b];
}

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

	poww[0] = 1;

	for (int i = 1; i < N; i++)
		poww[i] = poww[i - 1] * 2ll;
	int n, A;
	cin >> n >> A;

	vector<int> x(n);

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

	int cntA = 0;
	vector<int> exhibitL;
	vector<int> exhibitR;
	for (int i = 0; i < n; i++) {
		if (x[i] == A)
			cntA++;
		else if (x[i] > A) {
			exhibitR.push_back(x[i] - A);
		}
		else {
			exhibitL.push_back(A - x[i]);
		}
	}

	ldp[0][0] = 1;
	rdp[0][0] = 1;

	for (int i = 0; i < exhibitL.size(); i++) {
		int ii = i + 1;
		for (int j = 0; j < M; j++) {
			ldp[ii][j] = ldp[ii - 1][j];
			if (j - exhibitL[i] >= 0) {
				ldp[ii][j] += ldp[ii-1][j - exhibitL[i]];
			}
		}
	}


	for (int i = 0; i < exhibitR.size(); i++) {
		int ii = i + 1;
		for (int j = 0; j < M; j++) {
			rdp[ii][j] = rdp[ii - 1][j];
			if (j - exhibitR[i] >= 0) {
				rdp[ii][j] += rdp[ii-1][j - exhibitR[i]];
			}
		}
	}

	int ans = 0;

	for (int i = 1; i < M; i++) {
		n = exhibitL.size();
		int m = exhibitR.size();

		int temp = ldp[n][i] * rdp[m][i] * binpow(cntA);
		ans += temp;
	}

	ans += binpow(cntA) - 1;

	cout << ans << '\n';

}

Measured memory_bytes: 4620
import static java.lang.System.out;
import java.util.Scanner;
 
public class Main {
      public static void main(String...args) {
                String str = new Scanner(System.in).nextLine();
                String[] list = str.split(" ");
                String x = list[0];
                String y = list[1];
 
                int a = Integer.parseInt(x);
                int b = Integer.parseInt(y);
 
                int sum = a * b;
                int cm = (a + b) * 2;
 
                out.println(sum + " " + cm);
 
      }
 
 
}

Measured memory_bytes: 26056
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.sqrt

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
//    1 2 10 12 14
//     1 8 2 2
    val (n, m) = readIntegerList()
    val xList = readIntegerList().sorted()

    val diffArray = IntArray(m - 1)
    var pre = xList.first()
    for ((i, x) in xList.drop(1).withIndex()) {
        diffArray[i] = x - pre
        pre = x
    }

    val ans = diffArray.toList().sortedDescending().drop(max(0, n - 1)).sum()
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 57136
H, W, A, B = map(int, input().split())

grid = [["0" for _ in range(W)] for _ in range(H)]

for i in range(H):
    for j in range(W):
        if (i < B and j < A) or (i >= B and j >= A):
            grid[i][j] = "1"

for row in grid:
    print("".join(row))

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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

int main() {
	int N;
	cin >> N;
	set<string>se;
	vector<string> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
		if (se.count(v[i])) {
			cout << "No" << endl;
			return 0;
		}
		se.insert(v[i]);
		if (i != 0) {
			if (v[i][0] != v[i - 1][v[i - 1].size() - 1]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef long long ll;
const long long MOD = 1000000000 + 7;

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

    const int ms = 1001000;
    vector<int> seen(ms, 0);
    vector<int> a(n), f(ms, 0);
    for (int i = 0; i < n; i++){
        cin >> a[i];
        f[a[i]]++;
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++)
    {
        if (seen[a[i]] == 1)
            continue;
        seen[a[i]] = 1;
        for (int j = 2; a[i] * j <= ms; j++)
        {
            seen[a[i] * j] = 1;
            f[a[i]*j]++;
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++){
        if(f[a[i]]==1){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11852
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int d = sc.nextInt();

			int rect1 = a * b;
			int rect2 = c * d;

			System.out.println(rect1 >= rect2 ? rect1 : rect2);

		} finally {
			sc.close();
		}
	}
}

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

int main() {
  string S;
  cin >> S;
  int countx = 0;
  int countmaru = 0;
  for(int i = 0; i < S.length(); i++){
    if(S.at(i) == 'x'){
      countx++;
    }else if(S.at(i) == 'o'){
      countmaru++;
    }
  }
  if(countx >= 8 || countmaru + 15 - S.length() < 8){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }

}


Measured memory_bytes: 256
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}


int i_gcd(int a, int b);
int i_gcd(int a, int b) {
	if (!b)return a;
	return i_gcd(b, a % b);
}
int i_lcm(int a, int b);
int i_lcm(int a, int b) {
	return (a * b) / i_gcd(a, b);
}

// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
ll _pfact(ll a);
static ll pf[100000000];
static ll pc;

ll _pfact(ll a) {
	long i, r;
	if (a % 2 == 0) {
		pf[pc] = 2; pc++;
		return(_pfact(a / 2));
	}
	r = sqrt(a);
	for (i = 3; i <= r; i += 2) {
		if (a % i == 0) {
			pf[pc] = i; pc++;
			return(_pfact(a / i));
		}
	}
	if (a != 1) {
		pf[pc] = a; pc++;
	}
	return 0;

}

//同じものの最初の文字をNULLにして降順
int _sort(const void* a, const void* b);
int _sort(const void* a, const void* b) {
	char rc;

	rc = strcmp((char*)b, (char*)a);
	if (rc == 0) {
		*(char*)a = 0x00;
		return(1);
	}
	return(rc);
}


#pragma endregion


// 055 B - Training Camp
#define _dev 1000000007
int main(void) {
	int n;
	ll ans = 1;

	scanf("%d", &n);
	for (int i = 1; i <= n; i++) 
		ans = ans * i % _dev;
	
	printf("%lld\n",ans);
	return 0;
}






Measured memory_bytes: 2124
#include <stdio.h>

int main(void)
{
  int kuku[81];
  for(int i = 1;i <= 9; i++){
    for(int k = 1;k <= 9; k++){
      kuku[(i-1)*9+k-1] = i * k;
    }
  }
  
  int N;
  scanf("%d", &N);
  
  int isgood  = 0;
  
  for(int i = 0; i<81; i++){
    if(kuku[i] == N){
      isgood = 1;
      break;
    }
  }
  
  if(isgood){
    printf("Yes");
  }else{
    printf("No");
  }
  
  return 0;
}
  
  

Measured memory_bytes: 128
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
*/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll val[55];
ll n,ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>val[i];
	for(int i=1;i<n;i++)
		for(int j=i+1;j<=n;j++)
			ans+=val[i]*val[j];	
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    map<int, int> mp;
    REP(i, n){
        mp[a[i]]++;
        mp[a[i] + 1]++;
        mp[a[i] - 1]++;
    }

    int ans = 0;
    for(auto x : mp){
        ans = max(ans, x.second);
    }
    cout << ans << endl;
}


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

bool s[16][16];
int p[16];
int cnt;

signed main() {

    int n, m;
    scanf("%d %d" , &n, &m);
    for ( int i= 0; i < m; i++ ) {
        int k;
        scanf("%d", &k);
        for ( int j = 0; j < k; j++ ) {
            int S;
            scanf("%d", &S);
            s[i][S-1] = true;
        }
    }

    for ( int i = 0;  i < m; i++ ) {
        scanf("%d", &p[i]);
    }

    for ( int i = 0; i < (1<<n); i++ ) {
        bool flg = true;
        for ( int j = 0; j < m; j++ ) {
            int tmp = 0;
            for ( int k = 0; k < n; k++ ) {
                if ( s[j][k] && ( i & ( 1 << k ) ) ) tmp++;
            }
            if ( tmp % 2 != p[j] ) flg = false;
        }
        if ( flg ) cnt++;
    }

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

    return 0;
}

Measured memory_bytes: 256
import sys
import random

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def write_output(out):
    with open("my_sample2.out", mode="w") as f:
        for x in out:
            f.write(str(x + 1) + "\n")

def main():
    d = int(readline())
    c = list(map(int, readline().split()))
    s = [list(map(int, readline().split())) for _ in range(d)]

    sat_cur = 0
    last = [1] * 26
    out = [-1] * d

    for day in range(d):
        estimate = [0.0] * 26
        for cid in range(26):
            if s[day][cid] > 16000:
                estimate[cid] = last[cid] * c[cid] + c[cid] ** 1
        cur = estimate.index(max(estimate))
        out[day] = cur
        sat_cur += s[day][cur]
        last[cur] = 1
        for cid in range(26):
            if cid != cur:
                last[cid] += 1
                sat_cur -= last[cid] * c[cid]

    for _ in range(500):
        sat_temp = 0
        change_day = random.randint(0, d - 1)
        change_cid = random.randint(0, 25)
        last = [1] * 26
        for day in range(d):
            if day == change_day:
                cur = change_cid
            else:
                cur = out[day]
            sat_temp += s[day][cur]
            last[cur] = 1
            for cid in range(26):
                if cid != cur:
                    last[cid] += 1
                    sat_temp -= last[cid] * c[cid]
        # print(change_day, change_cid, sat_temp)
        if sat_temp > sat_cur:
            out[change_day] = change_cid

    for x in out:
        print(x + 1)

    #write_output(out)




if __name__ == '__main__':
    main()


Measured memory_bytes: 78748
#include<cstdio>
int H =0;
int W =0;
int N =0;
const int MAXN =10000;
int a[MAXN]={0};

int main(void)
{
	scanf("%d %d",&H,&W);
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d",&a[i]);	
	}
	int num =0;
	int t =0;
	int ans[H][W]={0};
	for(int j=0;j<H;j++){
		int m = 0; int n =0;
		if(j%2==0){
			for(int m=0;m<W;m++){
			if(t<a[num]) {
				ans[j][m]=(num+1); t++;
			}
			else{
				ans[j][m]=num+2; t=1; num++;
			}
			
			}
		}
		else{
			for(int n=W-1;n>=0;n--){
			if(t<a[num]) 	{
				ans[j][n]=(num+1);t++;
			}
			else{
				ans[j][n]=num+2; t=1; num++;
			}
		
			}
		}
		
		
	} 
	
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			printf("%d ",ans[i][j]);
		}
		printf("\n");
	}

    return 0;
}


Measured memory_bytes: 256
n, m, x = map(int, input().split())
cl = []
al = []

for _ in range(n):
    c, *a = map(int, input().split())
    cl.append(c)
    al.append(a)

ans = float('inf')
for i in range(2 ** n):
    sum = 0
    l = [0] * m

    for j in range(n):
        if i >> j & 1:
            sum += cl[j]
            for k in range(m):
                l[k] += al[j][k]

    flg = all([e >= x for e in l])

    if flg:
        ans = min(ans, sum)

print(-1 if ans == float('inf') else ans)

Measured memory_bytes: 74264
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>
#include <regex>
#include <functional>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int MAX_N = 100000;

typedef long long ll;

int main() {
    const double PI = 3.14159265358979323846;
    int r;
    cin >> r;
    cout << std::setprecision(8) << r * 2.0 * PI << endl;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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 (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  vector<ll> ans(n,INF);
  deque<ll> que;
  ans[1]=1;
  que.pb(1);

  while(!que.empty()){
    ll x=que.front();
    que.pop_front();
    
    ll nx=(x*10)%n;
    if(ans[nx]>ans[x]) {
      ans[nx]=ans[x];
      que.push_front(nx);
    }

    ll nxt=(x+1)%n;
    if(ans[nxt]>ans[x]+1) {
      ans[nxt]=ans[x]+1;
      que.pb(nxt);
    }    
  }

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

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>

using namespace std;

int main(void){
    vector<int> A(5);
    for(int i=0;i<5;i++){
        cin>>A[i];
    }

    int last=0;
    int temp=10;
    for(int i=0;i<5;i++){
        if(A[i]%10!=0 && temp>A[i]%10){
            last=i;
            temp=A[i]%10;
        }
    }

    int ans=0;
    for(int i=0;i<5;i++){
        if(i==last){continue;}

        if(A[i]%10==0){ans+=A[i];}
        else{
            ans+=(A[i]/10)*10;
            ans+=10;
        }
    }

    ans+=A[last];

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
x = []
y = []
h = []
key = 0
for i in range(N):
    tmp = [int(i) for i in input().split()]
    if tmp[2] != 0:
        key = i
    x.append(tmp[0])
    y.append(tmp[1])
    h.append(tmp[2])

for Cx in range(100 + 1):
    for Cy in range(100 + 1):
        correct_flag = True
        H = abs(x[key] - Cx) + abs(y[key] - Cy) + h[key]
        for i in range(N):
            if h[i] == 0:
                if abs(x[i] - Cx) + abs(y[i] - Cy) < H:
                    correct_flag = False
                    break
            else:
                if abs(x[i] - Cx) + abs(y[i] - Cy) + h[i] != H:
                    correct_flag = False
                    break
        if correct_flag:
            print(Cx, Cy, H)
            break



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n,a[100010];
int main()
{
	int ps,nw,ans=0,up,l,mo;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	nw=0,ps=1;
	for(int i=n-1;i>=1;i--)
	{
		nw++;
		if(nw>=a[i]){nw--,ps=i+1;break;}
	}
	l=0;
	for(int i=ps-1;i>=1;i--)
	{
		if(a[i]>nw)l++;
	}
	up=(a[ps]-nw)&1;
	l=(l&1)^1;
	if(up&&l)puts("Second");
	else puts("First");
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V  = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class H> void rsz(V<T> &v, H h) { v.resize(h); }
template<class T, class H, class... R> void rsz(V<T> &v, H h, R... r) { v.resize(h); for (auto&& i : v) rsz(i, r...); }
using C = complex<double>;
const double eps = 1e-12;
const double pi = acos(-1.0);
istream &operator>>(istream &i, C &a) { double x, y; i >> x >> y; a = C(x, y); return i; }
int ccw(C p0, C p1, C p2) {
  p1 -= p0, p2 -= p0;
  if (imag(conj(p1) * p2) > eps) return 1;
  if (imag(conj(p1) * p2) < -eps) return -1;
  if (real(p2 / p1) > 1 + eps) return 2;
  if (real(p2 / p1) < -eps) return -2;
  return 0;
}
C int_p(const C &a, const C &b, const C &c, const C &d) {
  double s = imag(conj(a) * (d - c) + c * conj(d)) / imag(conj(d - c) * (b - a));
  return (1 - s) * a + s * b;
}

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  C a, b, c; cin >> a >> b >> c;
  if (ccw(a, b, c) == -1) swap(b, c);
  auto ck = [&](double r) {
    C ta = polar(r, arg(c - b) + pi / 2);
    C tb = polar(r, arg(a - c) + pi / 2);
    C tc = polar(r, arg(b - a) + pi / 2);
    C aa = int_p(a + tc, b + tc, a + tb, c + tb);
    C bb = int_p(b + ta, c + ta, b + tc, a + tc);
    C cc = int_p(c + tb, a + tb, c + ta, b + ta);
    double d = max({abs(cc - bb), abs(aa - cc), abs(bb - aa)});
    return d > 2 * r - eps;
  };
  double ok = eps, ng = abs(imag(conj(b - a) * (c - a))) / (abs(c - b) + abs(a - c) + abs(b - a));
  while (ng - ok > eps) {
    double m = (ok + ng) / 2;
    if (ck(m)) ok = m;
    else ng = m;
  }
  cout << fixed << setprecision(12) << ok << '\n';
}

Measured memory_bytes: 640
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let s = sc.chars();
    put!((0..s.len() / 2).filter(|&i|
        s[i] != s[s.len() - i - 1]).count());
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>


using namespace::std;

int main (){
//def
	float n,a,c;
	int b,d,cost;
//in
	cin>>n>>a>>b>>c>>d;
//main
	cost = min(b*(ceil(n/a)),d*(ceil(n/c)));
	cout<<cost<<endl;
	return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int n,k,d;
 cin>>n>>k;
 int i=0;
 map<int,int> m;
 while(i<k)
 {
 	cin>>d;
 	int j=0;
 	while(j<d)
 	{
 	    int x;
		 cin>>x;
		 m[x]=1;	
 		j++;
	}
	i++;
 }
 int ans=0;
 for(i=1;i<=n;i++)
 if(m[i]==0)
 ans++;
 cout<<ans<<endl;
 return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define MAX 9223372036854775807
#define MIN -9223372036854775807
#define PI 3.141592653589
#define setbits(n) __builtin_popcountll(n)
const ll mod=1e9+7;



int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll T=clock();
    
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<((a+b-1)/b)*c;



    cerr<<"\n\nTIME: "<<(double)(clock()-T)/CLOCKS_PER_SEC<<" sec\n";
    T = clock();
    return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <algorithm>
using namespace std;
int c[200005];
const int mod=1e9+7;
int fast_pow(int a,int n)
{
    int res=1;
    int temp=a;
    while(n)
    {
        if(n&1)
        {
            res=(1ll*res*temp)%mod;
        }
        temp=(1ll*temp*temp)%mod;
        n>>=1;
    }
    return res%mod;
}
bool cmp(int aa,int bb)
{
    return aa>bb;
}
int main()
{
    int n;
    cin>>n;
    int res=fast_pow(4,n-1);
    for(int i=0;i<n;i++)
    {
        cin>>c[i];
    }
    sort(c,c+n,cmp);
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        ans=(ans+1ll*(i+1)*c[i-1])%mod;
    }
    res=(1ll*res*ans)%mod;
    cout<<res;
    return 0;
}

Measured memory_bytes: 4432
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    vector<int> A, B;
    for (int i = 0 ; i < n ; i++) {
        int l, r; cin >> l >> r;
        A.push_back(l);
        B.push_back(r);
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    if (n % 2) {
        cout << B[n / 2] - A[n / 2] + 1 << '\n';
    } else {
        cout << (B[n / 2] + B[(n - 1) / 2]) - (A[n / 2] + A[(n - 1) / 2]) + 1 << '\n';
    }
}

Measured memory_bytes: 5120
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
a3=list(map(int,input().split()))
n=int(input())
for _ in range(n):
    b=int(input())
    for i in range(3):
        if b==a1[i]:
            a1[i]=0
        if b==a2[i]:
            a2[i]=0
        if b==a3[i]:
            a3[i]=0
if sum(a1)==0 or sum(a2)==0 or sum(a3)==0 or a1[0]+a2[0]+a3[0]==0 or a1[1]+a2[1]+a3[1]==0 or a1[2]+a2[2]+a3[2]==0 or a1[0]+a2[1]+a3[2]==0 or a1[2]+a2[1]+a3[0]==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9184
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char **argv)
{
	int A, B;
	scanf("%d", &A);
	scanf("%d", &B);
	int x[4];
	for (int i = 1; i < 4; i++)
		x[i] = 0;
	x[A] = 1;
	x[B] = 1;
	for (int i = 1; i < 4; i++) {
		if (x[i] == 0)
			printf("%d\n", i);
	}
	return 0;
}


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

int syc(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	
	int sum=0;
	int a;
	
	cin >> a;
	syc(a,2,50);
	
	int b[a];
	
	for(int i=0;i<a;i++){
		cin >> b[i];
		syc(b[i],0,100);
		//cout << b[i];
	}
			
	for(int j=0;j<a-1;j++){
		for(int k=j+1;k<a;k++){
			sum += b[j]*b[k];
		}	
	}
	
	cout << sum << endl;
	
	return 0;
}


Measured memory_bytes: 256
read_string(Str) :-
  current_input(Input),
  read_string(Input, '\n', ' ', _, Str).

read_number(Num) :-
  read_string(Str),
  number_string(Num, Str).

result_Y('YES').
result_N('NO').

solve(RGB, Ret) :-
  divmod(RGB, 4, _, R),
  R =:= 0 ->
    result_Y(Ret);
    result_N(Ret).

main :-
  read_number(RGB),
  solve(RGB, Ret),
  writeln(Ret).

:- main.


Measured memory_bytes: 8044
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a;
	vector <int> v;
    for(int i=0;i<3;i++){
    	cin>>a;
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	cout<<v[2]*10+v[1]+v[0];
	return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<vector>
#include<deque>
#include <numeric>
#include<cmath>
using namespace std;
#define ll long long

int main(void){
    int n,m;
    cin >>n>>m;
    vector<bool> hole(n+1,true);
    for(int i=0;i<m;i++){
        int idx;cin >> idx;
        hole[idx]=false;
    }
    
    ll count[n+1];
    count[0]=1;
    if(hole[1]) count[1]=1; else count[1]=0;
    for(int i=2;i<n+1;i++){
        if(hole[i]){
        count[i]=count[i-1]+count[i-2];
        count[i]%=1000000007;
        }else{
            count[i]=0;
        }
    }
    // for(int i=0;i<n+1;i++){
    //     cout << count[i]<<endl;
    // }
    cout << count[n]<<endl;
}


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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

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

  ll x;
  cin >> x;

  if (x >= 30) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include<vector>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define CEVCOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>
int main(void){
  int N; cin >> N;
  vector<vector<P>> G(N + 1);
  REP(i, N){
    int u, v, w;cin >> u >> v >> w;
    G[u].push_back(make_pair(v, w));
    G[v].push_back(make_pair(u, w));
  }
  
  vector<int> ans(N + 1 , -1);
  ans[1] = 0;
  /*q.first: nowNode , q.second: preNode*/
  queue<P> q;
  q.push({1, -1});
  while(!q.empty()){
    int now = q.front().first;
    int pre = q.front().second;
    q.pop();
    for(P p : G[now]){
      if(pre == p.first) continue;
      if(p.second % 2 == 0)  ans[p.first] = ans[now];
      else                   ans[p.first] = 1 - ans[now];
      q.push({p.first, now});
    }
  }

  for(int i = 1; i <= N ; i++)  cout << ans[i] << endl;
  
  return 0;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
template<class T> void PrintSet(const set<T> &se) {for (auto val : se) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

vector<ll> divisor(ll n)
{
    vector<ll> ret;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

int main()
{
    ll n; cin >> n;
    vector<ll> a(n);
    set<ll> p;
    rep(i, n)
    {
        cin >> a[i];
    }
    sort(ALL(a));
    //PrintVector(a);
    ll ans = 0;
    rep(i, n)
    {
        vector<ll> b = divisor(a[i]);
        //PrintSet(p);
        int f = 1;
        if (i < n - 1 && a[i] == a[i + 1]) f = 0;
        for (auto it : b)
        {
            if (p.count(it))
            {
                f = 0;
                break;
            }
        }
        if (f)
        {
            //COUT(a[i]);
            ans++;
        }
        p.insert(a[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 13904
S = list(input())
N = len(S)
A,B = '',''
if N%2 == 0:
    for i in range(N//2):
        A += '01'
        B += '10'
else:
    for i in range(N//2):
        A += '01'
        B += '10'
    A += '0'
    B += '1'

Aans,Bans = 0,0
for i in range(N):
    if S[i] != A[i]:
        Aans += 1
    if S[i] != B[i]:
        Bans += 1

print(min(Aans, Bans))

Measured memory_bytes: 4140
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Main {

    static int N;
    public static Node[] Nodes;

	static long changecount = 0;
   public static void main(String args[]) throws IOException{

	   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		N = Integer.parseInt( br.readLine()  );
	    Nodes = new Node[N];


	   String[] string =  br.readLine().split(" ");

       for(int i = 0 ; i < N ; i++){
    	   Nodes[i] =  new Node(Integer.parseInt(string[i] ) );
    	  // System.out.print("i ="+i);
       }

       //buildMaxHeap(Nodes);

       for(int i = N/2; 0 <= i ;i--){
      	// System.out.println(i);
      	 maxHeapify(i);
       }
       System.out.print(" ");
       for(int i = 0 ; i < N ; i++){

    	   System.out.print(Nodes[i].key);
    	   if(i < N-1 ){
    		   System.out.print(" ");
    	   }

       }


       System.out.println();




   }


   public static void maxHeapify(int i) {
       int left = i * 2 + 1, right = i * 2 + 2, largest;
       if (left < N && Nodes[left].key > Nodes[i].key) {
               largest = left;
       } else {
               largest = i;
       }
       if (right < N && Nodes[right].key > Nodes[largest].key) {
               largest = right;
       }

       if (largest != i) {
               int tmp = Nodes[i].key;
               Nodes[i].key = Nodes[largest].key;
               Nodes[largest].key = tmp;
               maxHeapify(largest);
       }
}





}



class Node{

	int  key;
    int index;
    Node( int x) {
        key = x;
    }

    void print(){

    	System.out.print("node "+index+": key = " +key+ ", ");
    }


}

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

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

using namespace std;

int k;
string s;

int memo[100][2][4];

int dfs(int i,bool smaller,int c){
	if(i==s.length()) return c==k?1:0;
	if(c>k) return 0;

	if(memo[i][smaller][c]!=-1) return memo[i][smaller][c];

	int res=0;
	if(smaller){
		rep(d,10){
			res+=dfs(i+1,true,c+(d==0?0:1));
		}
	}
	else{
		rep(d,s[i]-'0'+1){
			res+=dfs(i+1,d<s[i]-'0',c+(d==0?0:1));
		}
	}
	memo[i][smaller][c]=res;
	return res;
}

int main(){
	memset(memo,-1,sizeof memo);

	cin>>s>>k;
	cout<<dfs(0,false,0)<<'\n';

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

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


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



template<typename T>
T LIS(vector<T>& a) {/*長さに対する最小の最終要素*/

	T siz = a.size();
	vector<T> dp(a.size() + 10, INF);

	for (T i = 0; i < siz; i++) {
		*lower_bound(dp.begin(), dp.begin() + siz, a[i]) = a[i];
	}
	return lower_bound(dp.begin(), dp.begin() + siz, INF) - dp.begin();
}



int main() {


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

	multiset<int> st;
	int ans = 0;
	for (int i = 0; i < n;i++) {
		auto it = st.lower_bound(a[i]);
		if (it == st.begin()) {
			st.insert(a[i]);
			ans++;
		}
		else {
			--it;
			st.erase(it);
			st.insert(a[i]);
		}
	}
	cout << ans << endl;





	

	return 0;
}

Measured memory_bytes: 5760
import math._
import scala.collection.mutable.Queue

object Main {

  def calc(g: Array[Array[Int]]): Int = {
    val rows = g.length
    val cols = g(0).length

    var ans = 0
    val used = Array.fill(rows, cols)(false)
    for (i <- 0 to rows-1) {
      for (j <- 0 to cols-1) {
        if (g(i)(j) == 1 && !used(i)(j)) {
          ans += 1

          var q = new Queue[(Int, Int)]
          q.enqueue((i, j))
          while (!q.isEmpty) {
            val (r, c) = q.dequeue

            if (!used(r)(c)) {
              used(r)(c) = true
              for (dr <- -1 to 1; dc <- -1 to 1) {
                val row = r + dr
                val col = c + dc
                if (0 <= row && row < rows && 0 <= col && col < cols) {
                  if (g(row)(col) == 1 && !used(row)(col)) {
                    q.enqueue((row, col))
                  }
                }
              }
            }
          }
        }
      }
    }
    ans
  }

  def main(args: Array[String]) {
    val sc = new java.util.Scanner(System.in)

    var b = true
    while (b) {
      val w, h = sc.nextInt
      if (w == 0 && h == 0) {
        b = false
      }
      else {
        var g = Array.fill(h, w)(0)
        for (i <- 0 to h-1) {
          for (j <- 0 to w-1) {
            g(i)(j) = sc.nextInt
          }
        }

        println(calc(g))
      }
    }
  }
}

Measured memory_bytes: 70644
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rrep(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr ll INF = (ll)1e9;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	string s; cin >> s;
	int red = 0;
	rep(i, 0, s.size())if (s[i] == 'R')++red;
	string str = s;
	sort(all(str));
	int ans = 0;
	rep(i, 0, s.size()) {
		if (s[i] != str[i])++ans;
	}
	cout << ans / 2 << "\n";

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int s[15];
  s[0]=N/2+N/4+N/8+N/16+N/32+N/64;
  s[1]=N/3+N/9+N/27+N/81;
  s[2]=N/5+N/25;
  s[3]=N/7+N/49;
  s[4]=N/11;
  s[5]=N/13;
  s[6]=N/17;
  s[7]=N/19;
  s[8]=N/23;
  s[9]=N/29;
  s[10]=N/31;
  s[11]=N/37;
  s[12]=N/41;
  s[13]=N/43;
  s[14]=N/47;
  int a=0;
  int b=0;
  int c=0;
  int d=0;
  int e=0;
  for(int i=0;i<15;i++){
  		if(s[i]>=2)a++;
		 
		if(s[i]>=4)b++;
		
		if(s[i]>=14)c++;
		
		if(s[i]>=24)d++;
		
		if(s[i]>=74)e++;
		  
  }
  
  int ans=0;
  if(b>=2)ans+=(a-2)*b*(b-1)/2;
  if(d>=1)ans+=d*(a-1);
  if(c>=1)ans+=c*(b-1);
  if(e>=1)ans+=e;
  cout << ans << endl;
  
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int M = in.nextInt();
        int s[] = new int[M];
        int c[] = new int[M];
        for(int i=0; i<M; i++){
            s[i] = in.nextInt();
            c[i] = in.nextInt();
        }

        boolean flag = true;
        int num[] = new int[N];

        for(int i=0; i<N; i++){
            num[i] = -1;
        }

        for(int i=0; i<M; i++){
            if(s[i]-1 > N){
                flag = false;
                break;
            }
            if(num[s[i]-1] == -1){
                num[s[i]-1] = c[i];
            }else{
                if(num[s[i]-1] != c[i]){
                    flag = false;
                    break;
                }
            }
        }

        //
        if(num[0] == 0 && N != 1) flag = false;

        if(flag){
            for(int i=0; i<num.length; i++){
                if(i==0){
                    if(num.length != 1 && num[i] == -1) System.out.print("1");
                    else if(num.length == 1 && num[i] == -1) System.out.print("0");
                    else System.out.printf("%d", num[i]);
                }else{
                    if(num[i] == -1) System.out.print("0");
                    else System.out.printf("%d", num[i]);
                }     
            }
        }else{
            System.out.print("-1");
        }
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define endl '\n'
#define line cout<<"----------------------"<<endl
#define mp make_pair
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
const ll  mx=300009;
vector<pair<ll ,ll > > v;
ll  dp[100001][109];
int main()
{
    ll  n,w;
    cin>>n>>w;
    for(ll  i=0;i<n;i++)
    {
        ll  a,b;
        cin>>a>>b;
        v.pb(mp(a,b));
    }
    for(int i=1;i<=w;i++)
    {

        for(int j=0;j<n;j++)
        {
            dp[i][j]=dp[i][j-1];
            if(v[j].first>i) continue;
            dp[i][j]=max(dp[i][j],dp[i-v[j].first][j-1]+v[j].second);
        }
    }
    cout<<dp[w][n-1]<<endl;
}
/*
3 5
3 3
4 2
2 4
*/


Measured memory_bytes: 85376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
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 _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int mod=1e9+7;


template< typename T >
struct BinaryIndexedTree {
  vector< T > data;
  int n;
 
  BinaryIndexedTree(int sz) {
    n=sz;
    data.assign(++sz, 0);
  }
 
  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }
 
  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
 
  T sum_between(int i, int j){
      if(i>j)return 0;
      return sum(j)-sum(i-1);
  }
 
  // a[0]+...+a[ret+1] >= x
    int lower_bound(T x){
        int ret = -1;
        int k = 1;
        while(2*k <= n) k <<= 1;
        for( ;k>0; k>>=1){
            if(ret+k < n && data[ret+k] < x){
                x -= data[ret+k];
                ret += k;
            }
        }
        return ret + 1;
    }

    void print(){
      rep(i,n){
        if(i)cout<<" ";
        cout<<sum_between(i,i);
      }
      cout<<endl;
    }
};

int main(){
  int n;cin>>n;
  int a[n];rep(i,n)cin>>a[i];
  int ok=1e9+7;
  int ng=0;
  while(ok-ng>1){
    int mid=(ok+ng)/2;
    int b[n+1];b[0]=0;
    rep(i,n){
      b[i+1]=(mid-a[i]>=0?1:-1);
      b[i+1]+=b[i];
    }
    vector<int> sortedb(n+1);rep(i,n)sortedb[i+1]=b[i+1];
    sortedb[0]=0;
    sort(all(sortedb));
    sortedb.erase(unique(all(sortedb)),sortedb.end());
    BinaryIndexedTree<int> BIT(n+1);
    ll ctr=0;
    rep(i,n+1){
      int bindex=lower_bound(all(sortedb),b[i])-sortedb.begin();
      ctr+=BIT.sum(bindex-1);
      BIT.add(bindex,1);
    }
    if(ctr>1ll*n*(n+1)/4)ok=mid;
    else ng=mid;
  }
  cout<<ok<<endl;
}

Measured memory_bytes: 1856