akhauriyash/Code-Regression huggingface dataset:
n = int(input())
l = [int(x) for x in input().split()]
flag = 0
l[0] -= 1

for x in range(1, n):
    if l[x - 1] < l[x]:
        l[x] -= 1
    elif l[x - 1] > l[x]:
        flag = 1
        break

print("Yes" if (flag == 0) else "No")

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define trav(a,x) for (auto& a: x)
#define cout(tt) cout<<"Case #"<<(tt)<<": ";
#define minheap(name) priority_queue <int, vector<int>, greater<int> > (name); 
#define ll long long int
/*	Things to remember handling:
	1. int overflows
	2. array boundaries
	3. base cases (n=1)
*/

using namespace std;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
		int W,N;
		cin>>N>>W;
		int v[N],w[N];
		FOR(i,0,N){
			cin>>w[i];
			cin>>v[i];
		}
		vector<vector<long long int>> dp(N+1,vector<long long int>(W+1,0));
		FOR(i,1,N+1){
			FOR(j,1,W+1){
				if(w[i-1]<=j){
					int newWeight = j-w[i-1];
					dp[i][j] = max(dp[i-1][j], v[i-1] + dp[i-1][newWeight]); 
				}else
					dp[i][j] = dp[i-1][j];
			}
		}
		cout<<dp[N][W]<<endl;
			
	
}


Measured memory_bytes: 82992
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
#define F first
#define S second
#define MK make_pair
const ll E=1e17+7;



int main(){
    int n;
    cin>>n;
    cout<<n/3<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
p=998244353
r=range
f=[1]
for i in r(k):f+=[-~i*f[i]%p]
print(sum(f[k-1]*pow(f[i]*f[k-1-i],-1,p)for i in r(n-1,k))%p)

Measured memory_bytes: 28876
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int a,b;
double c;
int ilong(int a)
{
    if(a==0) return 0;
    int i=0;
    while(a!=0)
    {
        a/=10;
        i++;
    }
    return i;
}
bool zhengshu(double a)
{
    int i=a;
    return i==a;
}
int main()
{
    cin>>a>>b;
    c=a*pow(10,ilong(b))+b;
    if(zhengshu(sqrt(c))) cout<<"Yes\n"; else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
#include <set>
//#include <map>
//#include <queue>
//#include <deque>
#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b%mod ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	vll a(n) ;
	set<ll> s ;
	for(auto &i:a) cin >> i ;
	for(int i=0;i<(1<<n);i++){
		bitset<25> bit(i) ;
		ll sum = 0 ;
		for(int j=0;j<n;j++) if(bit[j]) sum += a.at(j) ;
		s.insert(sum) ;
	}
	ll q ; cin >> q ;
	for(int i=0;i<q;i++){
		ll b ; cin >> b ;
		cout << (s.count(b)?"yes":"no") << endl ;
	}
}



Measured memory_bytes: 3104
import sys
def input():return sys.stdin.readline()[:-1]
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
n,m,k=NM()
a=[0]+L()
b=[0]+L()
ans=0
INF=10**9+7
from bisect import bisect, bisect_left, bisect_right
for i in range(1,n+1):
    a[i]+=a[i-1]
    if a[i]>INF:
        a[i]=INF
for i in range(1,m+1):
    b[i]+=b[i-1]
    if b[i]>INF:
        b[i]=INF
for i in range(n+1):
    x=k-a[i]
    if x<0:
        continue
    ans=max(ans,i+bisect_right(b,x)-1)
print(ans)

Measured memory_bytes: 119752
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static Scanner;

class Program
{
    static void Main() => new Program().Solve();

    public void Solve()
    {
        long n = ReadLong();
        long m = ReadLong();
        long k = ReadLong();
        long[] a = ReadLong(n).ToArray();
        long[] b = ReadLong(m).ToArray();
        long[] aa = new long[n];
        long[] bb = new long[m];
        aa[0] = a[0];
        bb[0] = b[0];
        for (long i = 1; i < n; i++) aa[i] = aa[i - 1] + a[i];
        for (long i = 1; i < m; i++) bb[i] = bb[i - 1] + b[i];

        var x = Array.BinarySearch(aa, k);
        if (x < 0) x = ~x - 1;

        long mx = 0;
        long j = 0;
        for (long i = x; i >= -1; i--)
        {
            while ((i == -1 ? 0 : aa[i]) + bb[j] <= k)
            {
                j++;
                if (j == m) break;
            }
            j--;
            mx = Math.Max(mx, i + j + 2);
            if (j < 0) j = 0;
        }
        Console.WriteLine(mx);
    }
}

static class Scanner
{
    static Queue<string> que = new Queue<string>();

    public static string Read()
    {
        if (!que.Any()) foreach (var s in Console.ReadLine().Split()) que.Enqueue(s);
        return que.Dequeue();
    }
    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());
    public static decimal ReadDecimal() => decimal.Parse(Read());

    public static IEnumerable<string> Read(long n)
    {
        for (long i = 0; i < n; i++) yield return Read();
    }
    public static IEnumerable<int> ReadInt(long n) => Read(n).Select(int.Parse);
    public static IEnumerable<long> ReadLong(long n) => Read(n).Select(long.Parse);
    public static IEnumerable<double> ReadDouble(long n) => Read(n).Select(double.Parse);
    public static IEnumerable<decimal> ReadDecimal(long n) => Read(n).Select(decimal.Parse);
}

