akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

// header area
ll func(int n){
    vector<int> x(n + 1);
    int num = n;
    ll count=1;
	for (int i = 2; i <= n; i++) {
		while (num%i == 0) {    // 素数で割り切れなくなるまで割っていく
			x.at(i)++;  //割った個数を配列に足す
			num /= i;
		}
	}

	for (int i = 2; i <= n; i++)
	{	
		count *= x.at(i) + 1; //それぞれを+1して掛けていく
	}
    // cout << "f(" << n << "):" << count << endl;
    return count;
}

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

    static short f[10000000+1]={0};
    rep(i, 10000000+1) f[i]++;

    for(int k=2;k<=N;k++){
        // cout << k << endl;
        for(int i=k;i<=N;i+=k){
            f[i]++;
        }
    }

    ll ans=0;
    for(ll k=1;k<=N;k++){
        ans += k*f[k];
        // cout << ans << endl;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 23132
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
          Copyright                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz(a) int((a).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,n) for(int i=(1);i<=(n);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 200005;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Test.insert(x)late ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return (pwur * pwur) % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}

/// My Code -------------------------------------------------

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));
    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);
    int n;
    cin>>n;
    vi a(n),b(n),c(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    rep(i,n)cin>>c[i];
    sort(all(a));
    sort(all(c));
    int p1=0,p2=0,ans=0;
    rep(i,n){
        p1=lower_bound(all(a),b[i])-a.begin();
        p2=c.size()-(upper_bound(all(c),b[i])-c.begin());
        ans+=p1*p2;
    }
    cout<<ans<<enl;


    return 0;
}


Measured memory_bytes: 5572
#include <iostream>
#include <vector>
using namespace std;
//#define MAX 1300000
const int MAX = 1300000;

vector<int> prime(MAX);

void mk_prime(){
    for( int i = 0; i < MAX; i++){
        prime[i] = 1;
    }
    prime[0] = 0;
    prime[1] = 0;
    for( int i = 2; i < MAX; i++ ){
        if( prime[i] == 1 ){
            for( int j = 2 * i; j < MAX; j += i ){
                prime[j] = 0;
            }
        }
    }
}

int main(){
    mk_prime();
    int k;

    while( cin >> k, k ){
        if( prime[k] == 1 ){
            cout << 0 << endl;
            continue;
        }
        int s, e;
        for( int i = k - 1; ; i-- ){
            if( prime[i] == 1 ){
                s = i;
                break;
            }
        }
        for( int i = k + 1; ; i++ ){
            if( prime[i] == 1 ){
                e = i;
                break;
            }
        }
        //int ans = e - s;
        cout << e - s << endl;
    }
}

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

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long 
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll; 
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
// int ab  (int  x ) { return (x>0?x:-x); }
//
//
int main(){
	int a ; 
	string s; 
	cin >> a >> s; 
	if( a >= 3200) cout << s << endl; 
	else cout << "red"<<endl; 
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(final String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int Y = scan.nextInt();
        boolean isFound = false;
        x: for (int i = 0; i <= N; i++) {
            y: for (int j = 0; j <= N - i; j++) {
                int k = N - i - j;
               int total = 10000*i + 5000*j + 1000*k;
               if (total == Y) {
                   System.out.println(i +" "+ j +" "+k);
                   isFound = true;
                   break x;
               }
            }
        }
        if (!isFound) {
            System.out.println(-1 +" "+ -1 +" "+-1);
        }
    }
}

Measured memory_bytes: 23764
# coding: utf-8
from collections import deque
def main():
    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1
    D = [[0 for _ in range(N)] for _ in range(N)]
    D[X][Y] = 1
    D[Y][X] = 1
    queue = deque([[X, Y]])
    visited = [[False for _ in range(N)] for _ in range(N)]
    visited[X][Y] = True 
    while queue:
        x,y = queue.popleft()
        for i, j in zip([1, 0, -1, 0], [0, 1, 0, -1]):
            nx, ny = x+i, y+j
            if nx < 0 or nx >= N or ny < 0 or ny >= N:
                continue
            if visited[nx][ny]:
                continue
            else:
                visited[nx][ny] = True
                D[nx][ny] = min(abs(ny-nx), D[x][y]+1)
                queue.append([nx, ny])
    ans = [0 for _ in range(N)]
    cnt = 0
    for i in range(N):
        for j in range(i+1, N):
            v = D[i][j]
            ans[v-1] += 1
    print(*ans[:-1], sep="\n")
main()

