akhauriyash/Code-Regression huggingface dataset:
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#include<numeric>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

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

    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: 256
#include<stdio.h>

int main()
{
  int i,n,num=0,a[100],temp,flag;
  scanf("%d",&n);
  for (i = 0; i < n; i++) 
    scanf("%d",&a[i]);
  flag = 1;
  while(flag == 1) {
  flag=0;
  for (i =n-2; i >=0;i--) {
    if(a[i]>a[i+1]){
      temp = a[i+1];
      a[i+1] = a[i];
      a[i] = temp;
      num++;
      flag = 1;
    }
  }
  }
  for(i = 0; i<n-1;i++)
    printf("%d ",a[i]);
  printf("%d\n",a[n-1]);
  printf("%d\n",num);
  return 0;
}

Measured memory_bytes: 1792
import java.io.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.StringTokenizer; 
import java.util.*;


public  class Main 
{

	   
	   static class FastReader 
	    { 
	        BufferedReader br; 
	        StringTokenizer st; 
	       
	  
	        public FastReader() 
	        { 
	            br = new BufferedReader(new
	                     InputStreamReader(System.in)); 
	        } 
	  
	        String next() 
	        { 
	            while (st == null || !st.hasMoreTokens()) 
	            { 
	                try
	                { 
	                    st = new StringTokenizer(br.readLine()); 
	                } 
	                catch (IOException  e) 
	                { 
	                    e.printStackTrace(); 
	                } 
	            } 
	            return st.nextToken();
	            
	        } 
	  
	        int nextInt() 
	        { 
	            return Integer.parseInt(next()); 
	        } 
	  
	        long nextLong() 
	        { 
	            return Long.parseLong(next()); 
	        } 
	  
	        double nextDouble() 
	        { 
	            return Double.parseDouble(next()); 
	        } 
	  
	        String nextLine() 
	        { 
	            String str = ""; 
	            try
	            { 
	                str = br.readLine(); 
	            } 
	            catch (IOException e) 
	            { 
	                e.printStackTrace(); 
	            } 
	            return str; 
	        }

			public Character charAt(int i) {
				// TODO Auto-generated method stub
				return null;
			} 
	    } 

  

	  // Complete the hurdleRace function below.
//    public static void solve() {
//    	FastReader s=new FastReader();

   
    public static void main(String[] args) throws IOException {
    	FastReader s=new FastReader();
        String S = s.next();  	
        for(int i=0;i<S.length();i++) {
        	System.out.print("x");
        }
       	
    }	
}





        
    

      
 

