akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

int main() {
    int N, K;
    int ans = 1;

    cin >> N >> K;

    for (int i = 1; i <= N; i++) {
        int A = ans * 2;
        int B = ans + K;
        if (A > B) {
            ans = B;
        } else if (A < B) {
            ans = A;
        } else if (A == B) {
            ans = A;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
date = input()
if date == "SUN":
    print(7)
elif  date == "MON":
    print(6)
elif  date == "TUE":
    print(5)
elif  date == "WED":
    print(4)
elif  date == "THU":
    print(3)
elif  date == "FRI":
    print(2)
else:
    print(1)


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



int main() {
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	string ans = "";
	int f = 0;
	for (int i = 0; i < n;) {
		ans += f ? t[i] : s[i];
		i += f;
		f ^= 1;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
n = int(input())
ans = [[0 for i in range(3)] for i in range(n)]

for i in range(3):
    for j in input().split():
        for k, l in enumerate(j):
            ans[k][i] = l
a = 0
for i in ans:
    a += len(set(i))-1
print(a)


Measured memory_bytes: 9116
#include <stdio.h>

int key[500001];
int left[500001];
int right[500001];
int root;
int head;

void printpre(int i){
    if(i == -1) return;
    printf(" %d", key[i]);
    printpre(left[i]);
    printpre(right[i]);
}

void printin(int i){
    if(i == -1) return;
    printin(left[i]);
    printf(" %d", key[i]);
    printin(right[i]);
}

void insert(int z){
    int y = -1;
    int x = root;
    while(x != -1){
        y = x;
        if(z < key[x])
            x = left[x];
        else
            x = right[x];
    }

    if(y == -1) {
        root = head;
    } else if(z < key[y]) {
        left[y] = head;
    } else {
        right[y] = head;
    }
    key[head] = z;
    left[head] = -1;
    right[head] = -1;
    head++;
}

int main(void){
    int n;
    scanf("%d", &n);
    root = -1;
    while(n--){
        char cmd[8];
        scanf("%s", cmd);
        if(cmd[0] == 'i'){
            int z;
            scanf("%d", &z);
            insert(z);
        } else {
            printin(root);
            puts("");
            printpre(root);
            puts("");
        }
    }
}



Measured memory_bytes: 7632
n, t = map(int, input().split())
a = [tuple(map(int, input().split())) for _ in range(n)]
a.sort()

d = [0] * (6000)
for c, v in a:
    for i in reversed(range(t)):
        d[i+c] = max(d[i+c], d[i] + v)

print(max(d))

Measured memory_bytes: 46168
#include <iostream>

using namespace std;

int main()
{
  int a, b, c, i, ans = 0;
  cin >> a >> b >> c;
  ans = i; 
  for(i=a; i<=b; i++)
  {
    if( c % i == 0 )
       ans = ans+1;
  }
  cout << ans << endl;
} 



Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz 100005
ll ar[sz];

int main()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);
	    freopen("output.txt","w",stdout);
	#endif

string s;
cin>>s;
if(s=="SUN") cout<<"7"<<endl;
if(s=="MON") cout<<"6"<<endl;
if(s=="TUE") cout<<"5"<<endl;
if(s=="WED") cout<<"4"<<endl;
if(s=="THU") cout<<"3"<<endl;
if(s=="FRI") cout<<"2"<<endl;
if(s=="SAT") cout<<"1"<<endl;

}

Measured memory_bytes: 3532
n = gets.chomp.to_i
as = gets.split.map(&:to_i)
h = Hash.new(0)
as.each do |a|
  h[a-1] += 1
  h[a] += 1
  h[a+1] += 1
end
puts h.sort_by { |k,v| v }.last.last


Measured memory_bytes: 21248
#include <cstdio>
#include <algorithm>

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

using namespace std;

int n, m;
int x[1400][1400];
int dp[1400][1400];

int main(){
	scanf("%d%d", &n, &m);
	rep(i, n){
		rep(j, m){
			scanf("%d", &x[i][j]);
		}
	}
	rep(i, n){
		dp[i][0] = !x[i][0];
	}
	rep(i, m){
		dp[0][i] = !x[0][i];
	}
	for(int i = 1; i < n; ++i){
		for(int j = 1; j < m; ++j){
			if(!x[i][j]){
				dp[i][j] = min(dp[i - 1][j - 1], min(dp[i][j - 1], dp[i - 1][j])) + 1;
			}
		}
	}
	int ans = 0;
	rep(i, n){
		rep(j, m){
			ans = max(dp[i][j], ans);
		}
	}
	printf("%d\n", ans * ans);
	return 0;
}

Measured memory_bytes: 15872
#include <iostream>

using namespace std;

int main()
{
    int r,x,d;
    int n;
    int v;
    int a;
    int y;
    int p;
    int m;
    int u;
    int o;
    int e;
    int q;
    cin >>r>>d>>x;
    n=r*x-d;
    cout<<n<< endl;
    v=n*r-d;
    cout<<v<<endl;
    a=v*r-d;
    cout<<a<<endl;
    y=a*r-d;
    cout<<y<<endl;
    p=y*r-d;
    cout<<p<<endl;
    m=p*r-d;
    cout<<m<<endl;
    o=m*r-d;
    cout<<o<<endl;
    u=o*r-d;
    cout<<u<<endl;
    e=u*r-d;
    cout<<e<<endl;
    q=e*r-d;
    cout<<q<<' ';
    return 0;

}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()) {
  v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t) {
  stringstream ss;
  ss << f;
  ss >> t;
}


#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb push_back


#define MOD 1000000007LL
#define EPS 1e-8


int main() {
  string w;
  cin >> w;
  int a[32] = {0};
  for (char s : w) {
    a[s - 'a']++;
  }
  bool b = false;
  rep(i, 32) {
    if (a[i] & 1)b = true;
  }
  cout << (b ? "No" : "Yes") << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

def dil(i):
    if 1<=i<=8:
        return [i-1,i,i+1]
    if i==0:
        return [0,1]
    if i==9:
        return [8,9]

K = I()

#dp[i][j][k]:i桁，スタートj,ラストk
dp = [[[0]*10 for _ in range(10)] for _ in range(12)]
for i in range(10):
    dp[1][i][i] = 1

for i in range(2,12):
    for j in range(10):
        for k in range(10):
            if 1<=k<=8:
                dp[i][j][k] = dp[i-1][j][k-1]+dp[i-1][j][k]+dp[i-1][j][k+1]
            if k==0:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j][k+1]
            if k==9:
                dp[i][j][k] = dp[i-1][j][k-1]+dp[i-1][j][k]

#dp2[i][j]: i桁，スタートjのルンルン数の総数
dp2 = [[0]*10 for _ in range(12)]
for i in range(12):
    for j in range(10):
        dp2[i][j] = sum(dp[i][j])

i = 1
aa = 0
while 1:
    if aa+sum(dp2[i][1:]) >= K:
        L = i
        break
    aa += sum(dp2[i][1:])
    i += 1

for i in range(L):
    K -= sum(dp2[i][1:])

temp = 0
now = 0
ans = ''
dl = [i for i in range(1,10)]
for l in range(L):
    last_j = dl[0]
    for j in dl:
        if temp+now+dp2[L-l][j]>=K:
            break
        else:
            now += dp2[L-l][j]
            last_j = j+1
    ans += str(last_j)
    temp = temp+now
    now = 0
    dl = dil(last_j)

print(int(ans))

Measured memory_bytes: 38772
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    vpl A(N); 
    F0R(i, N) {
        ll X; cin >> X;
        A[i] = {X, i};
    }
    sort(all(A)); reverse(all(A));
    ll dp[N+1][N+1]; F0R(i, N+1) F0R(j, N+1) dp[i][j] = -1000000000000000;
    dp[0][0] = 0;
    F0R(i, N) {
        F0R(j, i+1) {
            ll X = A[i].f;
            ll P = A[i].s;
            ll D1 = abs(A[i].s - j);
            ll D2 = abs(N-1-(i-j)-A[i].s);
            dp[i+1][j] = max(dp[i+1][j], dp[i][j] + X * D2);
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + X * D1);
        }
    }
    ll ans = 0;
    F0R(i, N+1) {
        ans = max(ans, dp[N][i]);
    }
    cout << ans << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 34984
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cout << v << " ";                                                          \
  }                                                                            \
  cout << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
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;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  string S, T;
  cin >> S >> T;
  int ans = 0;
  REP(i, 3) {
    if (S[i] == T[i])
      ans++;
  }
  print(ans);
}

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

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int Q = sc.nextInt();
    int[] T = new int[Q];
    int[] F = new int[Q];
    char[] C = new char[Q];
    for (int i = 0; i < Q; i++) {
      T[i] = sc.nextInt();
      if (T[i] == 2) {
        F[i] = sc.nextInt();
        C[i] = sc.next().charAt(0);
      }
    }
    sc.close();

    StringBuilder pre = new StringBuilder();
    StringBuilder suf = new StringBuilder();
    boolean rev = false;
    for (int i = 0; i < Q; i++) {
      if (T[i] == 1) {
        rev = !rev;
      } else {
        if (rev ^ F[i] == 1) {
          pre.append(C[i]);
        } else {
          suf.append(C[i]);
        }
      }
    }
    pre.reverse();

    StringBuilder ans = new StringBuilder()
        .append(pre)
        .append(S)
        .append(suf);
    if (rev) ans.reverse();
    System.out.println(ans);
  }
}

