akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=(b);++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define pi pair<int, int>
#define mk make_pair
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N=11e2+10;
char s[N];
void solve()
{
   int len,k;
   cin>>k>>s+1;
   len=strlen(s+1);
   rep(i,1,len)
   {
       if(i>k) {
            printf("...");
            break;
       }
       else printf("%c",s[i]);
   }
}
int main()
{
	//ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//int _;cin>>_;while(_--)
	solve();
}


Measured memory_bytes: 3768
#include <stdio.h>

int main(void){
  int n, x, i, j, k, count;
  int num, countSet[10000] = {};
  for(num = 0; ; num++){
    count = 0;
    scanf("%d %d", &n, &x);
    if(n == 0 && x == 0)
      break;
    for(i = 1; i <= n; i++){
      for(j = i + 1; j <= n; j++){
	for(k = j + 1; k <= n; k++){
	  if(i + j + k == x)
	    count++;
	}
      }
    }
    countSet[num] = count;
  }

  for(i = 0; i < num; i++)
    printf("%d\n", countSet[i]);
  return 0;
}

Measured memory_bytes: 648
from collections import deque

n,q = map(int, input().split())
que = deque([])

for i in range(n):
    name, time = input().split()
    time = int(time)
    que.append([name, time])

t = 0

while len(que) > 0:
    atop = que.popleft()
    spend = min(atop[1],q)
    t += spend
    atop[1] -= spend
    if atop[1] == 0:
        print(atop[0],t)
    else:
        que.append(atop)


Measured memory_bytes: 13276
N,A,B = map(int,input().split(" "))
S = input()

a = 0
b = 0
for i in range(N):
    if S[i] == 'a':
        if a + b < A + B:
            print("Yes")
            a += 1
        else:
            print("No")
    elif S[i] == 'b':
        if a + b < A + B and b < B:
            print("Yes")
            b += 1
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 4016
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
B=[list(map(int,input().split())) for _ in range(M)]
B.sort(key=lambda x:-x[1])
i,j=0,0
while i<=N-1:
  for l in range(B[j][0]):
    if A[i]>=B[j][1]:
      print(sum(A))
      exit()
    A[i]=B[j][1]
    i+=1
    if i==N:
      print(sum(A))
      exit()
  j+=1
  if j==M:
    print(sum(A))
    exit()
print(sum(A))

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

int top,S[1000];

void push (int x) {
  S[++top] = x;
}

int pop() {
  top --;
  return S[top+1];
}

int main () {
  int a,b;
  top = 0;
  char s[100];

  while (scanf("%s",s) != EOF) {
    if (s[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
    }
    else if (s[0] == '-') {
      b = pop();
      a = pop();
      push(a - b);
    }
    else if (s[0] == '*') {
      a = pop();
      b = pop();
      push(a * b);
    }
    else {
      push (atoi(s));
    }
  }

  printf("%d\n",pop());

  return 0;

}


Measured memory_bytes: 2108
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();

        int count=0;
        
        while(a>=b){
            b = b*2;
            count++;
        }

        while(b>=c){
            c = c*2;
            count++;
        }

        String res;
        
        if(count<=k){
            res = "Yes";
        }else{
            res = "No";
        }
        System.out.println(res);
        
        
        
        
        
        }
    }

Measured memory_bytes: 35688
#include<bits/stdc++.h>
using namespace std;
int n,a[10010][10010],t=0;
bool flag[10010],fl=0;
bool judge()
{
	for(int i=1;i<=n;++i)
		if(a[i][0]!=n)
			return 0;
	return 1;
}

int main()
{	cin>>n;
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<n;++j)
			cin >> a[i][j];
		a[i][0]=1;
	}
	while(1)
	{
		if(judge())
		{
			printf("%d\n",t);
			return 0;
		}
		fl=0;
		memset(flag,0,sizeof(flag));
		++t;
		for(int i=1;i<=n;++i)
		{
			if(flag[i] || a[i][0]==n) 
				continue;
			int x=a[i][a[i][0]],y=a[x][a[x][0]];
			if(!flag[x] && !flag[i] && i==y)
			{
				fl=1;
				flag[x]=1;flag[i]=1;
				++a[i][0];++a[x][0];
			}
		}
		if(!fl)
		{
			printf("-1\n");
			return 0;
		}
	}
	return 0;
} //test



Measured memory_bytes: 39552
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
using namespace std;

