akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    string s[n];
    REP(i,n){
        cin >> s[i];
    }
    int ans = 0;
    for(int a = 0; a < n; a++){
        char t[n][n];
        REP(i,n){
            REP(j,n){
                t[i][j] = s[(i + a) % n][j];
            }
        }
        REP(i,n){
            REP(j,n){
                if(t[i][j] != t[j][i]) goto no;
            }
        }
        ans++;
        no:;
    }
    cout << ans * n << endl;
    return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int solve(int cur, const vector<vector<int>>& g, const vector<bool>& vec) {
	vector<bool> visited = vec;
	bool complete = [=]() -> bool {
		for (auto x : visited) {
			if (!x) {
				return false;
			}
		}
		return true;
	}();

	if (complete) {
		return 1;
	}

	int res = 0;
	for (auto next : g[cur]) {
		if (visited[next]) {
			continue;
		}

		visited[next] = true;
		res += solve(next, g, visited);
		visited[next] = false;
	}

	return res;
}

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

	int n, m;
	cin >> n >> m;

	vector<vector<int>> g(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;

		g[a].push_back(b);
		g[b].push_back(a);
	}

	vector<bool> visited(n);
	visited[0] = true;

	cout << solve(0, g, visited) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int r,d,x;
  cin >> r >> d >> x;
  
  int a = x;
  for(int i = 0 ; i < 10 ; i++){
    cout << a*r - d << endl;
    a = a*r - d;
  }
}

Measured memory_bytes: 256
#pragma comment (linker, "/STACK:256000000")
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long a = 0;a < b;++a)
#define ALL(x) (x).begin(),(x).end()
void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}
void solve() {
    int n;
    cin >> n;
    int ans = 0;
    REP(i, n) {
        string s;
        cin >> s;
        if (s == "E869120")ans++;
    }
    cout << ans << endl;
}
int main() {
    init();
    solve();
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << v[k - 1] << endl;
}


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

double abs(double x) {
    if (x > 0.0) {
        return x;
    } else {
        return x * (-1);
    }
}

int main(){

    int N;
    cin >> N;

    int a[110];
    int sum = 0;
    for (int i=0; i<N; i++) {
        cin >> a[i];
        sum += a[i];
    }
    double mean;
    mean = sum * 1.0/N;

    int itr = -1;
    double diff = 10000;
    for (int i=0; i<N; i++) {
        if (abs(a[i]-mean) < diff) {
            itr = i;
            diff = abs(a[i]-mean);

        }
    }

    cout << itr << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

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

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

inline int gcd(int a, int b) { return (a%b == 0) ? b : gcd(b, a%b); }
inline int fac(int n) { return (n==0) ? 1 : n * fac(n - 1); }

int main() {
    int n;
    cin >> n;
    int a[n+1];
    for (int i = 1; i < n+1; i++) {
        cin >> a[i];
    }

    int cnt = 0;
    for (int i = 1; i < n+1; i++) {
        int j = a[i];
        if (a[j] == i)
        {
            cnt++;
        }
    }

    cout << cnt / 2 << endl;

    return 0;
}


Measured memory_bytes: 3944
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int a, b ;
    cin >> a >> b ;
    double fa,fb ;
    fa = a ;
    fb = b ;
    printf("%d %d %.5f\n",(a/b),(a%b),(fa/fb)) ;
    return 0 ;
}


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

int main(){
    int a, b;
    cin >> a >> b;
    int c = b - a;
    int x = 0;
    for(int i = 1; i < c; i++) x += i;
    cout << x - a <<endl;
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<int> a(n+1,0);
    int temp;
    long long ans=1;
    for(int i=1; i<=n; i++){
        temp=i;
        for(int j=2; j<=i; j++){
            while(temp%j==0){
                temp/=j;
                a[j]++;
            }
        }
    }
    for(int i=0; i<=n; i++){
        ans=(ans*(a[i]+1))%MOD;
    }
    cout << ans << endl;
    return 0;
}


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

const int MAX_N = 300000 + 10;
const int MAX_M = 100000 + 10;

struct BIT {
  int n;
  vector<int> tree;
  BIT(int n):n(n),tree(n+1) {} 
  void update(int idx, int val) {
    for (int x=idx+1; x<=n; x+=x&-x) tree[x] += val;
  }
  int sum(int idx) {
    int sum=0;
    for (int x=idx+1; x>0; x-=x&-x) sum += tree[x];
    return sum;
  }
};

