akhauriyash/Code-Regression huggingface dataset:
n = int(input())

w = [(list(map(int, input().split()))) for i in range(n)]#x,y,h
w.sort(key=lambda x:(x[2]),reverse=True)
hcon1 = 0
hcon2 = 0
for cx in range(101):
    for cy in range(101):
        for i in range(n):
            if w[i][2] > 0:
                if i == 0:
                    hcon1 = abs(w[i][0] - cx) + abs(w[i][1] - cy) + w[i][2]
                elif i != 0 and i != n - 1:
                    hcon2 = abs(w[i][0] - cx) + abs(w[i][1] - cy) + w[i][2]
                    if hcon1 != hcon2:
                        break
                    else:
                        hcon1 = hcon2
                else:
                    hcon2 = abs(w[i][0] - cx) + abs(w[i][1] - cy) + w[i][2]
                    if hcon1 != hcon2:
                        break
                    else:
                        print(cx,cy,hcon1)
                        exit()
            else:
                if i == 0:
                    hcon1 = 1
                elif i != 0 and i != n - 1:
                    if hcon1 > abs(w[i][0] - cx) + abs(w[i][1] - cy) + w[i][2]:
                        break
                else:
                    if hcon1 > abs(w[i][0] - cx) + abs(w[i][1] - cy) + w[i][2]:
                        break
                    else:
                        print(cx, cy, hcon1)
                        exit()

Measured memory_bytes: 3064
#include <stdio.h>
     
    int main(void) {
      double num1, num2;
      scanf("%lf %lf", &num1, &num2);
      if(num1 > num2){
        printf("GREATER\n");
      } else if(num1 < num2){
        printf("LESS\n");
      } else if(num1 == num2){
        printf("EQUAL\n");
      }
      return 0;
    }

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#include <bitset>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    int x;
    cin >> x;
    int rate=2000;
    int ans=0;
    while(x<rate){
        ans++;
        rate-=200;
    }
    cout << ans << endl;
}

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



using namespace std;

void work0(int);
void work1(int);
void work2(int);


int main() {
	int d, n;
	cin >> d >> n;
	switch (d) {
		case 0: work0(n); break;
		case 1: work1(n); break;
		default : work2(n);
	}
	
} 


void work0(int n) {
	if (n == 100) {
		cout << 101 << endl;
	}
	else {
		cout << n << endl;
	}
}

void work1(int n) {
	int i;
	int t = 0;
	if (n == 100) {
		cout << 10100 << endl;
	}
	else {
		cout << n << "00" << endl;
	}
}


void work2(int n) {
	if (n == 100) {
		cout << 1010000 << endl;
	}
	else {
		cout << n << "0000" << endl;
	}
}






Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd); FUNC(printde);
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s; cin >> s;
    // auto one = [&](int i){ return s[i] == '1'; };
    auto zero = [&](int i){ return s[i] == '0'; };
    vector<string> vs;
    int idx = 0, prev = 0;
    while(idx < n && zero(idx)){ ++idx; }
    prev = idx;
    while(idx <= n){
        if(idx == n || (zero(idx) && (zero(idx + 1) || idx + 1 == n))){
            if(idx - prev){
                vs.push_back(s.substr(prev, idx - prev));
            }
            idx += 2;
            while(idx < n && zero(idx)){ ++idx; }
            prev = idx;
        }
        ++idx;
    }
    prints(vs);
    int ans = 0;
    for(auto& str : vs){
        int n = str.size();
        auto one = [&](int i){ return str[i] == '1'; };
        auto zero = [&](int i){ return str[i] == '0'; };
        vector<int> memo(n, -1);
        function<int(int)> f = [&](int idx){
            if(idx < 0 || idx >= n){ return 0; }
            if(memo[idx] != -1){ return memo[idx]; }
            int idx0 = idx;
            if(zero(idx)){ return memo[idx0] = f(idx + 1); }
            int start = idx;
            while(idx < n && one(idx)){ ++idx; }
            if(idx == n){ return memo[idx0] = 0; }
            int a1 = idx - start + f(idx + 2);
            int a2 = f(idx + 1);
            ++idx;
            start = idx;
            while(idx < n && one(idx)){ ++idx; }
            int a3 = idx - start + f(idx + 1);
            int a4 = idx - start - 1 + f(idx - 1);
            return memo[idx0] = max({a1, a2, a3, a4});
        };
        ans += f(0);
        prints(f(0));
    }
    cout << ans << '\n';
}


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

using namespace std; 

#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(),vec.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define fp(i,a,b,p) for(int i=a;i<b;i+=p)
#define SZ(x) (int)x.size()

typedef  vector<string> vs;
typedef  vector<int> vi;
typedef  vector<long long> vl;	


int main(){
	
	int a,b;
	
	cin >> a >> b; 
	
	
	if(max(a,b) > 8){
		cout << ":(" << endl;
	}else{
		cout << "Yay!" << endl;
	}

    return 0;
}


Measured memory_bytes: 256
a = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
p = [[0]*3 for _ in range(3)]

for i in b:
    for j in range(3):
        for k in range(3):
            if a[j][k] == i:
                p[j][k] = 1
                
ans = False
for i in range(3):
    w = True
    for j in range(3):       
        if p[i][j] != 1:
            w = False
            break
            
    if w:
        ans = True
        
for i in range(3):
    w = True
    for j in range(3):       
        if p[j][i] != 1:
            w = False
            break
            
    if w:
        ans = True
        
if p[0][0] == 1 and p[1][1] == 1 and p[2][2] == 1:
    ans = True
    