const int MAXN = 3005;
int dp[MAXN][MAXN], pt[MAXN][MAXN];

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

	string s, t;
	cin >> s >> t;

	int n = s.length(), m = t.length();
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			if (dp[i-1][j] >= dp[i][j-1]) {
				dp[i][j] = dp[i-1][j];
				pt[i][j] = -1;
			}
			else {
				dp[i][j] = dp[i][j-1];
				pt[i][j] = 1;
			}

			if (s[i-1] == t[j-1]) {
				if (dp[i][j] < dp[i-1][j-1] + 1) {
					dp[i][j] = dp[i-1][j-1] + 1;
					pt[i][j] = 0;
				}
			}
		}
	}

	//~ cerr << dp[n][m] << endl;

	vector<char> ans;
	for (int i = n, j = m; !(i == 0 || j == 0); ) {
		if (pt[i][j] == 0) {
			ans.push_back(s[i-1]);
			--i, --j;
		}
		else if (pt[i][j] == -1) {
			--i;
		}
		else {
			--j;
		}
	}
	for (int i = ans.size() - 1; i >= 0; --i) {
		cout << ans[i];
	}
	cout << endl;
}


Measured memory_bytes: 70784
from collections import Counter, defaultdict
import math
import random
from decimal import Decimal, ROUND_HALF_UP, ROUND_CEILING
from functools import lru_cache, reduce
from itertools import combinations_with_replacement, product, combinations


def read_int():
    return int(input())


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


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def mt(f):
    import time
    import sys

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        print(e - s, 'sec', file=sys.stderr)
        return ret

    return wrap


@mt
def slv(S, X, P):
    X_ = [[P[i], [x]] for i, x in enumerate(X)]
    i = 0
    j = len(X_) - 1
    # while len(X_) != 1:
    while i < j:

        if X_[i][0] >= X_[j][0]:
            X_[i][0] += X_[j][0]
            X_[i][1] += X_[j][1]
            j -= 1
        else:
            X_[j][0] += X_[i][0]
            X_[j][1] += X_[i][1]
            i += 1

    t = 0
    pos = S
    p0 = S
    p1 = S
    for o in X_[i][1]:
        if p0 < o < p1:
            continue

        t += abs(pos - o)
        if o < pos:
            p0 = o
        else:
            p1 = o
        pos = o

    return t


def main():

    N, S = read_int_n()
    X = []
    P = []
    for _ in range(N):
        x, p = read_int_n()
        X.append(x)
        P.append(p)

    # import random
    # N = 100000
    # S = N / 2
    # X = [x + 1 for x in range(N)]
    # P = [random.randint(1, 1000000000) for _ in range(N)]

    print(slv(S, X, P))


if __name__ == '__main__':
    main()

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