Measured memory_bytes: 147720
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static class UnionFind{
		private int cnt;
		int parent[];
		int[] rank;
		UnionFind(int n){
			cnt=n;
			parent =new int[n];
			Arrays.fill(parent, -1);
			
			
		}
		int root(int x)
		{
			if(parent[x]<0)
			{
				return x;
			}else {
				return parent[x]=root(parent[x]);
			}
			
			
		}
		int size(int a)
		{
			return -parent[root(a)];
		}
		public boolean connect(int a,int b)
		{
			a=root(a);
			b=root(b);
			if(a==b) {
				return false;
			}
			if(size(a)<size(b))
			{
				int r=a;
				a=b;
				b=r;
			
			}
			parent[a]+=parent[b];
			parent[b]=a;
			return true;
		}
		
		
		
	}
	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int m=scan.nextInt();
		int a[]=new int[m];
		int b[]=new int[m];
		for(int i=0;i<m;i++)
		{
			a[i]=scan.nextInt()-1;
			b[i]=scan.nextInt()-1;
			
		}
		UnionFind uf=new UnionFind(n);
		long[] ans=new long[m];
		ans[m-1]=(long)n*(n-1)/2;
		for(int i=m-1;i>=1;i--)
		{
			ans[i-1]=ans[i];
			if(uf.root(a[i])!=uf.root(b[i])) {
				ans[i-1]-=(long)uf.size(a[i])*uf.size(b[i]);
				uf.connect(a[i], b[i]);
			}
		}
		for(int i=0;i<m;i++)
		{
			System.out.println(ans[i]);
		}
	}
	
}


Measured memory_bytes: 80388
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll n;
    ll a[200010];
    ll sum = 0;
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        sum += a[i];
    }
    ll origin = sum;
    ll result = 1e10;
    for (int i = 0; i < n-1; i++) {
        sum-=a[i];
        result = min(result, abs(sum-(origin-sum)));
    }
    std::cout << result << std::endl;
    
}


Measured memory_bytes: 1792
#include <iostream>
#include <math.h>
#include <string>

using namespace std;

void solve();

int main() {
	solve();
	return 0;
}

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

int D, G;
int p[10], c[10];
void solve() {
	cin >> D >> G;
	for (int i = 0; i < D; i++)cin >> p[i] >> c[i];
	int max = 1000;
	for (int b = 0; b < pow(2, D); b++) {   //1のところだけコンプボーナスをとる
		int dif = G,num = 0;
		for (int i = 0; i < D; i++) {
			int t = b & (int)pow(2, i);
			if (t != 0) {
				dif -= (100 * (i + 1)*p[i] + c[i]);
				num += p[i];
			}
		}
		//ここから貪欲
		for (int i = D-1; i >= 0 && dif > 0 ; i--) {
			int t = b & (int)pow(2, i);
			if (t == 0) {
				int used = floor(dif/(100*(i+1)));
				if (used > p[i] - 1)used = p[i] - 1;
				dif -= 100 * (i + 1)*used;
				num += used;
			}
		}
		if (dif <= 0 && max > num)max = num;
	}
	cout << max;
	return;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int batu = 0;
    rep(i, S.length()) {
        if (S[i] ==  'x') batu++;
    }
    if (batu >= 8) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }

    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String N = scanner.next();
		String result = "No";

		for (int i = 0; i < 2; i++) {
			if (N.substring(i, i+1).equals("9")) {
				result = "Yes";
			}

		}
		System.out.println(result);
	}

}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    string S;
    ll N,K;
    cin >>S>>K;
    N = S.size();
    ll now=1;
    rep(i,K){
        if(S[i]!='1'){
            cout<<S[i]<<endl;
            return 0;
        }
    }
    
    
    cout << 1 << endl;


    return 0;
    

}

Measured memory_bytes: 3624
N = input()

N = list(N)

if N[len(N)-1] == '3':
    print('bon')

elif N[len(N)-1] == '0' or N[len(N)-1] == '1' or N[len(N)-1] == '6' or N[len(N)-1] == '8':
    print('pon')
    
else:
    print('hon')

Measured memory_bytes: 9060
#include <bits/stdc++.h>
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) x.begin(),x.end()
using namespace std;


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

    int x,a;
    cin >> x >> a;
    if (x < a) cout << 0 << endl;
    else cout << 10 << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<cmath>
static const long long mod= 1000000007;
using namespace std;

vector<long long>a(1005, 1);

void prime(int n) {
    if (n == 1)return;
    prime(n - 1);
    for (int i = 2; i <= n; ++i) {
        if (n % i == 0) {
            ++a[i];
            n /= i;
            --i;
            if (n == 1)return;
        }
    }
}


int main() {
    int n;
    cin >> n;
    prime(n);
    long long sum = 1;
    for (int i = 2; i <= n; ++i) {
        sum *= a[i];
        sum %= mod;
    }
    cout << sum << endl;
    return 0;
}

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

int Judge(string WordT, string WordH){
	int i = 0;
	int Judge = 0;
	while(i < WordT.size() && i < WordH.size()){
		if(WordT[i] != WordH[i]){
			if(WordT[i] > WordH[i]) Judge = 1;
			if(WordT[i] < WordH[i]) Judge = -1;
			break;
		}
		i++;
	}
	if(Judge == 0 && WordT.size() > WordH.size()) Judge = 1;
	if(Judge == 0 && WordT.size() < WordH.size()) Judge = -1;
	return Judge;
}