if p[0][2] == 1 and p[1][1] == 1 and p[2][0] == 1:
    ans = True

        
if ans:
    print("Yes")
else:
    print("No")

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

int main()
{
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  int max1 = min(A,B);
  int max2 = min(C,D);
  cout << (max1 + max2) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF INT32_MAX / 2
#define PIE 3.14159265358979323

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;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
#define int long long

signed main() {
    int d, t, s;
    cin >> d >> t >> s;
    if (s * t >= d)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  string s;
  cin>>s;
  int a=s.size();
  int sum=0;
  for(int i=0;i<a;i++)
    sum=(sum*10+s[i]-'0')%9;
     if(sum==0)cout<<"Yes";
     else cout<<"No";
}


Measured memory_bytes: 3720
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		 String s  = in.next();
		 int nam = s.length();
		 
		 int cnt = 0;int memo = 0;
		 for(int i = 0; i < nam ; i++){
		     if(s.charAt(i)=='A' && cnt == 0){
		         cnt = 1;
		     }else if(cnt>0){
		         cnt++;
		         if(s.charAt(i) == 'Z'){
		             memo = cnt;
		         }
		     }
		 }
        System.out.print(memo);
	}
}

Measured memory_bytes: 25648
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cmath>

using ll = long long;

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    int slen = s.size(), tlen = t.size(),
        ruis[slen+1], ruit[tlen+1];
    ruis[0] = ruit[0] = 0;
    for (int i=0; i<slen; i++) {
        if (s[i] == 'A') ruis[i+1] = ruis[i] + 1;
        else ruis[i+1] = ruis[i] - 1;
    }
    for (int i=0; i<tlen; i++) {
        if (t[i] == 'A') ruit[i+1] = ruit[i] + 1;
        else ruit[i+1] = ruit[i] - 1;
    }
    int q, a, b, c, d; cin >> q;
    while (q--) {
        cin >> a >> b >> c >> d;
        int sdif = ruis[b] - ruis[a-1],
            tdif = ruit[d] - ruit[c-1];
        cout << (abs(sdif - tdif) % 3 == 0 ? "YES" : "NO") << '\n';
    }
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i=i+2)
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin >> s;
  int len = s.length();
  rep(i,len){
    if(!(s[i]=='h'&&s[i+1]=='i')){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" <<endl;
  return 0;
}


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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)

int main(void)
{
    li a, b;
    cin >> a >> b;
    cout << b * 2 - a << endl;
    return 0;
}

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

int main(void) {
  int N, i;
  char area[4][3][10];

  /* 初期化 */
  memset(area, 0, 4*3*10);

  /* 情報数読取り */
  scanf("%d\n", &N);

  /* 情報格納 */
  for (i = 0; i < N; i++) {
    int b, f, r, v;
    scanf("%d %d %d %d\n", &b, &f, &r, &v);
    b--; f--; r--;
    area[b][f][r] = area[b][f][r] + v;
  }

  /* 情報表示 */
  {
    int b, f, r;

    for (b = 0; b < 4; b++) {
      for (f = 0; f < 3; f++) {
        for (r = 0; r < 10; r++)
          printf("%2d", area[b][f][r]);
        printf("\n");
      }
      if (b != 3)
        printf("####################\n");
    }
  }
  return 0;
}

Measured memory_bytes: 624
import math
N,D = map(int, input().split())
X = [list(map(int, input().split()))for _ in range(N)]
ans = 0
for i in range(0,N-1):
    for j in range(i+1,N):
        dis = math.sqrt(sum([(X[i][k]-X[j][k])**2 for k in range(D)]))
 
        if dis.is_integer():
            ans += 1
print(ans)

Measured memory_bytes: 3064
h,w,k= map(int, input().split())
s = [[int(i) for i in input()] for i in range(h)]

for i in range(h):
    for j in range(1,w):
        s[i][j]+=s[i][j-1]

for i in range(w):
    for j in range(1,h):
        s[j][i]+=s[j-1][i]

#　１行目、一列目をゼロにする。
s=[[0]*w]+s
for i in range(h+1):
    s[i]=[0]+s[i]

ans=float('inf')
#bit 全探索
for i in range(2**(h-1)):
    line=[]
    for j in range(h-1):
        if (i>>j)&1:
            line.append(j+1)
    cnt=len(line)
    line=[0]+line+[h]
    x=0
    flag=True
    for k1 in range(1,w+1):
        v=0
        for l in range(len(line)-1):
            # どう分割してもダメな奴に✖︎のフラグ立てる
            if s[line[l+1]][k1]-s[line[l+1]][k1-1]-s[line[l]][k1]>k:
                flag=False
                
            v=max(s[line[l+1]][k1]-s[line[l+1]][x]-s[line[l]][k1]+s[line[l]][x],v)
            
        if v>k:
            cnt+=1
            x=k1-1
            
    if flag:
        ans=min(cnt,ans)
        
print(ans)

Measured memory_bytes: 45276
#include <iostream>
using namespace std;
int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];

  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      if (a[j] > a[j+1]) {
        int tmp = a[j];
        a[j] = a[j+1];
        a[j+1] = tmp;
      }
    }
  }
  cout << a[0] << " " << a[1] << " " <<	a[2] <<	endl;
  return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n,b[50][3][2];
  cin>>n;
  for(int i=0;i<n;i++)
    for(int j=0;j<3;j++)
      for(int k=0,h,m;k<2;k++)
    cin>>h>>m,b[i][j][k]=h*60+m;
  int ans=0;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      for(int k=0;k<n;k++){
    int res=0;
    for(int p=0;p<n;p++){
      if(b[p][0][0]<=b[i][0][1]&&b[i][0][1]<=b[p][0][1]&&
         b[p][1][0]<=b[j][1][1]&&b[j][1][1]<=b[p][1][1]&&
         b[p][2][0]<=b[k][2][1]&&b[k][2][1]<=b[p][2][1])res++;
    }
    ans=max(ans,res);
      }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3116