Measured memory_bytes: 158052
n = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(n-2):
    a,b,c = p[i],p[i+1],p[i+2]
    if (a<b and b<c) or (a>b and b>c):
        ans += 1
print(ans)

Measured memory_bytes: 3060
//om namah shivaay
//faith over fear
//no one wants to die,yet death is the destination we all share 

#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

ll a[1002];
int main(){
    ll n,k;
    cin>>n>>k;
    forn(i,n) cin>>a[i];
    sort(a,a+n);
    ll s=0;
    forn(i,k) s+=a[i];
    cout<<s;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
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;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;

int lcm(int m, int n)
{
    if ((0 == m) || (0 == n))
        return 0;

    return ((m / gcd(m, n)) * n);  // lcm = m * n / gcd(m,n)
}  //lcm

signed main()
{
    int k;
    cin >> k;
    std::vector<int> a(k);
    std::vector<int> bigger(k);
    std::vector<int> smaller(k);
    for (int i = 0; i < k; i++) {
        cin >> a[i];
        bigger[i] = a[i] * 2 - 1;
        smaller[i] = a[i];
    }
    if (a[k - 1] != 2) {
        cout << -1 << endl;
    } else {
        for (int i = k - 2; i >= 0; i--) {
            bigger[i] = ((bigger[i + 1] / a[i]) + 1) * a[i] - 1;
            smaller[i] = (a[i] >= smaller[i + 1]) ? a[i] : (a[i] * min((int)1, smaller[i + 1] % a[i])) + smaller[i + 1] - smaller[i + 1] % a[i];
            if (a[i] > bigger[i + 1] || smaller[i] > bigger[i]) {
                cout << -1 << endl;
                return 0;
            }
        }
        cout << smaller[0] << " " << bigger[0];
    }
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int n;
    cin>>n;
    if(n%1000==0){
      cout<<0<<endl;
    }else
    {
       int ans=1000-n%1000;
       cout<<ans<<endl;
    }
    
   
	
	return 0;
}

Measured memory_bytes: 3656
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    N = int(input())
    A_lsit = list(map(int, input().split()))

    A_square_list = [A**2 for A in A_lsit]

    sum_A = sum(A_lsit)
    sum_A_square = sum(A_square_list)

    print( ((sum_A**2 - sum_A_square)// 2) % 1000000007 )

if __name__ == "__main__":
    main()



Measured memory_bytes: 31424
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>

#define llong long long
#define rep(i,l,n) for(llong (i)=(l);(i)<(n);(i++))
#define _min(a,b) ((a)<(b)?(a):(b))
#define _max(a,b) ((a)>(b)?(a):(b))
#define _abs(a) ((a)>0?(a):(-(a)))

using namespace std;

int main(){
	int N;
	cin >> N;
	int count = 0;
	rep(i,0,N){
		int a,b;
		cin >> a >> b;
		if( a==b ){
			count++;
		}else{
			count = 0;
		}
		if( count==3 ){
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
}


Measured memory_bytes: 3636
//coded by: pranonrahman-------------------------------------
//-----------------------------------------------------------
//-----------------------------------------------------------
#include<bits/stdc++.h>
using namespace std;


#define O_O ios_base::sync_with_stdio(0); cin.tie(NULL)
#define endl '\n'
#define PI acos(-1.0)
#define CASE(n) cout << "Case " << n << ": "
#define CASE_(n) cout << "Case " << n << endl
#define FIXED(n) cout << fixed << setprecision(n)
#define MOD 1000000007

inline void normal(long long &a) { a %= MOD; (a < 0) && (a += MOD); }
inline long long modMul(long long a, long long b) { normal(a), normal(b); return (a*b)%MOD; }
inline long long modAdd(long long a, long long b) { normal(a), normal(b); return (a+b)%MOD; }
inline long long modSub(long long a, long long b) { normal(a), normal(b); a -= b; normal(a); return a; }
inline long long modPow(long long b, long long p) { long long r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline long long modInverse(long long a) { return modPow(a, MOD-2); }
inline long long modDiv(long long a, long long b) { return modMul(a, modInverse(b)); }


int main()
{
    O_O;
#ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
#endif
    long long t=1;
    //cin >> t;
    long long T = t;
    while(t--)
    {
        //write your code here
        int n;
        cin >> n;
        int arr[n+5];
        int cThik =0,cVul =0;
        for(int i=0;i<n;i++)
        {
        	cin >> arr[i];
        	if(arr[i]==i+1)	cThik++;
        	else 			cVul++;
        }
        if(cVul<=2)	cout << "YES\n";
        else 		cout << "NO\n";
    }
    return 0;
}




Measured memory_bytes: 3652
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int A, B, C;

int main() {
    cin >> A >> B >> C;

    if (A == B and B == C) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')

typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int n;
bool check(vector<vector<int>> cnt, int s)
{
    for (int i = 0; i < n; i++)
    {
        if ((s >> i) & 1)
        {
            for (int j = 0; j < n; j++)
            {
                if (cnt[i][j] != -1 && cnt[i][j] != (s >> j & 1))
                    return false;
            }
        }
    }
    return true;
}
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    //int n;
    cin >> n;
    //vector<int> cnt(n + 1, 1);
    vector<vector<int>> cnt(n, vector<int>(n, -1));
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        //bool ok = 1;
        for (int j = 1; j <= a; j++)
        {
            int x, y;
            cin >> x >> y;
            x--;
            cnt[i][x] = y;
        }
    }
    int num = (1 << n) - 1;
    //cout << "num:" << num << "\n";
    for (int s = 0; s <= num; s++)
    {
        //bool ok = 1;
        if (check(cnt, s))
        {
            ans = max(ans, __builtin_popcount(s));
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 r, d, x;
  cin >> r >> d >> x;
  for (i64 i = 0; i < 10; i++)
  {
    x = r * x - d;
    cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 256
fn main() {
    let (x, y) = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let mut iter = s.split_whitespace().map(|i| i.parse::<i32>().unwrap());
        (iter.next().unwrap(), iter.next().unwrap())
    };

    if x * 4 < y {
        println!("No");
        return;
    }
    if x * 2 > y {
        println!("No");
        return;
    }
    if (x * 2 - y) % 2 == 0 {
        println!("Yes");
        return;
    }
    println!("No");
}

Measured memory_bytes: 2160
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
#define int lint
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
signed main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n)
    {
        cin >> v.at(i);
    }
    sort(v.begin(), v.end());
    vector<bool> flag(v.at(n - 1) + 1, true);
    int ans = 0;
    int skip = -1;
    rep(i, n)
    {
        if (skip == v.at(i))
            continue;
        if (flag.at(v.at(i)))
        {
            if (i != n - 1 && v.at(i) == v.at(i + 1))
                skip = v.at(i);
            else
                ans++;
            for (int p = 2 * v.at(i); p <= v.at(n - 1); p += v.at(i))
            {
                flag.at(p) = false;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4780
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.000001
#define pi 3.141592653589793
#define pii pair<int,int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define sti stack <int>
#define stll stack <ll>
#define mseti multiset <ll>
#define msetd multiset <ll, greater <ll> >
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define stp setprecision(12)//use fixed before stp
#define endl '\n'
ll ans[100009];
ll e[100009];
void dfs(vpl v[],ll q,ll w)
{
    if(w%2==1)
        ans[q]=1;
    e[q]=1;
    for(auto i:v[q])
    {
        if(e[i.ff]==0)
            dfs(v,i.ff,(w+i.ss));
    }
}
int main()
{  
    FAST
    ll n;
    cin>>n;
    vpl v[n+1];
    ll x,y,z;
    for(ll i=1;i<n;i++)
    {
        cin>>x>>y>>z;
        v[x].pb(mp(y,z));
        v[y].pb(mp(x,z));
    }
    dfs(v,1,0);
    for(ll i=1;i<=n;i++)
    {
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 10752
a = input()
b = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
     "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
i = 0
while len(a) > i:
    if a[i] in b:
        b.remove(a[i])
    else:
        pass
    i += 1
if not b:
    print("None")
else:
    print(b[0])


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n,k;
  cin >> n >> k;
  if(k%2) {
    ll ans=(n/k)*(n/k)*(n/k);
    cout << ans << endl;
  }
  else {
    n/=(k/2);
    ll ans=(n/2)*(n/2)*(n/2)+((n+1)/2)*((n+1)/2)*((n+1)/2);
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){	
	int result=0;
	string S;
	cin>>S;
	while((int)S.length()>1){
		if(S[0]==S[(int)S.length()-1]){
				S.erase(0,1);
				S.erase((int)S.length()-1);
		}else if(S[0]=='x'){
			result++;
			S.erase(0,1);
		}else if(S[(int)S.length()-1]=='x'){
			result++;
			S.erase((int)S.length()-1);
		}else{
			print("-1");
			return 0;
		}
	}
	print(result);
	return 0;
}



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

int main() {
    long
     x1,l1,x2,l2,t;
    cin >> x1 >> l1 >> x2 >> l2 >> t;
    if(x1 > x2){
        x1 = x1 - l1*t;
        x2 = x2 - l2*t;
        if(x1 <= x2){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }else{
        x1 = x1 + l1*t;
        x2 = x2 + l2*t;
        if(x2 <= x1){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }

    return 0;

 }


Measured memory_bytes: 3624
#include <stdio.h>

int main( void )
{
    int a;
    int b;
    int c;
    
    scanf("%d %d %d",&a,&b,&c);
    
    if(( a < b ) && ( b < c )){
        printf("Yes\n");
    } else {
        printf("No\n");
    }
        
    return 0;
}

Measured memory_bytes: 1812
//17571@nith.ac.in @Ankit Verma
#include <bits/stdc++.h>
#define ff  first
#define ss  second
#define pb  push_back
#define ll  long long
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define ld  long double
#define eb  emplace_back
#define ull unsigned long long
#define all(v) v.begin(), v.end()
#define f(i,x,n)  for(int i=x;i<n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
#define bolt ios::sync_with_stdio(false)
using namespace std;

void IoI() {
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}

int32_t main() {
	//IoI();
	bolt;
	cin.tie(nullptr);
	cout.tie(nullptr);
	ll a, b, c; cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);
	cout << a << " " << b << " " << c << endl;
	

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long w = sc.nextLong();
		sc.close();
		if (h == 1 || w == 1) {
			System.out.println(1);
			return;
		}
		long v = h * w;
		if (v % 2 == 0) {
			System.out.println(v / 2);
		} else {
			System.out.println((v / 2) + 1);
		}
	}
}


Measured memory_bytes: 22740
#include<stdio.h>

int main(void)
{
	long a;
	long b;
	long gcd;
	long lcm;
	long r;
	long a2;
	long b2;
	
	while(scanf("%ld %ld", &a, &b) != EOF){
		a2 = a;
		b2 = b;
		while(1){
			if(a > b){
				r = a % b;
				if(r == 0){
					gcd = b;
					break;
				}
				a = b;
				b = r;
			}
			else if(b > a){
				r = b % a;
				if(r == 0){
					gcd = a;
					break;
				}
				b = a;
				a = r;
			}
			else {
				gcd = a;
				break;
			}
		}
		lcm = a2 * b2 / gcd;
		
		printf("%ld %ld\n", gcd, lcm);
	}
	
	return (0);
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
// グリッドの(i, j)を中心とした周囲のマス
const int aroTblX[8] = {  1,  1,  1,  0, -1, -1, -1,  0 };
const int aroTblY[8] = { -1,  0,  1,  1,  1,  0, -1, -1 };
int main()
{
  int H, W;
  cin >> H >> W;
  char grid[H][W];
  // 入力された値を配列に保存
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      cin >> grid[i][j];
    }
  }
  // 各マスの設定
  for (int i = 0; i < H; ++i)
  {
    for (int j = 0; j < W; ++j)
    {
      if (grid[i][j] == '#')
      {
		// 入力が#の場合はそのまま出力
        cout << grid[i][j];
        continue;
      }
      else if (grid[i][j] == '.')
      {
        // 入力が.の場合は周囲のマスを検索
        int cntMine = 0;
        for (int k = 0; k < 8; ++k)
        {
          int around_x = i + aroTblX[k];
          int around_y = j + aroTblY[k];
          if (around_x < 0 || around_x >= H || around_y < 0 || around_y >= W)
          {
            // マスが枠外に出てしまう場合は無視
            continue;
          }
          if (grid[around_x][around_y] == '#')
          {
            // 周囲マスに#があったら数値を加算
            ++cntMine;
          }
        }
        grid[i][j] = '0' + cntMine;	// 加算して文字列として渡す
      }
      cout << grid[i][j];
    }
    cout << endl;
  }
  return 0;
}

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

#define ft first
#define sd second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define x x__
#define y y__

using namespace std;

typedef long long int ll;
typedef long double ld;

const int MAXN = 300;
const int INF = 1000000010;
const ll MOD = 1000000007LL;

int N;
char s[MAXN], t[MAXN];
char ans[MAXN];

int main() {
    scanf("%d", &N);
    scanf("%s", s);
    scanf("%s", t);

    for (int i = N; i <= 2*N; ++i) {
        for (int j = 0; j < N; ++j) {
            ans[j] = s[j];
        }
        for (int j = 0; j < N; ++j) {
            ans[i-j-1] = t[N-j-1];
        }

        bool flag = true;
        for (int j = 0; j < N; ++j) {
            if (ans[j] != s[j]) {
                flag = false;
            }
        }

        if (flag) {
            printf("%d", i);
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int main(){
	int k;
	cin>>k;
	int cur=7%k;
	if(cur==0){
		cout<<1<<endl;
		return 0;
	}
	for(int i=2;i<=k+1000;i++){
		cur=cur*10%k+7%k;
		cur%=k;
		if(cur==0){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 3188
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<string>
using namespace std;

/*
??£???????¨????
	ax + by = c
	dx + ey = f
????§£x, y???????????????????????°??????
*/
int main() {
	double a, b, c, d, e, f;
	int cnt = 0;						//??\??????????????£???????¨????????????°
	std::vector<double> x_vector;		//x????§£???????´?
	std::vector<double> y_vector;		//y????§£???????´?

#if 0
	while (cnt < 1) {
		cin >> a >> b >> c >> d >> e >> f;
#else
	while (cin >> a >> b >> c >> d >> e >> f) {
#endif
		if (
			(a < -1000) || (1000 < a) ||
			(b < -1000) || (1000 < b) ||
			(c < -1000) || (1000 < c) ||
			(d < -1000) || (1000 < d) ||
			(e < -1000) || (1000 < e) ||
			(a < -1000) || (1000 < f)
			) {
			break;
		}
		double x = (b * f - c * e) / (b * d - a * e);
		double y = (c * d - a * f) / (b * d - a * e);

		cnt++;
		x_vector.push_back(x);
		y_vector.push_back(y);
	}

	for (unsigned int i = 0; i < cnt; i++) {
		std::cout << std::fixed << std::setprecision(3) << x_vector[i] + 0 << " ";
		std::cout << std::fixed << std::setprecision(3) << y_vector[i] + 0 << endl;
	}

	cnt = 0;
	x_vector.clear();
	y_vector.clear();

	//???????????°
	//while (1);

	return 0;
}

Measured memory_bytes: 3244
# 0 ≦ X, Y, Z ≦ K
# X + Y + Z = S
# 2 ≦ K ≦ 2500
# 0 ≦ S ≦ 3K

K, S = list(map(int, input().split()))

cnt = 0
# X
for i in range(K + 1):
    # Y
    for j in range(K + 1):
        Z = S - i - j
        if 0 <= Z and Z <= K:
            cnt += 1
print(cnt)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    ll a, b, k;
    cin >> a >> b >> k;
    cout << max(0LL, a - k) << " " << max(0LL, min(b, b - (k - a))) << endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	string S;
	cin >> S;
	string a[S.size()];
	for (int i = 0; i < S.size(); i++) {
		a[i] = "x";
	}
	for (int i = 0; i < S.size(); i++) {
		cout << a[i];
	}
}


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

int n;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++){
			if(i*j == n){
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#define scanf_s scanf
#include <string>
#include <stdio.h>
#include <math.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <iostream>
using namespace std;

#define MAX 500000
#define MAX_  2000000000
struct tree
{
	long long int key = MAX_ + 1;
	tree *left = NULL, *right = NULL, *p = NULL;
};
void insert(tree &T,tree &z)
{
	tree *y = NULL , *x = &T;
	while (x->key != MAX_ + 1) {
		y = x;
		if (z.key < x->key) { x = x->left; }
		else { x = x->right; }
		if (x == NULL) break;
	}
	z.p = y;
	if (y == NULL) { 
		T = z; 
	}
	else if (z.key < y->key) { 
		y->left = &z; 
	}
	else { 
		y->right = &z; 
	}
}
void print_1(tree *T) {
	if (T != NULL) {
		printf(" %lld", T->key);
		print_1(T->left);
		print_1(T->right);
	}
}
void print_2(tree *T) {
	if (T != NULL) {
		print_2(T->left);
		printf(" %lld", T->key);
		print_2(T->right);
	}
}

int main() {
	int m, cou = 0;
	string s;
	tree t, id[MAX];
	scanf_s("%d", &m);
	for (int i = 0; i < m; ++i) {
		cin >> s;
		if (s == "insert") {
			scanf_s("%lld", &id[cou].key);
			insert(t, id[cou]);
			++cou;
		}
		else {
			print_2(&t);
			printf("\n");
			print_1(&t);
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 34552
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    while(--k >= 0){
        vector<int> b(n+1, 0);
        for(int i=0; i<n; ++i){
            ++ b[max(i-a[i], 0)];
            -- b[min(i+a[i]+1, n)];
        }
        for(int i=0; i<n; ++i)
            b[i+1] += b[i];
        b.resize(n);
        a = move(b);
        if(a == vector<int>(n, n))
            break;
    }

    cout << a[0];
    for(int i=1; i<n; ++i)
        cout << ' ' << a[i];
    cout << endl;

    return 0;
}


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

using namespace std;

void solve() {
    int n; cin >> n;
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0 || i % 5 == 0)
            continue;
        ans += i;
    }
    cout << ans;
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long
#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++)

using namespace std;

int main() {
  string s;
  cin >> s;
  int a_index = s.find('A');
  int z_index = s.find_last_of('Z');
  cout << (z_index - a_index) + 1 << "\n";

  return(0);
}


Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))
cnt = 0
sum_a = sum(list(map(abs, a)))
min_a = min(list(map(abs, a)))
for i in a:
  if i < 0:
    cnt += 1
if cnt%2 == 0:
  print(sum_a)
else:
  print(sum_a-min_a*2)

Measured memory_bytes: 14412
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		int ans = Integer.MAX_VALUE;
		for(int i = a[0]; i <= a[n-1]; i++) {
			int x = 0;
			for(int j = 0; j < n; j++) {
				x += (int)Math.pow(a[j]-i, 2);
			}
			if(x < ans) {
				ans = x;
			}
		}
		System.out.println(ans);
	}


	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

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

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 22612
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#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 _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n;cin>>n;
  vector<int> a(n);
  rep(i, n) {
    cin>>a[i];
  }
  dump(a);

  multiset<int> S;
  S.insert(-1);
  rep(i, 0, n){
    auto it = S.lower_bound(a[i]);
    it--;
    if (*it==-1) {
      dump("hello");
      S.insert(a[i]);
    }
    else{
      S.erase(it);
      S.insert(a[i]);
    }
    dump(S);
  }
  cout << sz(S)-1 << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


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

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

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

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

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

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

int main() {
    int h, w;
    cin >> h >> w;

    int n;
    cin >> n;

    queue<int> colors;
    rep(i, n) {
        int a;
        cin >> a;
        rep(j, a)colors.push(i);
    }

    vector<vector<int>> picture(h, vector<int>(w, 0));

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            picture[i][j] = colors.front();
            colors.pop();
        }
    }

    rep(i, h) {
        if (i % 2 == 0) continue;
        reverse(picture[i].begin(), picture[i].end());
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << picture[i][j] + 1 << ' ';
        }
        cout << endl;
    }


}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt();
		int sum = 0;
		for (int i = 0; i < x; i++) {
			if (isPrime(scanner.nextInt()))
				sum++;
		}
		System.out.println(sum);
	}

	public static boolean isPrime(int i) {
		if (i == 2)
			return true;
		if (i % 2 == 0)
			return false;
		int k = 3;
		while (k <= Math.sqrt(i)) {
			if (i % k == 0)
				return false;
			k += 2;
		}
		return true;
	}
}

Measured memory_bytes: 29412
import java.util.Scanner;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.Arrays;
import java.util.Stack;

public class Main {
	static Scanner scn = new Scanner(System.in);
	static int count = 0, min = Integer.MAX_VALUE;

	public static void main(String[] args) 
	{
		int n =scn.nextInt();
		System.out.println(n*n);
		
	}
	public  static void subset(int arr[], int k, int sum, String ans, int prev) {
		if (sum == k) {
			System.out.print(ans + " ");
			return;
		}
		if (sum > k)
			return;

		for (int i = prev; i < arr.length; i++) {
			subset(arr, k, sum + arr[i], ans + arr[i], i);
		}
	}

	public static int gcd(int a, int b) {
		if (a == 0)
			return b;
		int l = gcd(b % a, a);
		return l;
	}

	public static void grid(int arr[][], int h, int v, int sum, int n, int m) {
		if (h == n - 1 && v == m - 1) {
			sum = sum + arr[h][v];
			if (sum <= min)
				min = sum;
			return;
		}
		if (h >= n)
			return;
		if (v >= m)
			return;
		grid(arr, h + 1, v, sum + arr[h][v], n, m);
		grid(arr, h, v + 1, sum + arr[h][v], n, m);
		grid(arr, h + 1, v + 1, sum + arr[h][v], n, m);
	}

	public static int  last(int arr[],int m,int i)
	{	
		if(i==arr.length)
		{	
			return -1;	
		}
		int s=last(arr, m, i+1);
		if(arr[i]==m && s==-1)
		{	
			return i;
		}
		return s;
		
	}
}


Measured memory_bytes: 23764
#include <cstdio>
#include <string>
#include <iostream>

int main(){
        std::string S;
        int ans=0;
        int N ;
        bool b = true;
        std::cin >> S;
        N = (int)(S.length());

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


                if ( b){
                        if (S[i] == '0'){
                                        ans += 1;
                        }
                        b = false;
                } else {
                        if (S[i] == '1'){
                                        ans += 1;
                        }

                        b = true;
                }

        }
        if ( ans > N/2 )
                        ans = N -ans;

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

        return 0;
}

Measured memory_bytes: 512