struct Range {
  int a, b;
  int len() const {return b - a;}
};
Range ranges[MAX_N];

int main2() {
  int N, M;
  scanf("%d%d", &N, &M);
  REP(i, N) {
    int L, R;
    scanf("%d%d", &L, &R);
    ranges[i] = {L, R+1};
  }
  sort(ranges, ranges + N, [](const Range& lhs, const Range& rhs) {
    return lhs.len() < rhs.len();
  } );

  BIT bit(MAX_M);
  int p = 0;
  for (int d = 1; d <= M; d++) {
    while (p < N && ranges[p].len() < d) {
      bit.update(ranges[p].a, +1);
      bit.update(ranges[p].b, -1);
      p++;
    }
    int ans_d = 0;
    ans_d += N - p;
    for (int i = d; i <= M; i += d) {
      ans_d += bit.sum(i);
    }
    printf("%d\n", ans_d);
  }
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a, b, n;
  cin >> a >> b;
  if((a+b)%2==0) co((a+b)/2);
  else co("IMPOSSIBLE");
  
  
  return 0;
}


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

int main() {
    int x, y;

    while(true) {
        cin >> x >> y;
        if (x == 0 && y == 0) {
            break;
        }
        if (x > y)
            printf("%d %d\n", y, x);
        else
            printf("%d %d\n", x, y);
    }
}


Measured memory_bytes: 3076
# Sort II - Counting Sort
def	countingSort(A,n,k):
    result = []
    # Prepare Bucket
    C = [0]*(k+1)
    # Throw number into bucket
    for a in A:
        C[a] += 1
    # Pick up index from first in order
    for i,c in enumerate(C):
        while c > 0:
            result.append(i)
            c -= 1
    return result

n = int(input())
A = list(map(int, input().split()))
k = max(A)
B = countingSort(A,n,k)
print(*B)


Measured memory_bytes: 233788
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class SearchGraph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public SearchGraph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
		discoverTime = new int[totalVertex];
		finishTime = new int[totalVertex];
	}
	
	int[] discoverTime = new int[totalVertex];
	int[] finishTime = new int[totalVertex];
	
	public void DFS() {
		
		for(int i = 0; i < discoverTime.length; i++) {
			if (discoverTime[i] == 0) {
				stepTimeCounter += 1;
				performDFS(i);
				
			}
		}
		
		for(int i = 0; i < discoverTime.length; i++) {
			System.out.println((i + 1) + " " + discoverTime[i] + " " + finishTime[i]);
		}
	}
	
	private int stepTimeCounter = 0;
	
	private void performDFS(int vertex) {
		if (discoverTime[vertex] > 0) {
			return;
		}
		discoverTime[vertex] = stepTimeCounter; 
		for(int i = 0; i < adjList.get(vertex).size(); i++) {
			if (discoverTime[adjList.get(vertex).get(i)] == 0) {
				stepTimeCounter += 1;
				performDFS(adjList.get(vertex).get(i));
			}
		}
		stepTimeCounter += 1;
		finishTime[vertex] = stepTimeCounter;
	}
}

public class Main {
	public static void main(String argv[]) {
		SearchGraph g = new SearchGraph();
		g.loadAdjList();
		g.DFS();
	}
}