#include<iostream>
using namespace std;
int main(){
	int a,b,n;
	while(cin >> a >> b >> n){
		int sum=0;
		a %= b;
		
		for(int i=0; i<n; i++){
			a*=10;
			sum += a/b;
			a%=b;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstring>

using namespace std;

int q = 1;
int cell[7][7][7];
int p[7][7][7];
int N;
int M1,M2;
int a[30],b[30];

int main(){
  int c = 0;
  while(1){
    cin >> N;
 

    if(N == 0 ) break;

    memset(cell , 0 , sizeof(cell));
    memset(a , 0 , sizeof(a));
    memset(b , 0 , sizeof(b));
    memset(p , 0 , sizeof(p));

    for(int i = 1; i < 6 ; i++){
      for(int j = 1; j < 6 ; j++){
	int tmp;
	cin >> tmp;
	for(int k = 1 ;k < 6 ; k++){  
	  cell[i][j][6-k] = tmp % 10;
	  tmp /= 10;
	}
      }
    }

    cin >> M1;
    for(int i = 0; i < M1 ; i++){
      cin >> a[i];
    }

    cin >> M2;
    for(int i = 0; i < M2 ; i++){
      cin >> b[i];
      //     cout << b[i] << " ";
    }
    //cout << endl;
    while(N){
      // pテヲツ崢エテヲツ鳴ー
      memset(p,0,sizeof(p));

      for(int i = 1; i < 6 ; i++){
	for(int j = 1; j < 6 ; j++){
	  for(int k = 1 ;k < 6 ; k++){  

	    if(cell[i][j][k] == 1){
	      for(int t = -1; t <= 1 ; t++){
		for(int s = -1; s <= 1 ; s++){
		  for(int u = -1; u <= 1 ; u++){
		    p[i+t][j+s][k+u]++;
		  }
		}
	      }
	      p[i][j][k]--;
	    }
	  }
	}
      }
 


      //テヲツ猟・テ」ツ?ォテ」ツ?。テ」ツ?古」ツ?淌」ツ?、テ」ツ?ィ
      for(int i = 1; i < 6 ; i++){
	for(int j = 1; j < 6 ; j++){
	  for(int k = 1 ;k < 6 ; k++){  

	    if(cell[i][j][k] == 0){
	      for(int s = 0 ; s < M1 ; s++){
		if(p[i][j][k] == a[s]){
		  //		  cout << "IN ";
		  cell[i][j][k] = 1;
		  break;
		}
	      }
	    }
	    else if(cell[i][j][k] == 1){
	      int x = 1;
	      for(int s = 0 ; s < M2 ; s++){
		if(p[i][j][k] == b[s]) x = 0;      
	      }
	      if(x == 1){
		cell[i][j][k] = 0;
	      }
	    }
	  }
	  
	}
      }
    
      N--;    
    }

    //テ・ツ?コテ・ツ環?
    if(c != 0) cout << endl;
    c = 1;
    cout << "Case " << q << ":" << endl;
    q++;
    
    for(int i = 1; i < 6 ; i++){
      if(i != 1)
      cout  << endl;
      for(int j = 1; j < 6 ; j++){
	for(int k = 1 ;k < 6 ; k++){  
	  cout << cell[i][j][k];
	}
	cout << endl;
      }
    } 
  }
  
  return 0;
}

Measured memory_bytes: 1172
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int a[999999];
	a[0] = 2;
	long long k = 1;
	for (long long i = 2; i<=999999; i++)
	{
		int flag = 1;
		for (long long j = 2; j <= sqrt(i) + 1;j++)
		{
			if (i%j == 0)
			{
				flag = 0;
				break;
			}
		}
		if (flag)
			a[k] = i, k ++ ;
	}
	int n;
	while (cin >> n)
	{
		long long ans = 0;
		for (long long x = 0; x < k; x++)
		{
			if (n >= a[x])
				ans++;
			else
				break;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3376
#include <iostream>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>
#include <map>

using namespace std;

bool used[10];
bool tabu[10];
int keisu[10];
int ans;
int cnt; // 文字数


void dfs(int k, int sum){
    if (k == cnt) {
        if (sum == 0) {
            ans++;
        }
        return;
    }
    
    for (int i = 0; i < 10; i++) {
        if (used[i] || (i == 0 && tabu[k])) {
            continue;
        }
        used[i] = true;
        dfs(k + 1, sum + i * keisu[k]);
        used[i] = false;
    }
    return;
}

int main(){
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            return 0;
        }
        vector<string> str(n);
        map<char, int> id;
        cnt = 0;
        ans = 0;
        
        for (int i = 0; i < 10; i++) {
            used[i] = false;
            tabu[i] = false;
            keisu[i] = 0;
        }

        for(int i = 0; i < n; i++){
            cin >> str[i];
            string s = str[i];
            for (int j = 0; j < s.size(); j++) {
                if (id.find(s[j]) == id.end()) {
                    id[s[j]] = cnt++;
                }
                if (j == 0 && s.size() > 1) { // 0にならない記号か
                    tabu[id[s[j]]] = true;
                }
                if (i != n - 1) {
                    keisu[id[s[j]]] += (int)pow(10, s.size() - j - 1);
                }else{
                    keisu[id[s[j]]] -= (int)pow(10, s.size() - j - 1);
                }
            }
        }
        dfs(0, 0);
        cout << ans << endl;
    }
}

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

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define pb push_back
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>
#define wz cout<<"-----"<<endl;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;

const ll maxn = 1e5 + 10, MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

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


void init() {

}

vector<int>E[maxn];


int main(){
//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
//    ios_base::sync_with_stdio(0);
    init();
    int n,m; cin >>n >>m;
    for (int i = 0; i <m; i++){
        int x, y; cin >> x >> y;
        E[x].pb(y);
        E[y].pb(x);
    }
    for (int i = 1; i <= n; i++) {
        cout << E[i].size() << endl;
    }
    return 0;
}


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

using namespace std;

int a[100000];

int main(){
	int n;
	int ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	while(1){
	for(int i=1;i<=n;i++)
	{
		if(a[i]%2==1)
		{
			cout<<ans;
			return 0;
		}
		else a[i]/=2;
	}
	ans++;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main()
{
	int A[101] = {0};
	int n,m;
	int game[101];
	int B;
	
	scanf("%d%d", &n, &m);
	
	for (int i = 0; i < m; i++){
		scanf("%d", &game[i]);
	}
	
	for (int i = 0; i < m; i++){
		//A[game[i]]++;
		for(int j = 0; j < n; j++){
			scanf("%d", &B);
			if(B == game[i]){
				A[j+1]++;
			}
			else{
				A[game[i]]++;
			}
		}
	}
	for (int i = 1; i <= n; i++){
		printf("%d\n", A[i]);
	}
}

Measured memory_bytes: 1024
N, Q = map(int, input().split())
S = input()

t = [0] * (N + 1)

for i in range(N):
    t[i + 1] = t[i] + (1 if S[i:i + 2] == 'AC' else 0)

for i in range(Q):
    l, r = map(int, input().split())
    print(t[r - 1] - t[l - 1])


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

long long ans=0;
int main()
{
	int i,j,n;
	scanf("%d%d",&n,&i);
	while(--n)
	{
		scanf("%d",&j);
		if(j<i) ans+=(i-j);
		i=max(i,j);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 3824
package main

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

type Flood struct {
	first int
	areas int
}

type Stack []interface{}

func (s *Stack) peek() (val interface{}, err error) {
	l := len(*s)
	if l > 0 {
		val = (*s)[l-1]
		return
	} else {
		err = fmt.Errorf("stack is empty")
		return
	}
}

func (s *Stack) push(val interface{}) {
	*s = append(*s, val)
}

func (s *Stack) pop() (val interface{}, err error) {
	l := len(*s)
	if l > 0 {
		*s, val = (*s)[:l-1], (*s)[l-1]
		return
	} else {
		err = fmt.Errorf("stack is empty")
		return
	}
}

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	s := nextLine()
	stack := make(Stack, 0, len(s))
	floods := make(Stack, 0, len(s)/2)
	var sum int
	for i, c := range s {
		switch c {
		case '\\':
			stack.push(i)
		case '/':
			a, err := stack.pop()
			if err != nil {
				break
			}
			ai := a.(int)
			sum += i - ai
			f := Flood{i, i - ai}
			for {
				p, err := floods.peek()
				if err != nil {
					break
				}
				if p.(Flood).first > ai {
					f.areas += p.(Flood).areas
					floods.pop()
				} else {
					break
				}
			}
			floods.push(f)
		case '_':
		}
	}
	fmt.Println(sum)
	fmt.Print(len(floods))
	for _, f := range floods {
		fmt.Print(" ", f.(Flood).areas)
	}
	fmt.Println()
}



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

int main() {

    int n, k, d, a;
    cin >> n >> k;

    bool Snack[n] = {false};

    for (int i = 0; i < k; i++) {
        cin >> d;
        for (int j = 0; j < d; j++) {
            cin >> a;
            Snack[a - 1] = true;
        }
    }

    int c = 0;
    for (int i = 0; i < n; i++) {
        if (Snack[i]==0)
            c++;
    }

    cout << c;

    return 0;
}



Measured memory_bytes: 3636
o = input()
e = input()

lo = len(o)
le = len(e)
i = 0
res = []
while True:
    if i == len(o):
        break
    else:
        res.append(o[i])
    if i == len(e):
        break
    else:
        res.append(e[i])
        i += 1

print(''.join(res))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}
int a[105];int n,p;
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>p;
	for(int i=0;i<=n;i++){
		if(i*10000>p) break;
		for(int j=0;j<=n;j++){
			if(i+j>n) break;
			if(i*10000+j*5000>p) break;
			if(i*10000+j*5000+(n-i-j)*1000==p){
				cout<<i<<" "<<j<<" "<<(n-i-j)<<endl;
				return 0;
			} 
		}
	}
	cout<<-1<<" "<<-1<<" "<<-1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
long long a [100010];
int main (){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++) scanf("%lld",&a[i]);
int zero =0;

for(int i=0;i<n;i++)if(a[i]==0) zero ++;
if(zero >0){
// a[i] contains 0
printf("0\n");
return 0;
}
long long prod =1;
for(int i=0;i<n;i++){
if(a[i ] <=1000000000000000000/ prod ){
// This condition is equivalent to prod*a[i] <=10ˆ18
prod *=a[i];
}else{
printf("-1\n");
return 0;
}
}
printf("%lld\n",prod );
}


Measured memory_bytes: 4604
#A - AKIBA △
S = input()
S = list(S)

SS = []
for p in S:#Aを追加する空白を作る
    SS.append('')
    SS.append(p)
SS.append('')


result = 'NO'
if len(S) <= 9 and 'K' in S and 'I' in S and 'H' in S and 'B' in S and 'R' in S:
    for i in range(1<<(len(SS))):
        SSS = SS.copy()
        for j in range(len(SS)):
            mask = 1 << j
            if mask & i != 0:#処理を行う
                if SSS[j] == '':
                    SSS[j] = 'A'
        for k in SSS:
            if k == '':
                SSS.remove('')
        if SSS == ['A','K','I','H','A','B','A','R','A']:
            result = 'YES'
print(result)

Measured memory_bytes: 74296
/* EVERYTHING STARTS AS NOTHING ! :) */
#include<bits/stdc++.h>
using namespace std;

#define ull unsigned long long
#define ll long long
#define null NULL
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main (){
	double n ;
	cin >> n ;
	double k = n / 3 ;
	cout << fixed << setprecision(12) << k*k*k ;
	return 0 ;
}
		

Measured memory_bytes: 256
n,m,x=map(int,input().split())

a=list(map(int,input().split()))

costa=0
costb=0
for i in a:
    if i<x:
        costa+=1
    elif i>x:
        costb+=1

print(min(costa,costb))

"""


5 3 3
1 2 4

1


7 3 2
4 5 6

0

10 7 5
1 2 3 4 6 8 9

3
"""

Measured memory_bytes: 3060
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;

int n,m;
int q;

int ar[100005];

vector<int> pos[100005];

int finish[100005];// N

bool done[100005];// M

void fail(){
  puts("No");
  exit(0);
}

void doit(set<int> rest){
  int lastpos=q;
  bool ng=false;
  REP(i,m) if(rest.count(i)){
    if(pos[i].empty()) lastpos=-1;
    else if(pos[i][0]>lastpos) ng=true;
    else lastpos=pos[i][0];
  }
  if(!ng){
    puts("Yes");
  }else{
    puts("No");
  }
  exit(0);
}
int main(){
  cin>>n>>m>>q;
  REP(i,q){
    scanf("%d",&ar[i]);--ar[i];
    pos[ar[i]].pb(i);
  }

  REP(i,m) reverse(ALL(pos[i]));

  {
    int lastpos=q;
    bool ng=false;
    REP(i,m){
      if(pos[i].empty()) lastpos=-1;
      else if(pos[i][0]>lastpos) ng=true;
      else lastpos=pos[i][0];
    }
    if(!ng){
      puts("Yes");
      return 0;
    }
  }
  REP(i,n) finish[i]=q;

  int seek=q-1;

  bool last=false;

  set<int> rest;
  REP(i,m) rest.insert(i);

  while(seek>=0){
    int val=ar[seek];
    if(done[val]){
      --seek;
      continue;
    }
    done[val]=1;

    int j=0;
    REP(i,n){
      while(j<pos[val].size() && finish[i]<=pos[val][j]){
        ++j;
      }
      if(j==pos[val].size()){
        doit(rest);
      }else{
        finish[i]=pos[val][j];
        ++j;
      }
    }
    rest.erase(val);
  }
  puts("Yes");

  return 0;
}




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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

int main(){
	int m1, d1, m2, d2; cin >> m1 >> d1 >> m2 >> d2;
	if(d2 == 1) cout << 1;
	else cout << 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a1=a[::2]
a2=a[1::2]
if a1==a2 and len(set(a1))==1:
    print(n//2)
    exit()
import collections as c
c1=c.Counter(a1)
c2=c.Counter(a2)
c1=c1.most_common()
c2=c2.most_common()
ans=0
if c1[0][0]==c2[0][0]:
    ans=min((n//2-c1[0][1])+(n//2-c2[1][1]),(n//2-c1[1][1])+(n//2-c2[0][1]))
else:
    ans=(n//2-c1[0][1])+(n//2-c2[0][1])
print(ans)

Measured memory_bytes: 20360
#include<bits/stdc++.h>
using namespace std;
int main(){
	float a,b,c,d,x,y;
	cin>>a>>b>>c>>d;
	y=ceil(a/d);
	x=ceil(c/b);
	if(x<=y){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 3720
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;
const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    


int main(){
   IOS

   int h, n; cin>>h>>n;

   vector<int> a(n); 
   int s = 0;
   for(int & x : a)cin>>x, s += x;

    cout<<(s >= h ? "Yes" : "No");
   


   


}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  string A, B, C;
  cin >> A >> B >> C;
  transform(A.begin(), A.end(), A.begin(), ::toupper);
  transform(B.begin(), B.end(), B.begin(), ::toupper);
  transform(C.begin(), C.end(), C.begin(), ::toupper);
  cout << A[0];
  cout << B[0];
  cout << C[0] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(30);
using namespace std;

int main()
{
    IOS;
    string s;
    cin>>s;
    for(char c='a'; c<='z'; c++){
        if(s.find(c)==-1){
            cout<<c;
            return 0;
        }
    }
    cout<<"None";
    return 0;
}


Measured memory_bytes: 3712
using System;
using System.Linq;

class Class1
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        long N = long.Parse(input[0]);
        long M = long.Parse(input[1]);
        long K = long.Parse(input[2]);

        long[] An = Console.ReadLine().Split(' ').Select(_ => long.Parse(_)).ToArray();
        long[] Bm = Console.ReadLine().Split(' ').Select(_ => long.Parse(_)).ToArray();

        // 累積和を計算しておく
        long[] anTotal = new long[N + 1];
        for (long i = 1; i <= N; i++)
        {
            anTotal[i] = anTotal[i - 1] + An[i - 1];
        }

        long[] bmTotal = new long[M + 1];
        for (long i = 1; i <= M; i++)
        {
            bmTotal[i] = bmTotal[i - 1] + Bm[i - 1];
        }

        long max = 0;
        long j = M;
        for (long i = 0; i <= N; i++)
        {
            if (anTotal[i] > K)
            {
                break;
            }

            while (anTotal[i] + bmTotal[j] > K)
            {
                j = j - 1;
            }

            max = Math.Max(i + j, max);
        }

        Console.WriteLine(max);
    }
}

Measured memory_bytes: 73104
#include<iostream>

using namespace std;

#define INF 1000000009

int main(){
    long long int n, h[100009], dp[100009];
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> h[i];
        dp[i] = INF;
    }
    dp[0] = 0;
    for(int i=0;i<n-1;i++){
        if(i<=n-3){
            dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
            dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
        }
        if(i==n-2){
            dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
N = int(input()) - 1
rst = ''

for i in range(1, 15):
    if N >= 26 ** i:
        N -= 26 ** i
        continue
    for j in range(i):
        rst += chr(ord('a') + N % 26)
        N //= 26
    print(rst[::-1])
    break

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

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

    int h, w;
    cin >> h >> w;

    vector<vector<int>> c(10, vector<int>(10));
    rep(i, 10) rep(j, 10) cin >> c[i][j];
    
    vector<vector<int>> a(h, vector<int>(w));
    rep(i, h) rep(j, w) cin >> a[i][j];

    // const int INF = 1001001001;
    // vector<vector<int>> dist(10, vector<int>(10, INF));
    // rep(i, 10) dist[i][i] = 0;
    // rep(i, 10) rep(j, 10) dist[i][j] = a[i][j];
    
    rep(k, 10) rep(i, 10) rep(j, 10){
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
    }

    int res = 0;
    rep(i, h) rep(j, w){
        if(a[i][j] == -1) continue;
        res += c[a[i][j]][1];
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 384
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (K, S): (i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };

    let ans = (0..(K + 1))
        .map(|x| (0..(K + 1))
        .filter(|&y| S - K <= x + y && x + y <= S)
        .count())
        .sum::<usize>();

    println!("{}", ans);
}

Measured memory_bytes: 4352
//  .:::.   .:::.
// :::::::.:::::::
// :::::::::::::::
// ':::::::::::::'
//   ':::::::::'
//     ':::::'
//       ':'
#include <bits/stdc++.h>
#define rep(i,a,b) for (i=a;i<b;i++)
#define rep2(i,a,b) for (i=a;i>=b;i--)
#define mod 1000000007
#define mod2 998244353
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define INF  1e9+5
#define f first
#define s second
#define endl '\n'
#define ll long long
#define ii pair <int,int>
#define pll pair <ll,ll>
#define vi vector <int>
#define vl vector <ll>
#define vvi vector < vi >
#define vii vector < ii >
#define vpl vector < pll >
#define vvii vector < vii >
#define vll vector < ll >
#define vb  vector <bool>
#define pb push_back
#define mk make_pair
#define pg priority_queue<ll, vector<ll>, greater<ll>>
#define pq priority_queue<ll>
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define cset(a) __builtin_popcountll(a)
#define FILL(a, b, T) fill_n((T *)a, sizeof(a) / sizeof(T), b)
using namespace std;
ll a[100001][3], dp[100001][3];
int main()
{
    FIO;
    ll t, q, maxx, n, k, i, j, k1, k2, k3, x, flag, ans, sum, cnt, prev;
    cin>>n>>k;
    vll v(n), w(n);
    rep(i,0,n)
    {
        cin>>w[i]>>v[i];
    }
    k1 = 0;
    rep(i,0,n)
    {
        k1+=v[i];
    }
    ll dp[k1+1];
    FILL(dp,INF*n,ll);
    dp[0] = 0;
    rep(i,0,n)
    {
        rep2(j,k1,v[i])
        {
            dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
            // dp[j] = max(dp[j], dp[j-1]);
        }
    }
    // cout<<k1<<endl;
    // rep(i,0,k1+1)
    // {
    //     cout<<dp[i]<<" ";
    // }
    // cout<<k1<<endl;
    rep(i,0,k1+1)
    {
        if( dp[i] <= k)
        {
            ans = i;
            // cout<<i<<" "; 
        }
    }
    // cout<<dp[90]<<endl;
    cout<<ans<<endl;
    return 0;    
}


Measured memory_bytes: 1024
// Infinite Sequence
// * frank_c1
// * 2017 / 09 / 30

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

const int maxn = (int)(1e6) + 5;
const int mo = (int)(1e9) + 7;
int f[maxn];

inline void add(int& x, int v) {
	x += v; if (x >= mo) x -= mo;
}

int main() {
	int n, res = 0;
	scanf("%d", &n);
	f[0] = 1; int w = 1;
	for (int i = 1; i <= n; ++i) {
		f[i] = w; if (i > 1) add(f[i], mo - f[i - 2]); add(w, f[i]);
	} LL ww = (1LL * (n - 1) * (n - 1)) % mo;
	for (int i = 0; i + 1 < n; ++i) add(res, f[i] * (ww + i + 1) % mo); 
	add(res, 1LL * f[n - 1] * (n - 1) % mo); add(res, f[n]);
	return printf("%d\n", res), 0;
}

Measured memory_bytes: 4096
package main

import (
	"fmt"
	"math"
)

func main() {
	var a int
	fmt.Scan(&a)
	c500 := (a / 500) * 1000
	a = a % 500
	c5 := (a / 5) * 5
	fmt.Println(c500 + c5)
}

//-------------------------------------------
// util tools

// abs 絶対値を返す
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// sliceInt []intをスライスする
func sliceInt(k int) []int {
	s := make([]int, getDigit(k))
	count := 0
	for k > 0 {
		i := k % 10
		s[len(s)-1-count] = i
		count++
		k = k / 10
	}
	return s
}

// sliceIntSum []intの合計を出す
func sliceIntSum(v []int) int {
	sum := 0
	for _, x := range v {
		sum += x
	}
	return sum
}

// reverse []intを反転
func reverse(s []int) []int {
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		s[i], s[j] = s[j], s[i]
	}
	return s
}

// getDigit intの桁数を取得
func getDigit(num int) int {
	digit := 0
	for num != 0 {
		num /= 10
		digit++
	}
	return digit
}

// getSumDigit intの各位の和を返す
func getSumDigit(num int) int {
	sum := 0
	for num != 0 {
		t := num % 10
		num /= 10
		sum += t
	}
	return sum
}

// lastPrime 素数 エラトステネスの篩
func lastPrime(max int64) int64 {
	if max <= 1 {
		return 2
	}
	primes := make([]int64, 1, max)
	primesF := make([]float64, 1, max)
	primes[0] = 2
	primesF[0] = 2.0

	count := int64(1)
	for n := int64(3); ; n += 2 {
		flag := true
		f := float64(n)
		rf := math.Sqrt(f)
		for i := 1; i < len(primes); i++ {
			if primesF[i] > rf {
				break
			} else if (n % primes[i]) == 0 {
				flag = false
				break
			}
		}
		if flag {
			count++
			if count >= max {
				return n
			}
			primes = append(primes, n)
			primesF = append(primesF, f)
		}
	}
}


Measured memory_bytes: 512
import scala.collection.mutable.ArrayBuffer

object Main extends App {
  val n = readInt
  val arr = readLine.split(" ").map(_.toInt).toBuffer
  val outBuf = ArrayBuffer.fill(n)(0)
  var i = 0
  
  var arraySize = n
  while(i < n) {
    var j = arraySize
    var found = false
    while (found == false && j > 0) {
      j -= 1
      val num = arr(j)
      
      if (num == j + 1) {
        outBuf(arraySize - 1) = num
        arr.remove(j)
        found = true
      }
    }
    arraySize -= 1
    i += 1
  }
  
  if (arr.size == 0) outBuf.foreach(println) else println(-1)
}

Measured memory_bytes: 27320
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {
	
	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================
	

	int N;
	cin >> N;
	string S, T;
	cin >> S >> T;


	string ans= "";

	for (int i = 0; i < N; i++) {
		ans += S[i];
		ans += T[i];
	}


	cout << ans;



}



Measured memory_bytes: 256
using System;

class Abc
{
    static void Main()
    {
        int[] ab = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        int a = ab[0];
        int b = ab[1];
        if (0 < a) Console.WriteLine("Positive");
        else if (b < 0 && (b - a + 1) % 2 == 0) Console.WriteLine("Positive");
        else if (b < 0 && (b - a + 1) % 2 != 0) Console.WriteLine("Negative");
        else if (a <= 0 && b >= 0)Console.WriteLine("Zero");

    }
}

Measured memory_bytes: 11092
n = int(input())
a = list(map(int, input().split(' ')))
dic = {}
com = {}
ans = 0
for v in a:
    try:
        t = dic[v]
        ans += t
        com[v] += t
        dic[v] += 1
    except:
        dic[v] = 1
        com[v] = 0

for k in range(n):
    print(ans - (dic[a[k]]-1))

Measured memory_bytes: 94036
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <queue>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<int> a(N);
  for (auto& ai: a) scanf("%d", &ai);

  int const inf = 2e9;

  std::multiset<int> b;
  for (size_t i = 0; i < N; ++i) {
    auto it = b.lower_bound(a[i]);
    if (it == b.begin()) {
      b.insert(a[i]);
      continue;
    }
    b.erase(--it);
    b.insert(a[i]);
  }
  printf("%zu\n", b.size());
}


Measured memory_bytes: 5376
# include <bits/stdc++.h>
# define rep(i, n) for(ll i = 0; i < (n); ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define ll long long
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define P pair<int, int>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll lmax(ll a, ll b){if(a>= b) return a;return b;}
ll lmin(ll a, ll b){if(a>= b) return b;return a;}


int main() {
  int n; cin >> n;
  vector<int> a(n-1);
  rep(i, n-1) {
    cin >> a[i];
    --a[i];
  }

  vector<int> v(n, 0);
  rep(i, n-1){
    ++v[a[i]];
  }
  rep(i, n){
    cout << v[i] << endl;
  }
}


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

int main(){
  int a, b;
  cin >> a >> b;
  vector<int> h(1000,0);
  for (int i=1; i<1000; i++){
     h[i] = h[i-1] + i;
  }
  cout << h[b-a-1] - a << endl;
}


Measured memory_bytes: 256
#include<iostream> 
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <vector>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
	int x;
	cin >> x;
	if (1800 <= x) {
		cout << 1 << endl;
		return 0;
	}
	else if (1600 <= x) {
		cout << 2 << endl;
	}
	else if (1400 <= x) {
		cout << 3 << endl;
	}
	else if (1200 <= x) {
		cout << 4 << endl;
	}
	else if (1000 <= x) {
		cout << 5 << endl;
	}
	else if (800 <= x) {
		cout << 6 << endl;
	}
	else if (600 <= x) {
		cout << 7 << endl;
	}
	else if (400 <= x) {
		cout << 8 << endl;
	}
	
}


Measured memory_bytes: 3628
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;

ll gcd(ll a, ll b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
     
 ll lcm(ll a, ll b)  
 {  
    return (a*b)/gcd(a, b);  
 }  


int main()
{
	FAST;
	
	int n;
	cin >> n;
	
	vector<int> arr[n+1];

	for(int i=0 ; i<n ; i++)
	{
	    int temp;
	    cin >> temp;
	    arr[temp].push_back(i);
	}   
	
	int last = -1;
	for(int i=1 ; i<=n ; i++)
	{
	    bool flag = false;
	    for(int j=0 ; j<arr[i].size() ; j++)
	    {
	        if(arr[i][j] > last)
	        {
	            last = arr[i][j];
	            flag = true;
	            break;
	        }
	    }
	    
	    if(!flag)
	    {
	        if(i == 1)
	            cout << "-1";
	        else
	            cout << n-(i-1);
	        return 0;
	    }
	}
	cout << "0";
	return 0;
}


Measured memory_bytes: 11264
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string S;
	cin >> S;

	for (char c = 'a'; c <= 'z'; c++) {
		bool flag = true;
		for (int i = 0; i < S.size(); i++) {
			if (S[i] == c) flag = false;
		}
		if (flag) {
			cout << c << "\n";
			return 0;
		}
	}

	cout << "None\n";
	return 0;

}

Measured memory_bytes: 512
def gcd2(x,y):
  if y==0: return x
  return gcd2(y,x%y)
def gcd(a):
  ans = a[0]
  for i in range(1,len(a)):
    ans = gcd2(ans,a[i])
  return ans
N = int(input())
a = list(map(int,input().split()))
print(gcd(a))

Measured memory_bytes: 14224
/*
        @uthor: Kashish Gilhotra
        user: CodeChef, CodeForces, HackerEarth, HackerRank, SPOJ: kashish001
*/

#include <bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
  
#define int long long int 
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

double EPS = 1e-9; 
int INF = 1000000005; 
long long INFF = 1000000000000000005LL;
const int mod = 1e9 + 7; 

//#define CI cpp_int
string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << " " ;
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define RESET(a, b) memset(a, b, sizeof(a)) 
#define EB emplace_back
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define size(v) (int)v.size() 
#define endl "\n"
#define UMO unordered_map
#define USO unordered_set
#define setBits(n) __builtin_popcountll(n)
#define MX *max_element
#define MN *min_element
#define TC int t; cin >> t; while (t--) 

void Panda() {
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
}
  
int32_t main() {
 
    FAST;

   
    
    Panda();

    return 0; 
} 

Measured memory_bytes: 3616
#include <iostream>
#include <stdio.h>
#include <string.h>
#define MAX_N 200005
#define int long long

using namespace std;

int n,ans=0;
int a[MAX_N];
int x[MAX_N];
int s[MAX_N];

inline bool check(int a,int b)
{
	return (x[b]^x[a-1])==(s[b]-s[a-1]);
}

int cal_p(int p)
{
	int l=p,r=n;
	while(r-l>1)
	{
		int mid=(l+r)>>1;
		if(check(p,mid)) l=mid;
		else r=mid;
	}
	if(check(p,r)) return r;
	return l;
}

signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		x[i]=x[i-1]^a[i];
		s[i]=s[i-1]+a[i];
	}
	for(int i=1;i<=n;i++)
	{
		int p=cal_p(i);
		ans+=(p-i+1);
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 4992
import bisect
from collections import Counter
from collections import defaultdict
s=input()
t=input()
#s="contest"
#t="antakuso"
sd=Counter(s)
td=Counter(t)
N=len(t)
Ns=len(s)
for ts in td:
    if ts not in sd:
        print(-1)
        exit()
D=defaultdict(list)
for i in range(Ns):
    D[s[i]].append(i)
ans=0
for i in range(N):
    if i==0:
        pre=min(D[t[i]])
    else:
        L=D[t[i]]
        idx=bisect.bisect(L,pre)
        if idx==len(L):
            ans+=Ns
            pre=min(L)
        else:
            pre=L[idx]
    if i==N-1:
        ans+=pre+1
print(ans)


Measured memory_bytes: 7924
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL N = 7005;
const LL M = 205;
const LL INF = 0x3f3f3f3f3f3f3f;
const double inf = 2e9;
const double Pi = acos(-1);
const LL MOD = 1e9+7;
const double eps = 1e-8;
LL n,m;
struct nd
{
	LL h,p;
}s[N];
LL dp[N];
bool cmp(nd a,nd b) {return a.h+a.p < b.h+b.p ; }
int main()
{
	while (~scanf("%lld",&n))
	{
		memset(dp,INF,sizeof dp);
		for (LL i=1;i<=n;i++)
			scanf("%lld%lld",&s[i].h,&s[i].p);
		sort(s+1,s+1+n,cmp);
		dp[0]=0;
		for (LL i=1;i<=n;i++)
			for (LL j=i;j>=1;j--)
				if (dp[j-1]<=s[i].h)
					dp[j] = min(dp[j],dp[j-1]+s[i].p);
		LL ans = 1;
		for (LL i=1;i<=n;i++)
			if (dp[i]<INF)
				ans = i;
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 384