akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	int n;
	int h;
	int w;
	cin>>n >> h >> w;

	int ans = 0;
	for (int i = 0; i < n; i++) {
		int a, b; cin >> a >> b;

		if (a >= h && b >= w)ans++;
	}

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

Measured memory_bytes: 256
#include <stdio.h>

#define MAX (999999)

int main(void)
{
	int i, j;
	char p[MAX] = {0};
	// ツェツ素ツ青板表ツ催ャツ青ャツづ可使ツづつスツェ
	int n, ans;
	
	// ツつアツづつゥツづァツ素ツ青板表ツ催ャツ青ャ
	p[0] = 1;
	for (i = 2; i <= (MAX / 2); i++){
		for (j = 2; (i * j) <= MAX; j++){
			if (p[(i * j) - 1] == 0){
				p[(i * j) - 1] = 1;
			}
		}
	}
	// ツつアツつアツづ慊づ！
	
	// ツ本ツ氾板つ「ツづつュツづヲツー
	while (scanf("%d", &n) != EOF){
		ans = 0;
		for (i = 0; i < n; i++){
			if (p[i] == 0){
				ans++;
//				printf("%d:", i);
			}
		}
		printf("%d\n", ans);
	}
	
	return (0);
}

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

int64_t n,A,B,C,D;

int main()
{
    cin>>n>>A>>B>>C>>D;
    for(int64_t i=0;i<n;i++)
        if(C*(n-i-1)-D*i<=B-A&&B-A<=-C*i+D*(n-i-1))
        {
            cout<<"YES\n";
            return 0;
        }
    cout<<"NO\n";
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            while(true){
                int n = sc.nextInt();
                if(n==0){
                    break;
                }

                int[] point = new int[n];
                int maxPoint=0;
                int maxN=0;
                int minPoint=1000;
                int minN=0;

                for(int i=0;i<n;i++){
                    point[i] = sc.nextInt();

                    if(maxPoint<point[i]){
                        maxPoint = point[i];
                        maxN = i;
                    }
                    if(minPoint>point[i]){
                        minPoint = point[i];
                        minN = i;
                    }
                }

                point[maxN] = 0;
                point[minN] = 0;

                int sum =0;
                for(int i=0;i<n;i++){
                    sum = sum + point[i];
                }

                int answer = sum/(n-2);
                System.out.println(answer);
            }
        }
    }
}


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

int main(void){
    int a[3];
    rep(i,3)cin >> a[i];
    sort(a,a+3);
    cout << a[2]-a[0] << endl;
    return 0;
}

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


int ASC(const void *a, const void *b) {
	return *(int *)b - *(int *)a;//降順
}
int GCD(int a, int b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main(void)
{
	double a;
	scanf("%lf",&a);
	double ans = a*3.14159*2;
	printf("%lf",ans);
	return 0;
}

Measured memory_bytes: 1740
#include<stdio.h>
int main()
{
char s[3];
        scanf("%s",&s);
        if(s[0]=='a'&&s[1]=='b'&&s[2]=='c')
            printf("Yes");
        else if(s[0]=='a'&&s[1]=='c'&&s[2]=='b')
            printf("Yes");
        else if(s[0]=='b'&&s[1]=='a'&&s[2]=='c')
            printf("Yes");
        else if(s[0]=='b'&&s[1]=='c'&&s[2]=='a')
            printf("Yes");
        else if(s[0]=='c'&&s[1]=='a'&&s[2]=='b')
            printf("Yes");
        else if(s[0]=='c'&&s[1]=='b'&&s[2]=='a')
            printf("Yes");
            else
                printf("No");
            return 0;

}

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

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

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int N;
    cin >> N;

    ll tot = 0;
    int bs = INT_MAX;

    vi a(N), b(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i] >> b[i];
        tot += a[i];

        if (a[i] > b[i]) {
            bs = min(bs, b[i]);
        }
    }

    if (a == b) { cout << 0 << endl; return 0; }

    ll ans = tot - bs;
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<set>
#include <functional>
#include <limits>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

template<typename T>
class segment_tree{
	int n;
	T fval;
	function<T(T,T)> operation;
	vector<T> dat;
	
	T _query(int a, int b, int k, int l, int r){
		if(r <= a || b <= l){
			return fval;
		}
		
		if(a <= l && r <= b){
			return dat[k];
		}else {
			T vl = _query(a, b, k * 2 + 1, l, (l + r) / 2 );
			T vr = _query(a, b, k * 2 + 2, (l + r) / 2, r);
			return operation(vl, vr);
		}
	}
	
public:
	
	segment_tree(){
		
	}
	
	segment_tree(int n_, T val, function<T(T,T)> fun){
		init(n_, val, fun);
	}
	
	~segment_tree(){
		
	}
	
