akhauriyash/Code-Regression huggingface dataset:
//ITP1_7_C
//????????????  37???

using System;
using System.Collections.Generic;

class ITP1_7_C
{
    static void Main(string[] args)
    {

        int[] st = Array.ConvertAll<string, int>((Console.ReadLine().Split(' ')), delegate (string value)
        {
            return int.Parse(value);
        });

        int r = st[0];
        int c = st[1];

        int[,] sheet = new int[ r + 1 , c + 1];

        for(int row = 0;row < r; row++)
        {

            int[] cdata = Array.ConvertAll<string, int>((Console.ReadLine().Split(' ')), delegate (string value)
            {
                return int.Parse(value);
            });

            for (int col = 0; col < c; col++)
            {
                sheet[row , col] = cdata[col];
                sheet[row, c] += cdata[col];
                sheet[r, col] += cdata[col];
            }

            sheet[r, c] += sheet[row, c];
        }

        for(int row = 0;row <= r; row++)
        {
            for(int col = 0;col <= c; col++)
            {
                Console.Write(sheet[row, col]);
                if (col < c)
                    Console.Write(" ");
            }

            Console.Write("\r\n");

        }

    //    Console.Write("\r\n");
    }

}

Measured memory_bytes: 9408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, v[22], c[22];

    cin >> n;
    REP(i, n)
    cin >> v[i];
    REP(i, n)
    cin >> c[i];

    int res = 0;
    REP(i, n)
    res += max(0, v[i] - c[i]);

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
let n = Int(readLine()!)!
let a = readLine()!.split(separator: " ").map { Int($0)! }

var acc = 0
var min = 0

for num in a {
  if min > num {
    acc = acc &+ (min - num)
  } else {
    min = num
  }
}

print(acc)


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

struct Card{
	char suit;
	int value;
};

void selectionSort(Card A[],int n){
	for(int i=0;i<n;i++){
		int min_num = i;
		for(int j=i+1;j<n;j++){
			if(A[min_num].value>A[j].value){
				min_num = j;
			}
		}
		if(i!=min_num){
			swap(A[i],A[min_num]);
		}
	}
}

int bubbleSort(Card A[],int n){
	int flag = 1;
	
	for(int i=0;flag;i++){
		flag = 0;
		for(int j=n-1;j>=i+1;j--){      //利用i+1减少运算次数 
			if(A[j].value<A[j-1].value){
				swap(A[j],A[j-1]);
				flag = 1;
			}
		}
	}
}