Measured memory_bytes: 70136
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *D = map(int, read().split())
    D.sort()

    print(D[N // 2] - D[N // 2 - 1])
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 20636
#include<bits/stdc++.h>
using namespace std;
long double pi = 3.14159265358979323846264338327950;

int main() {
	int a, b, h, m;
	cin >> a >> b >> h >> m;
	long double h_kaku = 0.5 * m + 30 * h;
	long double m_kaku = 6 * m;
	long double kaku;

	long double ans;

	if (h_kaku > m_kaku) {
		kaku = h_kaku - m_kaku;
		ans = (a * a + b * b) - (2 * a * b * cos(kaku * pi / 180));
	}
	else if (h_kaku < m_kaku) {
		kaku = m_kaku - h_kaku;
		ans = (a * a + b * b) - (2 * a * b * cos(kaku * pi / 180));
	}
	else {
      kaku = m_kaku - h_kaku;
		ans = (a * a + b * b) - (2 * a * b * cos(kaku * pi / 180));
    }
	long double ans2 = sqrt(ans);

	cout << fixed <<setprecision(20)<<ans2 << endl;
	return 0;
}


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

using namespace std;

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

int main() {
  int N;
  cin >> N;
  
  vector<int> cards(N);
  rep(i, N){
    cin >> cards.at(i);
  }
  
  sort(cards.begin(), cards.end());
  reverse(cards.begin(), cards.end());
  
  int score = 0;
  rep(i, N){
    score += (i % 2 ? -1 : 1) * cards.at(i);
  }
  cout << score << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n, cont = 0;
    //int a[100];
    scanf("%d", &n);
    for (int i = 1; i < n+1; i += 2){
        int num_div = 0;
        for (int k = 1; k < i+1; ++k){
            if ((i%k) == 0) ++num_div;
        }
        if (num_div == 8){
            //a[cont] = i;
            ++cont;
        }
    }
    /*for(int i = 0; i < 100; ++i)
        printf("%d ",a[i]);
    printf("\n");*/
    printf("%d\n", cont);

}


Measured memory_bytes: 128
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import qualified Data.Set as S

main :: IO ()
main = do
  m <- getl toInt
  unless (m == 0) $ do
    xs <- replicateM m (getl $ wrds toInt)
    n <- getl toInt
    unwords . map show . solve m xs <$> replicateM n (getl $ wrds toInt) >>= putStrLn
    main

solve :: Int -> [[Int]] -> [[Int]] -> [Int]
solve m xs ys = maybe [] id $ find f ls
  where
    db = S.fromList ys
    ls = map (\cs -> zipWith (-) cs (head xs)) ys
    f z = all (\c -> S.member c db) $ map (zipWith (+) z) xs

toInt :: String -> Int
toInt = read

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 5616
// B - Collatz Problem
#include <bits/stdc++.h>
using namespace std;

int in(){int x;cin>>x;return x;}

int main(){
	int ans = 0;
	for(int s=in(); s>4 || s==3; ans++) s = s%2? 3*s+1: s/2;
	ans += 4;
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
#define ll long long
#define ar array
static auto _ = [] {
    std::ios::sync_with_stdio (0);
    std::cin.tie (0);
    std::cout.tie (0);
    std::cerr.tie (0);
    return 0;
}
();

void solve() {
    int n, mostVotes = 0 ;
    cin >> n;
    string s;
    map<string, int> data;
    for(int i = 0; i < n; ++i){
        cin >> s;
        data[s] ++;
        mostVotes = max(mostVotes, data[s]);
    }
    for(auto d : data){
        if(d.second == mostVotes){
            cout << d.first << endl;
        }
    }
}

int main() {
    ios::sync_with_stdio (0);
    cin.tie (0);
    int testCases;
    testCases =1 ;
    while (testCases --) {
        solve();
    }
    return 0;
}




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

int main()
{
	int N;
	double ans;

	scanf("%d", &N);

	int m = (N + 1) / 2;

	//printf("%d\n", m);

	ans = double(double(m)/N);

	printf("%f", ans);

	return 0;
}
	

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int x,y,a;
	cin>>x>>y;
	if(x<y){
			swap(x,y);
			}
	while(1){
		a=x%y;
		swap(x,y);
			y=a;
		if(y==0){
			break;
			}
		}
		cout<<x<<endl;
	return 0;
	}

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

#define ff               first
#define ss               second
#define pb               push_back
#define all(x)           (x).begin(), (x).end()
#define mem0(x)          memset(x, 0, sizeof (x))
#define mem1(x)          memset(x, -1, sizeof (x))

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector <ii> vii;
typedef vector<vii> vvii;
typedef vector <ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;

vvi g;
vi vis;
int sz;

void dfs(int u){
    vis[u] = 1;
    sz++;
    for (int v: g[u]){
        if (!vis[v]) dfs(v);
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    g.assign(n, vi());
    vis.assign(n,0);
    for (int i = 0; i < m; ++i) {
        int u,v; cin >> u >> v; u--; v--;
        g[u].pb(v);
        g[v].pb(u);
    }
    int ans = 0;
    for (int j = 0; j < n; ++j) {
        if (!vis[j]){
            sz = 0;
            dfs(j);
            ans = max(ans, sz);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 21144
from fractions import gcd
N=int(input())
A=list(map(int,input().split()))
tA=list(reversed(A))
l=[0]
r=[0]
m=[]
for i in range(N):
  tmpl = l[i]
  tmpa = A[i]
  tmpta = tA[i]
  l.append(gcd(l[i],A[i]))
  r.append(gcd(r[i],tA[i]))
r=list(reversed(r))
for i in range(N):
  m.append(gcd(l[i],r[i+1]))
print(max(m))

Measured memory_bytes: 16124
def main():

    N = int(input())
    p = []
    for _ in range(N): p.append(int(input()))

    d = dict()
    for i in range(N):
        if i == 0:
            d[p[i]] = 1
        else:
            if p[i] - 1 in d:
                d[p[i]] = d[p[i]-1] + 1
            else:
                d[p[i]] = 1
    return N - max(list(d.values()))


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 34976
N = int(input())
X = [int(i) for i in input().split()]
s = min(X)
g = max(X)
ans = float('inf')
for i in range(s, g+1):
    n = 0
    for x in X:
        n += (x-i)**2
    ans = min(ans, n)
print(ans)


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

using namespace std;

#define el				'\n'
#define sz(v)			((int)((v).size()))
#define all(v)          ((v).begin()),((v).end())
#define clr(v, d)		memset(v, d, sizeof(v))

double const EPS = 1e-8, PI = acos(-1);
const int N = 2e5 + 9, M = 100 + 9, OO = (int) 1e9 + 1;
const long long MOD = 1e9 + 7;

typedef long long ll;

void OUTPUT() {
	cout << fixed << setprecision(12);
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
}

void READ() {
	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
}

int n, arr[M], tot, part, ans = OO;
int main() {
//	READ();
	OUTPUT();
	int x, a;
	cin >> x >> a;
	cout << (x < a ? 0 : 10);

	return 0;

}


Measured memory_bytes: 256
S = input()
Q = int(input())

is_reverse = False
b = ''
a = ''

for i in range(Q):
    q = input().split()
    if len(q) == 1:
        is_reverse = not is_reverse

    else:
        if (q[1] == '2' and not is_reverse) or (q[1] == '1' and is_reverse):
            a += q[2]
        else:
            b += q[2]

if is_reverse:
    print(a[::-1] + S[::-1] + b)

else:
    print(b[::-1] + S + a)


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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define ump unordered_map<ll , ll>

void doit(){
	ll n,i,j,k,c,ans=0,x;
	cin >> n;
	vector<ll>v(n);
	ump mp;
	for(i=0;i<n;i++) {
		cin >> v[i];
		mp[v[i]]++;
	}

	rep(i,0,n){
		x = v[i];
		ll x1,x2;
		bool ok = 0;
		for(j = 1; j*j <= x ; j++){ if(ok)break;
			if(x%j==0){
				x1 = x / j ;
				x2 = j ;
				if(x1 != x && mp.find(x1)!= mp.end()){
					ok=1;
					break;
				}
				if(x2 != x && mp.find(x2)!= mp.end()){
					ok=1;
					break;
				}
				if(x1==x && mp[x]>1){
					ok = 1; break ;
				}
				if(x2==x && mp[x]>1){
					ok = 1; break ;
				}
			}
		}
		if(ok==0)ans++;
	}
	cout << ans <<"\n";
	
	}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output1.txt","w",stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t = 1;
	//cin>>t;
	for(ll i = 1; i <= t; i++){
		doit();
	}
}


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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int d[n];
    int num = 0;
    for (int i = 0; i < n; i++) {
      cin >> d[i];
      bool unique = true;
      for (int j = 0; j < i; j++) {
        if (d[j] == d[i]) {
          unique = false;
        }
      }
      if (unique){
        num++;
      }
    }
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX_N 200000
using namespace std;
typedef long long lnt;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n, a[MAX_N+5], c[20];
void inc(int x) {for (int i = 0; i < 20; i++) c[i] += x>>i&1;}
void dec(int x) {for (int i = 0; i < 20; i++) c[i] -= x>>i&1;}
bool chk() {for (int i = 0; i < 20; i++) if (c[i] > 1) return false; return true;}
int main() {
	read(n); lnt tot = 0;
	for (int i = 1; i <= n; i++) read(a[i]);
	for (int l = 1, r = 1; l <= n; ) {
		for (; r <= n; r++) {inc(a[r]); if (!chk()) break;}
		if (r <= n) dec(a[r]); tot += r-l, dec(a[l++]);
	}
	return printf("%lld\n", tot), 0;
}


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

vector<int>adj[N], lst;
bool is[N];
int dp[N];

void dfs(int n)
{
    if(is[n]) return;
    is[n] = true;
    for(int x : adj[n]) dfs(x);
    lst.push_back(n);
}

int main()
{
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= m; i++)
    {
        int x, y;
        cin >> x >> y;
        adj[x].push_back(y);
    }
    for(int i = 1; i <= n; i++) dfs(i);
    for(int i = 1; i <= n; i++)
    {
        for(int x : adj[lst[i - 1]])
        {
            dp[lst[i - 1]] = max(dp[lst[i - 1]], dp[x] + 1);
        }
    }
    int ans = 0;
    for(int i = 1; i <= n ; i++) ans = max(ans, dp[i]);
    cout << ans << endl;
}





Measured memory_bytes: 8824
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N;
    cin >> N;
    cout << 800 * N - 200 *(N / 15) << endl;
}



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

#define int long long int

const int INF = 0x3f3f3f3f;
const int MAXW = 1e5+200;
const int MAX = 1e3;

using namespace std;
                    /* pos, w */
int V[MAX],W[MAX],dp[MAX][MAXW],n,wmax;

int solve(int pos, int w) {
    if(pos==n) return 0;
    if(~dp[pos][w]) return dp[pos][w];

    int ans=0;
    if(w-W[pos]>=0) {
        ans=V[pos]+solve(pos+1,w-W[pos]);
    }

    ans=max(ans,solve(pos+1,w));

    return dp[pos][w]=ans;
}

int32_t main() {

    memset(dp,-1,sizeof(dp));
    scanf("%lld%lld",&n,&wmax);

    for(int i=0;i<n;i++){
        scanf("%lld%lld",&W[i],&V[i]);
    }

    solve(0,wmax);
    printf("%lld\n",solve(0,wmax));

    return 0;
}


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

typedef long long ll;

const ll INF = 1ll << 60;
const int MAX_N = 100000;

ll A[MAX_N], D[MAX_N];
ll stops[MAX_N];

int main() {
	ll N, T, Q;
	cin >> N >> T >> Q;

	for (int i = 0; i < N; i++) {
		cin >> A[i] >> D[i];
		stops[i] = INF;
	}

	ll s = -INF;
	if (D[0] == 2) stops[0] = s;

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

		if (D[i - 1] == 1 && D[i] == 2) {
			s = (A[i] + A[i - 1]) / 2;

			for (int j = i - 1; j >= 0 && D[j] == 1; j--)
				stops[j] = s;
		}
		
		if (D[i] == 2) stops[i] = s;
	}

	for (int i = 0; i < Q; i++) {
		ll x;
		cin >> x;
		x--;
		ll ans;
		if (D[x] == 1) ans = min(A[x] + T, stops[x]);
		else ans = max(A[x] - T, stops[x]);
		cout << ans << endl;
	}
}

Measured memory_bytes: 5368
import java.io.IOException;
import java.util.*;

public class Main {

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

        System.out.println(c + " " + a + " " + b);
    }
}

Measured memory_bytes: 21716
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;

int main(){
  int N, ans = 0, check ;
  cin >> N ;
  int A[N], Num[1000001] = {} ;
  for(int i=0;i<N;i++){
    cin >> A[i] ;
    Num[A[i]]++ ;
  }
  sort(A,A+N) ;
  if(A[0] == 1){
    if(A[1] != 1){
      cout << 1 << endl ;
    }  
    else{
      cout << 0 << endl ;
    }  
    return 0 ;
  }  
  for(int i=N-1;i>=0;i--){
    if(Num[A[i]] > 1) continue ;
    check = 1 ;
    for(int j=2;j*j<=A[i];j++){
      if((A[i] % j) == 0){
        if(Num[(A[i]/j)] > 0){
          check = 0 ;
          break ;
        }
        if(Num[j] > 0){
          check = 0 ;
          break ;
        }
      }
    }
    if(check > 0) ans++ ;
  }
  cout << ans << endl ;
  return 0 ;
}  

Measured memory_bytes: 8276
# -*- coding: utf-8 -*-
"""
Created on Sat Jul  7 20:14:40 2018
SHPC_A
@author: maezawa
"""

a, b = list(map(int, input().split()))
if a+b == 15:
    print('+')
elif a*b == 15:
    print('*')
else:
    print('x')

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

typedef long long ll;
typedef unsigned long long int llu;
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define mem(a, v) memset(a, v, sizeof(a))
#define PI acos(-1)
#define S(a) scanf("%d",&a)
#define SL(a) scanf("%lld",&a)
#define S2(a, b) scanf("%d%d",&a,&b)
#define nl printf("\n")
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define deb2(x, y) cout<<#x<<" : "<<x<<" | "<<#y<<" : "<<y<<endl;
#define deb3(x, y, z) cout<<#x<<" : "<<x<<" | "<<#y<<" : "<<y<<" | "<<#z<<" : "<<z<<endl;
#define debv(x) {cout<<#x<<" : "<<endl; for(int ii =0; ii < x.size(); ii++) cout<<x[ii]<<" "; cout<<endl; }
#define debarr(x, xs) {cout<<#x<<" : "<<endl; for(int ii =0; ii < xs; ii++) cout<<x[ii]<<" "; cout<<endl; }
//auto T=clock(); 
//cout<<double(clock()-T)/CLOCKS_PER_SEC<<'\n';
//cout << fixed << setprecision(10) << f(0, 0, 0) << "\n";
const ll mod = 1000000007LL;
const int lmt = 1000005;

int main(){
    int n;
    S(n);
    int cnt = 0;
    for(int i = 0; i < n; i++) {
        int x;
        S(x);
        if(x%2 == 1)
            cnt++;
    }
    if(cnt %2 == 0)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}

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

#ifdef _LOCAL_DEBUG
#include "templates/debug.h"
#else
#define debug(...) 
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int& it : a)
        cin >> it;
    int j = 0;
    ll cash = 1000;
    for (int i = 0; i < n - 1; i++) {
        if (a[i] > a[i + 1]) {
            cash += (ll)(a[i] - a[j]) * (cash / a[j]);
            j = i + 1;
        }
    }
    cash += (ll)(a[n - 1] - a[j]) * (cash / a[j]);
    cout << cash << '\n';
    return 0;
}