int main(){
	//???????????????????????°n????????????
	int n;
	cin >> n;
	//??????????????????????????????????????????
	vector<string> T;
	vector<string> H;
	for(int i = 0; i < n; i++){
		string WordT;
		string WordH;
		cin >> WordT;
		cin >> WordH;
		T.push_back(WordT);
		H.push_back(WordH);
	}
	//????¨???????????¨??????????
	int PointT = 0;
	int PointH = 0;
	for(int i = 0; i < n; i++){
		if(Judge(T[i], H[i]) == 1) PointT +=3;
		if(Judge(T[i], H[i]) == 0) PointT++, PointH++;
		if(Judge(T[i], H[i]) == -1) PointH +=3;
	}
	//????¨????????????¨?????????
	cout << PointT << " " << PointH << endl;
//	system("pause");
	return 0;
}

Measured memory_bytes: 1324
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

stack<ll> s;
ll n;
bool used[1100], ok = true;
int main() {
	cin >> n;
	REP(i, n) {
		ll a;
		cin >> a;
		if (a > 0) {
			if (used[a]) ok = false;
			else {
				s.push(a);
				used[a] = true;
			}
		}
		else {
			if (s.empty() or s.top() != a * -1)ok = false;
			else {
				s.pop();
				used[a * -1] = false;
			}
		}
		if (!ok) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	cout << "OK" << endl;
}



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

using namespace std;
typedef long long ll;

int main() {
	int a, b, c, d, e, f, g, aa, dd, ee;
	cin >> a >> b >> c >> d >> e >> f >> g, aa = a, dd = d, ee = e;
	ll ans = b;
	ans += a/2*2, a %= 2;
	ans += d/2*2, d %= 2;
	ans += e/2*2, e %= 2;
	if( a && d && e ) {
		ans += 3;
	} else if( a && d && ee ) {
		++ans;
	} else if( a && e && dd ) {
		++ans;
	} else if( d && e && aa ) {
		++ans;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
//Author : Prakhar Asaiya
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=a;i<b;++i)
#define REPN(i,a,b) for(int i=a;i<=b;++i)
#define REPV(i,a,b) for(int i = a; i>= b; --i)
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define with_tests int t; cin>>t; while(t--){ solve(); }
#define without_tests solve();
#define ll long long
#define INF 100000000
#define ff first
#define ss second
const int M=1e9+7;

void solve()
{
	int n, k;
	cin>>n>>k;
	vector<int> H(n);
	for(auto&e : H)
	{
		cin>>e;
	}
	vector<int> dp(n, 1e9);
	dp[0] = 0;
	REP(i,0,n)
	{
		REPN(j,i+1,i+k)
		{
			if(j < n)
			dp[j] = min(dp[j], dp[i] + abs(H[j] - H[i]));
		}
	}
	cout<<dp.back()<<"\n";
}

int main()
{/*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#*/
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  //with_tests;
  without_tests;
  return 0;
}


Measured memory_bytes: 3988
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long

int N;
//here begins your code

int f(int N){
	if(N == 1){
		return 1;
	}
	else{
		return N * f(N - 2);
	}
}
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> N;
  if(N % 2 == 1){
  	cout << 0 << endl;
  	return 0;
  }

  int p = 1;
  while(true){
  	int num = 2 * pow(5,p);
  	if(num > N){
  		break;
  	}
  	p++;
  }

  int ans = 0;
  for(int i = 1; i < p ; i++){
  	int num = 2 * pow(5,i);
  	ans += (N / num);
  }
  cout << ans << endl;
  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// }}} 1

int main() {

    char c;
    scanf("%c", &c);

    if( c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
        printf("vowel\n");
    else
        printf("consonant\n");

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int search(int a, int b);

int main(void)
{
	int a, b;
	int gcd, lcm;

	while(scanf("%d %d", &a, &b) != EOF){
		if (a > b){
			gcd = search(a, b);
		}
		else {
			gcd = search(b, a);
		}


		lcm = (a / gcd) * b;

		printf("%d %d\n", gcd, lcm);
	}

	return (0);
}

int search(int a, int b)
{
	int r;

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

Measured memory_bytes: 596
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);
	    String s=gs();

	    System.out.print(s.substring(0,s.length()-8));
//	    if (s.length() >= 4 && s.substring(0, 4).equals("YAKI")) {
//	    	System.out.print("Yes");
//	    }else {
//	    	System.out.print("No");
//	    }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35548
//_nebula_
#include<bits/stdc++.h>
using namespace std;
#define int long  long
#define double long double
int t;
bool vis[200005];
vector<int>grp[200005];
const int M=998244353;
int factt(int n)
{
    int ans=1;
    for(int i=1;i<=n;i++)
    {
        ans*=i;
        ans=ans%M;
    }
    return ans;
}
int max(int a,int b,int c)
{
    return max(a,max(b,c));
}
int min(int a,int b,int c)
{
    return min(a,min(b,c));
}
int fspow(int x,int y)
{
    int ans;
    if(y==0) return 1;
    ans=fspow(x, y/2);
    if(y%2==0) return (ans*ans)%M;
    return (x*((ans*ans)%M))%M;;
}
int gcd(int x,int y)
{
    if(x<y) swap(x,y);
    if(y==0) return x;
    return gcd(x%y,y);
}
int p2(int x)
{
    int ans=0;
    while(x>=1)
    {
        ans++;
        x/=2;
    }
    return ans;
}
int v=0;
void dfs(int s)
{
    if(vis[s]) return;
    vis[s]=1;
    v++;
    for(int i=0;i<grp[s].size();i++) dfs(grp[s][i]);
}
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    t=1;
    // freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //  cin>>t;
    // int tmp=t;
    while(t--)
    {
        int n,m;
        cin>>n>>m;
        for(int i=0;i<m;i++)
        {
            int x,y;
            cin>>x>>y;
            grp[x].push_back(y);
            grp[y].push_back(x);
        }
        int mx=0;
        for(int i=1;i<=n;i++)
        {
            if(!vis[i])
            {
                dfs(i);
                mx=max(mx,v);
                v=0;
            }
        }
        cout<<mx<<"\n";
    }
}


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

ll p(ll a, int n) {
  ll b = 1;
  for(int i=0;i<n;i++) {
    b *= a;
    b %= MOD;
  }
  return b;

}

ll solve(ll n) {
  /*
  if(n == 1) {
    return 0;
  }
  ll res = p(10, n) % MOD;
  res = (res - p(9, n)) % MOD;
  res = (res - p(9, n)) % MOD;
  res = (res + p(8, n)) % MOD;
  */
  ll res=p(10,n)-p(9,n)-p(9,n)+p(8,n);
  res%=MOD;
  res=(res+MOD)%MOD;
  return res;
}

int main() {
  ll n;
  cin >> n;
  cout << solve(n);
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stdio.h>
#include <string>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 998244353;
ll n, a[3010], dp[3010][3010];
const ll INF = 1000000000000000;

ll pow(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return pow(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = pow(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return pow(x, mod - 2);
}

ll res(ll x, ll y)
{
	if (dp[x][y] != INF)
	{
		return dp[x][y];
	}
	else if (x == y)
	{
		return dp[x][y] = a[x] * (n % 2 == 1 ? 1 : -1);
	}
	else if ((n - (y - x)) % 2 == 1)
	{
		return dp[x][y] = max(res(x + 1, y) + a[x], res(x, y - 1) + a[y]);
	}
	else
	{
		return dp[x][y] = min(res(x + 1, y) - a[x], res(x, y - 1) - a[y]);
	}
}

int main(void)
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = i; j <= n; j++)
		{
			dp[i][j] = INF;
		}
	}
	cout << res(1, n) << endl;
	cin >> n;
}


Measured memory_bytes: 70144
#include <stdio.h>
int main(void){
int s;
int S=0;
int m=100;
int i=0;
    
for(;~scanf("%d",&s);)i++?S+=s,s%10&&(m=fmin(m,s)):0;
m>99&&(S=m);
printf("%d",S%10?S:S-m);
}

Measured memory_bytes: 2156
// AOJ ALDS1_3_C Doubly Linked List
// 2018.5.1 bal4u
 
#include <stdio.h>
 
#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
 
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}
 
void skip(int k) { while (k--) gc(); }
 
void out(int n)
{
	int i;
	char ob[20];
 
	if (!n) { pc('0'); return; }
	i = 0; while (n) ob[i++] = n%10 + '0', n/=10;
	while (i--) pc(ob[i]); 
}
 
int que[1500005]; int top, end;
 
int main()
{
	int n, i, t;
	char op;
 
	n = in(); top = 0, end = 1;
	while (n--) {
		if (gc() == 'i') {
			skip(6);
			que[end++] = in();
		} else {
			skip(5);
			op = gc();
			if (op == 'L') {
				skip(4);
				top++;
			} else if (op == 'F') {
				skip(5);
				end--;
			} else {
				que[top] = t = in();
				i = end; while (que[--i] != t);
				if (i > top) {
					if (end - i < i - top) {
						while (++i < end) que[i-1] = que[i];
						end--;
					} else {
						while (--i > top) que[i+1] = que[i];
						top++;
					}
				}
			}
		}
	}
	i = end-1; out(que[i--]);
	while (i > top) pc(' '), out(que[i--]);
	pc('\n');
	return 0;
}


Measured memory_bytes: 5420
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int k = n; ; ++k)
    {
        int a = k % 10, b = (k / 10) % 10, c = (k / 100);
        if (a == b && b == c)
            return cout << k, 0;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h> 
using namespace std;
int main()
{
	int n;
	scanf("%d", &n);
	double a[n],ans;
	for(int i = 0; i < n; i++){
        scanf("%lf", &a[i]);
	}
	sort(a, a + n);
	ans=(a[0]+a[1])/2;
	for(int i = 2; i < n; i++){
        ans=(ans+a[i])/2;
	}
	printf("%f\n", ans);
	
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#define int long long
using namespace std;
const int INF = 10000000000000;//5000000000000000

signed main() {
	string S;
	cin >> S;
	int one = 0;
	int zero = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '0') zero++;
		else one++;
	}
	cout << min(one, zero) * 2 << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main(){
    int n;
    cin>>n;
    vector<int> h(n);
    for (int& i : h) cin >> i;
    int mh = h[0], r = 1;
    for (int i = 1; i < n; ++i)
        if (mh <= h[i]) mh = h[i], ++r;
    cout << r;
    return 0;
}

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

const int MAX_N = 210000;

int N;
int a[MAX_N], b[MAX_N];
pair<int, int> itv[MAX_N];

bool solve() {
  bool frag = true;
  for (int i = 0; i < N; i++) {
    itv[i].first = b[i];
    itv[i].second = a[i];
  }
  sort(itv, itv + N);
  int ans = 0;
  int t1 = 0;
  int t2 = itv[N - 1].first;
  for (int i = 0; i < N; i++) {
    t1 += itv[i].second;
    if (t1 <= itv[i].first && t2 >= itv[i].first) {
    }
    else {
      frag = false;
      break;
    }
  }
  return frag;
}

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> a[i] >> b[i];
  bool ans = solve();
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3328
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

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

#include <bits/stdc++.h>

using namespace std;
int static dp[100001];
int go(int arr[],int n,int i)
{
    if(i==n-1)return dp[i]=0;
    else if(i==n-2)return dp[i]=abs(arr[n-1]-arr[n-2]);
    if(dp[i]!=-1)return dp[i];
    return dp[i]=min(abs(arr[i]-arr[i+1])+go(arr,n,i+1),abs(arr[i]-arr[i+2])+go(arr,n,i+2));
}
int main()
{
    int n;cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)cin>>arr[i];
    memset(dp,-1,sizeof(dp));
    cout<<go(arr,n,0)<<endl;
}


Measured memory_bytes: 8288
# -*- coding: utf-8 -*-

#注文してから料理が届くまでの時間
Time = []
for i in range(5):
    a = int(input())
    Time.append(a)

#注文してから次の注文が出来るまでの時間
nextTime = list(map(lambda x: (x+9)//10*10, Time))

#bestに最短時間を代入
best = 10**5
sum = 0
for i in range(5):
    for j in range(5):
        if i == j:
            sum = sum + Time[j] 
        else:
            sum = sum + nextTime[j]
    best = min(best, sum)
    sum = 0

print(best)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static final int MAX_A = 30000;

    public static void main(String[] args) {
        // read input
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();

        // solve
        if (N == 3) {
            System.out.printf("2 5 63\n");
            return;
        }
        List<Integer> as = new ArrayList<>();
        as.addAll(Arrays.asList(2, 4, 3, 9));
        N -= 4;
        // add multitples of 2
        for (int i = 2; 6 * i - 2 <= MAX_A; i++) {
            if (N < 2) {
                break;
            }
            as.add(6 * i - 2);
            as.add(6 * i - 4);
            N -= 2;
        }
        // add multitples of 3
        for (int i = 2; 12 * i - 3 <= MAX_A; i++) {
            if (N < 2) {
                break;
            }
            as.add(12 * i - 9);
            as.add(12 * i - 3);
            N -= 2;
        }
        // add multiples of 6
        for (int i = 1; 6 * i <= MAX_A; i++) {
            if (N == 0) {
                break;
            }
            as.add(6 * i);
            N--;
        }
        as.forEach(a -> System.out.printf("%d ", a));
        System.out.printf("\n");
    }
}

Measured memory_bytes: 50180
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<ll>
#define vvint vector<vint>
#define P pair<int,int>
#define INT_MAX 2147483647
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(void) {
	int a[3][3];
	bool x[3][3];
	rep(i, 3) {
		rep(j, 3) {
			cin >> a[i][j];
			x[i][j] = false;
		}
	}
	int n; cin >> n;
	rep(l, n) {
		int b; cin >> b;
		rep(i, 3) {
			rep(j, 3) {
				if (a[i][j] == b) {
					x[i][j] = true;
				}
			}
		}
	}

	int cnt = 0;
	rep(i, 3) {
		rep(j, 3) {
			if (x[i][j] == true) {
				cnt++;
			}
			if (cnt == 3) {
				cout << "Yes" << endl;
				return 0;
			}
		}
		cnt = 0;
	}
	rep(i, 3) {
		rep(j, 3) {
			if (x[j][i] == true) {
				cnt++;
			}
			if (cnt == 3) {
				cout << "Yes" << endl;
				return 0;
			}
		}
		cnt = 0;
	}
	rep(i, 3) {
		if (x[i][i] == true) {
			cnt++;
		}
		if (cnt == 3) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cnt = 0;

	rep(i, 3) {
		if (x[i][2-i] == true) {
			cnt++;
		}
		if (cnt == 3) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}



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

const int nax=2e5+5;
ll s[nax];
int h,w,a,b;
const int mod=1e9+7;

void pre()
{
    s[0]=1;
    for(int i=1;i<nax;i++)
    {
        s[i]=s[i-1]*i;
        s[i]%=mod;
    }
}

ll pp(ll a,ll b)
{
    if(b==0) return 1;
    ll res=pp(a,b/2);
    res*=res;
    res%=mod;
    if(b&1) res*=a;
    res%=mod;
    return res;
}

ll inv(ll a)
{
    return pp(a,mod-2);
}

ll nk(int n,int k)
{
    ll res=s[n];
    res*=inv(s[k]);
    res%=mod;
    res*=inv(s[n-k]);
    res%=mod;
    return res;
}

int main()
{
    cin>>h>>w>>a>>b;
    pre();
    ll ans=0;
    for(int i=1;i<=h-a;i++)
    {
        ll akt=nk(b-1+i-1,i-1);
        akt*=nk(h-i+w-b-1,h-i);
        akt%=mod;
        ans+=akt;
        if(ans>=mod) ans-=mod;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void) {
	int n, k;
	cin >> n >> k;
	int ans = 1;
	for (int i = 0; i < n; ++i) {
		if (ans * 2 - ans > k) {
			ans += k;
		}
		else {
			ans *= 2;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
 
int main(){
int N,X,L=0,a=1,i;
  scanf("%d %d",&N,&X);
  int *D=(int*)malloc(sizeof(int)*N);
  for(i=0;i<N;i++){
  	scanf("%d",&D[i]);
    L+=D[i];
    if(L<=X)a++;
    else break;
  }
  printf("%d\n",a);
  free(D);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fill( x, y ) memset( x, y, sizeof x )
#define copy( x, y ) memcpy( x, y, sizeof x )
using namespace std;

typedef long long LL;
typedef pair < int, int > pa;

inline int read()
{
	int sc = 0, f = 1; char ch = getchar();
	while( ch < '0' || ch > '9' ) { if( ch == '-' ) f = -1; ch = getchar(); }
	while( ch >= '0' && ch <= '9' ) sc = sc * 10 + ch - '0', ch = getchar();
	return sc * f;
}

LL table[25], t[25];
int D, L_D, L, ans, d[25];

inline void init()
{
	table[ 0 ] = 1;
	for( int i = 1 ; i <= 18 ; i++ ) table[ i ] = table[ i - 1 ] * 10;
}

inline void solve()
{
	int n = ( L >> 1 ) - 1; LL cur = D;
	for( int i = 0 ; i <= n ; i++ )
	{
		t[ i ] = table[ L - 1 - i ] - table[ i ];
		if( cur >= 0 )
		{
			LL c = cur % t[ i ];
			d[ i ] = -cur / t[ i ];
			if( c % table[ i + 1 ] ) d[ i ]--, c -= t[ i ];
			if( c % table[ i + 1 ] || abs( d[ i ] ) >= 10 ) return;
			cur = c;
		}
		else
		{
			LL c = ( -cur ) % t[ i ];
			d[ i ] = ( -cur ) / t[ i ];
			if( c % table[ i + 1 ] ) d[ i ]++, c -= t[ i ];
			if( c % table[ i + 1 ] || abs( d[ i ] ) >= 10 ) return ;
			cur = -c;
		}
	}
	if( cur ) return;
	int ret = 1; if( L & 1 ) ret = 10;
	for( int i = 0 ; i <= n ; i++ )
	{
		if( i ) ret *= 10 - abs( d[ i ] );
		else ret *= 10 - ( d[ i ] <= 0 ) - abs( d[ i ] );
	}
	ans += ret;
}

int main()
{
#ifdef wxh010910
	freopen( "data.in", "r", stdin );
#endif
	init();
	D = read(); int tmp = D;
	if( D % 9 ) return puts( "0" ), 0;
	while( tmp ) tmp /= 10, L_D++;
	for( L = L_D ; L <= ( L_D << 1 ) ; L++ ) solve();
	return printf( "%d\n", ans ), 0;
}


Measured memory_bytes: 256
#![allow(unused)]

use std::cmp::{min, max};

macro_rules! dbg {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

//
// Based on EbTech's Scanner https://stackoverflow.com/q/56449027
//
struct Scanner<'a, R: std::io::BufRead> {
    reader: R,
    buf: String,
    iter: std::str::SplitWhitespace<'a>,
}

impl<'a, R: std::io::BufRead> Scanner<'a, R> {
    fn new(reader: R) -> Scanner<'a, R> {
        Scanner { reader: reader, buf: String::new(), iter: "".split_whitespace() }
    }

    fn get_str(&mut self) -> &str {
        if let Some(t) = self.iter.next() {
            return t;
        }
        self.buf.clear();
        self.reader.read_line(&mut self.buf).expect("I/O error");
        self.iter = unsafe { std::mem::transmute(self.buf.split_whitespace()) };
        self.get_str()
    }

    fn get<T: std::str::FromStr>(&mut self) -> T {
        self.get_str().parse().ok().expect("Parse error")
    }
}

fn main() {
    let stdin = std::io::stdin();
    solve(Scanner::new(stdin.lock()));
}

const W_INF: i64 = 100000000001; // 10^9 x 100 + 1

fn solve<R: std::io::BufRead>(mut sc: Scanner<R>) {
    let n: usize = sc.get();
    let wmax: i64 = sc.get();
    let (ws, vs): (Vec<i64>, Vec<usize>) =
        (0..n).map(|_| (sc.get::<i64>(), sc.get::<usize>())).unzip();

    let wsum: i64 = ws.iter().sum();
    let vsum: usize = vs.iter().sum();

    // dp[i][v] = 品物 1, 2, ..., i+1 で価値が v 以上になる最小の重さ
    let mut dp = vec![W_INF; vsum + 2];
    dp[vsum] = wsum;

    for i in 0..n {
        let mut dp_ = vec![W_INF; vsum + 2];
        for v in (0..(vsum + 1)).rev() {
            dp_[v] = *[
                dp_[v + 1],
                dp[v],
                if v <= vs[i] { ws[i] } else { dp[v - vs[i]] + ws[i] },
            ].iter().min().unwrap();
        }
        dp = dp_;
    }

    println!("{}", (0..(vsum + 1)).rev().find(|&v| dp[v] <= wmax).unwrap());
}

Measured memory_bytes: 8444
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	string S; cin >> S;
  int n = S.size();

  // LR -> 分岐, RL -> 集合
  VI cn;
  rep(_,n) cn.PB(1);

  rep(_,2){
    int cnt1 = 0; int cnt2 = 0;
    rep(i,n){
      if((S[i]=='R')&&(S[i+1]=='L')){
        if(i%2){
          cn[i] += cnt1; cn[i+1] += cnt2;
          cnt1 = 0; cnt2 = 0;
        }else{
          cn[i] += cnt2; cn[i+1] += cnt1;
          cnt1 = 0; cnt2 = 0;
        }
      }else if(S[i]=='R'){
        if(i%2){
          cnt1 += cn[i]; cn[i] = 0;
        }else{
          cnt2 += cn[i]; cn[i] = 0;
        }
      }
    }
    reverse(ALL(cn));
    reverse(ALL(S));
    rep(i,n){
      if(S[i]=='L') S[i] = 'R';
      else S[i] = 'L';
    }
  }

  rep(i,n){
    cout << cn[i] << ' ';
  }
  cout << endl;

	return 0;
}


Measured memory_bytes: 1096
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define RFOR(i, a, b) for (int i = (b)-1, i##_min = (a); i >= i##_min; --i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()

#define pb push_back
#define mp make_pair
#define fst first
#define snd second

using namespace std;
using i64 = int64_t;
using u64 = uint64_t;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<i64>;
using vd = vector<double>;
using pi = pair<int, int>;
using pl = pair<i64, i64>;
using pd = pair<double, double>;

constexpr int INF = 1 << 30;
constexpr int MOD = 1000000007;

template <typename T>
void print(T &v) {
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) cout << " ";
    cout << *it;
  }
  cout << endl;
}

int main() {
  int n;
  cin >> n;
  vi A(n), L(n);
  REP(i, n) cin >> A[i];
  L[0] = A[0];
  int length = 1;

  REP(i, n) {
    if (L[length - 1] < A[i]) {
      L[length++] = A[i];
    } else {
      *lower_bound(L.begin(), L.begin() + length, A[i]) = A[i];
    }
  }

  cout << length << endl;
}


Measured memory_bytes: 3612
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        int X = scanner.nextInt();

        int[] C = new int[N];
        int[][] A = new int[N][M];

        for (int i = 0; i < N; i++) {
            C[i] = scanner.nextInt();
            for (int j = 0; j < M; j++) {
                A[i][j] = scanner.nextInt();
            }
        }

        backtrack(0, A, C, 0, X, new int[M], new boolean[N]);
        if (minimum == Long.MAX_VALUE) {
            System.out.println(-1);
        } else {
            System.out.println(minimum);
        }
    }

    private static long minimum = Long.MAX_VALUE;

    private static void backtrack(long minPrice, int[][] A, int[] C, int start, int X, int[] calculated, boolean[] visited) {
//        System.out.println(Arrays.toString(calculated));
//        System.out.println(" start = " + start + " minPrice = " + minPrice);
        if (start > C.length) {
            return;
        }

        int flag = 0;
        for (int value : calculated) {
            if (value < X) {
                flag = 1;
                break;
            }
        }
        if (flag == 0) {
            minimum = Math.min(minPrice, minimum);
            return;
        }


        for (int i = start; i < C.length; i++) {

            if (!visited[i]) {
                visited[i] = true;
                for (int j = 0; j < calculated.length; j++) {
                    calculated[j] += A[i][j];
                }
                minPrice += C[i];

                backtrack(minPrice, A, C, start + 1, X, calculated, visited);

                visited[i] = false;
                for (int j = 0; j < calculated.length; j++) {
                    calculated[j] -= A[i][j];
                }
                minPrice -= C[i];

            }
        }
    }
}

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

long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}


int main()
{
    int H, W;
    char map[25][25];
    int d[25][25];
    int dx[4] = {-1, 0, 1, 0};
    int dy[4] = {0, 1, 0, -1};
    typedef pair<int, int> P;
    int ans, temp, x, y;
    
    cin >> H >> W;
    REP(i, H)
        REP(j, W)
            cin >> map[i][j];
    
    ans = 0;
    REP(i, H)
        REP(j, W){
            if(map[i][j] == '#')
                continue;
            REP(k, H)
                REP(l, W)
                    d[k][l] = -1;
            queue<P> now;
            now.push(make_pair(i, j));
            d[i][j] = 0;
            while(!now.empty()){
                P p = now.front();
                x = p.first;
                y = p.second;
                now.pop();
                REP(k, 4){
                    if(x+dx[k] >= 0 && x+dx[k] < H && y+dy[k] >= 0 && y+dy[k] < W && map[x+dx[k]][y+dy[k]] == '.' && d[x+dx[k]][y+dy[k]] == -1){
                        now.push(make_pair(x+dx[k], y+dy[k]));
                        d[x+dx[k]][y+dy[k]] = d[x][y] + 1;
                    }
                }
            }
            temp = 0;
            REP(k, H)
                REP(l, W)
                    if(temp < d[k][l])
                        temp = d[k][l];
            //cout << i << " " << j << " " << temp << endl;
            if(ans < temp)
                ans = temp;
        }
    
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int N;
LL A[114514];
vector<int> es[114514];

LL dfs(int v, int p) {
  int num_ch = 0;
  LL s = 0;
  LL maxa = 0;
  for (int u : es[v]) {
    if (p == u) continue;
    LL a = dfs(u, v);
    s += a;
    maxa = max(maxa, a);
    num_ch++;
  }

  if (num_ch == 0) return A[v];
  LL ret = A[v]*2 - s;
  if (0 <= (s-ret)/2 && (s-ret)/2 <= min(s-maxa, s/2)) return ret;
  puts("NO");
  exit(0);
}

int main() {
  scanf("%d", &N);
  rep(i, N) {
    scanf("%lld", &A[i]);
  }

  rep(i, N-1) {
    int u, v;
    scanf("%d%d", &u, &v);
    --u;
    --v;
    es[u].eb(v);
    es[v].eb(u);
  }

  vector<int> vs(N);
  rep(i, N) vs[i] = i;
  random_shuffle(all(vs));
  
  int cnt = 0;
  rep(i, N) {
    int v = vs[i];
    if (es[v].size() > 1) {
      cnt++;
      if (dfs(v, v) != 0) {
        puts("NO");
        exit(0);
      }

      if (cnt > 20) {
        puts("YES");
        exit(0);
      }
    }
  }

  if (N > 2) {
    puts("YES");
    exit(0);
  }

  assert(N == 2);
  if (A[0] == A[1]) puts("YES");
  else puts("NO");
}


Measured memory_bytes: 14976
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>

using namespace std;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

vector<ll> count(8, 0);
ll morethan = 0;

int main() {
	ll N;
	cin >> N;
	for (ll n = 0; n < N; n++) {
		ll a;
		cin >> a;
		if (a >= 3200)morethan++;
		else ::count[a / 400]++;
	}
	if (morethan == N)cout << "1 " << N << endl;
	else {
		ll c = 0;
		for (ll n = 0; n < 8; n++) {
			if (::count[n] > 0)c++;
		}
		cout << c << " " << c+morethan << endl;
	}
	return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
N = int(input())
A = [int(i) for i in input().split()]

C = [[] for i in range(H)]
tempL = 0
remR = W
for i in range(N):
    Aleft = A[i]
    while Aleft > remR:
        if tempL % 2 == 0:
            for j in range(remR):
                C[tempL].append(i+1)
        else:
            for j in range(remR):
                C[tempL] = [i+1] + C[tempL]
        tempL += 1
        Aleft -= remR
        remR = W
    if tempL % 2 == 0:
        for j in range(Aleft):
            C[tempL].append(i+1)
    else:
        for j in range(Aleft):
            C[tempL] = [i+1] + C[tempL]
    if remR == Aleft:
        tempL += 1
        remR = W
    else:
        remR -= Aleft
for i in range(H):
    print(" ".join(map(str, C[i])))

Measured memory_bytes: 3572