	void init(int n_, T val, function<T(T,T)> fun){
		fval = val;
		
		operation = fun;
		
		n = 1;
		
		while(n < n_) n *= 2;
		
		dat.resize(2 * n - 1);
	
		for(int i = 0; i < 2 * n - 1; i++) dat[i] = fval;
	}

	void update(int k, T a){
		k += n - 1;
		dat[k] += a;
		while(k > 0){
			k = (k - 1) / 2;
			dat[k] = operation(dat[k*2 + 1],dat[k*2 + 2]);
		}
	}
	
	T query(int a, int b){
		return _query(a, b, 0, 0, n);
	}
	
};



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, K;
	int res = 0;
	vector<int> a, sum, sum2, v;
	segment_tree<int> seg;
	
	cin>>N>>K;
	
	a.resize(N);
	sum.resize(N+1);
	sum2.resize(N+1);
	seg.init(N + 2, 0, [](int first, int second){ return (first+second);});
	
	for(int i = 0; i < N; i++){
		cin>>a[i];
		a[i] -= K;
	}
	
	for(int i = 0; i < N; i++){
		sum[i+1] += sum[i] + a[i];
		v.push_back(sum[i+1]);
	}
	
	v.push_back(0);
	
	sort(v.begin(), v.end());
	
	v.erase(unique(v.begin(), v.end()), v.end());
	
	for(int i = 0; i <= N; i++){
		sum2[i] = lower_bound(v.begin(), v.end(), sum[i]) - v.begin();
	}
	
	seg.update(sum2[0], 1);
	
	for(int i = 0; i < N; i++){
		
		res += seg.query(0, sum2[i+1]+1);
		seg.update(sum2[i+1], 1);
	}
	
	cout<<res<<endl;
	
	
	return 0;
}


Measured memory_bytes: 8280
A,B,C,X,Y = map(int,input().split())
C*=2
minxy = min(X,Y)
maxxy = max(X,Y)
ans1 = C * minxy + A * (X-minxy) + B * (Y-minxy)
ans2 = A*X + B*Y
ans3 = C * maxxy
print (min(ans1,ans2,ans3))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld double
#define ff first
#define ss second
int main(){
	string w; cin>>w;
	vector<int>a(26,0);
	for(int i=0;i<(int)w.length();++i){
		a[w[i]-'a']++;
	}
	bool ans=true;
	for(int i=0;i<26;++i){
		if(a[i]&1){
			ans=false;
			break;
		}
	}
	if(ans) printf("Yes\n");
	else printf("No\n");
	return 0;
}


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

//iは１～Hのインデックス番号

//これらはインデックス番号を返してるだけ
int parent(int i){
    return i/2;
}
//インデックス番号Hを超えることはありえない
int left_child(int i){
    return i*2;
}

int right_child(int i){
    return i*2+1;
}

int main(){
    int H; cin >> H;
    vector <int> A(H+1);
    rep(i,H) cin >> A[i];
    
    rep(i,H){
        cout << "node " << i << ": " << "key = " << A[i] << ", ";
        if(parent(i)>=1) cout << "parent key = " << A[parent(i)] << ", ";
        if(left_child(i)<=H) cout << "left key = " << A[left_child(i)] << ", ";
        if(right_child(i)<=H) cout <<"right key = " << A[right_child(i)] <<", ";
        cout << endl;
        
    }
}


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

long long lcm(long long number1,long long number2){
	long long m = number1;
	long long n = number2;

	if(number2 > number1){
		m = number2;
		n = number1;
	}

  long long tmp = m % n;
  while(tmp!=0){
    m = n;
    n = tmp;
    tmp = m % n;
  }
  return number1 * number2 /n;
}