int main(){
	int n;
	cin>>n;
	Card A[n],B[n];
	for(int i=0;i<n;i++){
		cin>>A[i].suit>>A[i].value;
		B[i].suit = A[i].suit;
		B[i].value = A[i].value;
	}
	
	bubbleSort(A,n);
	selectionSort(B,n);
	
	for(int i=0;i<n;i++){
		if(i)
			cout<<" ";
		cout<<A[i].suit<<A[i].value;
	}
	cout<<endl;
	cout<<"Stable"<<endl;
	
	
	for(int i=0;i<n;i++){
		if(i)
			cout<<" ";
		cout<<B[i].suit<<B[i].value;
	}
	cout<<endl;
	
	int flag = 1;
	for(int i=0;i<n;i++){
		if(A[i].suit!=B[i].suit){
			flag = 0;
			break;
		}
	}
	
	if(flag == 1){
		cout<<"Stable"<<endl;
	}
	else{
		cout<<"Not stable"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 1001001001;

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> X(N);

    ll ans = INF;
    for(ll i=0;i<N;i++) cin >> X[i];
    for(ll i=0;i<N-K+1;i++){
        ll pre_ans;
        ll l = i,r = i+K-1;
        if(X[l]*X[r] < 0){
            pre_ans = min(abs(X[l]),abs(X[r]))*2 + max(abs(X[l]),abs(X[r]));
        }
        else{
            pre_ans = max(abs(X[l]),abs(X[r]));
        }
        ans = min(ans,pre_ans);
    }
    cout << ans << endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
// #include <unordered_map>
#define vi vector <ull>
#define ii pair<ull,ull>
#define vii vector<ii>
 
#define seti set<ull>
#define mii map<ull,ull>
#define um unordered_map
#define ll long long
#define ull  long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MAX 100100
#define _ << " " <<

ull mod = 1e9+7;
 
using namespace std;





void solve(){
	int n,k;
	cin >> n >> k;
		
	int dp[k+1];
	dp[0] = 0;
	for(int i = 1; i <= k; i++){
		dp[i] = -1;
	}
	int a[n];


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

	for(int i = 1; i <= k; i++){
		dp[i] = 0;
		for(int j = 0; j < n; j++){
			if(i-a[j] >= 0 && dp[i-a[j]] == 0){
				dp[i] = 1;
				break;
			}
		}
	}

	if(dp[k]){
		cout << "First";
	}else{
		cout << "Second";
	}

}
 
 
int main(){
	// freopen("data.in", "r", stdin);
	// freopen("data.out", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ull q;
	// cin >> q;
	q = 1;
	for(ull i = 0; i < q; i++){
		// cout << "Case #" << i+1 << ":" << endl;
 
		solve();
		// cout << endl;
	}
 
	
 
	return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
	int N, i, j, k, count = 0;
	string str;
	cin >> N;
	cout << N * 2 * M_PI;
	return 0;
}

Measured memory_bytes: 3816
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX-1;
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;
struct edge { ll from; ll to; ll cost; };


int main(){
	string s;
	cin >> s;

	string s1;
	string s2;
	rep(i, 0, s.size()) {
		if (s[i] != 'x')s1.pb(s[i]);
	}
	reverse(all(s));
	rep(i, 0, s.size()) {
		if (s[i] != 'x')s2.pb(s[i]);
	}

	if (s1 != s2) { 
		cout << "-1" << endl;
		return 0;
	}


	vector<int>xcnt1;
	vector<int>xcnt2;
	int ans = 0;
	if (s1.size() % 2 != 0) {
		int cnt = 0;
		int ind = 0;
		int xcnt = 0;
		while (cnt <= s1.size()/2 && ind < s.size()) {
			if (s[ind] != 'x') {
				xcnt1.pb(xcnt);
				xcnt = 0;
				cnt++;
			}
			else {
				xcnt++;
			}
			ind++;
		}
		reverse(all(s));
		cnt = 0;
		ind = 0;
		xcnt = 0;
		while (cnt <= s1.size() / 2 && ind < s.size()) {
			if (s[ind] != 'x') {
				xcnt2.pb(xcnt);
				xcnt = 0;
				cnt++;
			}
			else {
				xcnt++;
			}
			ind++;
		}
		rep(i, 0, xcnt1.size()) {
			ans += abs(xcnt1[i] - xcnt2[i]);
		}
	}
	else {
		int cnt = 0;
		int ind = 0;
		int xcnt = 0;
		while (cnt < s1.size() / 2 && ind < s.size()) {
			if (s[ind] != 'x') {
				xcnt1.pb(xcnt);
				xcnt = 0;
				cnt++;
			}
			else {
				xcnt++;
			}
			ind++;
		}
		reverse(all(s));	
		cnt = 0;
		ind = 0;
		xcnt = 0;
		while (cnt < s1.size() / 2 && ind < s.size()) {
			if (s[ind] != 'x') {
				xcnt2.pb(xcnt);
				xcnt = 0;
				cnt++;
			}
			else {
				xcnt++;
			}
			ind++;
		}
		rep(i, 0, xcnt1.size()) {
			ans += abs(xcnt1[i] - xcnt2[i]);
		}

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1212
#include <stdio.h>
                                                                                                
  
int main(void){
                                                                                                
   
    int i, j, t;

    int s[3];
   
      
    scanf("%d %d %d", &s[0], &s[1], &s[2] );
   

    for( i = 1 ; i < 3 ; i = i + 1 ){

         if( s[0] < s[i] ){

             t = s[i];

             s[i] = s[0];

             s[0] = t;

             }

         } 
              

    if( s[0] == s[1] + s[2] ) printf("Yes\n");

    else printf("No\n");
   

    return 0;
                                                          
}

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

using namespace std;

int main() {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  vector<bool> W(30 + 35), S(3000 + 35);
  W[0] = S[0] = true;
  for (int i = 0; i <= 30; i++) {
    if (W[i]) {
      W[i + A] = W[i + B] = true;
    }
  }
  for (int i = 0; i <= 3000; i++) {
    if (S[i]) {
      S[i + C] = S[i + D] = true;
    }
  }
  int max_a = 100 * A, max_b = 0;
  auto chmax = [&](int a, int b) {
    // b / (a+b) > max_b / (max_a+max_b)
    if (b * (max_a + max_b) > max_b * (a + b)) {
      max_a = a;
      max_b = b;
    }
  };
  for (int i = 0; i <= 30; i++) {
    if (!W[i]) continue;
    for (int j = 0; j <= 3000; j++) {
      if (!S[j]) continue;
      if (i * E < j) continue;
      if (i * 100 + j > F) continue;
      chmax(i * 100, j);
    }
  }
  cout << max_a + max_b << " " << max_b << endl;

  return 0;
}
/* vim:set fdm=marker: */


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

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int scoreAlice = 0, scoreBob = 0;
	bool flag = true;
	for (int i = n - 1; i >= 0; i--) {
		if (flag == true) {
			scoreAlice += a[i];
			flag = false;
		}
		else {
			scoreBob += a[i];
			flag = true;
		}
	}
	cout << scoreAlice - scoreBob << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

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

  int H, W; cin >> H >> W;
  vector<string> s(H);
  rep(i, H) cin >> s[i];
  int left[H][W], right[H][W], up[H][W], down[H][W];

  rep(i, H) {
      int cur = 0;
      rep(j, W) {
          if(s[i][j]=='#') cur = 0;
          else ++cur;
          left[i][j] = cur;
      }
  }
  rep(i, H) {
      int cur = 0;
      for(int j = W-1; j >= 0; --j) {
          if(s[i][j]=='#') cur = 0;
          else ++cur;
          right[i][j] = cur;
      }
  }
  rep(j, W) {
      int cur = 0;
      rep(i, H) {
          if(s[i][j]=='#') cur = 0;
          else ++cur;
          up[i][j] = cur;
      }
  }
  rep(j, W) {
      int cur = 0;
      for(int i = H-1; i >= 0; --i) {
          if(s[i][j]=='#') cur = 0;
          else ++cur;
          down[i][j] = cur;
      }
  }

  // Output
  int ans = -1;
  rep(i, H) rep(j, W) {
      if(s[i][j]=='#') continue;
      ans = max(ans, left[i][j]+right[i][j]+up[i][j]+down[i][j]-3);
  }
  cout << ans << '\n';
  return 0;
}


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

inline char to_lower(const char& c) { return (c - 'A') + 'a'; }

int main() {
  int N, K;
  cin >> N >> K;
  string s;
  cin >> s;
  for(int i = 0; i < N; ++i) {
    if(i == K - 1) {
      cout << to_lower(s[i]);
    } else {
      cout << s[i];
    }
  }
  cout << endl;
  return 0;
}

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


int main() {
	long long int n,a,b;
	cin>>n;
	cin>>a;
	cin>>b;
	long long int x=n/(a+b);
	long long int totalblueballs=x*a;
	long long int y=n%(a+b);
	totalblueballs=totalblueballs+min(y,a);
	cout<<totalblueballs<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (){
	unsigned int W,H,x,y,r;
	//x and y shouldnt be min 0,0
	scanf ("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if (W>=x && H>=y && W>=x+r && H>=y+r)
	{
		//need to meet these condition so the cirlce is on rectangle if one false then it means it is not inside so use &&
		//x,y coor r jari jari
		printf ("Yes\n");
	}else{
		printf ("No\n");
		}
	return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
#ifdef _DEBUG
#include "../../../debug_print.hpp"
#else
#define debug(...)
#endif
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    string s;
    scan(s);
    rep(i, s.size()) { cout << 'x'; }
    cout << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
using namespace std;

const int MAX_N =100000;
int N,M,a[MAX_N],b[MAX_N];
pair<int,int> itv[MAX_N];

int main(){
    cin >> N >> M;
    for(int i=0;i<M;i++){
        cin >> a[i] >> b[i];
    }
    for(int i =0;i<M;i++){
        itv[i].first = b[i];
        itv[i].second = a[i];
    }
    sort(itv,itv +M);

    int ans =0 ,t=0;
    for(int i =0;i<M;i++){
        if(t<= itv[i].second){
            ans++;
            t =itv[i].first;
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

using namespace std;

int main(){
	int h,w,n; scanf("%d%d%d",&h,&w,&n);
	printf("%d\n",min((n+h-1)/h,(n+w-1)/w));
	return 0;
}


Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const S = arg[1].split("");
    
    let answer = 0;
    
    for(let i=0; i<N-1; i++) {
        const front = S.slice(0, ~~i + 1); 
        const back  = S.slice(~~i + 1, N);
        
        let map = {}
        
        for(let j in front) {
            if(!map[front[j]]) {
                map[front[j]] = 1
            }
        }
        
        for(let j in back) {
            if(map[back[j]]) {
                map[back[j]]++;
            }
        }
        
        let temp = 0;

        for(let key in map) {
            if(map[key] > 1) {
                temp++;
            }
        }
        
        answer = Math.max(answer, temp);
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
#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<complex>
#include<bitset>
#include<stack>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
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 long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
vector<string> v;
map<pair<int,string>,bool> used;
int n; string s;
void dfs(int k) {
	if (used[{k, s}])return;
	used[{k, s}] = true;
	if (k < 0) {
		v.push_back(s); return;
	}
	vector<int> u;
	bool exinex = false;
	rep(i, n) {
		if (s[i] == 'a' + k) {
			u.push_back(i);
		}
		if (s[i] == 'a' + k + 1) {
			exinex = true;
			break;
		}
	}
	int len = u.size();
	if (len == 0 && exinex)return;
	if (!exinex)dfs(k - 1);
	rep(j, len) {
		s[u[j]] = 'a' + k+1; dfs(k - 1); s[u[j]] = 'a' + k;
	}
	return;
}
int main(){
	while (cin >> s) {
		if (s == "#")break;
		n = s.length();
		v.clear(); used.clear();
		dfs(24);
		sort(v.begin(), v.end());
		int len = v.size();
		cout << len << endl;
		if (len <= 10) {
			rep(j, len) {
				cout << v[j] << endl;
			}
		}
		else {
			rep(j, 5) {
				cout << v[j] << endl;
			}
			Rep(j, len - 5, len) {
				cout << v[j] << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 12420
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

int main() {
	int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
	string S; cin >> S;
	bool z = 1;
	if (C < D) {
		for (int i = A; i < D; i++) {
			if (S[i] == '#'&&S[i - 1] == '#') {
				z = 0; break;
			}
		}
		if (z == 1)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else {
		bool d = 0;
		for (int i = A; i < C; i++) {
			if (S[i] == '#'&&S[i - 1] == '#') {
				z = 0; break;
			}
		}
		for (int i = B - 1; i < D; i++) {
			if (S[i - 1] == S[i] && S[i] == S[i + 1] && S[i] == '.')d = 1;
		}
		if (z == 1 && d == 1)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	
}





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

using namespace std; 

int n; 
int a[4020], c[4020]; 
int pw[2020], pb[2020]; 
int cw[2020][2020], cb[2020][2020], dp[2020][2020]; 

int main() {
    scanf("%d", &n); 
    for (int i = 1; i <= 2 * n; i++) {
        char s[2];
        scanf("%s %d", s, &a[i]); 
        if (s[0] == 'W') c[i] = 0, pw[a[i]] = i; 
        else c[i] = 1, pb[a[i]] = i; 
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j < i; j++) {
            if (pw[i] < pw[j]) {
                cw[i][0]++; 
            }
        }
        for (int j = 1; j <= n; j++) {
            cw[i][j] = cw[i][j - 1]; 
            if (pw[i] < pb[j]) {
                cw[i][j]++; 
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j < i; j++) {
            if (pb[i] < pb[j]) {
                cb[0][i]++;
            }
        }
        for (int j = 1; j <= n; j++) {
            cb[j][i] = cb[j - 1][i]; 
            if (pb[i] < pw[j]) {
                cb[j][i]++; 
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        dp[i][0] = dp[i - 1][0] + cw[i][0]; 
        dp[0][i] = dp[0][i - 1] + cb[0][i]; 
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            dp[i][j] = min(dp[i - 1][j] + cw[i][j], dp[i][j - 1] + cb[i][j]); 
        }
    }
    printf("%d\n", dp[n][n]); 
    return 0; 
}
//

Measured memory_bytes: 48000
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;

signed main(){
	//cout << fixed << setprecision(10);
	map<int,int> mp;
	while(1){
		string s; cin>>s;
		if(s.empty())break;
		rep(i,0,s.size()){
          if('A'<=s[i] && s[i]<='Z'){
            char c=s[i];
            c+=32;
            s[i]=c;
          }
          mp[s[i]-'a']++;
        }
	}
	rep(i,0,26){
		cout<<(char)('a'+i)<<" : "<<mp[i]<<endl;
	}


	return 0;
}


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

int main(){
    string devide[4] = {"dream","dreamer","erase","eraser"};

    string S;
    cin >> S;
    reverse(S.begin(),S.end());
    for(int i = 0;i < 4;i++) reverse(devide[i].begin(),devide[i].end());

    bool can = true;
    for(int i = 0;i < S.size();){
        bool can2 = false;
        for(int j = 0;j < 4;j++){
            string d = devide[j];
            if(S.substr(i,d.size()) == d){
                can2 = true;
                i += d.size();
            }
        }
        if(!can2){
                can = false;
                break;
            } 
    }

    if(can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main() {
    string s; cin >> s;
    int l = MAX;
    int r = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'A') chmin(l, i);
        if (s[i] == 'Z') chmax(r, i);
    }

    cout << r - l + 1 << endl;
    return 0;
}

Measured memory_bytes: 3704
from itertools import product
N = int(input())
A = []
XY = []
for i in range(N):    
    a = int(input())
    A.append(a)
    xy = [list(map(int,input().split())) for _ in range(a)]
    XY.append(xy)
flag = 0
ans = 0
for i in product((0,1), repeat=N):
    for idx, j in enumerate(i):
        if j:
            for x, y in XY[idx]:
                if i[x-1] != y:
                    flag = 1
                if flag:
                    break
        if flag:
            break
    if flag == 0:
        ans = max(ans, sum(i))
    if flag:
        flag = 0
print(ans)

Measured memory_bytes: 73700
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, t, b = 0, c = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &t);
		c += t*t;
		b += t;
	}
	int x1 = int(b/n), x2 = x1+1;
	auto solve = [n, b, c](int x){return n*x*x-2*x*b+c;};
	printf("%d\n", min(solve(x1), solve(x2)));
	return 0;
}

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

int* s;

int main(void)
{
	int N;
	cin >> N;

	s = new int[N];
	int sum = 0;
	for (int i = 0; i < N; ++i) {
		cin >> s[i];
		sum += s[i];
	}

	sort(s, s + N);

	int i = 0;
	while (sum % 10 == 0) {
		if (i == N)	break;
		if (s[i] % 10 == 0) {
			++i;
			continue;
		}
		sum -= s[i];
		++i;
	}

	if (sum % 10 == 0)	sum = 0;

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
use std::collections::HashSet;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn dfs(neighbors: &Vec<Vec<(usize, usize)>>, u: usize, d: usize, height: &mut Vec<usize>, visited: &mut HashSet<usize>) {
    if visited.contains(&u) {
        return;
    }
    visited.insert(u);
    height[u] = d;
    for &(v, w) in neighbors[u].iter() {
        dfs(neighbors, v, d + w, height, visited);
    }
}

fn main() {
    input! {
        n: usize,
        uvw: [(usize, usize, usize); n - 1],
    }

    let mut neighbors = vec![vec![]; n];
    for (u, v, w) in uvw {
        let u = u - 1;
        let v = v - 1;
        neighbors[u].push((v, w));
        neighbors[v].push((u, w));
    }

    let mut visited = HashSet::new();
    let mut height = vec![0; n];
    dfs(&neighbors, 0, 0, &mut height, &mut visited);

    for h in height {
        println!("{}", if h % 2 == 0 { 0 } else { 1 });
    }
}


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

int main(){
    long long N,A,B,X;
    cin>>N>>A>>B;
    if(A>B){
        X=A;
        A=B;
        B=X;
    }
    if((B-A)%2==0){
        cout<<(B-A)/2<<endl;
        //cout<<"a";
    }
    else{
        if(A-1<N-B){
            cout<<(A+B-1)/2<<endl;
            //cout<<"b";
        }
        else{
            cout<<(2*N-A-B+1)/2<<endl;
            //cout<<"c";
        }
    }
}


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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int n;cin>>n && n;){
		vi hs(n),ws(n);
		rep(i,n) cin>>hs[i]>>ws[i];
		vs grid(4);
		rep(i,4) cin>>grid[i];
		
		queue<pii> q;
		q.emplace(0,0);
		vi vis(1<<16);
		while(q.size()){
			int bit,turn; tie(bit,turn)=q.front(); q.pop();
			if(bit==(1<<16)-1){
				cout<<turn<<endl;
				break;
			}
			if(vis[bit]) continue;
			vis[bit]=1;
			
			rep(k,n){
				repi(i0,-hs[k]+1,4) repi(j0,-ws[k]+1,4){
					bool ok=true;
					char color='?';
					int mask=0;
					rep(i,hs[k]) rep(j,ws[k]){
						if(i0+i<0 || 4<=i0+i || j0+j<0 || 4<=j0+j) continue;
						mask|=1<<(i0+i)*4+(j0+j);
						if(bit>>(i0+i)*4+(j0+j)&1) continue;
						if(color=='?') color=grid[i0+i][j0+j];
						if(grid[i0+i][j0+j]!=color) ok=false;
					}
					if(ok && !vis[bit|mask]) q.emplace(bit|mask,turn+1);
				}
			}
		}
	}
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

const long long INF = 1e18;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;

    __int128 ret = 1;
    bool ok = true, zero = false;
    for (int i=0; i<n; i++) {
        long long a;
        cin >> a;
        ret *= a;
        if (a == 0)
            zero = true;
        if (ret > INF)
            ok = false;
    }

    cout << (zero ? 0 : ok ? (long long) ret : -1) << "\n";

    return 0;
}


Measured memory_bytes: 3604
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int count = 0;
        if(s.length() % 2 == 0){
        	String s1 = s.substring(0, s.length() / 2);
            String s0 = s.substring(s.length() / 2);
            StringBuffer str = new StringBuffer(s0);
            String s2 = str.reverse().toString();
            for(int i = 0; i < s1.length(); i++){
            	if(s1.charAt(i) != s2.charAt(i)){
                	count++;
                }
            }
        }else{
        	String s1 = s.substring(0, s.length() / 2);
            String s0 = s.substring((s.length() / 2) + 1);
            StringBuffer str = new StringBuffer(s0);
            String s2 = str.reverse().toString();
            for(int i = 0; i < s1.length(); i++){
            	if(s1.charAt(i) != s2.charAt(i)){
                	count++;
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 35672
#include <bits/stdc++.h>
using namespace std;
#define pb push_back

int main() {
	int n;
	cin>>n;
	vector<int>v;
	for(int i=0; i<(1<<n); i++){
		int x;
		cin>>x;
		v.pb(x);
	}
	sort(v.begin(), v.end());
	int fir=v.back();
	vector<int>ne;
	ne.pb(fir);
	v.pop_back();
	multiset<int>s;
	for(auto u:v){
		s.insert(u);
	}
	
	while(1){
		if(s.empty()){
			cout<<"Yes";
			return 0;
		}
		sort(ne.begin(), ne.end());
		reverse(ne.begin(), ne.end());
		vector<int>ne2;
		for(auto u:ne){
			auto it=s.lower_bound(u);
			if(it==s.begin()){
				cout<<"No";
				return 0;
			}
			it--;
			ne2.pb((*it));
			s.erase(s.find((*it)));
		}
		for(auto u:ne2){
			ne.pb(u);
		}
	}
	
	return 0;
}

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

using namespace std;
#define int long long

const int INF = 200000000007;


  
signed main(){
    int n;
    cin>>n;
    pair<string,pair<int,int>> s[n];
    int p;
    string s0;
    for(int i=0;i<n;i++){
        cin >>s0  >>p;
        s[i]=make_pair(s0,make_pair(100-p,i+1));
      
    }
    sort(s,s+n);
    for(int i=0;i<n;i++)cout<<(s[i].second).second<<endl;

   
    

    
    return 0;
}

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

constexpr int MOD = 1e9 + 7;

int main() {
  ios::sync_with_stdio(false);
  ll N, K;
  cin >> N >> K;
  vector<int> V(N);
  for (int& i : V) {
    cin >> i;
  }
  ll res = 0;
  for (int i = 0; i < N; i++) {
    ll a = 0, b = 0;
    for (int j = 0; j < N; j++) {
      if (V[j] > V[i]) {
        a++;
        if (j < i) {
          b++;
        }
      }
    }
    res += K * b;
    res %= MOD;
    res += K * (K - 1) / 2 % MOD * a;
    res %= MOD;
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }


int main() {
	int n;
	vector<int> v;

	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		v.push_back(a);
	}
	int c = 0;

	for (int i = 1; i < n - 1; i++) {
		int a = v[i-1];
		int b = v[i+1];
		if (a < b) {
			a ^= b;
			b ^= a;
			a ^= b;
		}
		if (a > v[i] && v[i] > b) c++;
	}
	cout << c << endl;
}


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

int main() {

    int n;
    cin >> n;

    vector<float> v(n);

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

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

    float tmp_num1 = 0;
    float tmp_num2 = 0;
    for ( int i = 0; i < n - 1; i++ ) {
        tmp_num1 = v[i];
        tmp_num2 = v[i+1];
        v[i+1] = ( v[i] + v[i+1] ) / 2;
//        cout << tmp_num1 << " " << tmp_num2 << " " << v[i+1] << endl;
    }

    cout << v[n-1] << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    String s = sc.next();
    String t = sc.next();
    StringBuilder ans = new StringBuilder();
    for (int i = 0; i < n; i++) {
      ans.append(s.charAt(i));
      ans.append(t.charAt(i));
    }
    pw.println(ans.toString());
  }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int a[N],b[N];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n+1;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)scanf("%d",&b[i]);
	long long ans=0;
	for(int i=1;i<=n+1;i++)
	{
		if(b[i-1])
		{
			ans+=min(a[i],b[i-1]);
			a[i]=max(0,a[i]-b[i-1]);
		}
		ans+=min(a[i],b[i]);
		b[i]=max(0,b[i]-a[i]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
typedef long long ll;
 
vector<pair<int, ll> > path[100005];
int par[100005];
int dep[100005];
int siz[100005];
ll cst[100005];
int hev[100005];
void dfs(int a){
	siz[a]=1;
	for(int i=0; i<path[a].size(); i++){
		int d=path[a][i].first;
		if(d==par[a]) continue;
		par[d]=a;
		dep[d]=dep[a]+1;
		cst[d]=path[a][i].second;
		dfs(d);
		siz[a]+=siz[d];
		if(!hev[a] || siz[hev[a]]<siz[d])
			hev[a]=d;
	}
}
 
ll k;
ll add[100005];
ll edgecost(int a){
	ll ret=add[a]+add[par[a]]+cst[a];
	return ret%k ? ret : 0;
}
 
int pos[100005];
int hl_par[100005];
 
ll bit[100005];
ll sum(int i){
	ll ret=0;
	while(i){
		ret+=bit[i];
		i-=i&-i;
	}
	return ret;
}
void set(int i, ll x){
	x-=sum(i+1)-sum(i);
	i++;
	while(i<100005){
		bit[i]+=x;
		i+=i&-i;
	}
}
 
ll cost(int a, int b){
	int p=hl_par[a], q=hl_par[b];
	if(p==q) return abs(sum(pos[a])-sum(pos[b]));
	if(dep[p]<dep[q]){
		swap(p, q);
		swap(a, b);
	}
	return sum(pos[a]) - sum(pos[p])
		+ edgecost(p) + cost(par[p], b);
}
 
int main(){
	int n;
	cin >> n >> k;
	for(int i=0; i<n-1; i++){
		int a, b;
		ll c;
		cin >> a >> b >> c;
		path[a].push_back(make_pair(b, c));
		path[b].push_back(make_pair(a, c));
	}
	for(int i=0; i<n; i++) hev[i]=0;
	par[0]=dep[0]=cst[0]=0;
	dfs(0);
 
	for(int i=0; i<n; i++) add[i]=0;
 
	int cnt=0;
	for(int i=0; i<n; i++){
		if(i && hev[par[i]]==i) continue;
		int j=i;
		do{
			pos[j]=cnt++;
			hl_par[j]=i;
		}while(j=hev[j]);
	}

	for(int i=0; i<100005; i++) bit[i]=0;
	for(int i=0; i<n; i++)
		set(pos[i], edgecost(hev[i]));
	 
	int q;
	cin >> q;
	for(int i=0; i<q; i++){
		string s;
		ll a, b;
		cin >> s >> a >> b;
		if(s[0]=='a'){
			add[a]+=b;
			set(pos[a], edgecost(hev[a]));
			if(a) set(pos[a]-1, edgecost(a));
		}else{
			cout << cost(a, b) << endl;
		}
	}
}

Measured memory_bytes: 21132
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

typedef struct Edge{
    ll to, cost;
} Edge;

vector<vector<Edge>> g;
vector<int> ans;
void dfs(int x,int col) {
    if (ans[x] != -1) return;
    ans[x] = col;
    for (auto &&e:g[x]) {
        int y = col;
        if (e.cost%2==1) {
            if (y==1) y = 0;
            else y = 1;
        }
        dfs(e.to, y);
    }
    return;
}

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    g.resize(n);
    ans.resize(n, -1);
    vector<int> cnt(n);
    REP(i,n-1) {
        int u, v, w;
        cin >> u >> v >> w;
        --u, --v;
        cnt[u]++; cnt[v]++;
        g[u].push_back({v, w});
        g[v].push_back({u, w});
    }
    int st = 0;
    REP(i,n) if (cnt[i] == 1) st = i;
    dfs(st, 0);
    for (auto&& e: ans) cout << e << endl;
    return 0;
}

Measured memory_bytes: 10624
#include<iostream>
using namespace std;
int main(){
 int a,b,c,d;
 cin >> a >> b >> c >> d;
 if(a+b > c+d){
  cout << "Left" << endl;
 }
 else if(a+b < c+d){
  cout << "Right" << endl;
 }
 else{
  cout << "Balanced" << endl;
 }
}

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

int main(){
    l a,e,y,x,n,N;cin >> N;n=0;e=0;
    map<l,l> w;
    for(l i=0;i<N;i++){cin>>a;w[a]=i;}
    
    multiset<l> S;
    vector<l> d={-1,-1,N,N};
    for(l i=0;i<4;i++)S.insert(d[i]);

    for(l i=N;i>=1;i--){
        l k=w[i];
        S.insert(k);
        auto t=S.lower_bound(k),p=t,q=t,r=t,s=t;
        p--;p--;q--;r++;s++;s++;

        n+=(*q-*p)*(*r-k)+(k-*q)*(*s-*r);
        e+=n;
    }

    cout<<e<<endl;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;

int main(int argc, char *argv[]) {
    string result = "Yes";
    ll N;
    cin >> N;
    vector<pair<ll, ll>> BA;
    
    rep(i, N){
        ll A, B;
        cin >> A >> B;
        BA.push_back(make_pair(B, A));
    }
    sort(ALL(BA));
    
    ll now = 0;
    rep(i, N){
        if(BA[i].second + now <= BA[i].first){
            now += BA[i].second;
        }else{
            result = "No";
            break;
        }
    }
    
    cout << result << endl;
    return 0;
}



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

using namespace std;

using ll = long long;

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

    int n;
    cin >> n;

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

    int num_house = 0;
    for (int i = 0; i < n; ++i) {
        bool can_see = true;
        for (int j = 0; j < i; ++j)
            if (h[j] > h[i]) {
                can_see = false;
                break;
            }
        if (can_see) ++num_house;
    }

    cout << num_house << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    A=list(map(int,input().split()))
    minA=INF
    c_m=0
    sumA=0
    for i in A:
        if i<0:
            c_m+=1
        minA=min(minA,abs(i))
        sumA+=abs(i)
    if c_m%2==1:
        print(sumA-2*minA)
    else:
        print(sumA)
        
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 64752
n = int(input())

def prime_factor(n):
	factor = []
	for i in range(2, int(n ** 0.5) + 1):
		while (n % i == 0):
			factor.append(i)
			n //= i
	if n != 1:
		factor.append(n)
	return factor

from collections import Counter

f = prime_factor(n)
c = Counter(f)
res = 0
for k, v in c.items():
    num = c[k] # 指数
    i = 1
    while num >= i:
        num -= i
        res += 1
        i += 1

print(res)

Measured memory_bytes: 66372
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int n,i,j,d[55],ans=0;
  cin >> n;
  for (i=0;i<n;i++) cin >> d[i];
  for (i=0;i<n-1;i++) for (j=i+1;j<n;j++){
    ans+=d[i]*d[j];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
using namespace std;

int main() {
  // input
    int n;cin >> n;
    long k;cin >> k;
    vector<int> a(n + 1);
    vector<int> b(n + 1);
    for(int i = 1;i < n + 1; i++) cin >> a[i] >> b[i];

  // compute 
    int ans = 0;
    vector<long> c(100100,0);

    for(int i = 1;i < n + 1; i++) {
        c[a[i]] += b[i];
    }

    for(int i = 1;i < 100100 ; i++) {
        if(c[i] < k){
            k = k - c[i];
        }else{
            cout << i << endl;
            return 0;
        }
    } 

  // output  

}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    ll h,w; cin >> h >> w;

    ll ans = 0;
    if(w == 1 || h == 1) {
        cout << 1 << '\n';
        return 0;
    }
    rep(i,h) {
        if(i%2==0) ans += (w+1)/2;
        else ans += w/2;
    }
    cout << ans << '\n';


    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
      int h = int.Parse(Console.ReadLine());
      int w = int.Parse(Console.ReadLine());
      int n = int.Parse(Console.ReadLine());
      
      float M = Math.Max(h,w);
      
      Console.WriteLine(Math.Ceiling(n/M));
      
    }
}


Measured memory_bytes: 27452
N = int(input())
sqrt = 1
for i in range(1,N+1):
    if((i**2)<=N and ((i+1)**2>N)):
        sqrt = i
        break

        
for i in range(sqrt):
    if(N%(sqrt-i)==0):
        a = sqrt-i
        break

b = int(N/a)
print(a-1+b-1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,n,ans;
    cin>>a;
    if(a%1000 == 0)
        ans = 0;
    else {
    b = a/1000;
    ans = (b+1)*1000 - a;
    }
    cout<<ans<<endl;
}



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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

ll kai(ll x) {
   ll ret =1;
   while (x > 0) {
      ret *= x;
      x--;
   }
   return ret;
}

int main() {
   ll n;
   cin >> n;
   string march = "MARCH";
   map<char, int> m;
   rep (i, n) {
      string s;
      cin >> s;
      char c = s[0];
      if (c=='M' || c=='A'||c=='R'||c=='C'||c=='H') {
         m[s[0]]++;
      }
   }
   ll a[5] = {0};
   int cnt = 0;
   for (auto x:m) {
      // debug2(x.first, x.second)
      a[cnt] = x.second;
      cnt++;
   }

   ll sum = 0;
   rep (i, 3) {
      repp (j, i+1, 4) {
         repp (k, j+1, 5) {
            sum += a[i] * a[j] * a[k];
         }
      }
   }
   cout << sum << endl;


   return 0;
}

Measured memory_bytes: 384