#define ll long long
#define mx 100005
int ar[mx];
char ch[mx];
vector<ll>v;
int n,m;
void func(int pre,ll num)
{
    if(pre>9 || pre<0 || num>3234566667*1LL)return;
    v.push_back(num);
    func(pre+1,num*10+(pre+1));
    func(pre,num*10+pre);
    func(pre-1,num*10+(pre-1));
}
void solve()
{
    cin>>n;
    for(int i=1;i<=9;i++)func(i,i);
    sort(v.begin(),v.end());
    //cout<<v.size()<<endl;
    printf("%lld\n",v[n-1]);
}
int main()
{
    int t=1;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 1400
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll kai(ll a){
    ll res = 1;
    while(a>1){
        res = res * a % MOD;
        a--;
    }
    return res % MOD;
}

int main(){ 
    ll n, m; cin >> n >> m;
    ll a = min(n, m), b = max(n, m);
    ll res;
    if(b-a>=2) res = 0;
    else if(b-a == 0){
        res = kai(a) * kai(b) % MOD * 2 % MOD;
    }
    else{
        res = kai(a) * kai(b) % MOD;
    }
    cout << res << ln;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>pii;
//#define int ll
const int maxn=2e5+10,inf=0x3f3f3f3f,mod=1000000007;
//#define DEBUG//#define lowbit(x) ((x) & -(x))//<<setiosflags(ios::fixed)<<setprecision(9)
void read(){}
template<typename T,typename... T2>inline void read(T &x,T2 &... oth) {
	x=0; int ch=getchar(),f=0;
	while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	if(f)x=-x;
	read(oth...);
}
signed main()
{
	std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	#ifdef DEBUG
		freopen("input.in", "r", stdin);
	//	freopen("output.out", "w", stdout);
	#endif
	string a,b;
	cin>>a>>b;
	bool ok=1;
	int len=min(a.length(),b.length());
	for(int i=0;i<len;i++)
		if(a[i]!=b[i])
			ok=0;
	cout<<(ok?"Yes":"No")<<endl;
	return 0;
}




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

int lex_smaller(char* s1, char* s2)
{
	int i;
	for (i = 0; s1[i] != 0 && s2[i] != 0; i++) {
		if (s1[i] < s2[i]) return 1;
		else if (s1[i] > s2[i]) return -1;
	}
	if (s1[i] == s2[i]) return 0;
	else if (s1[i] == 0) return 1;
	else return -1;
}

void push(char* s, char** heap, int* n)
{
	int i = *n;
	char *tmp;
	heap[(*n)++] = s;
	while (1) {
		if (i == 0) break;
		else if (lex_smaller(heap[i], heap[(i - 1) / 2]) == 1) {
			tmp = heap[(i - 1) / 2];
			heap[(i - 1) / 2] = heap[i];
			heap[i] = tmp;
			i = (i - 1) / 2;
		} else break;
	}
}

char* pop(char** heap, int* n)
{
	int i = 0, j;
	char *tmp, *output = heap[0];
	heap[0] = heap[--(*n)];
	while (1) {
		if (i * 2 + 1 >= *n) break;
		else if (i * 2 + 2 >= *n) j = i * 2 + 1;
		else if (lex_smaller(heap[i * 2 + 1], heap[i * 2 + 2]) == 1) j = i * 2 + 1;
		else j = i * 2 + 2;
		if (lex_smaller(heap[j], heap[i]) == 1) {
			tmp = heap[j];
			heap[j] = heap[i];
			heap[i] = tmp;
			i = j;
		} else break;
	}
	return output;
}

int main()
{
	int i, N, L;
	char S[101][101];
	scanf("%d %d", &N, &L);
	for (i = 1; i <= N; i++) scanf("%s", S[i]);
	
	int j, k, n = 0;
	char ans[10001] = {}, *tmp, **heap = (char**)malloc(sizeof(char*) * N);
	for (i = 1, k = 0; i <= N; i++) push(S[i], heap, &n);
	while (n > 0) {
		tmp = pop(heap, &n);
		for (j = 0; j < L; j++) ans[k++] = tmp[j];
	}
	
	printf("%s\n", ans);
	fflush(stdout);
	return 0;
}

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


int main (void) {
    int N, D;
    int X[10][10];
    int distance, cnt;
    
    scanf("%d %d", &N, &D);
    
    for (int i=0;i<N;i++) {
        for (int j=0;j<D;j++) {
            scanf("%d", &(X[i][j]));
        }
    }

    cnt = 0;
    for (int i=0;i<N-1;i++) {
        for (int j=i+1;j<N;j++) {
            distance = 0;
            for (int k=0;k<D;k++) {
                distance += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
            }

            if (pow((int)sqrt(distance), 2) == (double)distance) {
                cnt++;
            }
        }
    }

    printf("%d\n", cnt);
    return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	int K;
	cin>>K;
	cout<<(K/2)*((K+1)/2)<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define Max 45
int a[Max];
  
main(void){
  int i,n,x;
 
  scanf("%d",&n);
  x=f(n);
  printf("%d\n",x);
  return 0;
}

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

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

vector<int> G[200000];
ll c[200000];
ll ans[200000];

void dfs(int v, int p, ll sum) {
  ans[v] = c[v] + sum;
  REP(i, G[v].size()) {
    int ne = G[v][i];
    if (ne == p) continue;
    dfs(ne, v, ans[v]);
  }
}

int main() {
  int n, q;
  cin >> n >> q;
  REP(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  REP(i, q) {
    int p, x;
    cin >> p >> x;
    p--;
    c[p] += x;
  }
  dfs(0, -1, 0ll);
  REP(i, n) {
    if (i) cout << " ";
    cout << ans[i];
  }
  cout << "\n";
  return 0;
}

Measured memory_bytes: 28672
// tested by Hightail: https://github.com/dj3500/hightail
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define INF 1001001001
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))
#define mp make_pair
#define pii pair<int,int>
#define ll long long
#define vi vector<int>
#define SZ(x) ((int)((x).size()))
#define fi first
#define se second
#define wez(n) int (n); scanf("%d",&(n));
#define wez2(n,m) int (n),(m); scanf("%d %d",&(n),&(m));
#define wez3(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k));
inline void pisz(int n) { printf("%d\n",n); }
template<typename T,typename TT> ostream& operator<<(ostream &s,pair<T,TT> t) {return s<<"("<<t.first<<","<<t.second<<")";}
template<typename T> ostream& operator<<(ostream &s,vector<T> t){FOR(i,SZ(t))s<<t[i]<<" ";return s; }
#define DBG(vari) cout<<"["<<__LINE__<<"] "<<#vari<<" = "<<(vari)<<endl;
#define ALL(t) t.begin(),t.end()
#define FOREACH(i,t) for (__typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define TESTS wez(testow)while(testow--)
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define REPD(i,a,b) for(int (i)=(a); (i)>=(b);--i)
#define REMAX(a,b) (a)=max((a),(b));
#define REMIN(a,b) (a)=min((a),(b));
#define IOS ios_base::sync_with_stdio(0);

const int N = 200200;
int a[N], x[N];

int main () {
   wez(n);
   FORI(i,n) scanf("%d", a+i);
   vi v;
   REPD(i,n,1) {
      int s = a[i];
      for (int j = 2*i; j <= n; j += i) {
         s += x[j];
      }
      x[i] = s % 2;
      if (x[i] == 1) v.pb(i);
   }
   pisz(SZ(v));
   for (int g : v) printf("%d ", g);
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define nl              cout<<endl
#define real            signed
#define endl            '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;

real main() 
{
	ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     int ans=0;
     string s;
     cin>>s;
     
     for (auto i : s)ans+=(i=='2');
     cout<<ans;




     return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#define pr(x) printf("%s %lld\n", #x , x)
int main()
{
    //freopen("in.txt", "w", stdout);
    int flag[200005], array[200005];
    int n ; 
    scanf("%d",&n);
    memset(flag , 0 , sizeof(flag));
    for(int i = 0 ; i < n -1 ; i++){
        scanf("%d",&array[i]);
        flag[array[i] - 1]++;
    }
    for(int j = 0 ; j < n ; j++) printf("%d\n",flag[j]);    
}   

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

using db = double;
using ll = long long;
using vi = vector <int>;
#define op operator
#define pb push_back

int a[5];
int c[14];

int main() {
	ios :: sync_with_stdio(0);

	while(cin >> a[0]) {
		char t;
		for(int i = 1; i < 5; i ++)
			cin >> t >> a[i];
		fill(c, c + 14, 0);
		for(int i = 0; i < 5; i ++)
			c[a[i]] ++;

		auto f = [&](int i) {
			return count(c, c + 14, i);
		};
		auto straight = [&]() {
			bool r = 0;
			for(int i = 1; i <= 10; i ++) {
				bool t = 1;
				for(int j = i; j < i + 5; j ++)
					if(!c[(j - 1) % 13 + 1])
						t = 0;
				r |= t;
			}
			return r;
		};

		if(f(4))
			cout << "four card\n";
		else if(f(3) && f(2))
			cout << "full house\n";
		else if(straight())
			cout << "straight\n";
		else if(f(3))
			cout << "three card\n";
		else if(f(2) == 2)
			cout << "two pair\n";
		else if(f(2))
			cout << "one pair\n";
		else
			cout << "null\n";
	}

	return 0;
}

Measured memory_bytes: 3032
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)


struct Problem {

	ULL N, M;
	ULL A[100000];
	ULL SA[100001];
	ULL I[100001] = {};

	pair<ULL, ULL> Solve2(UL minP) {
		ULL numh = 0;
		ULL ans = 0;
		rep(i, N) {
			UL d = minP - A[i];
			if (A[i] > minP) d = 0;
			if (d > 100000) continue;
			numh += I[d];
			ans += SA[I[d]] + A[i] * I[d];
		}
		return { numh, ans };
	}

	void Solve() {
		cin >> N >> M;
		rep(i, N) cin >> A[i];
		sort(A, A + N);
		reverse(A, A + N);
		SA[0] = 0;
		rep(i, N) SA[i + 1] = SA[i] + A[i];
		rep(i, N) I[A[i]] = i + 1;
		for(UL i = 100000; i > 0; i--) I[i - 1] = max(I[i - 1], I[i]);

		ULL l = 0, r = 200001;
		ULL Mbuf = M;
		ULL ans = 0;
		while (r - l != 1) {
			ULL m = (r + l) / 2;
			auto buf = Solve2(m);
			//cout << "<" << m << "," << buf.first << "," << buf.second << ">" << endl;
			if (buf.first > M) l = m;
			else { Mbuf = M - buf.first; ans = buf.second; r = m; }
		}
		ans += Mbuf * l;
		cout << ans << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll H,W,h,w,ans;
  cin >> H>>W>>h>>w;
  ans = H*W-(h*W+w*H-h*w);
  cout << ans<< endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,D,X;
  cin>>N>>D>>X;
  int A,ans=X;
  for(int i=0;i<N;i++){
    cin>>A;
    ans+=(D+A-1)/A;
  }
  cout<<ans<<endl;
}

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

using namespace std;

int main() {
	char a[19];
	int i;
	
	for(i=0;i<19;i++){
		cin >> a[i];
	}
	
	for(i=0;i<19;i++){
		if(a[i]==','){
			cout << " ";
		}else{
			cout << a[i];
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8

a = input()
q = int(input())
mode = 1
L = ''
R = ''

for _ in range(q):
    q_list = input().split()

    if q_list[0] == '1':
        mode *= -1
    else:
        if q_list[1] == '1':
            if mode == 1:
                L += q_list[2]
            else:
                R += q_list[2]
        else:
            if mode == -1:
                L += q_list[2]
            else:
                R += q_list[2]
result = L[::-1] + a + R
if mode == -1:
    result = result[::-1]
print(result)


Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
using ll= long long ;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i<(ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}

int main() {
ll n;
cin>>n;
vcl a(n),cnt(n+1,1);
rep(i,n)cin>>a[i];

vcl s(n+1); 
for (ll i = 0; i < n; ++i) s[i+1] = s[i] + a[i];
sort(s.begin(), s.end());
ll j=0;
rep(i,n){
    if(s[i+1]==s[i])cnt[j]++;
    else j++;
}
ll ans=0;
rep(i,j+1)ans+=c2(cnt[i]);
cout<<ans<<endl;
return 0;
}



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

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int main(){
    int H, W;
    cin >> H >> W;

    vector<string> a(H);
    rep(i, H) cin >> a[i];

    vector<bool> row(H);
    rep(i, H) {
        bool res = true;
        rep(j, W) {
            if (a[i][j] != '.') {
                res = false;
                break;
            }
        }
        row[i] = res;
    }

    vector<bool> col(W);
    rep(i, W) {
        bool res = true;
        rep(j, H) {
            if (a[j][i] != '.') {
                res = false;
                break;
            }
        }
        col[i] = res;
    }

    rep(i, H) {
        rep(j, W) {
            if (!row[i] && !col[j]) {
                cout << a[i][j];
            }
        }
        if (!row[i]) cout << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int N;
	unsigned long long int sum=1;
	
	scanf("%d", &N);
	
	unsigned long long int A[N];

	
	for(int i=0;i<N;i++){
		scanf("%llu", &A[i]); 
		if(A[i]==0){
			printf("0");
			return 0;
	}
	for(int i=0;i<N; i++){
		
		}
	}
		for(int i=0; i<N;i++){
			if(A[i]<=1000000000000000000/sum){
				sum*=A[i];
			
		}
		else{
			printf("-1");
		return 0;
		}
	}
	printf("%lld", sum);
	
	return 0;
}



Measured memory_bytes: 4012
#include <stdio.h>
#include <stdlib.h>
#define N 500000

void merge(int *,int,int,int);
void mergeSort(int *,int,int);

int count;

int main()
{
  int n,i,S[N];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %d",&S[i]);
  }

  mergeSort(&S[0],0,n);

  for(i=0;i<n;i++){
    printf("%d",S[i]);
    if(i != n-1) printf(" ");
  }
  printf("\n");

  printf("%d\n",count);

  return 0;
}

void merge(int *A,int left,int mid,int right)
{
  int n1,n2,i,j=0,k=0;

  n1 = mid - left;
  n2 = right - mid;

  int L[n1],R[n2];

  for(i=0;i<n1;i++){
    L[i] = A[left+i];
  }
  for(i=0;i<n2;i++){
    R[i] = A[mid+i];
  }
  L[n1] = 1000000000;
  R[n2] = 1000000000;

  for(i=left;i<right;i++){
    count++;
    if(L[j]<=R[k]){
      A[i] = L[j];
      j += 1;
    }
    else{
      A[i] = R[k];
      k += 1;
    }
  }
}
void mergeSort(int *A,int left,int right)
{
  int mid;

  if(left+1 < right){
    mid = (left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}


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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

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

  int yummy = 0;
  while (true) {
    if (c <= 0) {
      break;
    }
    c--;
    yummy++;
    if (b > 0) {
      b--;
      yummy++;
    } else if (a > 0) {
      a--;
    } else {
      break;
    }
  }
  if (b > 0) {
    yummy += b;
  }
  p(yummy);
}

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

int main () {
  int N; cin >> N;
  
  int64_t ans=0;
  for (int i=1; i<=N; i++) {
    if (i==1) ans =1;
    else ans = (ans * i) % 1000000007;
    
  }
  cout << ans  << endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  string O,E;
  cin>>O>>E;
  
  if(O.size()==E.size()){
    for(int i=0;i<O.size();i++){
      cout<<O[i]<<E[i];
    }
  }
  else{
    for(int i=0;i<E.size();i++){
      cout<<O[i]<<E[i];
    }
    cout<<O[O.size()-1];
  }
}

Measured memory_bytes: 3632
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    if (n % 2 == 1) {
      System.out.println(n*2);
    } else {
      System.out.println(n);
    }
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;			
	   
int main() {
			fast
			// #ifndef ONLINE_JUDGE
			// freopen("input.txt","r",stdin);
			// freopen("output.txt","w",stdout);
			// #endif

			char x;
			cin>>x;
			if(x>='A' and x<='Z')
			cout<<'A';
			else
			cout<<'a';
			return 0;
		 }	


Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;

void debug(vec &v) {
	int n = v.size();
	rep(i, n) {
		if (i > 0)cout << " ";
		cout << v[i];
	}
	cout << endl;
}

void solve() {
	string s, t; cin >> s >> t;
	t += s; cout << t << endl;
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}


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

int main(){
 int N; cin >> N;
  vector<ll> A(N);
  for(int i = 0; i < N; i++){ cin >> A[i];}
  
  sort(A.begin(),A.end());
  
  vector<ll> rec; vector<ll> squre;
  
  int head = 0; int tail = 0;
  
  while( head < N && tail < N){
    if( A[head] != A[tail]){ head++; continue;}
    
    while( A[head] == A[tail] && tail < N){ tail++;}
    
    if( tail-head >= 4){ rec.push_back(A[head]); squre.push_back(A[head]);
                       }
    else if( tail-head >= 2){ rec.push_back(A[head]);
                            }
    
    head = tail;
  }
  
  ll m = rec.size(); 
  ll ans = 0;
  if( m >= 2){
    ans = max(ans, rec[m-1]*rec[m-2]);
   
  }
  if( !squre.empty()){
   ans = max( ans, squre.back()*squre.back());
    
  }
  
  cout << ans << endl; return 0;}
                  

Measured memory_bytes: 1660
str_list=[]
tmp=[]
s=''
str_list=list(input())
for i in str_list:
    if i =='0':
        tmp.append('0')
    elif i == '1':
        tmp.append('1')
    elif i == 'B' and tmp:
        tmp.pop()
for i in range(len(tmp)):
    s+=tmp[i]
print(s)


Measured memory_bytes: 3060
#define DEBUG 1
#include <bits/stdc++.h>
using namespace std;
typedef          char      s8;
typedef unsigned char      u8;
typedef          short    s16;
typedef unsigned short    u16;
typedef          int      s32;
typedef unsigned int      u32;
typedef          long int s64;
typedef unsigned long int u64;
typedef float             f32;
typedef double            f64;
#define rep(_i, _n) for (int _i = 0; _i < (int)(_n); _i++)
#if DEBUG
#define PHERE()			{ cerr << "L" << setw(3) << __LINE__ << ": PHERE" << clock() << endl; }
#define PVAL( _var )	{ cerr << "L" << setw(3) << __LINE__ << ":" << #_var "=" << (_var) << endl; }
#else
#define PHERE()
#define PVAL( _var )
#endif


int main()
{
	//////// 入力 ////////
	int N;
	cin >> N;
	/////////////////////
	
	int A[N];
	int ANS[N];
	memset( ANS, 0, sizeof(ANS) );
	u32 allXor = 0;
	rep( i, N ) {
		cin >> A[i];
		allXor ^= A[i];
	}
	
//DEL 	u32 mask = 0;
//DEL 	rep( bit, 32 ) {
//DEL 		if( ((allXor<<bit) & 1 ) != 0 ) {
//DEL 			mask |= (1<<bit);
//DEL 		}
//DEL 	}
	
	//////// 出力 ////////
	rep( i, N ) {
		cout << (A[i] ^ allXor) << " ";
	}
	/////////////////////
	
	return 0;
}
#if 0
↓他人の合計
10100	11010	00000
01011	00101	11111
01001	00111	11101
11000	10110	01100

↓1bitの合計が奇数なら、1が立ってる人は0、0が立ってる人は1
              偶数なら、1が立ってる人は1、0が立ってる人は0
1	0
0	1
1	0
1	0
#endif


Measured memory_bytes: 5096
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    /**
     * @param args
     * @throws IOException
     * @throws NumberFormatException
     */
    public static void main(String[] args) throws NumberFormatException,
            IOException {

        BufferedReader reader = new BufferedReader(new InputStreamReader(
                System.in));

        int len = Integer.parseInt(reader.readLine());
        int[] arr = new int[len];

        String line;

        for (int i = 0; i < len; i++) {
            line = reader.readLine();
            arr[i] = Integer.parseInt(line);
        }
        
        int resultCount = 0;
        for (int j = 0; j < arr.length; j++) {
            if (isPrime(arr[j])) {
                resultCount++;
            }
        }

        System.out.println(resultCount);

    }
    
    private static boolean isPrime(int value) {

        if(value == 2) return true;
        if(value ==  3) return true;
        if(value ==  5) return true;
        if(value ==  7) return true;
        
        if(value % 2 == 0) return false;
        if(value % 3 == 0) return false;
        if(value % 5 == 0) return false;
        if(value % 7 == 0) return false;

        double max = Math.sqrt(value);
        for (int i = 7; i <= max; i +=2 ) {
            if (value % i == 0) return false;
        }
        
        return true;
    }

}

Measured memory_bytes: 11000
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	var ans int
	d := int(1e9) + 7
	for i := k; i <= n+1; i++ {
		min := (i - 1) * i / 2
		max := (2*n - i + 1) * i / 2
		ans += max - min + 1
		ans %= d
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1752
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const int N_MAX = 2e5+10;
int N;
vector<vector<int> > Tree(N_MAX);
vector<int> v(N_MAX,0);
vector<int> ans(N_MAX,0);

void dfs(int u, int p){
  ans[u] = v[u] + ans[p];
  for(const int &w:Tree[u]) dfs(w,u);
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int Q;cin >> N >> Q;
  rep(i,N-1){
    int x,y;cin >> x >> y;
    Tree[x].push_back(y);
  }
  while(Q--){
    int p,x;cin >> p >> x;
    v[p] += x;
  }
  dfs(1,0);
  rep(i,N) cout << ans[i+1] SPF;
  cout << endl;
  return 0;
}


Measured memory_bytes: 21120
const [n, as] = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\n/)
const length = Number(n) - 1
const arr = as.split(/\s/).map(Number).sort((a, b) => b - a)

let count = 0
let result = 0
for (let i = 0; true; i++) {
  result += arr[i]
  count++
  if (count === length) {
    break
  }
  if (i !== 0) {
    result += arr[i]
    count++
  }
  if (count === length) {
    break
  }
}
console.log(result)

Measured memory_bytes: 55152
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807/2;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
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 dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


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

int n;

int main(){
	cin>>n;
	for(int i=1;i<=n+1;i++){
		if((int)((double)i*1.08)==n){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<":("<<endl;
	return 0;
}

Measured memory_bytes: 256
/******************************************************************************

            EYENINE,THE ELDER_WAND!!!
            THE ROOT OVER MINUS EIGHTY ONE!!

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

#include<bits/stdc++.h>
#define ALL_UP_WITH return 0
#define vi vector<int>
using namespace std;
int count1=0;
bool digit[10];

bool ok(int x){
    while(x){
        if(digit[x%10])
            return false;
            x/=10;
    }
    return true;
}
int main(){

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

    int n,k;
    for(scanf("%d%d",&n,&k);k--;){
        int x;
        scanf("%d",&x);
        digit[x]=true;
    }
    while(!ok(n))n++;
    printf("%d\n",n);


    ALL_UP_WITH;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll x;
    ll year;
    ll k = 100;
    ll t;
    cin >> x;
    for(year=1;year<x;year++)
    {
        t = k/100;
        k = k + t;
        if(k>=x)
            break;
    }
    cout << year << endl;
    return 0;
}

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

using namespace std;

int main() {
  int M1, D1, M2, D2;
  cin >> M1 >> D1 >> M2 >> D2;

  if (D2 == 1) {
    cout << '1' << endl;
  } else {
    cout << '0' << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]
def main():
    N, M = map(int,input().split())
    G = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map(int,input().split())
        G[a-1].append(b-1)
    for e in G[0]:
        if N-1 in G[e]:
            print("POSSIBLE")
            exit(0)
    print("IMPOSSIBLE")

if __name__ == '__main__':
    main()


Measured memory_bytes: 62156
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int D[] = new int[N];
        int counter[] = new int[N];

        for(int i=0; i < N; i++) {
            D[i] = sc.nextInt();
            counter[D[i]]++;
            // System.out.println("c[" + D[i] + "]: " + counter[D[i]]);
        }

        if(D[0] != 0 || counter[0] >= 2){
            System.out.println(0);
        }else{
          long sum = 1;
          for(int i = 1; i < N; i++) {
              for(int j = 0; j < counter[i]; j++) {
                sum *= counter[i-1];
                sum %= 998244353L;
              }
          }
          System.out.println(sum);
        }
    }
}


Measured memory_bytes: 60396
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;

int size_of_lis(const vector<ll>& vec){
  // size of longest increasing subarray
  int N = vec.size();
  vector<ll> dp(N+1,LINF);
  dp[0] = -LINF;
  rep(i,N){
    // upperで<=, lowerで<
    int num = int(upper_bound(dp.begin(),dp.end(),vec[i]) - dp.begin());
    dp[num] = min(dp[num],vec[i]);
  }
  return int(lower_bound(dp.begin(),dp.end(),LINF) - dp.begin()) - 1;
}

void solve(long long N, std::vector<long long> A){
  rep(i,N) A[i]=-A[i];
  cout << size_of_lis(A) << endl;
}

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int digit(pair<int,int> a, pair<int,int> b){
  return abs(a.first-b.first)+abs(a.second-b.second);
}
int main() {
  cout << fixed << setprecision(10);
  int n,m;
  cin >> n >> m;
  vector<pair<int,int>> a(n),b(m);
  rep(i,n){
    cin >> a.at(i).first >> a.at(i).second;
  }
  rep(i,m){
    cin >> b.at(i).first >> b.at(i).second;
  }
  vector<int> ans(n);
  rep(i,n){
    int temp = INF;
    rep(j,m){
      int dist = digit(a.at(i),b.at(j));
      if(temp>dist){
        temp = dist;
        ans.at(i)=j+1;
      }
    }
  }
  rep(i,n){
    cout << ans.at(i) << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    string a,b;
    cin >> a >> b;
    vector <vector<ll>> arr(a.size(),vector<ll>(b.size(),0));
    ll n = a.size();
    ll m = b.size();
    arr[0][0] = 0;
    for (int z=0;z<m;z++){
    	if (b[z] == a[0]){
    		arr[0][z] = 1;
    	}
    	if (z - 1 >= 0)
    	arr[0][z] = max(arr[0][z],arr[0][z-1]);
    }
    for (int z=0;z<n;z++){
    	if (a[z] == b[0]){
    		arr[z][0] = 1;
    	}
    	if (z - 1 >= 0)
    	arr[z][0] = max(arr[z][0],arr[z-1][0]);
    }
    for (int z=1;z<n;z++){
    	for (int x=1;x<m;x++){
    		if (a[z] == b[x]){
    			arr[z][x] = arr[z-1][x-1]+1;
    		}
    		arr[z][x] = max(arr[z][x],max(arr[z][x-1],arr[z-1][x]));
    	}
    }
    string ans;
   ll i = n-1, j = m-1; 
   while (i > -1 && j > -1) 
   { 
      // If current character in X[] and Y are same, then 
      // current character is part of LCS 
      if (a[i] == b[j]) 
      { 
          ans += a[i]; // Put current character in result 
          i--; j--;    // reduce values of i, j and index 
      } 
  
      // If not same, then find the larger of two and 
      // go in the direction of larger value 
      else if (i!= 0 && (j == 0 || arr[i-1][j] > arr[i][j-1])) 
         i--; 
      else
         j--; 
   }    
    for (int z=ans.size()-1;z>-1;z--){
    	cout << ans[z];
    }
    cout << endl;
    cin >> a;
}


Measured memory_bytes: 70784
#include<stdio.h>
int main(void)
{
	double a,b;

		while(scanf("%lf %lf",&a,&b)!=EOF) {
			if(35.50>a && 71.00>b){
				printf("AAA\n");
			}
			else if (37.50>a && 77.00>b){
				printf("AA\n");
			}
			else if (40.00>a && 83.00>b){
				printf("A\n");
			}
			else if (43.00>a && 89.00>b){
				printf("B\n");
			}
			else if(50.00>a && 105.00>b){
				printf("C\n");
			}
			else if(55.00>a && 116.00>b){
				printf("D\n");
			}
			else if(70.00>a && 148.00>b){
				printf("E\n");
			}
			else{
				printf("NA\n");
			}
		}
		return 0;
}

Measured memory_bytes: 1036
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
#define N 100010
vector<ll>g[N+1];
ll n,m,dp[N],vis[N],ans=0;
void dfs(ll x){
	if(vis[x])return;
	vis[x]=1;
	for(int i=0;i<g[x].size();i++){
		dfs(g[x][i]);
		dp[x]=max(dp[x],dp[g[x][i]]+1);
	}ans=max(ans,dp[x]);
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		ll u,v;
		cin>>u>>v;
		g[u].pb(v);
	}
	for(int i=1;i<=n;i++){
		dfs(i);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9344
import java.util.*;
class Main {
    final int INF = 1000000009;
    int[] arr;
    private int cost(int i, int j) {
    	return Math.abs(arr[i] - arr[j]);
	}

	private void run() {
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        arr = new int[N];
        for (int i = 0; i < N; i++) arr[i] = sc.nextInt();
        int[] dp = new int[N];
        dp[N-1] = 0;
        for (int i = N - 2; i >= 0; i--) {
            int res = INF;
            for (int j = 1; j <= K; j++) {
                if (i + j >= N) break;
                res = Math.min(res, dp[i + j] + cost(i, i + j));
            }
        	dp[i] = res;
        }
		System.out.println(dp[0]);
    }
  
	public static void main(String[] args) {
    	Main m = new Main();
      	m.run();
	}
}


Measured memory_bytes: 52468
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1LL << 60;

struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

ll N;
int main() {
    cin >> N;
    Sieve sieve = Sieve(55555);
    vector<ll> v;

    for (int i = 11; i <= 55555; i++) {
        if (i % 5 != 1) continue;

        if (sieve.isPrime(i)) {
            v.push_back(i);
        }
        if (v.size() == N) break;
    }

    rep(i, v.size()) {
        cout << v[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 3648
import Text.Printf
main = do
  s <- getContents
  let l = map words . lines $ s
  mapM_ (putStrLn . printf "%.6f" . invpol [] ) l

invpol::[Double] -> [String] -> Double
invpol [x] [] = x
invpol y (x:xs)
  | x == "+" = invpol (((head.tail $ y) + (head y) ):(tail.tail $ y)) xs
  | x == "-" = invpol (((head.tail $ y) - (head y) ):(tail.tail $ y)) xs
  | x == "*" = invpol (((head.tail $ y) * (head y) ):(tail.tail $ y)) xs
  | x == "/" = invpol (((head.tail $ y) / (head y) ):(tail.tail $ y)) xs
  | otherwise = invpol (((read::String->Double) x):y) xs

Measured memory_bytes: 4452