int main(){
  long long A, B, C, D;
  cin >> A >> B >> C >> D;
  long long r = lcm(C, D);
  
  cout << (B - A + 1) - (B/C - (A-1)/C) -(B/D - (A-1)/D) + (B/r - (A-1)/r) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define rep(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000000000001
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
void YN(int a){if(a==1)printf("Yes\n");if(a==0)printf("No\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int main(){
  LL H,W,dp[110][110],dx[2]={0,1},dy[2]={1,0},x,y,i,j,k,a,ans=0;
  char s[110][110];
  scanf("%lld%lld",&H,&W);
  rep(i,H)scanf("%s",s[i]);
  rep(i,H)rep(j,W)dp[i][j]=INF;
  dp[0][0]=0;
  if(s[0][0]=='#')dp[0][0]++;
  rep(i,H)rep(j,W)rep(k,2){
    x=i+dy[k],y=j+dx[k],a=0;
    if(s[i][j]=='.'&&s[x][y]=='#')a++;
    dp[x][y]=MIN(dp[x][y],dp[i][j]+a);
  }

  printf("%lld\n",dp[H-1][W-1]);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int MAX = 999999999;

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

    vector<int> nums(n);
    rep(i, n) cin >> nums[i];

    vector<int> origin_nums = nums;
    sort(all(nums));

    rep(i, n){
        cout << nums[n/2 + (int)(origin_nums[i] < nums[n/2]) - 1] << endl;
    }
}

Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
 
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;

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

void pp(vector<vi> &v){
	rep(i, v.size()){
		rep(j, v.size()){
			cout << v[i][j] << ' ';
		}
		cout << endl;
	}
	cout << endl;
}

bool check(vector<vi> &v, int nx, int ny, int revdir){
	rep(i, 4){
		if(revdir == i) continue;
		int x = nx+dx[i];
		int y = ny+dy[i];
		if(v[y][x] == 1) return false;
	}
	return true;
}

int main(){
	int d;
	cin >> d;
	rep(k, d){
		if(k)cout << endl;
		int n;
		cin >> n;
		vector<vi> v(n+4, vi(n+4, 0));
		rep(i, n+4) rep(j, n+4) if(i == 0 || i == n+3 || j == 0 || j == n+3) v[i][j] = 1;
		int x = 2;
		int y = n+3-2;
		int dir = 0;
		v[y][x] = 1;

		bool end = false;
		while(1){
			int nx = x+dx[dir];
			int ny = y+dy[dir];
			if(check(v, nx, ny, (dir+2)%4)){
				v[ny][nx] = 1;
				x = nx, y = ny;
				end = false;
			}else{
				dir = (dir+1)%4;
				if(end) break;
				end = true;
			}
		}

		//pp(v);
		for(int i = 2; i < n+2; i++){
			for(int j = 2; j < n+2; j++){
				cout << (v[i][j]?'#':' ');
			}
			cout << endl;
		}
	}

	return 0;
}

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

using namespace std;

#define int long long 
#define double long double 
#define endl '\n'
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007

int32_t main()
{
	int n;
	cin >> n;
	cout << n+(n*n)+(n*n*n) << endl;
	return 0;
}


Measured memory_bytes: 3488
#include<stdio.h>

int factorial(int n){
	if(n>0)
		return n*factorial(n-1);
	else
		return 1;
}

int main(void){

	int n;

	scanf("%d",&n);

	if(n == 20)
		printf("2432902008176640000\n");
	else
		printf("%d\n",factorial(n));

	return 0;
}

Measured memory_bytes: 576
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
int main()
{
	int H,W,h,w,tot,sum,cnt;
	cin>>H>>W;
	cin>>h>>w;
	tot=H*W;
	sum=h*W+H*w-h*w;
	cnt=tot-sum;
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

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

//最大公約数
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}

//最小公倍数
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int main(){
	char s;
	int f = 1;
	
	while (scanf("%c", &s), s != '\n'){
		if (f == 1){
			printf("%c", s+('A'-'a'));
			f = 0;
		}
		if (s == ' ') f = 1;
	}
	
	cout << endl;
	
	return 0;
}

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


def main():
    """Function."""
    n = int(input())
    s = str(input())
    t = str(input())

    counter = 0
    for i in range(n):
        if s[-(i+1):] == t[:(i+1)]:
            counter = i + 1

    print(len(s) + len(t) - counter)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
N, A, B, K = map(int, input().split())
mod = 998244353
frac = [1]*(N+1)
for i in range(2,N + 1):
    frac[i] = i * frac[i-1]%mod
fraci = [None]*(N+1)
for i in range(N + 1):
    fraci[i] = pow(frac[i], mod-2, mod)
def comb(a, b):
    if not a >= b >= 0:
        return 0
    return frac[a]*fraci[b]*fraci[a-b]%mod

ans = 0
for i in range(N+1):
    if (K - i*A) % B:
        continue
    j = (K-i*A)//B
    ans = (ans + comb(N, i)*comb(N, j))% mod
print(ans)
 

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

int main() {
    string s; cin >> s;
    int m = s.size();
    int n; cin >> n;
    vector<int> l(n), r(n);
    vector<vector<int>> sg(m);
    for (int i = 0; i < n; ++i) {
        cin >> l[i] >> r[i];
        --l[i], --r[i];
        if (m % 2 == 0) {
            if (l[i] < m / 2 && r[i] >= m / 2) {
                int g = min(m / 2 - l[i], r[i] - m / 2 + 1);
                int tl = m / 2 - g, tr = m / 2 + g - 1;
                if (tl == l[i] && tr == r[i]) continue;
                if (tl == l[i]) l[i] = tr + 1;
                else r[i] = tl - 1;
            }
        } else {
            if (l[i] <= m / 2 && r[i] >= m / 2) {
                int g = min(m / 2 - l[i], r[i] - m / 2);
                int tl = m / 2 - g, tr = m / 2 + g;
                if (tl == l[i] && tr == r[i]) continue;
                if (tl == l[i]) l[i] = tr + 1;
                else r[i] = tl - 1;
            }
        }
        // printf("l = %d r = %d\n", l[i], r[i]);
        if (r[i] < m / 2) sg[l[i]].push_back(r[i]);
        else sg[m - 1 - r[i]].push_back(m - 1 - l[i]);
    }
    for (int i = 0; i < m / 2; ++i) {
        if (sg[i].empty()) continue;
        sort(sg[i].begin(), sg[i].end());
        sg[i].resize(unique(sg[i].begin(), sg[i].end()) - sg[i].begin());
        for (int j = 0; j + 1 < sg[i].size(); ++j) sg[sg[i][j] + 1].push_back(sg[i][j + 1]);
        sg[i].resize(1);
    }
    vector<int> t(m + 1);
    int sum = 0;
    for (int i = 0; i < m / 2; ++i) {
        sum += t[i];
        int ch = ((((s[i] - 'a') + sum) % 26) + 26) % 26;
        int diff = ((s[m - 1 - i] - 'a') - ch + 26) % 26;
        // printf("i = %d diff = %d\n", i, diff);
        if (diff != 0 && sg[i].empty()) {
            puts("NO");
            return 0;
        }
        if (diff != 0) {
            sum += diff;
            t[sg[i][0] + 1] += 26 - diff;
        }
    }
    puts("YES");
}


Measured memory_bytes: 8448
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include<iomanip>
#include<unordered_map>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;
using namespace std;






class UnionFind
{
public:
  UnionFind(int num)
  {
      parent=vector<int>(num,-1);
  }
  int root(int a)
  {
    if(parent[a]<0)return a;
    return parent[a]=root(parent[a]);
  }
  int size(int a)
  {
    return -parent[root(a)];
  }
  bool connect(int a,int b)
  {
    int pa=root(a),pb=root(b);
    if(pa==pb)return false;
    if(size(pa)>size(pb))swap(pa,pb);
    parent[pb]+=parent[pa];
    parent[pa]=pb;
    return true;

  }
  void print()
  {
    rep(i,10)cout<<parent[i]<<" ";
    cout<<endl;
  }
private:
  vector<int>parent;

};
ll calc(int a,int b)
{
  ll res=0;
  res+=(ll)a<<31;
  res+=b;
  return res;
}


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  int k,l;
  cin>>n>>k>>l;
  UnionFind uni1(n+1),uni2(n+1);

  rep(i,k){int a,b;cin>>a>>b;uni1.connect(a,b);}
  rep(i,l){int a,b;cin>>a>>b;uni2.connect(a,b);}
  unordered_map<ll,int>ma;
  repi(i,1,n+1)
  {
    ll a=calc(uni1.root(i),uni2.root(i));

    ma[a]+=1;
  }
  repi(i,1,n+1)cout<<ma[calc(uni1.root(i),uni2.root(i))]<<"\n";
  cout<<flush;

  return 0;

}


Measured memory_bytes: 9928
#include<bits/stdc++.h>
using ll = long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end()

#define INF (ll)1e9 //10^9:∞
#define LLINF (ll)1e12
#define MOD (ll)(1e9+7) //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define F first
#define S second
#define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr);

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)
#define endl "\n"

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/


/*.....................DEFINE FUNCTIONS ......................*/



/*.........................kemkemG0...........................*/
signed main() {
	__MAGIC__


	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;
	int score = 0;

	REP(i, S.size()-1) {if (S[i] == S[i + 1])score++;}


	cout << min(N - 1, score + 2 * K)<<endl;;

	return 0;
}


Measured memory_bytes: 3756
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  i64 n, a, b;
  cin >> n >> a >> b;

  i64 ans = 1;

  if (a > b) {
    ans = 0;
  } else if (n == 1) {
    ans = (a == b)? 1 : 0;
  } else if (n == 2) {
    ans = 1;
  } else {
    ans = (n-2) * (b-a) + 1;
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
use std::io::prelude::*;

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input! {
        ss: chars,
    }
    let mut sum = 0;
    let k = ss.len();
    for s in ss {
        if s == 'o' {
            sum+=1;
        }
    }
    let n = 15 - k;
    if n + sum >= 8 {
        println!("YES");
    } else {
        println!("NO");
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,l;
    cin >>n>>l;
    vector<string>s(n);
    for(int i=0;i<n;i++){
        cin >>s.at(i);
        }
        //for(int i=0;i<n;i++)cout<< s[i];
    sort(s.begin(),s.end());
    string ans;
    for(int i=0;i<n;i++){
        ans += s[i];

    }
    cout <<ans<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
char str[100005];
int main()
{
    scanf("%s",str);
    int len=strlen(str);
    int ans=0;
    for(int i=1;i<len;i++)
    {
        if(str[i]!=str[i-1])
            ans++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n, x, i;
    cin>>n;
    vector<long long int> a, b;
    for(i=0; i<n; i++){
        cin>>x;
        b.push_back(x);
    }
    a=b;
    sort(a.begin(),a.end());

    for(i=0; i<n; i++){
        if(b[i]==a[n-1]){
            cout<<a[n-2]<<endl;
        }
        else{
            cout<<a[n-1]<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4848
#include<iostream>
#include<string>
#include<complex>
#include<vector>
#include<algorithm>
#include<functional>
#include<array>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;


int main() {
	ull n,m=0,a=0,r=0,c=0,h=0;
	ull b = 0;
	cin >> n;
	string s[100001];
	for (int i = 0;i < n;i++) {
		cin >> s[i];
		if (s[i][0] == 'M') { m++; }
		if (s[i][0] == 'A') { a++; }
		if (s[i][0] == 'R') { r++; }
		if (s[i][0] == 'C') { c++; }
		if (s[i][0] == 'H') { h++; }
	}
	b = (m*a*r) + (m*a*c) + (m*a*h) + (m*r*c) + (m*r*h) + (m*c*h) + (a*r*c) + (a*r*h) + (a*c*h) + (r*c*h);
	cout << b << endl;
	return 0;
}

Measured memory_bytes: 6272
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

void debug_out() { std::cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

template <class T>
inline bool chmin(T &a, T b){
    if (a > b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T &a, T b){
    if (a < b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,m,d;
    cin >> n >> m >> d;
    long double ans;
    if(d==0){
        ans = m-1;
        ans /= n;
    }
    else{
        ans = 2*(n-d)*(m-1);
        debug(ans);
        ans /= (n*n);
    }
    cout << fixed << setprecision(15) << ans << endl;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $N);
$a = explode(" ", trim(fgets(STDIN)));
$answer = 0;
for ($i = 0; $i < $N - 1; $i++) {
    if ($a[$i] == $a[$i+1]) {
        $answer++;
        $i++;
    }
}
echo $answer . PHP_EOL;

Measured memory_bytes: 4728
#include <iostream>
using namespace std;
#define in(v) v; cin >> v;
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)

template<int MOD> struct MInt {
  long long val;
  MInt(long long val = 0) : val(val % MOD) { if (val < 0) val += MOD; }
  MInt operator+(const MInt& n) const { return MInt(val) += n; }
  MInt operator-(const MInt& n) const { return MInt(val) -= n; }
  MInt& operator+=(const MInt& n) { val = (val + n.val) % MOD; return *this; }
  MInt& operator-=(const MInt& n) { val = (MOD + val - n.val) % MOD; return *this; }
  friend ostream& operator<<(ostream& os, const MInt& n) { os<<n.val; return os; }
};
using mint = MInt<1000000007>;

int A[100];
mint dp[101][100001], dp_sum[101][100001];
mint sum[100002];
int main() {
  int in(N); int in(K);

  rep(i, N) cin >> A[i];

  dp[0][0] = 1; // i番目までにj個配るパターン数

  rep(i, N) {
    sum[0] = 0;
    rep(j, K+1) sum[j+1] = sum[j] + dp[i][j];
    rep(j, K+1) dp[i+1][j] = sum[j+1] - sum[max(0, j-A[i])];
  }

  cout << dp[N][K] << endl;
  return 0;
}


Measured memory_bytes: 158976
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define p 1000000007
#define rt register int
#define l putchar('\n')
#define ll long long
#define r read()
using namespace std;
inline ll read(){
    ll x = 0; char zf = 1; char ch = getchar();
    while (ch != '-' && !isdigit(ch)) ch = getchar();
    if (ch == '-') zf = -1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); return x * zf;
}
void write(ll y){if(y<0)putchar('-'),y=-y;if(y>9)write(y/10);putchar(y%10+48);}
void writeln(const ll y){write(y);putchar('\n');}
int i,j,k,m,n,x,y,z,cnt,sum,ans;
int f[210][100010],a[200010],g[100010];
int main(){
	n=r;m=r;f[0][m]=1;
	for(rt i=1;i<=n;i++)a[i]=r;sort(a+1,a+n+1);
	for(rt i=1;i<=n;i++)g[a[i]]=i;
	for(rt i=1;i<=m;i++)g[i]=max(g[i],g[i-1]);
	for(rt i=1;i<=n;i++)
	for(rt j=0,now=0;j<=m;j++)if(f[i-1][j]){
		now=g[j];
		if(n-now-i+1>0)f[i][j]=(f[i][j]+(ll)(n-now-i+1)*f[i-1][j])%p;
		for(rt k=1;k<=now;k++)(f[i][j%a[k]]+=f[i-1][j])%=p;
	}
	for(rt i=0;i<=m;i++)(ans+=1ll*f[n][i]*i%p)%=p;
	cout<<ans;
    return 0;
}








Measured memory_bytes: 78720
import java.util.Arrays;
import java.util.Scanner;

/**
 * ABC111C
 */
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] ai1 = new int[100050];
        int[] ai2 = new int[100050];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            if (i % 2 == 1) {
                ai1[a[i]]++;
            } else {
                ai2[a[i]]++;
            }
        }
        int oddMax = 0;
        int oddMaxV = 0;
        int evenMax = 0;
        int evenMaxV = 0;
        for (int i = 0; i < ai1.length; i++) {
            if (oddMax < ai1[i]) {
                oddMax = ai1[i];
                oddMaxV = i;
            }
            if (evenMax < ai2[i]) {
                evenMax = ai2[i];
                evenMaxV = i;
            }
        }
        Arrays.sort(ai1);
        Arrays.sort(ai2);
        if (oddMaxV == evenMaxV) {
            System.out.println(Math.min(n - ai1[ai1.length - 2] - ai2[ai2.length - 1],
                    n - ai1[ai1.length - 1] - ai2[ai2.length - 2]));
        } else {
            System.out.println(n - ai1[ai1.length - 1] - ai2[ai2.length - 1]);
        }
        sc.close();
    }
}

Measured memory_bytes: 50884
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   main.c
 * Author: kundaikwangwari
 *
 * Created on August 1, 2019, 9:38 AM
 */


#include <stdio.h>
#define N 3
#define MAX 8
#define NIL -1


typedef struct{
    int Board[N][N];
}Data;



int xdistance[4]={0,1,0,-1};
int ydistance[4]={1,0,-1,0};

int IsValid(Data Puzzle){
    
    int sum=0,ytransitions,xtransitions;
    for(int i=0;i<N;i++){
 
    for(int j=0;j<N;j++){
        if(Puzzle.Board[i][j]==0)continue;
        ytransitions=(Puzzle.Board[i][j]-1)/N-i;
        xtransitions=(Puzzle.Board[i][j]-1)%N-j;
        if(ytransitions<0) sum-=ytransitions;
        else sum+=ytransitions;
        if(xtransitions<0) sum-=xtransitions;
        else sum+=xtransitions;
}
}
 
return sum;
}


void SwapPositions(int *A,int *B){
 int temp;
 temp=*A;
 *A=*B;
 *B=temp;
 
 
}


int DepthFirstSearch(int x,int y,int max,int count,Data Puzzle){
    
  int heuristic = IsValid(Puzzle), xtotal,ytotal, Sol=NIL;   
  if(heuristic==0) return count;
  if(count+heuristic>max) return NIL; 
  for(int i=0;i<4;i++){
    xtotal=x+xdistance[i];
    ytotal=y+ydistance[i];      
   
    if(!(0<=xtotal && xtotal<3 && 0<=ytotal && ytotal<3)) continue;
    
    SwapPositions(&Puzzle.Board[y][x],&Puzzle.Board[ytotal][xtotal]);
    Sol=DepthFirstSearch(xtotal,ytotal,max,count+1,Puzzle);
    if(Sol!= NIL) return Sol;  
    
     SwapPositions(&Puzzle.Board[y][x],&Puzzle.Board[ytotal][xtotal]);
  }   
  return NIL;
}




int main(void){
    Data Puzzle,tempPuzzle;
    int xstart,ystart;

    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            scanf("%d",&Puzzle.Board[i][j]);
            if(Puzzle.Board[i][j]==0){
                xstart=j;
                ystart=i;   
            }
        }
    }
    tempPuzzle=Puzzle;
    for(int i=1;i<100;i++){
        Puzzle=tempPuzzle;
    int Sol=DepthFirstSearch(xstart,ystart,i,0,Puzzle);
    if(Sol!=NIL){
        printf("%d\n",Sol);
        break;
    }
    }
    return 0;
}




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


int main()
{
    //ios_base::sync_with_stdio(false);
    long long int n,a,b,c,d,e;
    cin>>n>>a>>b;
    c=abs(a-b);
    if(c%2==0)
        cout<<c/2<<"\n";
    else
    {
        c=0;
        d=a-1;
        e=n-b;
        if(d<e)
        {
            c+=d;
            b-=d;
            a=1;
            while((b-a)%2!=0)
            {
                c++;
                b--;
            }
            c+=(b-a)/2;
        }
        else{
            c+=e;
            a+=e;
            b=n;
            while((b-a)%2!=0)
            {
                c++;
                a++;
            }
            c+=(b-a)/2;
        }
        cout<<c<<"\n";
    }
    return 0;
}


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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
#define VL vector<lol>
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int modPow(long long a, long long n, long long p) {
  if (n == 0) return 1; // 0乗にも対応する場合
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}

int main()
{
    lol result{0};
    lol n; cin >> n;
    //lol a = modPow(10, n, MOD);
    result = (modPow(10, n, MOD)-((modPow(9, n, MOD)+modPow(9, n, MOD))%MOD-modPow(8, n, MOD)));
    result += MOD;
    result %= MOD;
    

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3628
N, T = map(int, input().split())
t = list(map(int, input().split()))
ans = 0
for i in range(len(t)):
    if i == len(t)-1:
        ans += T
    elif t[i+1] - t[i] < T:
        ans += t[i+1] - t[i]
    else:
        ans += T
print(ans)

Measured memory_bytes: 25200
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
	int A,B; cin >> A >> B;
	int ans = 0;
	int now = 1;
	rep(i,300){
		if(now >= B) break;
		now += A-1;
		ans++;
	}
	cout << ans << endl;
	
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = list(map(lambda x: int(x) - 1, input().split()))
loop = []
start = 0
index = 0
check = [-1] * N
fin = False
count = 0
while True:
    if check[index] != -1:
        start = check[index]
        break
    else:
        loop.append(index)
        if len(loop) == K + 1:
            print(index + 1)
            fin = True
            break
        check[index] = count
        count += 1
        index = a[index]

if not fin:  # len(loop)<=K
    if (K + 1 - start) % len(loop[start:]) == 0:
        print(loop[-1] + 1)
    else:
        print(loop[start + (K + 1 - start) % len(loop[start:]) - 1] + 1)


Measured memory_bytes: 97324
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

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

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
      solve();
  }
}

// https://img.atcoder.jp/abc134/editorial.pdf
/*
後ろから ans 個の数列を作る
できた ans 個の数列の初項列がわかれば, ans がわかる
これは, "広義"単調減少列, 同じ数を許す
*/

template<typename T>
vector<T> lis(vector<T> a) {
  vector<T> b;
  b.eb(a[0]);
  rep3(i, 1, sz(a)) {
    int it = ub(b, a[i]); // ub !!
    if (it == sz(b)) {
      b.eb(a[i]);
    } else {
      b[it] = a[i];
    }
  }
  return b;
}

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  reverse(all(a));
  auto b = lis(a);
  cout << sz(b) << endl;
}