Measured memory_bytes: 28296
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main(){
    int N;
    cin >> N;
    string S1, S2;
    cin >> S1 >> S2;
    ull ans;
    bool X;
    if(S1[0] == S2[0]) {
        ans = 3;
        X = true;
    }
    else {
        ans = 6;
        X = false;
    }

    for(int i = 1; i < N; i++){
        if(S1[i] == S1[i + 1]){
            if(X) ans *= 2;
            else ans *= 3;
            X = false;
        }else if(S1[i] == S2[i]){
            if(X) ans *= 2;
            X = true;
        }
        ans %= 1000000007;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict
N = int(input())
V = list(map(int, input().split()))

if len(set(V)) == 1:
    print(len(V)//2)
    sys.exit(0)

odd = defaultdict(int)
even = defaultdict(int)

for i in range(N):
    if i % 2 == 0:
        even[V[i]] += 1
    else:
        odd[V[i]] += 1

evenMax = 0
oddMax = 0
ev = 0
evenList = []
oddList = []
for k, v in even.items():
    evenList.append((v, k))
for k, v in odd.items():
    oddList.append((v, k))

evenList.sort(reverse=True)
oddList.sort(reverse=True)

ans = 0

if evenList[0][1] == oddList[0][1]:
    ans = min(N - evenList[0][0] - oddList[1][0],
              N - evenList[1][0] - oddList[0][0])
else:
    ans = N - evenList[0][0] - oddList[0][0]

print(ans)


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

signed main(){
    ll h;
    cin >> h;
    int r=1;
    int count = 0;
    while(1){
        r=r*2;
        count++;
        if(r>h) break;
    }

    int ans=0;
    int plus=1;
    rep(i,count){
        ans+=plus;
        plus*=2;
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split(' ')))

A.sort()
A.append(0)
dp = [True] * (10 ** 6 + 5)
ans = 0
for i in range(N):
    if dp[A[i]-1]:
        if A[i] != A[i + 1]:
            ans += 1
        dp[A[i]-1::A[i]] = [False] * (len(dp) // A[i])

print(ans)

Measured memory_bytes: 107356
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N =0;
  int count = 0;
  vector<int> vec(9);
  for (int i = 0; i < 9; i++) {
   vec.at(i) = i+1;
}
vector<int> seki(81);
  for (int i = 0; i < 81; i++) {
   seki.at(i) = (vec.at(i/9))*(vec.at(i % 9));
    }
   
   cin >> N;
  for (int i = 0; i < 81; i++) {
   if(seki.at(i)==N)
   {
     count ++;
   }
    }
  if(count > 0) cout << "Yes" << endl;
    else        cout << "No" <<endl;
}


Measured memory_bytes: 256
Scanf.scanf "%d" (fun n ->
    let n = n - 1 in
    let calc r digits =
        let rec loop r i acc =
            if i = 0 then acc else
                loop (r / 26) (i - 1) (Printf.sprintf "%c%s" (char_of_int ((r mod 26) + 97)) acc)
        in
        loop r digits ""
    in
    let rec loop p digits d k =
        if n < k then calc (n - p) digits else
            loop k (digits + 1) (d * 26) (k + d)
    in
    loop 0 1 (26 * 26) 26 |> print_endline
)

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a;
	int b=0;
	for(int i=0;i<4;i++)
	{
		cin>>a;
		if(a=='+')
		++b;
		else
		--b;
	if(i==3)
	cout<<b;
	}
	
}

Measured memory_bytes: 256
H,W=map(int,input().split())
S=tuple(tuple(input()) for _ in range(H))

dp=[[10**9 for _ in range(W)] for __ in range(H)]
dp[0][0]=int(S[0][0]!='.')
for i in range(H):
    for j in range(W):
        for di,dj in [[0,1],[1,0]]:
            ni=i+di
            nj=j+dj
            if 0<=ni<H and 0<=nj<W:
                WB=S[i][j]=='.' and S[ni][nj]=='#'
                dp[ni][nj]=min(dp[ni][nj],dp[i][j]+int(WB))
print(dp[-1][-1])

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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
template <typename T>
void dump_stack(std::stack<T>& stack) {
  std::stack<T> temp;
  while (!stack.empty()) {
    T top = stack.top(); stack.pop();
    std::cout << top << " ";
    temp.push(top);
  }
  std::cout << endl;
  while (!temp.empty()) {
    T top = temp.top(); temp.pop();
    stack.push(top);
  }
}
template <typename T>
void dump_queue(std::queue<T>& queue) {
  std::queue<T> temp;
  while (!queue.empty()) {
    T top = queue.front(); queue.pop();
    std::cout << top << " ";
    temp.push(top);
  }
  std::cout << endl;
  while (!temp.empty()) {
    T top = temp.front(); temp.pop();
    queue.push(top);
  }
}

typedef long long ll;



int main() {
  int N,X,T;
  cin >> N >> X >> T;
  int a=0;
  int ans = N/X*T;
  int amari = N%X;
  if(amari>0) ans += T;
  cout << ans << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

int N;
size_t K;
vector<int> a, b;
vector<int> adj[100005];
map<pair<int, int>, int> mp;

void input(){
    cin >> N;
    a.resize(N-1, 0); b.resize(N-1, 0);
    rep(i, N-1){
        cin >> a[i] >> b[i];
        --a[i]; --b[i];
        adj[a[i]].push_back(b[i]);
        adj[b[i]].push_back(a[i]);
    }
}

void rec(int from, int now){
    int c = 1;
    for(auto to : adj[now]) if(to != from) {
        if(from != -1 && mp[make_pair(min(from, now), max(from, now))] == c) ++c;
        mp[make_pair(min(now, to), max(now, to))] = c++;
        rec(now, to);
    }
    
}

void solve(){
    rep(i, N) chmax(K, adj[i].size());
    rec(-1, 0);
}

void output(){
    cout << K << endl;
    rep(i, N-1){
        int l = min(a[i], b[i]);
        int r = max(a[i], b[i]);
        cout << mp[make_pair(l, r)] << endl;
    }
}

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

    input();
    solve();
    output();
    
    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using i64 = long long;

i64 gcd(i64 a, i64 b) {
    if (b > a) std::swap(a, b);
    return a % b ? gcd(b, a % b) : b;
}

int main() {
    i64 n;
    const i64 mod = 998244353;
    std::cin >> n;
    std::vector<i64> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    std::sort(a.begin(), a.end());

    i64 ret = a[0];
    for (i64 i = 1; i < n; i++) {
        ret = ret * gcd(a[i], i) % mod;
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

int main() {
  i64 x, y, s;
  while(cin >> x >> y >> s, x && y && s) {
    i64 ans = -1e18;
    for(int a = 1;a <= s - 1;a++) {
      for(int b = 1;b <= s - 1;b++) {
        i64 bf = a * (100 + x) / 100 + b * (100 + x) / 100;
        i64 af = a * (100 + y) / 100 + b * (100 + y) / 100;
        if(bf == s) {
          ans = max(ans , af);
        }
      }
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3096
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
#define eps 1e-15
#define maxn 105
#define maxm 410
#define inf 1000000007
#define mod 1000000007
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int>pii;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int K;
int main()
{
    K=read();
    if(K==1)
    {
        puts("1");puts("1");
        return 0;
    }
    int n=(K+3)/4*2;
    printf("%d\n",n);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            int res=0;
            if(i&1)  res=n+(i+j)%n+1;
            else     res=(i+j)%n+1;
            if(res>K)  res-=n;
            printf("%d ",res);
        }
        puts("");
    }
    return 0;
}

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

 
int main(){
  int n;
  string s;
  cin >> n >> s;
  int ans = n;
  rep(i,n){
    if(s[i] == s[i+1]) --ans;
  }
  cout << ans << endl;
  return 0;
}

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

class ITP1_10C
{
    static void Main()
    {
        while (true)
        {
            int a = int.Parse(Console.ReadLine());
            if (a == 0) { break; }
            int[] x = new int[a];
            int b = 0;
            string str = Console.ReadLine();
            for (int i = 0; i < a; i++)
            {
                x[i] = int.Parse(str.Split(' ')[i]);
                b += x[i];
            }
            double c = (double)b / a;
            double d, e = 0;
            for (int i = 0; i < a; i++)
            {
                d = 0;
                d = x[i] - c;
                e += d * d;
            }
            double f = e / a;
            Console.WriteLine(Math.Sqrt(f));
        }
    }
}

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

#define all(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef vector<ll> dlist;
typedef vector<dlist> matrix;

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

    ll t, n, a , b;
    cin >> n >> a >> b;

    ll r = n / (a + b);
    ll ans = a * r + min(a, n - (r * (a + b)));
    cout << ans << "\n";

    return 0;
}//RUL0


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

#define MAX 101010
#define EPS 1e-6
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3f

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using namespace std; 

using ll = long long;
using ii = pair<int,int>;

int n;
ll dp[MAX][3];
ll v[MAX];

ll solve(int i, int last) {
  if (i == n - 1)
    return 0;

  if (dp[i][last] != -1)
    return dp[i][last];

  ll op1 = llinf, op2 = llinf;
  if (i < n - 1)
    op1 = solve(i+1, 1) + abs(v[i+1] - v[i]);
  if (i < n - 2)
    op2 = solve(i+2, 2) + abs(v[i+2] - v[i]);

  return dp[i][last] = min(op1, op2);
}

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

  cin >> n;
  for (int i = 0; i < n; ++i)
    cin >> v[i];

  mset(dp, -1);
  cout << solve(0, 0) << ende;
  return 0;
}


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

const int MOD = 1000000007;

vector<vector<int>> graph;
long long dp[100000][2];
bool sht[100000][2];

long long dfs(int u, int p, int par)
{
    if (sht[u][par]) return dp[u][par];
    sht[u][par] = 1;
    
    dp[u][par] = 1;
    
    for (int v: graph[u])
    {
        if (v != p)
        {
            if (!par)
                (dp[u][par] *= dfs(v, u, 0) + dfs(v, u, 1)) %= MOD;
            else
                (dp[u][par] *= dfs(v, u, 0)) %= MOD;
        }
    }
    
    return dp[u][par];
}

int main()
{
    int n;
    cin >> n;
    graph.resize(n);
    for (int i = 1; i != n; ++i)
    {
        int u, v;
        scanf("%d %d", &u, &v);
        --u;
        --v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    
    cout << (dfs(0, -1, 0) + dfs(0, -1, 1)) % MOD;
}

Measured memory_bytes: 17152
#include <stdio.h>

int main(){

  int a,b,c;  
  scanf("%d %d %d",&a,&b,&c);

  /*
  // && ||
  if(a <= b && b <= c){
    printf("%d %d %d\n",a,b,c);
  }

  else if(a <= c && c <= b){
    printf("%d %d %d\n",a,c,b);
  }

  else if(b <= a && a <= c){
    printf("%d %d %d\n",b,a,c);
  }
  else if(b <= c && c <= a){
    printf("%d %d %d\n",b,c,a);
  }
  else if(c <= a && a <= b){
    printf("%d %d %d\n",c,a,b);
  }
  else if(c <= b && b <= a){
    printf("%d %d %d\n",c,b,a);
  }
  */

  int min, mid, max;

  min = a;
  mid = b;
  max = c;

  int tmp;

  if(max < mid){
    tmp = max;
    max = mid;
    mid = tmp;
  }
  if(max < min){
    tmp = max;
    max = min;
    min = tmp;
  }
   if(min > mid){
    tmp = mid;
    mid = min;
    min = tmp;
  }


  printf("%d %d %d\n",min,mid,max);
  
 

  return 0; 
}

Measured memory_bytes: 596
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n + 1, 0);

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

	vector<int> d(n + 1, 0);
	d[0] = 1;

	for (int i = 1; i < n + 1; ++i) {
		if (!a[i]) {
			d[i] = (d[i] + d[i - 1]) % MOD;
			if (i > 1) {
				d[i] = (d[i] + d[i - 2]) % MOD;
			}
		}
	}

	cout << d[n] << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  vector<int> n(4);
  for (auto &x: n) cin >> x;

  sort(n.begin(), n.end());
  if (n[0] == 1 && n[1] == 4 && n[2] == 7 && n[3] == 9) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }

  return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}

int main() {
  int N; cin >> N;
  vector<int> t(N + 1), x(N + 1), y(N + 1);
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  for(int i = 1; i <= N; ++i) {
    cin >> t[i] >> x[i] >> y[i];
  }
  string str = "Yes";
  
  REP(i, N + 1) {
    // cout << x.at(i) << " " << y.at(i) << " " << t.at(i) << endl;
    if((x.at(i) + y.at(i)) % 2 != t.at(i) % 2) {
      str = "No";
    }

    if(i == N) break;

    if((x.at(i + 1) + y.at(i + 1)) - (x.at(i) + y.at(i)) > t.at(i + 1) - t.at(i)) {
      str = "No";
    }
  }

  cout << str << endl;
}

Measured memory_bytes: 1408
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  rep(i, n){
    string s, t;
    cin >> s >> t;
    reverse(s.begin(), s.end());
    reverse(t.begin(), t.end());
    string res = "";
    int tmp = 0;
    rep(i, max(s.size(), t.size())){
      int sn = 0, tn = 0;
      if(i < s.size())sn = int(s[i] - '0');
      if(i < t.size())tn = int(t[i] - '0');
      int num = tmp + sn + tn;
      tmp = num / 10;
      res += char('0' + (num % 10));
    }
    if(tmp > 0)res += char('0' + tmp);
    reverse(res.begin(), res.end());
    if(res.size() <= 80)cout << res << endl;
    else cout << "overflow" << endl;
  }
	return 0;
}



Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main()
{
	//ios::sync_with_stdio(false);
	string s ;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < 3; i++)
		if (s[i] == '7')
			ans = 1;
	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

const long long MOD = 1000000007LL;

auto solve(long long N){
    long long ret = 1LL;
    for(long long i = 1LL;i <= N; ++i) {
        ret = (ret * i) % MOD;
    }

    return ret;
}

int main(){
    long long N;
    scanf("%lld",&N);
    auto result = solve(N);
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main() {
  ll k; 
  cin >> k;
  
  if(k<=1e16){
    cout << 2 << endl;
    if(k%3==2){ cout << k << " " << 1 << endl; } else { cout << 1+k << " " << 0 << endl; }
    return 0;
  }
  cout << 50 << endl;
  for(int i=0; i<50; i++){
    ll op = k/50+i;
    if(i>=50-(k%50)){op++;}
    cout<<op<<" ";
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 384
n, h = map(int, input().split())

a = 0
b = []
for i in range(n):
    A, B = map(int, input().split())
    a = max(a, A)
    b.append(B)
b = sorted([i for i in b if a < i], reverse=True)

cnt = 0
for i in b:
    cnt += 1
    h -= i
    if h <= 0:
        print(cnt)
        exit()
print(cnt + (h + a - 1) // a)


Measured memory_bytes: 9032
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C
{
    class Program
    {
        public static long N;
        public static long[] a;
        static void Main(string[] args)
        {
            a = new long[5];
            N = long.Parse(Console.ReadLine());
            for (long i = 0; i < 5; i++)
            {
                a[i] = long.Parse(Console.ReadLine());
            }
            long min = a.Min();
            long syo = N / min;
            long per = N % min;
            if (per == 0) { syo-=1; }
            Console.WriteLine(syo+5);
        }
    }
}


Measured memory_bytes: 13268
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int table[201][201];
void maketable() {
    rrep(i, 1, 201) {
        table[i][1] = 1;
        int tmp = i;
        rrep(j, 2, i + 1) {
            while (tmp % j == 0) {
                table[i][j]++;
                tmp /= j;
            }
        }
    }
}
int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    maketable();
    //5 * 10^15 days
    //2 1char -> 2 -> 4 -> 8 ...
    string s; cin >> s;
    ll k; cin >> k;
    rep(i, k) if (s[i] != '1') {cout << s[i] << endl; return 0;}
    cout << 1 << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  int odd_count = 1;
  for(int j=0; j<N; j++){
    if(vec.at(j) %2 == 0){
      odd_count *= 2;
    }
  }
  cout << pow(3,N) - odd_count << endl;
}

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

int main() {
	long long n, k;
	cin >> n >> k;

	long long ans = 0;

	if (k % 2 == 0) {
		ans = pow(((2 * n) / k) - (n / k), 3) + pow(n / k, 3);
	}
	else
	{
		ans = pow(n / k, 3);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<iomanip> 
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<queue>
#include<functional>
#include<vector>
#include<map>
#include<set>
#pragma warning(disable:4996)；

using namespace std;
#define ll long long

int main() {
	int a, b;
	scanf("%d%d", &a, &b); int c = a*b; bool flag = 0;
	for (int i = 1; i <= 3; i++)
	{
		if (c*i % 2 == 1) { flag = 1; }
	}
	if (flag) { cout << "Yes"; }
	else { cout << "No"; }







	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N, M;
  cin >> N >> M;
  vector<vector<pair<int, int> > > shi_by_p(N);
  int kami[M], shimo[M];
  for(int i=0; i<M; i++){
    int p, y;
    cin >> p >> y;
    kami[i] = p;
    p--;
    shi_by_p[p].push_back(make_pair(y, i));
  }
//  for(int i=0; i<shi_by_p.size(); i++) for(auto j: shi_by_p[i]) sort(j.begin(), j.end());
//  for(auto j: shi_by_p) for(auto i: j) cout << i.first << endl;
//  for(auto j: shi_by_p) sort(j.begin(), j.end(), greater<pair<int, int> >());  
  for(int i=0; i<shi_by_p.size(); i++) {
    if(shi_by_p[i].size() == 0) continue;
    sort(shi_by_p[i].begin(), shi_by_p[i].end()); 
  }
//  for(auto j: shi_by_p) for(auto i: j) cout << i.first << endl;
  for(int i=0; i<N; i++){
    if(shi_by_p[i].size() == 0) continue;
    for(int j=0; j<shi_by_p[i].size(); j++){
      auto tmp = shi_by_p[i][j];
      shimo[tmp.second] = j+1;
    }
  }
  for(int i=0; i<M; i++) cout << setfill('0') << right << setw(6) << kami[i] << setfill('0') << right << setw(6) << shimo[i] << endl;
  
  return 0;
}

Measured memory_bytes: 7808
#include<iostream>
#include<cstring>
#include<queue>
#include<vector>
#include<algorithm>
#include <cstdio>
using namespace std;
const int INF=1000000000;
typedef pair<long long,int> P;
int H,W,C[10][10],A[200][200],ans=0;
int dp[10][1<<10];
int reg(int a,int S){
	if(dp[a][S]!=-1)return dp[a][S];
	if(a==1)return 0;
	int res=INF;
	for(int i=0;i<10;++i){
		if(!(S>>i&1)){
			res=min(res,reg(i,S|1<<i)+C[a][i]);
		}
	}
	//cout<<a<<" "<<S<<" "<<res<<endl;
	return dp[a][S]=res;
}





int main(){
	cin>>H>>W;
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<10;++i){
		for(int j=0;j<10;++j){
			cin>>C[i][j];
		}
	}
	for(int i=0;i<H;++i){
		for(int j=0;j<W;++j){
			cin>>A[i][j];
			if(A[i][j]!=-1){
				ans+=reg(A[i][j],0);
			}
		}

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


Measured memory_bytes: 384
#include "bits/stdc++.h"

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	sort(s.begin(),s.end());
	sort(t.rbegin(), t.rend());
	if (s <t) {
		cout <<"Yes" << endl;
	}
	else {
		cout << "No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3636
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pob pop_back
#define ft first
#define ftt ft.ft
#define ftc ft.sc
#define sc second
#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
#define ctz __builtin_ctz
typedef pair<int, int> pii;
typedef pair<ll ,ll> pll;
const int maxn = 1e6 + 120;
 


int n,res ,m ,x ,a[maxn];
int main(){FAST;
    cin >> n >> m >> x;
    forp(i ,0 ,m)
        cin >> a[i];
    sort(a ,a + m);
    
    forp(i ,0 ,m){
        if(a[i] > x)
        {
          break;}
        res++;
    }
    cout << min(res ,m - res);
   return 0;
}
 












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

int search(vector <string> a, int i, int j,int H,int W)
{
	int number=0;
	if (i - 1 >= 0 && j - 1 >= 0)
		if (a[i-1][j-1] == '#')
			++number;
	if (i - 1 >= 0 && j + 1 <W)
		if (a[i-1][j+1] == '#')
			++number;
	if (i +1 <H && j - 1 >= 0)
		if (a[i+1][j-1] == '#')
			++number;
	if (i + 1 <H && j + 1 <W)
		if (a[i+1][j+1] == '#')
			++number;
	if (i - 1 >= 0 )
		if (a[i-1][j] == '#')
			++number;
	if (i + 1 <H)
		if (a[i+1][j] == '#')
			++number;
	if (j - 1 >= 0)
		if (a[i][j-1] == '#')
			++number;
	if (j + 1 <W)
		if (a[i][j+1] == '#')
			++number;
	return number;
}


int main()
{
	int H, W;
	cin >> H;
	cin >> W;
	int i, j;
	vector <string> a;
	string temp;
	for (i = 0; i < H; ++i)
	{
		cin >> temp;
		a.push_back(temp);
	}
	int t;
	for(i=0;i<H;++i)
		for (j = 0; j < W; ++j)
		{
			if (a[i][j] == '.')
			{
				t = search(a, i, j, H, W);
				a[i][j] = (char)('0' + t);
			}
		}

	for (i = 0; i < H; ++i)
	{
		cout << a[i] << endl;
	}


    return 0;
}

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

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

    pair<pair<string, int>, int> p[110];

    for(int i = 0; i < n; i++){
        string s;
        int x;
        cin >> s >> x;

        p[i] = make_pair(make_pair(s, -x), i);
    }

    sort(p, p+n);

    for(int i = 0; i < n; i++){
        cout << p[i].second+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc161_d
{
  class Program
  {
    static void Main(string[] args)
    {
      var K = CIn.ReadInt();

      var q = new Queue<long>();
      foreach (var i in Enumerable.Range(1, 9)) q.Enqueue(i);
      var count = 0;

      while (q.Count > 0)
      {
        var e = q.Dequeue();
        count++;
        if (count == K)
        {
          Console.WriteLine(e);
          return;
        }

        var l = e % 10;
        var a = Math.Max(0, l - 1);
        var b = Math.Min(9, l + 1);

        for (var i = a; i <= b; i++)
        {
          q.Enqueue(e * 10 + i);
        }
      }
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 14816
"""
    Template written to be used by Python Programmers.
    Use at your own risk!!!!
    Owned by enraged(rating - 5 star at CodeChef and Specialist at Codeforces).
"""
import sys
import bisect
import heapq
# from math import *
from collections import defaultdict as dd  # defaultdict(<datatype>) Free of KeyError.
from collections import deque  # deque(list) append(), appendleft(), pop(), popleft() - O(1)
from collections import Counter as c  # Counter(list)  return a dict with {key: count}
from itertools import combinations as comb
from bisect import bisect_left as bl, bisect_right as br, bisect
# sys.setrecursionlimit(2*pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()


def out(var): sys.stdout.write(var)


def l(): return list(map(int, data().split()))


def sl(): return list(map(str, data().split()))


def sp(): return map(int, data().split())


def ssp(): return map(str, data().split())


def l1d(n, val=0): return [val for i in range(n)]


def l2d(n, m, val=0): return [[val for i in range(n)] for j in range(m)]


a, b = sp()
for i in range(1, 40001):
    t1, t2 = int(0.08 * i), int(0.1 * i)
    if t1 == a and t2 == b:
        out(str(i))
        exit(0)
out("-1")


Measured memory_bytes: 40888
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    int N;
    cin >> N;
    int B[N - 1];
    REP(i, N - 1) cin >> B[i];

    int s = 0;
    s += B[0];
    REP(i, N - 2) {
        s += min(B[i], B[i + 1]);
    }
    s += B[N - 2];
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;



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

	int ans = 0;
	for (int i = 1; i <= 1000; i++) {
		for (int j = 2; j <= 10; j++) {
			if (pow(i, j) <= x) chmax(ans, (int)pow(i, j));
		}
	}

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

Measured memory_bytes: 512
#include<stdio.h>
int main(){
  int h = 0, m = 0, S;
  scanf("%d\n", &S);
  for(;S>=3600;h++)S-=3600;
  for(;S>=60;m++)S-=60;
  printf("%d:%d:%d\n", h, m, S);
  return 0;
}


Measured memory_bytes: 2748
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n;
  double x=0;
  cin >> n;
  char s[n];
  for(int i=0;i<n;++i) cin >> s[i];
  int ans[n];
  for(int i=0;i<n;++i) {
    if(s[i] == 'I') ++x;
    if(s[i] == 'D') --x;
     ans[i] = x;
  }
  sort(ans, ans+n,greater<int>());
  if(ans[0] < 0) ans[0] = 0;
  cout << ans[0] << endl;
}

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

using namespace std;

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

  for (int ti = 0; ti < t; ti++) {
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    for (int i = 0; i < n; i++) {
      cin >> x[i];
    }
    if (k >= n) {
      cout << 0 << endl;
      continue;
    }
    vector<int> a(n - 1);
    for (int i = 0; i < n - 1; i++) {
      a[i] = x[i + 1] - x[i];
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    int ans = x[n - 1] - x[0];
    for (int i = 0; i < k - 1; i++) {
      ans -= a[i];
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3628
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    ct=0
    for i in range(n):
        a,b=STRM()
        if b=='JPY':
            ct+=int(a)
        else:
            ct+=float(a)*380000
    print(ct)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))

x2 = 0

for i in range(N):
    if i % 2 == 0:
        x2 += A[i]
    else:
        x2 -= A[i]

R = [0] * N
R[0] = x2

for i in range(N - 1):
    R[i + 1] = 2 * A[i] - R[i]
print(*R)


Measured memory_bytes: 14028
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

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

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

void solve() {
    lli n;
    cin >> n;

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

    multiset<lli> last;

    for (int i = 0; i < n; ++i) {
        auto it = last.lower_bound(a[i]);

        if (it == last.begin()) {
            last.insert(a[i]);
        } else {
            it--;
            last.erase(it);
            last.insert(a[i]);
        }
    }
   cout << last.size() << "\n";
}

int main()
{
    IOS;
    lli t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5760