Measured memory_bytes: 32760
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try (Scanner sc = new Scanner(System.in)) {
			final int N = sc.nextInt();
			
			final int size = 5 * 2;
			
			boolean[][] opened = new boolean[N][size];
			for(int i = 0; i < N; i++){
				for(int j = 0; j < size; j++){
					opened[i][j] = sc.nextInt() == 1;
				}
			}
			
			long[][] score = new long[N][size + 1];
			for(int i = 0; i < N; i++){
				for(int j = 0; j <= size; j++){
					score[i][j] = sc.nextLong();
				}
			}
			
			long answer = Long.MIN_VALUE;
			
			for(int open_bit = 1; open_bit < (1 << size); open_bit++){
				
				long sum = 0;
				for(int shop = 0; shop < N; shop++){
					int same_count = 0;
					
					for(int i = 0; i < size; i++){
						if((open_bit & (1 << i)) == 0){ continue; }
						if(!opened[shop][i]){ continue; }
						
						same_count++;
					}
					
					sum += score[shop][same_count];
				}
				
				answer = Math.max(answer, sum);
			}
			
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 23892
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


def ZIP(n): return zip(*(MAP() for _ in range(n)))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    a, b, c, d = MAP()

    if ceil(a/d) >= ceil(c/b):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


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

int main()
{
    long a, b, ab, r, tmp;
    cin >> a >> b;
    ab = a*b;
    
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }

    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    
    cout << ab / b;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	int res = 0;

	for (int a = 0; a <= A; a++) {
		for (int b = 0; b <= B; b++) {
			for (int c = 0; c <= C; c++) {
				int total = 500 * a + 100 * b + 50 * c;
				if (total == X) {
					res++;
				}
			}
		}
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
fn read_line() -> String {
    let mut return_ = format!("");
    std::io::stdin().read_line(&mut return_).ok();
    return_
}

fn main() {
    let mut v: Vec<u32>;
    loop {
        v = read_line()
            .trim()
            .split_whitespace()
            .map(|x| x.parse().expect(""))
            .collect();
        v.sort();
        if v[1] == 0 && v[0] == 0 {
            break;
        }
        println!("{} {}", v[0], v[1]);
    }
}



Measured memory_bytes: 5036
=begin
  －－－－－－－－－－－－－－
  n = 乗客数
  c = バス定員
  k = 乗客がバスを待てる時間(分)
  ans = バスの最小本数
  now = 現在バスに乗っている客数
  T = T[i] = 乗客のバス停到着時刻
  limit T[i] + k
  乗客は バス停に到着した時刻(T[i]) から k分間 待つことができる (T[i] <= 乗客の待てる時間(x) <= T[i] + k)
  －－－－－－－－－－－－－－
  1: Tを到着時刻順に並び替える(昇順ソート)
  2: now = 0 なら Tの先頭を取り出す = T[i] して now += 1 して 次の要素へ
  3: limit を算出する
  4: now = c なら
    4.1: ans += 1　now = 0 にして 2,へ
  5: now < c 次のTに進む
    5.1: T <= limit の場合、now += 1
    5.2: T > limit の場合は、n
      5.2.1: now = 0 ans += 1　して 2, へ
=end

n, c, k = gets.split.map(&:to_i)
ans = 1
now = 0
limit = 0
T = n.times.map{gets.to_i}
T.sort!


T.each{|v|
  limit = v + k if now == 0

  if now == c
    ans += 1
    now = 1
    limit = v + k
  elsif now < c
    if v <= limit
      now += 1
    else
      ans += 1
      now = 1
      limit = v + k
    end
  end
}

puts ans

Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
const int INF=1e7+5;
long long n,a[INF];
unsigned long long sum;
int main(){
        cin>>n;
        for (long long i=1; i<=n; i++) {
                for (long long j=i; j<=n; j+=i)
                        a[j]++;
        }
        for (long long i=1; i<=n; i++)
                sum=sum+i*a[i];
        cout<<sum<<endl;
        return 0;
}


Measured memory_bytes: 81712
#include <stdio.h>

int check(int x){
	char s[6];
	snprintf(s,6,"%d",x);
	if(s[0]==s[4] && s[1]==s[3]){
		return 1;
	}else{
		return 0;
	}
}
int main(){
	int a,b;
	int i,ans=0;
	scanf("%d%d",&a,&b);
	for(i=a;i<=b;i++){
		if(check(i)==1){
			ans ++;
		}
	}
	printf("%d",ans);
	return 0;
}

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

int main() {
    ll n, m;
    cin >> n >> m;
    priority_queue<pair<ll, ll>> pq;
    for (int i = 0; i < n; ++i) {
        ll a;
        cin >> a;
        pq.push(make_pair(a, 1));
    }
    for (int j = 0; j < m; ++j) {
        ll b, c;
        cin >> b >> c;
        pq.push(make_pair(c, b));
    }
    ll ans = 0;
    for (int k = 0; k < n; ++k) {
        ans += pq.top().first;
        pair<ll, ll> sample = pq.top();
        sample.second--;
        pq.pop();
        if (sample.second != 0) pq.push(sample);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m, k;
    cin >> n >> m >> k;
    set<int> st;

    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= m; ++j) {
            int now = 0;
            now += i * m;
            now += (n-2*i) * j;
            st.insert(now);
        }
    }

    if (st.count(k)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 13184
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

int main() {
	int na, nb, nc, N;

	while(cin >> na >> nb >> nc >> N, na) {
		vi element(na+nb+nc, 2);
		vvi result(N, vi(4));

		REP(i, N) {
			cin >> result[i][0] >> result[i][1] >> result[i][2] >> result[i][3];
		}

		REP(i, N) {
			if(result[i][3]) {
				element[result[i][0]-1] = 1;
				element[result[i][1]-1] = 1;
				element[result[i][2]-1] = 1;
			}
		}
	
	
		REP(i, N) {
			if(!result[i][3]) {
				if(element[result[i][0]-1]==1 && element[result[i][1]-1]==1) {
					element[result[i][2]-1] = 0;
				}
				if(element[result[i][1]-1]==1 && element[result[i][2]-1]==1) {
					element[result[i][0]-1] = 0;
				}
				if(element[result[i][2]-1]==1 && element[result[i][0]-1]==1) {
					element[result[i][1]-1] = 0;
				}
			}
		}
	
		REP(i, element.size()) {
			cout << element[i] << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
char c[12][12];
bool f[12][12];
void dfs(int x,int y){
    if(x<0||y<0||x>=12||y>=12)return ;
    if(c[x][y]!='1')return ;
    if(!f[x][y])return ;
    f[x][y]=false;
    dfs(x+1,y);
    dfs(x,y+1);
    dfs(x-1,y);
    dfs(x,y-1);
    return ;
}
int main(){
    int ans;
    while(scanf("%s",c[0])!=EOF){
        for(int i=0;i<12;i++)for(int j=0;j<12;j++)f[i][j]=true;
        ans=0;
        for(int i=1;i<12;i++)scanf("%s",c[i]);
        for(int i=0;i<12;i++){
            for(int j=0;j<12;j++){
                if(c[i][j]=='1'&&f[i][j]){
                    ans++;
                    dfs(i,j);
                }
            }
        }
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 2596
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	cout << 800 * n - (n / 15) * 200 << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cctype>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cstring>
#include<list>
//#include<windows.h>
//#include<time.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mer make_pair
#define mme memset
#define ao(a) (a.begin(),a.end())
using namespace std;

const double pie1=3.1415926;//π1
const double pie2=3.14159265358979;//π2
const double pie3=3.14159265358979323846;//π3
const int vbi=999999999;
const int vli=-vbi;
const long long vbl=999999999999999999;
const long long vll=-vbl;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> piii;
typedef pair<pii,pii> pi4;
typedef pair<pll,ll> plll;
typedef pair<int,pii> ipii;
typedef pair<ll,pll> lpll;
typedef pair<pll,pll> pl4;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef set<int> sti;
typedef set<ll> stl;
typedef set<pii> spi;
typedef set<pll> spl;
priority_queue<int> pqi;
priority_queue<ll> pql;
queue<int> qi;
queue<ll> ql;

/*void bin_v(){
	char bin[1000];
	gets(bin);
}*/

bool pss(int a){
	for(int i=2;i<=sqrt(a);i++)
		if(a%i==0)
			return false;
	return true;
}
/////////////////////////////////////////////////////////////////////////////////////////

int n,m;
vector<int> v[100010];
int s[2][100010];

void dfs(int now,int last,int jl,int x){
	s[x][now]=jl;
	for(int i=0;i<v[now].size();i++)
		if(v[now][i]!=last)
			dfs(v[now][i],now,jl+1,x);
}

int main(){
	//my name is Veex_WCY
	ios::sync_with_stdio(false);
	cin>>n;
	m=n-1;
	for(int i=1;i<=m;i++){
		int a,b;
		cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	dfs(1,-1,0,0);
	dfs(n,-1,0,1);
	int sum1,sum2;
	for(int i=1;i<=n;i++){
		if(s[0][i]<=s[1][i])
			sum1++;
		else
			sum2++;
//		cout<<s[0][i]<<' '<<s[1][i]<<endl;
	}
	if(sum1>sum2)
		cout<<"Fennec";
	else
		cout<<"Snuke";
	return 0;
}


Measured memory_bytes: 14336
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scan = bufio.NewScanner(os.Stdin)

func main() {
	scanWords()
	a := scanNextInt()
	b := scanNextInt()
	c := scanNextInt()

	printCompareRusult(a, b, c)
}

func scanWords() {
	scan.Split(bufio.ScanWords)
}

func scanNextInt() int {
	scan.Scan()

	inputInt, err := strconv.Atoi(scan.Text())
	if err != nil {
		panic(err)
	}

	return inputInt
}

func printCompareRusult(a, b, c int) {
	if a < b && b < c {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}



Measured memory_bytes: 1092
#include <iostream>
#include<cmath>
#include <algorithm>
using namespace std;

int main()
{
    int heads, legs;
    cin >> heads >> legs;
    int sum = 2*heads;
    if(sum>legs)cout << "No";
    else if(sum==legs)cout << "Yes";
    else
    {
        sum = 2*heads;
        for(int i = 1; i <= heads; i++)
        {
            sum+=2;
            if(sum==legs){cout << "Yes";return 0;}
        }
        cout << "No";

    }

}


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

	int n;
	cin>>n;
	for (;n--;){
		int a,b,c;
		cin>>a>>b>>c;
		if (a>b) swap(a,b);
		if (b>c) swap(b,c);
		if (a*a + b*b == c*c)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
}

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

using namespace std;

int main() {
	int n, m = 1e9, b = 0;
	long r = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		r += abs(a);
		m = min(m, abs(a));
		b ^= a < 0;
	}
	cout << r - b * m * 2 << endl;
	return 0;
}


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

vector< vector< int > > to(100010);

int main(){
  int N,M;
  cin >> N >> M;
  vector<ll> H(N);
  REP(i,N) cin >> H[i];
  REP(i,M) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    to[a].emplace_back(b);
    to[b].emplace_back(a);
  }
  int ans = 0;
  REP(i,N) {
    if ( to[i].size() == 0 ) {
      ans++;
    } else {
      int ok = 1;
      for ( auto v : to[i] ) {
        if ( H[i] <= H[v] ) {
          ok = 0;
          break;
        }
      }
      if ( ok == 1 ) ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 9068
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;

ll N;
ll C;
ll s[100005];
ll t[100005];
ll c[100005];
ll imos[32][100005];
ll ans;

int main() {
    cin >> N >> C;

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

        imos[c[i]][s[i] - 1]++;
        imos[c[i]][t[i]]--;
   }

    for (int i = 1; i <= 30; i++) {
        for (int j = 1; j <= 100000; j++) {
            imos[i][j] += imos[i][j - 1];
        }
    }

    for (int i = 0; i <= 100000; i++) {
        ll cnt = 0;
        for (int j = 0; j <= C; j++) {
            if (imos[j][i]) {
                cnt++;
            }
        }
        ans = max(ans, cnt);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 26752
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		
		long[] lucas = new long[3];
		lucas[0] = 2;
		lucas[1] = 1;
		for(int i = 2;i <= N;++i) {
			lucas[i%3] = lucas[(i+1)%3] + lucas[(i+2)%3];
		}
		System.out.println(lucas[N%3]);
	}
}


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

 using namespace std;

 int main() {
   int a, b;
   cin >> a >> b;
   string ans;

   if (a <= 0) {
     if (0 <= b) ans = "Zero";
     else if ((b - a + 1) % 2 == 0) ans = "Positive";
     else ans = "Negative";
   }

   else ans = "Positive";

   cout << ans << endl;

}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define _GLIBCXX_DEBUG

using _loop_ll = long long;
#define REP(i,n) for(_loop_ll (i)=0; (i)<(_loop_ll)(n); (i)++)
#define FOR(i,a,b) for(_loop_ll (i)=(_loop_ll)(a); (i)<(_loop_ll)(b); (i)++)
#define FORR(i,a,b) for(_loop_ll (i)=(_loop_ll)(b)-1; (i)>=(_loop_ll)(a); (i)--)
 
#define ALL(v) (v).begin(),(v).end()
 
#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;

constexpr long long int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n;
    cin >> n;
    vl a(n);
    REP(i, n) cin >> a[i];
    // DEBUG_VEC(a);

    ll minn = 1e9;
    ll ans = 0;

    REP(i, n){
        if(minn > a[i]){
            ans++;
            minn = a[i];
        }
    }

    cout << ans << endl;
    

    

    return 0;
};


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
constexpr ll inf = 1LL << 60;
constexpr char newl = '\n';

using P = pair<int, int>;

P reduce(P p) {
  int g = __gcd(p.first, p.second);
  assert(g != 0);
  return make_pair(p.first / g, p.second / g);
}

int n, k;
constexpr int MaxN = 3005;
P ps[MaxN];

bool check(P o) {
  rep(i, n) ps[i].first -= o.first, ps[i].second -= o.second;
  int at = 0;
  map<P, int> cnt;
  rep(i, n) if (ps[i] == P(0, 0)) at++; else cnt[reduce(ps[i])]++;
  int cts = 0;
  for (auto p : cnt) cts = max(cts, p.second);
  rep(i, n) ps[i].first += o.first, ps[i].second += o.second;
  return at + cts >= k;
}

int main() {
  cin >> n >> k;
  rep(i, n) cin >> ps[i].first >> ps[i].second;
  rep(i, n) if (check(ps[i])) { cout << 1 << "\n"; return 0; }
  cout << 0 << "\n"; return 0;
}


Measured memory_bytes: 3304
#include <iostream>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <queue>
using namespace std;
#define print(x) for(auto& i:x) cout<<i<<" "; cout<<'\n';
#define scan(x) for(auto& i:x) cin>>i;
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define pii pair<int, int>
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<" "<<b<<endl
#define d3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define d4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define d5(a,b,c,d,e) cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl
ll mod=1e9+7;

void solve(){
	string s; cin>>s;
	if(s=="SSS") cout<<0<<endl;
	else if(s=="RRR") cout<<3<<endl;
	else if(s=="RRS" or s=="SRR") cout<<2<<endl;
	else cout<<1<<endl;
}

int main() {
	//freopen("test.txt", "r", stdin);
	FAST; int T=1;
	//cin>>T;
	while(T--) solve();
	return 0;
}

Measured memory_bytes: 3224
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    string N ;
    cin >> N ;

    size_t l = N.length();
    bool jud = false ;
    int count = 0; 
    
       
    for(int i = 0 ; i < l / 2; i++ ){
       
        if( N[i] == N[l-i-1]){
           count++;
        }
    }
       if(count == l / 2 ){
           jud = true ; 
       }
    
    if(jud == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n,m,c = gets.chomp.split(" ").map{|i|i = i.to_i}
b = gets.chomp.split(" ").map{|i|i = i.to_i}
a = []
n.times do
  a << gets.chomp.split(" ").map{|i|i = i.to_i}
end

count = 0
n.times do|i|
  sum = c
  m.times do|j|
    sum+=a[i][j]*b[j]
  end
  if sum>0 then count+=1 end
end
puts count






Measured memory_bytes: 1788
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,k,n) for(int (i)=(k);(i)<(n);(i)++)
using namespace std;
typedef long long int ll;

void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i+1;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}



int main() {
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << a[K-1] << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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 ll INF=1e18;

ll dp[200005][5];

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    V<ll> a(n);
    cinf(n,a);
    ll k=1+n%2;
    rep(i,n+1)rep(j,k+1)dp[i][j]=-INF;
    dp[0][0]=0;
    rep(i,n){
        rep(j,k+1){
            chmax(dp[i+1][j+1],dp[i][j]);
            ll now=dp[i][j];
            if((i+j)%2==0) now+=a[i];
            chmax(dp[i+1][j],now);
        }
    }
    cout<<dp[n][k]<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
(全探索できるなら全探索しろ)
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'\n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え(=でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
*/

Measured memory_bytes: 12716
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
		try{
			Scanner sc = new Scanner(System.in);
			String S = sc.nextLine();
			int result = S.length();
			if(result % 2 != 0){
				result -= 1;
			}else{
				result -= 2;
			}
			out : while(result > 2){
				int half = result/2;
				for(int i = 0; i < half; i++){
					if(S.charAt(i) != S.charAt(half+i)){
						result -= 2;
						continue out;
					}
				}
				break;
			}
			System.out.println(result);
			
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const int INF = INT_MAX / 2;

int main(){
    int N; cin >> N;
    vector<vector<int>> s(N, vector<int>(27, 0));
    for (int i = 0; i < N; i++)
    {
        string t; cin >> t;
        for (int j = 0; j < t.size(); j++)
        {
            int k = (int)(t[j]-'a');
            s[i][k]++;
        }
    }
    vector<int> v(27, INF);
    for (int i = 0; i < v.size(); i++)
    {
        for (int j = 0; j < N; j++)
        {
            v[i] = min(v[i], s[j][i]);        
        }        
    }
    string ans;
    for (int i = 0; i < v.size(); i++)
    {
        ans += string(v[i], 'a' + i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip	;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
struct edge{
	int to,cost;
};
int main(){
	int n,m,p,a,b;
	while(cin>>n>>m>>p>>a>>b,n){
		a--;b--;
		vi ken(n);
		rep(i,n)cin>>ken[i];
		vector<vector<edge> >G(m);
		rep(i,p){
			int q,r,co;cin>>q>>r>>co;
			q--;r--;
			edge e={r,co},ee={q,co};
			G[q].pb(e);
			G[r].pb(ee);
		}
		int N=1<<n;
		vector<vector<double> >dp(N,vector<double>(m,inf));
		dp[0][a]=0;
		rep(i,N)rep(j,m)if(dp[i][j]!=inf){
			rep(k,G[j].size())rep(l,n)if(!(i&1<<l)){
				double t=(double)G[j][k].cost/ken[l];
				dp[i|1<<l][G[j][k].to]=min(dp[i|1<<l][G[j][k].to],dp[i][j]+t);
			}
		}
		double out=inf;
		rep(i,N)out=min(dp[i][b],out);
		if(out==inf)cout<<"Impossible"<<endl;
		else cout<<shosu(9)<<out<<endl;
	}
}

Measured memory_bytes: 1368
#include <cstring>
#include <cstdint>
#include <iostream>
#include <string>
#include <memory>
#include <queue>
#include <limits>
#include <list>
#include <utility>
#include <sstream>
#include <random>
using namespace std;
const char* Player[2] = { "Alice", "Brown" };
long long bitmask64 = 0xffffffffffffffff - 1;
int main() {
	int turn = 1;
	long long x, y;
	cin >> x; cin >> y;

	turn = (abs(x - y) > 1) ? 0 : 1;


	cout << Player[turn];
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{

  int a, b, k, i, s1, s2, j;
  scanf("%d%d%d",&a,&b,&k);
  j=0;
  for(i=100000;i>=0;i--){
        s1=a%i;
        s2=b%i;
        if((s1==0)&&(s2==0)){
                j++;
                if(j==k){
                        printf("%d\n",i);
                        return 0;
                }
        }
  }
  return 0;
}

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

int main()
{
	int A = 0, B = 0;

	std::cin >> A >> B;
	
	int ans = 0;

	if ((A >= 10) || (B >= 10))
	{
		ans = -1;
	}
	else{
		ans = A * B;
	}

	std::cout << ans << std::endl;

	return 0;
}

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

#define MOD (1000000000+7)

long long N;

vector<int> p;

int main() {
	cin >> N;

	p.push_back( 2 );
	for(int i = 3; i <= N; i +=2 ) {
		int k = 0;
		for( int j = 3; j <= sqrt( i ); j += 2 ) {
			if( i % j == 0 ) {
				k = 1;
				break;
			}
		}

		if (k == 0 ) {
			 p.push_back( i );
		}
	}

	long long ans = 1;
	for( int i = 0; i < p.size(); i++ ) {
		int pp = p[i];
		int p1 = pp;
		int c = 0;
		while( p1 <= N ) {
			int div = N / p1;
			c += div;
			p1 *= pp;
		}
		ans = (ans * ( c + 1 ) ) % MOD;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ctime>
#include <cstdlib>
#define rep(i, N) for (long i = 0; i < (N); i++)
#define swap(a, b) (a += b, b = a - b, a -= b)
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> p(N), q(N), key(2);
    int sum = 0;
    rep(i, N)
    {
        cin >> p[i];
        if (p[i] != i + 1)
        {
            q[i] = 1;
        }
        else
        {
            q[i] = 0;
        }
        sum += q[i];
    }
    if (sum == 2)
    {
        int j = 0;
        rep(i, N)
        {
            if (q[i] == 1)
            {
                key[j] = i;
                j++;
            }
        }
        swap(p[key[0]], p[key[1]]);

        rep(i, N)
        {
            if (p[i] != i + 1)
            {
                cout << "NO" << endl;
                return 0;
            }
        }
        cout << "YES" << endl;
    }
    else if (sum == 0)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


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

int main()
{
  int H, N, A, sum = 0;
  cin >> H >> N;
  for(int i = 1; i <= N; i++)
  {
    cin >> A;
    sum += A;
  }
  if(sum >= H)
    cout << "Yes";
  else
    cout << "No";
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	string in;
	while (cin >> in && in != "#") {
		char st = 'A';
		for (int i = 0; i < in.size(); i++) {
			if (st == 'A') {
				if (in[i] == '0')
					st = 'X';
				else
					st = 'Y';
			} else if (st == 'X') {
				if (in[i] == '1')
					st = 'Z';
				else
					break;
			} else if (st == 'Y') {
				if (in[i] == '0')
					st = 'X';
				else
					break;
			} else if (st == 'Z') {
				if (in[i] == '0')
					st = 'W';
				else
					st = 'B';
			} else if (st == 'W') {
				if (in[i] == '0')
					st = 'B';
				else
					st = 'Y';
			} else if (st == 'B') {
				if (in[i] == '0')
					st = 'Y';
				else
					st = 'X';
			}
		}
		if (st == 'B')
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
}

Measured memory_bytes: 3184
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {

		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if(n==0)break;
			int[][] s = new int[n + 1][n + 1];
			for (int i = 1; i < n + 1; i++) {
				char[] tmp = sc.next().toCharArray();
				for (int j = 1; j < n + 1; j++) {
					s[i][j] = tmp[j - 1] == '.' ? 1 : 0;
				}
			}
			int ans = 0;
			for (int i = 1; i < n + 1; i++) {
				for (int j = 1; j < n + 1; j++) {
					if (s[i][j] == 0)
						continue;
					else {
						s[i][j] = Math.min(
								Math.min(s[i - 1][j], s[i - 1][j - 1]),
								s[i][j - 1]) + 1;
						ans = Math.max(s[i][j], ans);
					}
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 20000
#include <stdio.h>
#include <stdlib.h>

int N;
int nextNum[114514];
int* nexts[114514];
int* henIndice[114514];

int answer[114514];

void asumikana(int idx, int pidx, int pcolor) {
	int i;
	int nextColor = 1;
	for (i = 0; i < nextNum[idx]; i++) {
		if (nexts[idx][i] == pidx) continue;
		int color;
		if (nextColor == pcolor) nextColor++;
		color = nextColor++;
		answer[henIndice[idx][i]] = color;
		asumikana(nexts[idx][i], idx, color);
	}
}

int main() {
  int i,K;
  if(scanf("%d",&N)!=1)return 1;
  for(i=1;i<N;i++){
    int a,b;
    if(scanf("%d%d",&a,&b)!=2)return 1;

    nexts[a] = realloc(nexts[a], sizeof(int) * (nextNum[a] + 1));
		nexts[a][nextNum[a]] = b;
		henIndice[a] = realloc(henIndice[a], sizeof(int) * (nextNum[a] + 1));
		henIndice[a][nextNum[a]] = i;
		nextNum[a]++;

    nexts[b] = realloc(nexts[b],sizeof(int)*(nextNum[b]+1));
    nexts[b][nextNum[b]]=a;
    henIndice[b]=realloc(henIndice[b],sizeof(int)*(nextNum[b]+1));
    henIndice[b][nextNum[b]]=i;
    nextNum[b]++;
  }
  K=0;
  for(i=1;i<=N;i++){
    if(nextNum[i]>K)K=nextNum[i];
  }
  asumikana(1,0,0);

  printf("%d\n",K);
  for(i=1;i<N;i++){
    printf("%d\n",answer[i] );
  }
  return 0;
}


Measured memory_bytes: 9856
from collections import defaultdict, deque, Counter
import sys
import heapq
import math

# input = sys.stdin.readline

sys.setrecursionlimit(1000000000)

MIN = -10 ** 9
MOD = 10 ** 9 + 7


def norm(theta):
    if theta > math.pi:
        return theta - 2 * math.pi
    if theta < -math.pi:
        return theta + 2 * math.pi


def solve(state, xy):
    xx, yy = 0, 0
    for i in state:
        x, y = xy[i]
        xx += x
        yy += y
    return math.sqrt(xx * xx + yy * yy)


def main():
    N = int(input())
    # A, B = [int(a) for a in input().split()]
    # H = [int(a) for a in input().split()]
    xy = [
        [int(a) for a in input().split()]
        for _ in range(N)
    ]

    ttt = []
    ts = []
    for i, (x, y) in enumerate(xy):
        theta = math.atan2(y, x)
        m1 = theta - math.pi / 2
        m2 = theta + math.pi / 2
        b = [(m1, m2)]
        if m1 < -math.pi:
            b = [
                (-math.pi, m2),
                (m1 + 2 * math.pi, math.pi)
            ]
        elif m2 > math.pi:
            b = [
                (-math.pi, m2 - 2 * math.pi),
                (m1, math.pi)
            ]
        ts.append(b)
        # print(b)
        for xx, yy in b:
            ttt.append((xx, i, "enter"))
            ttt.append((yy, i, "leave"))

    result = 0
    state = set()
    for p, i, typ in sorted(ttt, key=lambda a: a[0]):
        # print(p, i, typ)
        if typ == "enter":
            state.add(i)
        else:
            state.remove(i)

        score = solve(state, xy)
        # print(state,score)
        result = max(result, score)
        # print(p, i)
    print(result)


# res = [(0,0),(0,0),(0,0),(0,0)]
# for x,y in xy:
#     if x>0:
#         px,py = res[1]
#         res[1] = (px+x,py+y)
#     else:
#         px, py = res[3]
#         res[3] = (px + x, py + y)
#     if y > 0:
#         px, py = res[0]
#         res[0] = (px + x, py + y)
#     else:
#         px, py = res[2]
#         res[2] = (px + x, py + y)


if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;


int main() {

    vector<ll > A(3, 0);
    cin >> A[0] >> A[1] >> A[2];
    sort(A.rbegin(), A.rend());
    cout << abs(A[0]-A[1]) + abs(A[1]-A[2]) << endl;
}

Measured memory_bytes: 256
def main():
  N, K = list(map(int, input().split()))
  h = tuple(map(int, input().split()))

  if N == 2:
    print(abs(h[1] - h[0]))
    exit()

  DP = [0 for i in range(N)]

  mi = min(N, K + 1)
  for i in range(1, mi):
    DP[i] = abs(h[i] - h[0])
  for i in range(1, N - 1):
    mi = min(N, i + K)
    for j in range(i, mi):
      t = DP[i] + abs(h[j] - h[i])
      if DP[j] > t:
        DP[j] = t
    if i + K <= N - 1:
      DP[i+K] = DP[i] + abs(h[i+K] - h[i])
  print(DP[N-1])
  
main()

Measured memory_bytes: 59488
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int memo[100005];

int main()
{
    ciosup;
    int n;
    cin >> n;
    vint b(n);
    REP(i, n)
    {
        cin >> b[i];
    }
    multiset<int> s;
    s.insert(b[0]);
    FOR(i, 1, n)
    {
        if (b[i] <= *s.begin()){
            s.insert(b[i]);
        }else{
            auto ite = s.lower_bound(b[i]);
            --ite;
            s.erase(ite);
            s.insert(b[i]);
        }
    }
    cout << s.size() << endl;
}


Measured memory_bytes: 5376
#include<iostream>
#include<stack>
#include<iomanip>
#include<algorithm>
#include<string>
#include<string.h>
#include<cmath>
#include<set>
#include<vector>
#include<queue>
#include<map>
#include<time.h>
using namespace std;
using ll = long long;
const int INF = 2e9 + 10;
using pii = pair<int, int>;
using vi = vector<int>;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define mp make_pair 
#define pb push_back
#define clr(x, v) memset(x, v, sizeof (x))
#define all(x) x.begin(), x.end()
#define fi first
#define se second
const int N = 1e6 + 10;
int n, k, x;
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    while (cin >> n >> x) {
        vector<int> a(n);
        for (int i = 0; i < n; i++) cin >> a[i];
        int g = 0;
        for (int i = 1; i < n; i++) {
            g = gcd(g, abs(a[i] - a[i - 1]));
        }
        int res = 0;
        for (int i = 0; i < n; i++) {
            res = max(res, gcd(g, abs(x - a[i])));
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 640
/*
Kaushal Jalan
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define r0 return 0;
#define f(k,i,n,j) for(ll k=i;k<=n;k=k+j)
#define cin(a) cin>>a;
#define loop int t;cin>>t;while(t--)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define mod 1000000007
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
int min(int a,int b){
    return (a<b)?a:b;
}
int max(int a,int b){
    return (a>b)?a:b;
}
int fp(int a,int b){
    if(b==0) return 1;
    int x=fp(a,b/2);
    x=(x*x)%mod;
    if(b&1) x=(x*a)%mod;
    return x;
}
void c_p_c()
{
    crap;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
signed main()
{
   // c_p_c();
    int k,a,b;
    cin>>k>>a>>b;
    int f=0;
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            f=1;
            break;
        }
    }
    if(f)
    cout<<"OK"<<endl;
    else
    cout<<"NG"<<endl;
}

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

using namespace std;

typedef long long ll;

int n, k;
ll h[100005], dp[100005];

int main(){
    //freopen("FROG2.INP", "r", stdin);

    cin >> n >> k;
    for (int i = 1; i <= n; i++){
        cin >> h[i];
    }
    for (int i = 1; i <= n; i++){
        dp[i] = 10000000000;
    }
    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);
    for (int i = 3; i <= n; i++){
        for (int j = max(1, i - k); j < i; j++){
            dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
        }
    }
    cout << dp[n];

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

const ll MOD = 1e9 + 7;

int main(void){
  int n, i;
  string s, t;
  cin >> n >> s >> t;

  ll ans = 1;
  bool prev;

  if(s[0]==t[0]){
    ans = 3;
    i = 1;
    prev = 0;
  }
  else{
    ans = 6;
    i = 2;
    prev = 1;
  }

  while(i<n){
    if(s[i]==t[i]){
      if(prev){

      }
      else{
        ans *= 2;
        ans %= MOD;
      }
      i++;
      prev = 0;
    }
    else{
      if(prev){
        ans *= 3;
        ans %= MOD;
      }
      else{
        ans *= 2;
        ans %= MOD;
      }
      i += 2;
      prev = 1;
    }
  }

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


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.Int();
            int K = in.Int();
            boolean[] snk = new boolean[N];
            for (int i = 0; i < K; i++) {
                int d = in.Int();
                for (int j = 0; j < d; j++) {
                    int A = in.Int() - 1;
                    snk[A] = true;
                }
            }
            int cnt = 0;
            for (boolean b : snk) {
                if (!b) cnt++;
            }
            out.println(cnt);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

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

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

    }
}



Measured memory_bytes: 33888