/*
4
4 1 3 3
3
*/


Measured memory_bytes: 1660
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#define PI 3.14159265358979323846

int main(void) {
	
	char S[100];
	scanf("%s", &S);
	int count1 = 0;
	int count2 = 0;
	for (int i = 0; i <= 100; i+=2) {
		if (S[i] == 'R' || S[i] == 'U' || S[i] == 'D') {
			count1++;
		}
		

		if (S[i + 1] == 'L' || S[i + 1] == 'U' || S[i + 1] == 'D') {
			count2++;
		}
	}

	if (count1 + count2 == strlen(S)) {
		printf("Yes");
	}
	else {
		printf("No");
	}



	return 0;
}


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

int main(void)
{
    int k,n,i;
    int array1[50];

    cin>>n>>k;
    for(i = 0;i<n;i++)
        cin>>array1[i];

    sort(array1,array1+n);

    int sum = 0;

    for(i = n-1;i>=n-k;i--)
        sum += array1[i];

        cout<<sum<<endl;


    return 0;
}






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

using namespace std;

int main(void) {
	string Nstr;
	cin >> Nstr;
	int K;
	cin >> K;
	long long ans = 0;
	bool bounded0 = true;
	for(int x0 = 0; x0 < Nstr.length(); ++x0) {
		long long ans0 = 0;
		bounded0 = (x0 == 0);
		//cout << "x0: " << x0 << ", bounded0: " << bounded0 << '\n';
		for(int v0 = 1; v0 <= (bounded0 ? (Nstr[x0] - '0') : 9); ++v0) {
			//cout << "v0: " << v0 << '\n';
			if(K == 1) {
				++ans0;
			} else {
				bool bounded1 = (bounded0 && (v0 == Nstr[x0] - '0'));
				for(int x1 = x0 + 1; x1 < Nstr.length(); ++x1) {
					long long ans1 = 0;
					//cout << "x1: " << x1 << ", bounded1: " << bounded1 << '\n';
					for(int v1 = 1; v1 <= (bounded1 ? (Nstr[x1] - '0') : 9); ++v1) {
						//cout << "v1: " << v1 << '\n';
						if(K == 2) {
							++ans1;
						} else {
							bool bounded2 = (bounded1 && (v1 == Nstr[x1] - '0'));
							for(int x2 = x1 + 1; x2 < Nstr.length(); ++x2) {
								long long ans2 = 0;
								for(int v2 = 1; v2 <= (bounded2 ? (Nstr[x2] - '0') : 9); ++v2) {
									++ans2;
								}
								//cout << "ans2: " << ans2 << '\n';
								ans1 += ans2;
								if(bounded2 && Nstr[x2] != '0') bounded2 = false;
							}
						}
					}
					//cout << "ans1: " << ans1 << '\n';
					ans0 += ans1;
					if(bounded1 && Nstr[x1] != '0') bounded1 = false;
				}
			}
		}
		//cout << "ans0: " << ans0 << '\n';
		ans += ans0;
	}
	cout << ans << '\n';
	return 0;
	//
	switch(K) {
		case 1:
			for(int i = 0; i < Nstr.length(); ++i) {
				if(i == 0) {
					ans += Nstr[i] - '0';
				} else {
					ans += 9;
				}
			}
			break;
		case 2:
			for(int i = 0; i < Nstr.length(); ++i) {
				long long ans2 = 0;
				long long ans2m = 0;
				for(int j = i + 1; j < Nstr.length(); ++j) {
					if(j == i + 1) {
						ans2m += Nstr[j] - '0';
					} else {
						ans2m += 9;
					}
					ans2 += 9;
				}
				if(i == 0) {
					ans += ((Nstr[i] - '0') - 1) * ans2 + ans2m;
				} else {
					ans += 9 * ans2;
				}
			}
			break;
		case 3:
			for(int i = 0; i < Nstr.length(); ++i) {
				long long ans2 = 0;
				long long ans2m = 0;
				for(int j = i + 1; j < Nstr.length(); ++j) {
					long long ans3 = 0;
					long long ans3m = 0;
					for(int k = j + 1; k < Nstr.length(); ++k) {
						if(j == i + 1 && k == j + 1) {
							ans3m += Nstr[k] - '0';
						} else {
							ans3m += 9;
						}
						ans3 += 9;
					}
					if(j == i + 1) {
						ans2 += ((Nstr[i] - '0') - 1) * ans2 + ans2m;
					} else {
						ans2 += 9 * ans2;
					}
					if(j == i + 1) {
						ans2m += Nstr[j] - '0';
					} else {
						ans2m += 9;
					}
					ans2 += 9;
				}
				if(i == 0) {
					ans += ((Nstr[i] - '0') - 1) * ans2 + ans2m;
				} else {
					ans += 9 * ans2;
				}
			}
			break;
	}
	cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
/*        string[] input = ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);
//        int a = int.Parse(input[2]);
//        int b = int.Parse(input[3]);*/
//        string temp = ReadLine();
        int a = int.Parse(ReadLine());
//        int b = int.Parse(ReadLine());
//        int c = int.Parse(ReadLine());
//        int d = int.Parse(ReadLine());
//        string a = ReadLine();
//        string b = ReadLine();
//        string c = ReadLine();
        if(a%2==0){
            WriteLine(a);
        }else{
            WriteLine(a*2);
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>

using namespace std;

int main(){
  int n;
  long long int a0;
  long long int a1;
  long long int sum = 0;

  cin >> n;
  cin >> a0;
  for(int i = 1; i < n; i++){
    cin >> a1;
    sum += a1;
  }

  if(a0 % 2 == sum % 2) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int x, y, cost;
    scanf ("%d%d", &x, &y);
    if (1 <= x && y <= 100 && y % 2 == 0){
        cost = (x + (y / 2));
        printf ("%d\n", cost);
    }
     return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

bool a[200000];

int main(){
	int n, k;
	while(true){
		cin >> n >> k;
		if(n == 0 && k == 0){
			break;
		}
		
		for(int i = 0; i <= n; i++){
			a[i] = false;
		}
		
		int num_;
		
		for(int i = 0; i < k; i++){
			cin >> num_;
			a[num_] = true;
		}
		
		int max = 0;
		
		int first, second;
		
		
		if(a[0]){
			first = 0;
			second = 0;
			max = 1;
			for(int i = 1; i <= n; i++){
				if(!a[i]){
					if(i - first - 1 > max){
						max = i - first - 1;
					}
					first = second;
					second = i;
				}
			}
			if(n - first > max){
				max = n - first;
			}
		}else{
			first = 0;
			max = 0;
			for(int i = 1; i <= n; i++){
				if(!a[i]){
					if(i - first - 1 > max){
						max = i - first - 1;
					}
					first = i;
				}
			}
			if(n - first > max){
				max = n - first;
			}
		}
		
		printf("%d\n", max);
	}
	return 0;
}

Measured memory_bytes: 1244