Measured memory_bytes: 3576
/*
    A - Payment
    https://atcoder.jp/contests/abc173/tasks/abc173_a
*/

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define ll long long // 10 ^ 18
#define forn(i, s, n) for (int i = s; i < n; i++)
#define whilen(val, n) while(n-- && cin >> val)
#define r_1(v) cin >> v
#define r_2(v1, v2) cin >> v1 >> v2

int main() {
    // ios::sync_with_stdio(0);
    // cin.tie(0);
    int n;
    r_1(n);
    if (n % 1000 == 0) cout << 0;
    else cout << abs((n % 1000) - 1000);
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>

int main(void){

    char S[100];
    char T[100];
    int flag=1,i;

    scanf("%s",S);
    scanf("%s",T);

    for(i=0;i<strlen(S);i++){
        if(S[i] != T[i]){
            flag = 0;
            break;
        }
    }

    if(flag==1){
        printf("Yes");
    }
    else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

int main(void)
{
	string S;
	cin >> S;

	sort(S.begin(), S.end());

	if(S == "abc")
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main(void)
{
	string s;
	cin >> s;
	int x;
	int op1,op2,op3;

	for(int i=-1;i<=1;i+=2)
	{
		for(int j=-1;j<=1;j+=2)
		{
			for(int k=-1;k<=1;k+=2)
			{
				x=(s[0]-'0')+i*(s[1]-'0')+j*(s[2]-'0')+k*(s[3]-'0');
				if(x==7)
				{
					op1=i;
					op2=j;
					op3=k;
					break;
				}
			}
			if(x==7)break;
		}
		if(x==7)break;
	}

	cout << s[0] << (op1==1 ? '+':'-') << s[1] << (op2==1 ? '+':'-') << s[2] << (op3==1 ? '+':'-') << s[3] << "=7" << endl;
}

Measured memory_bytes: 256
n = int(input())
a = sorted(list(map(int,input().split())))
cnt = [a[1],a[0]]
for i in range(1,n):
  a[i] %= cnt[-1]
  if (a[i] != 0) and (a[i] < cnt[-1]):
    cnt.append(a[i])
    cnt.pop(0)
if a[1] == 0:
  print(a[0])
else:
  while cnt[1] != 0:
    cnt.append(cnt[0]%cnt[1])
    cnt.pop(0)
  else:
    print(cnt[0])

Measured memory_bytes: 14224
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(A: int, B: int, C: int):

    ans = 0
    while(A%2 == 0 and B%2 == 0 and C%2 == 0):
        oA, oB, oC = A, B, C
        A2, B2, C2 = A//2, B//2, C//2
        A = B2 + C2
        B = A2 + C2
        C = A2 + B2
        if A == oA and B == oB and C == oC:
            print('-1')
            exit()
        ans += 1

    print(ans)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double INF=1e+10;
const long double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
char in[5100];
int R,G,B;
int main(){
	int a;scanf("%d",&a);
	scanf("%s",in);
	for(int i=0;i<a;i++){
		if(in[i]=='R')R++;
		if(in[i]=='G')G++;
		if(in[i]=='B')B++;
	}
	long long ret=(long long)R*G*B;
	for(int i=0;i<a;i++){
		for(int j=1;j<a;j++){
			if(i-j<0)continue;
			if(i+j>=a)continue;
			if(in[i]!=in[i-j]&&in[i]!=in[i+j]&&in[i-j]!=in[i+j])ret--;
		}
	}
	printf("%lld\n",ret);
}

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

int cc(long long i)
{
    int ans=0;
    while(i)
    {
        if(i%2)
        ans++;
        i/=2;
    }
    return ans;
}
int main() {
	// your code goes here

int n;
cin>>n;
int arr[n];
long long ans=0;
int ec = 0 ; int oc=0;
for(int i =0;i<n;i++)
{ cin>>arr[i];
 if(arr[i]&1) oc++; 
 else {
       int a=arr[i];
       long long c=0;
       while(a>0)
       {
           if(a%2==0)
           c++;
           else break;
           a=a/2;
       }
       ans+=c;
 }
    
}
 cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 256
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = if n <= m then  List.range n `To m else []
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

module ModOp = struct
  let prime = 1_000_000_007
  let (-) a b = (a + prime - b) mod prime
  let (+) a b = (a + b) mod prime
  let ( * ) a b = (a * b) mod prime

  let rec pow x n =
    if n = 0 then 1
    else if n mod 2 = 0 then pow (x*x) (n/2)
    else x * pow (x*x) (n/2)
end

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

let scan_list ?sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);
  arr

let atoi c = Char.code c - Char.code '0'
let itoa n = Char.chr (n + Char.code '0')

let rec powerset = function
  | [] -> [[]]
  | hd::tl ->
    let pws =  powerset tl in
    pws @ ListL.map pws ~f:(fun pw -> hd::pw)

let permutations l =
  let rec interleave x = function
    | [] -> [[x]]
    | (hd::tl) as l ->
      (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in
  let rec aux = function
    | [] -> [[]]
    | a::rest ->
      aux rest |> ListL.map ~f:(interleave a) |> List.concat in
  aux l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let zip l m =
  let n = min (List.length l) (List.length m) in
  List.combine (List.take n l) (List.take n m)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let s = scan "%s" id

let palidrome s =
  let s = String.to_list s in
  ListL.for_all ~f:(fun (a,b) -> a = b) (zip s @@ List.rev s)

let () =
  if palidrome s && palidrome @@ String.sub s 0 (String.length s / 2) &&
     palidrome @@ String.sub s ((String.length s)/2+1) (String.length s / 2) then
    Printf.printf "Yes\n"
  else Printf.printf "No\n"


Measured memory_bytes: 5360
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

const string YES = "Yes";
const string NO = "No";

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n, long long k, std::vector<long long> a){
    for(int i = k; i < n; ++i){
        cout << (a[i - k] < a[i] ? YES : NO) << endl;
    }
}


signed main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 4844
#include <iostream>

int main()
{
	int a, b, c;

	std::cin >> a >> b >> c;

	if (a < b && b < c) {
		std::cout << "Yes" << std::endl;
	}
	else  {
		std::cout << "No" << std::endl;
	}
    return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <algorithm>

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

int main() {
	
	int n;
	std::cin >> n;

	std::vector<int> a(n);
	REP(i, n) std::cin >> a[i];

	std::sort(a.begin(), a.end());

	std::cout << a[n - 1] - a[0] << std::endl;

	return 0;
}

Measured memory_bytes: 256
#encoding: utf-8                                                                                                                                                                 

def input
  size = []
  n = gets.chomp.to_i
  (1..n).each do |i|
    sz = gets.chomp.split(/\s/).collect{ |x| x.to_i}
    size << { :row => sz[0], :col => sz[1]}
  end
  [n, size]
end

def solve(n, size)
  dp = { }
  0.upto(n - 1).each do |i|
    i.upto(n - 1).each do |j|
      dp[[i, j]] = 0x3fffffff
    end
  end

  0.upto(n - 1) { |i| dp[[i, i]] = 0}

  1.upto(n - 1).each do |k|
    0.upto(n - k - 1).each do |i|
      i.upto(i + k - 1).each do |j|
        sz = size[i][:row] * size[j][:col] * size[i + k][:col]
        dp[[i, i + k]] = [dp[[i, i + k]], dp[[i, j]] + dp[[j + 1, i + k]] + sz].min
      end
    end
  end
  dp
end

def main
  n, size = input
#  p size                                                                                                                                                                        
  dp = solve(n, size)
  puts dp[[0, n - 1]]
end

main

Measured memory_bytes: 6216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s[1]==s[2]&&s[3]==s[1] || s[1]==s[2]&&s[0]==s[1]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define db double
#define iosks std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int N=1e7+10,M=3e4+10;
const ll inf=INT_MAX,mod=1e9+7;
const db pi=atan(1)*4;
ll pow2(ll a,ll b) {ll s=1; while(b) {if(b&1) s=(s*a)%mod; a=(a*a)%mod; b/=2; } return s;}
ll lcm(ll a,ll b) {return a/__gcd(a,b)*b; }
int read()
{
    int s=0,f=1; char ch=getchar();
    while(ch<'0'&&ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') {s=s*10+ch-'0'; ch=getchar();} return s*f;
}

string s;

int main()
{
    iosks;
    int ans=1e9,n,r=0,w=0;
    cin>>n>>s;
    for(int i=0;i<n;i++) if(s[i]=='R') r++;
    ans=min(r,n-r);
    for(int i=0;i<n;i++){
        if(s[i]=='W') w++;
        if(s[i]=='R') r--;
        ans=min(ans,max(r,w));
    }
    cout<<ans<<endl;
    return 0;
}
/**
23
3 2 1
3 2 1

*/

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using psi=pair<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
template<class T>void geti(T&a){for(auto&_:a)cin>>_;}
template<class T>void getii(T&a){for(auto&_:a)geti(_);}
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__)
#define dclt(t,...) t __VA_ARGS__;get(__VA_ARGS__)

int main(){
	int n,ans=0;
	cin>>n;
	vi a(n);
	for(auto&&i:a)cin>>i;
	
	rep(i,n){
		int minj=i;
		range(j,i,n){
			if(a[j]<a[minj]) minj=j;
		}
		if(i!=minj){
			ans++;
		swap(a[i],a[minj]);
		}
	}
	puti(a);
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  if(n % 2) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 0, f = 10;
  while(f <= n) {
    ans += n / f;
    f *= 5;
  }
  cout << ans << endl;
}

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

int main() {
  int NUM[8], P[8], Q[8];
  int N,p,q;
  cin >> N;
  rep(i, N) cin >> P[i];
  rep(i, N) cin >> Q[i];
  rep(i, N) NUM[i] = i+1;
  int cnt = 0;
  do {
    cnt++;
    bool flag = true;
    rep(i, N) {
      if(P[i] != NUM[i]) flag = false;
    }
    if(flag) p = cnt;
  } while(next_permutation(NUM, NUM+N));
  cnt = 0;
  do {
    cnt++;
    bool flag = true;
    rep(i, N) {
      if(Q[i] != NUM[i]) {
        flag = false;
      }
    }
    if(flag) q = cnt;
  } while(next_permutation(NUM, NUM+N));
  cout << abs(p - q) << endl;
  return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
const int maxn = 1001;
int vis[maxn][maxn];
int n,d1,d2;
void set(int d){
	int t = 0;
	for(;d % 4 == 0;d /= 4) ++ t;
	if(d % 4 == 1){
		for(int i = 0;i < n * 2;++i) for(int j = 0;j < n * 2;++j)
			vis[i][j] |= (i ^ j) >> t & 1;
	} else {
		for(int i = 0;i < n * 2;++i) for(int j = 0;j < n * 2;++j)
			vis[i][j] |= i >> t & 1;
	}
}
int main(){
	std::ios_base::sync_with_stdio(false),std::cin.tie(0);
	std::cin >> n >> d1 >> d2;
	set(d1); set(d2);
	for(int i = 0,cnt = 0;i < n * 2;++i) for(int j = 0;j < n * 2;++j)
		if(!vis[i][j]) {
			std::cout << i << ' ' << j << '\n';
			if(++cnt == n * n) return 0;
		}
}


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

#define ALL(a) (a).begin(), (a).end()
typedef long long ll;
#define INF ((int)1e9+1)

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(auto &e : a)cin >> e;
	vector<ll> dp(n,INF);
	for(int i = 0; i < n; i++){
		*lower_bound(ALL(dp), a[i]) = a[i];
	}
	cout << distance(dp.begin(), lower_bound(ALL(dp),INF)) << endl;
	return 0;
}



Measured memory_bytes: 3896
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define eb emplace_back
#define precision(n) cout << fixed << setprecision(n);
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
int main()
{
    fast;
    int a[100001];
    int n,m;
    cin>>n>>m;
    int sum=0;
    for(int i=0;i<m;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<m;i++)
    {
        sum+=a[i];
    }
    if(sum>n)
    {
        cout<<-1<<endl;
    }
    else
        cout<<n-sum<<endl;

    return 0;
}


Measured memory_bytes: 3704
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N, D = map(int, rl().split())
    XY = [list(map(int, rl().split())) for _ in range(N)]
    
    ans = 0
    for x, y in XY:
        if (x ** 2 + y ** 2) ** 0.5 <= D:
            ans += 1
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 100768
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define NL << endl
using namespace std;
using ll = long long;
const int INFINT = 1 << 30;
const ll INFLL = 1LL << 60;
const int MOD = 1000000007;
int gcd(int a, int b) {return b ? gcd(b, a%b) : a;}

int main() {

	int n;
	int i;

	cin >> n >> i;

	cout << n - i + 1 NL;

	return 0;
}

Measured memory_bytes: 256
import numpy as np

abc=list(map(int,input().split()))
abc=np.array(abc)
abc=np.sort(abc)

abc=abc-abc[0]

b=abc[1]
k=abc[2]-b

if b%2==0:
    ans=b//2+k
    print(ans)

else:
    ans=k+2+(b-1)//2
    print(ans)

Measured memory_bytes: 21424
import sys

n, m = map(int, input().split())
aaa = set()
if m != 0:
    for _ in range(m):
        aaa.add(int(input()))
    
    
dp = [0] * (n + 1) # 0 array
dp[0] = 1
dp[1] = 1 if 1 not in aaa else 0 # 入ってはいけない段に1が存在した場合は0
MOD = int(1e9) + 7

for i in range(2, n + 1):
    if i in aaa:
        continue
    dp[i] = (dp[i-2] + dp[i-1]) % MOD # 入ってはいけないところからの遷移の場合0を加算
print(dp[n])

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

using namespace std;

int num[1000010];
int cnt[1000010];

int main(){
	int n,k,q;
	scanf("%d%d%d", &n,&k,&q);
	for(int i=0;i<q;i++)
		scanf("%d", &num[i]);
	for(int i=0;i<=n;i++)
		cnt[i]=0;
	for(int i=0;i<q;i++)
		cnt[num[i]]++;
	for(int i=1;i<=n;i++)
		puts( cnt[i]>(q-k) ? "Yes" : "No" );
	return 0;	
}

Measured memory_bytes: 5120
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int X,Y;

int extgcd(int a,int b,int &x,int &y){
	int g=a;
	x=1,y=0;
	if(b!=0){
		g=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}
	return g;
}
 
// 逆元
int mod_inverse(int a,int m){
	int x, y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}
 
// 階乗
std::vector<int>fact;
void mod_fact(int n, int m){
	fact.resize(n+1);
	fact[0]=1;
	for(int i=1;i<=n;i++){
		fact[i]=fact[i-1]*i%m;
	}
}
 
// nCk mod p
int mod_nCr(int n, int k, int m){
	if(n<k)return 0;
	return fact[n]*mod_inverse(fact[k]*fact[n-k]%m,m)%m;
}

signed main(){
	cin>>X>>Y;
	mod_fact(1000010,MOD);
	if((X+Y)%3!=0){
		cout<<0<<endl;
	}
	else{
		int G=(X+Y)/3;
		int cnt=0;
		for(int i=G;i<=G*3-G;i++){
			if(i==X&&Y==X+Y-i){
				cout<<mod_nCr(G,cnt,MOD)<<endl;
				return 0;
			}
			cnt++;
		}
		cout<<0<<endl;
	}
	return 0;
}


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

int main(){
  int x,y,ans;
  cin >> x;
  ans = 0;
  if(x < 4){
    ans = 1;
  }else{
  for(int i = 2;i < x;i++){
    y = i;
    while(y < x){
      y *= i;
      if(ans < y && y <= x){
        ans = y;
        }
      }
    }
  }
      
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
from copy import deepcopy as dc
input = sys.stdin.buffer.readline
N = int(input())
d = [list(map(int, input().split())) for _ in range(N)]
d2 = dc(d)
for k in range(N):
  for i in range(N):
    for j in range(N):
      d2[i][j] = min(d2[i][k] + d2[k][j], d2[i][j])
f = 0
for i in range(N):
  for j in range(N):
    if d[i][j] != d2[i][j]:
      f = 1
if f:
  print(-1)
else:
  res = 0
  for i in range(N):
    for j in range(N):
      x = 1
      for k in range(N):
        if k != i and k != j:
          if d[i][j] == d[i][k] + d[k][j]: x = 0
      res += x * d[i][j]
          
  print(res // 2)

Measured memory_bytes: 56924
mod = 10 ** 9 + 7
N, M = map(int, input().split())
if abs(N - M) > 1:
    print(0)
else:
    if N < M:
        N, M = M, N
    ans = 1
    for i in range(1, M + 1):
        ans = ans * i % mod
    if N == M:
        print(ans ** 2 * 2 % mod)
    else:
        print(ans ** 2 * N % mod)

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

int n, l, q;
vector<int> x;
vector<vector<int>> memo, rmemo;

int calc(int lef, int righ, vector<vector<int>>& v);

int main() {
  cin >> n;
  x.resize(n);
  for (auto& p : x) cin >> p;
  cin >> l >> q;
  auto makememo = [] {
    vector<vector<int>> res(n, vector<int>(31, 0));
    for (int i = 0, j = 0; i < n; ++i) {
      while (j < n - 1 && x[j + 1] - x[i] <= l) ++j;
      res[i][0] = j;
    }
    for (int j = 1; j < 31; ++j)
      for (int i = 0; i < n; ++i) res[i][j] = res[res[i][j - 1]][j - 1];
    return res;
  };
  memo = makememo();
  reverse(x.begin(), x.end());
  for (auto& p : x) p = (long long)(1e9) - p;
  rmemo = makememo();
  for (int i = 0; i < q; ++i) {
    int a, b;
    cin >> a >> b;
    if (a < b) {
      --a, --b;
      cout << calc(a, b, memo) << endl;
    } else {
      a = n - a;
      b = n - b;
      cout << calc(a, b, rmemo) << endl;
    }
  }
  return 0;
}
int calc(int lef, int righ, vector<vector<int>>& v) {
  int res = 0;
  while (lef < righ) {
    int id = 0;
    while (v[lef][id] < righ) ++id;
    id = max(id - 1, 0);
    lef = v[lef][id];
    res += 1 << id;
  }
  return res;
}

Measured memory_bytes: 36500
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
const int N = 3e3 + 5;
const int mod = 1e9 + 7;
int dp[N][N], n, m;
char s[N][N];
int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; ++i)
		scanf("%s", s[i] + 1);
	dp[1][1] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			if (s[i + 1][j] == '.')
				(dp[i + 1][j] += dp[i][j]) %= mod;
			if (s[i][j + 1] == '.')
				(dp[i][j + 1] += dp[i][j]) %= mod;
		}
	}
	cout << dp[n][m];
}


Measured memory_bytes: 18688
a,b,c,x,y=gets.split.map(&:to_i)
ans=a*x+b*y
curr=0
0.upto(([x,y].max)) do |i|
  curr=a*[0,x-i].max+b*[0,y-i].max+2*c*i
  if ans>curr
    ans=curr
  end
end
puts ans


Measured memory_bytes: 14356
import sys
def solve():
    person = 0
    for i in range(0,H):
        for j in range(0,W):
            if geo[i][j] is not "_":
                search(i,j)
                person += 1
    print(person)

def search(i,j):
    temp = geo[i][j]
    geo[i][j] = "_"
    for a in range(0,4):
        idx, jdy = i + dx[a], j + dy[a]
        if(isOnMap(idx, jdy)):
            if(isNeededToSolve(temp, idx, jdy)):
                search(idx,jdy)

def isOnMap(i,j): return (0<=i and 0<=j and i<H and j<W)

def isNeededToSolve(temp,i,j):
    target = geo[i][j]
    return (target is not "_" and temp is target)

limit = 10**7
sys.setrecursionlimit(limit)

H, W, tempH = -1, -1, 0
dx = [-1,0,1,0]
dy = [0,-1,0,1]
geo = [[0 for i in range(1)]for j in range(1)]
while True:
    line = input()
    if H is -1 and W is -1:
        p = line.split(" ")
        H, W = int(p[0]), int(p[1])
        geo = [[0 for i in range(W)] for j in range(H)]
    else:
        geo[tempH] = list(line)
        tempH+=1
    if H is 0 and W is 0:break
    if tempH is H:
        solve()
        H, W, tempH = -1, -1, 0

Measured memory_bytes: 16080
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <queue>
#include <assert.h>
using namespace std;
#define LL long long
#define pii pair < int , int >
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int n;
double A[105];

int main(){

	// ios_base::sync_with_stdio(0);
	// cin.tie(0);
	// cout.tie(0);

	scanf("%d",&n);
	for ( int i = 0; i < n; i++ ){
		// cin >> A[i];
		scanf("%lf",&A[i]);
		A[i] = 1.0 / A[i];
	}
	double sum = 0;
	for ( int i = 0; i < n; i++ ) sum += A[i];
	sum = 1.0/sum;
	printf("%.10lf\n",sum);

	return 0;
}

Measured memory_bytes: 256