akhauriyash/Code-Regression huggingface dataset:
/*****
There are
N  squares arranged in a row from left to right. The height of the
i-th square from the left is Hi
For each square, you will perform either of the following operations once:
Decrease the height of the square by1.  or
Do nothing.
Determine if it is possible to perform the operations so that the heights
of the squares are non-decreasing from left to right.

*/

/****
Logic:
We employ a greedy strategy.
 Process the elements in increasing order,
 and decrease the current element whenever we can do so
  without making it less than the last element.
   (The first element should thus always be decreased.)
   If at any point the current element must be less than
    the last element, no matter what we do, the answer is no.

The reason this strategy is optimal is that decreasing an
 number will make it easier (or at least as easy) to deal
 with the next element in the list, since any value the next
 element could have taken will still work when the previous number is lower,
 and in fact decreasing the previous number expands the range of possible
 values for the next set. (For example, if we have an element 3, the next
element must be at least 3, but if we decrease
this to 2, all the same values 3 or higher still work, but 2 does as well.)


*/

#include<bits/stdc++.h>

using namespace std;

#define LL long long
int main()
{
    LL n;
    cin>>n;
    LL *arr= new LL[n];
    for(LL i=0; i<n; i++) cin>>arr[i];
    arr[0]--;
    bool flag= true;
    for(LL i=1; i<n; i++){
        if(arr[i]<arr[i-1]){
            flag= false;
            break;
        }
        ///if arr[i]== arr[i-1] do nothing (non-decreasing seqn)
        else if(arr[i]>arr[i-1]){
            arr[i]--;
        }

    }
    if(flag) cout<<"Yes\n";
    else cout<<"No\n";

}


Measured memory_bytes: 1024
#include<iostream>
#include<stack>
using namespace std;
int main(void){
	int num;
	stack<int> st;

	while(cin>>num){
		st.push(num);
		if(num==0){
			st.pop();//0ツづーツ渉慊つュ
			cout<<st.top()<<endl;
			st.pop();
		}
	}
	return 0;
}

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

using namespace std;

int main() {
    int a = 0, b = 0, c = 0, x = 0, kei = 0, cnt = 0;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> x;

    for (int i = 0; i <= a; ++i) {
        for (int j = 0; j <= b; ++j) {
            for (int k = 0; k <= c; ++k) {
                kei = (500 * i) + (100 * j) + (50 * k);
                if (x == kei)cnt++;
            }
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()
#define MP make_pair
#define F first
#define S second

int main()
{
	ll n,a,c,ma = 0;
	cin >> n >> a;
	if (n == 1) ma = a;
	else {
		for (ll i = 1; i < INF; i++) {
			c = i;
			if (c != 1) {
				for (ll j = 1; j < n; j++) {
					c = c * i;
					if (c > a) {
						c = -1;
						break;
					}
				}
			}
			if (c > a) c = -1;
			if (c == -1) break;
			else if (a % c == 0) ma = i;
		}
	}
	cout << ma << endl;
}

  

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
#include <stack>
#include <queue>
#include <cassert>
#include <forward_list>
#include <chrono>
#include <deque>
#include <list>
#include <random>
#include <cstdio>
#include <sstream>

using namespace std;
typedef pair<int, int> Vert;
int n, m;
vector<Vert> v;
vector<int> perm;

void permutation()
{
	int ans = 0;

	for (int i = 1; i < n+1; i++)
	{
		perm.push_back(i);
	}

	do
	{
		if (perm[0] != 1) { continue; }

		bool frag = true;
	
		for (int i = 0; i < n - 1; i++)
		{
			auto iter1 = find(v.begin(), v.end(), Vert(perm[i], perm[i + 1]));
			if (iter1 == v.end())
			{
				frag = false;
				break;
			}
		}
		
		if (frag) { ans++; }

	} while (next_permutation(perm.begin(), perm.end()));
	
	cout << ans << endl;
}

int main()
{
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		int j, k;
		cin >> j >> k;
		v.push_back(Vert(j, k));
		v.push_back(Vert(k, j));
	}

	permutation();

	return 0;
}

Measured memory_bytes: 888
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(void)
{
    int n, k, point[3];
    char t[100001];
    int pre, num[100001];
    long ans = 0;
    scanf("%d%d%d%d%d%s", &n, &k, &point[1], &point[2], &point[0], t);

    rep(i, n)
    {
        switch (t[i])
        {
        case 'r':
            num[i] = 0;
            break;
        case 's':
            num[i] = 1;
            break;
        case 'p':
            num[i] = 2;
            break;
        }
    }

    rep(i, k)
    {
        pre = -1;
        for (int j = i; j < n; j += k)
        {
            if (pre == num[j])
            {
                pre = -1;
                continue;
            }
            ans += point[num[j]];
            pre = num[j];
        }    
    }

    printf("%ld\n", ans);
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pb push_back
#define S second
#define F first

using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
const int maxn = 1e6 + 10;
const int mod= 1e9+7;
int a[maxn];
int32_t main(){
   int n,m;
   cin >> n >> m;
   int ans = 1;
   for (int i = 1;i <=n;i++){
        int b;
        cin >> b;
        a[b]++;
        if (a[b] > 1) ans = 0;
   }
   for (int i = 1;i <= m;i++){
        int b;
        cin >> b;
        a[b]+= 2;
        if (a[b] > 3) ans = 0;
   }
   int col = 0,row= 0,cnt = 1;
   if (a[n *m ] != 3) ans = 0;
   else {
        row++,col++;
   }

   for (int i = n * m - 1;i;i--){
        if (a[i] == 3){
            row++,col++;
        }else if (a[i] == 2){
            ans *= (row);ans %= mod;
            col++;
        }else if (a[i] == 1){
            ans *= (col);ans%= mod;
            row++;
        }else {
            int can = row * col - cnt;
            if (can <= 0) ans = 0;
            else ans = (ans * can) % mod;
        }
        cnt++;
   }
   cout << ans << endl;

}


Measured memory_bytes: 256
import sys
from collections import Counter
n = int(input())
s_ls = []
ct = Counter()
for i in range(n):
    s = sys.stdin.readline().strip()
    ct.update([s])
_max = max(ct.values())
for k, v in sorted([(k, v) for k, v in ct.items() if v == _max], key=lambda x:x[0]):
    print(k)

Measured memory_bytes: 50244
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define eb emplace_back
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define P 137  //check the limits, man
#define N 20005
const ll INF = 1e18;
bool cmp(triple A,triple B)
{
    return (ts(A)-tf(B))<(ts(B)-tf(A));
}
ll dp[N],ar[N];
int main()
{
    int n,i,j,a,b,c;
    in(n);
    vector<triple> vp(n);
    rep(i,n)
    {
        in3(a,b,c);
        vp[i]=mt(a,b,c);
    }
    sort(all(vp),cmp);
    rep(i,n)
    {
        tie(a,b,c)=vp[i];
        rep(j,b+1)
            ar[j+a]=max(ar[j+a],dp[j]+c);
        rep(j,N)
            dp[j]=max(ar[j],dp[j]),ar[j]=dp[j];
    }
    ll ans=0;
    rep(j,N)
        ans=max(ans,ar[j]);
    llout(ans);
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#include <atcoder/all>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n, q; cin >> n >> q;

	atcoder::dsu uf(n);
	REP(q) {
		int m; cin >> m;
		if (m == 0) {
			int a, b; cin >> a >> b;
			uf.merge(a, b);
		}
		else {
			int a, b; cin >> a >> b;
			if (uf.same(a, b)) {
				cout << 1 << endl;
			}
			else {
				cout << 0 << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
namespace mp = boost::multiprecision;
// 任意長整数型
using bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;
// ついでに有理数型
using rat = boost::rational<bint>;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()


int main(){
  char x;
  cin >> x;
  cout << ('A' <= x && x <= 'Z' ? "A" : "a") << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>          // printf(), scanf()
#define MAX_N 25

typedef struct node_tbl
{
	int parent;
	int left;
	int right;
} node;

const int nil = -1;
node t[MAX_N];

void
preparse(int u) /* ??????????????? */
{
	if (u == nil)
		return;

	printf(" %d", u);
	preparse(t[u].left);
	preparse(t[u].right);
}

void
inparse(int u) /* ??????????????? */
{
	if (u == nil)
		return;

	inparse(t[u].left);
	printf(" %d", u);
	inparse(t[u].right);
}

void
postparse(int u) /* ??????????????? */
{
	if (u == nil)
		return;

	postparse(t[u].left);
	postparse(t[u].right);
	printf(" %d", u);
}

int
main(int argc, char** argv)
{
	int n;
	int root;
	int v;
	int l, r;
	int i;

	scanf("%d", &n);
	for (i = 0; i < n; ++i)
		t[i].parent = nil;

	for (i = 0; i < n; ++i)
	{
		scanf("%d %d %d", &v, &l, &r);
		t[v].left = l;
		t[v].right = r;
		if (l != nil)
			t[l].parent = v;

		if (r != nil)
			t[r].parent = v;
	}

	for (i = 0; i < n; ++i)
	{
		if (t[i].parent == nil)
		{
			root = i;
			break;
		}
	}

	printf("Preorder\n");
	preparse(root);
	printf("\n");

	printf("Inorder\n");
	inparse(root);
	printf("\n");

	printf("Postorder\n");
	postparse(root);
	printf("\n");

	return 0;
}

Measured memory_bytes: 616
n, m = map(int, input().split())
ok = [0] * (n + 2)
ans = 0
for _ in range(m):
    l, r = map(int, input().split())
    ok[l] += 1
    ok[r + 1] -= 1
for i in range(1, n + 2):
    ok[i] += ok[i - 1]
    if ok[i] == m:
        ans += 1
print(ans)

Measured memory_bytes: 12732
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;

fn main() {
    let (r,g):(f64,f64);
    input!(r);
    input!(g);
    p(2_f64*g-r);
}

Measured memory_bytes: 4352
//142 B -Roler Coaster 2019/09/28
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int n , k; cin >> n >> k;
    vector<int> h(n);
    rep(i ,n) cin >> h[i];
    int ans=0;
    rep(i , n){
        if (h[i]>=k) ++ans;
    }
    cout << ans << endl;
}   

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <algorithm>

char S[3005];
char T[3005];
int dp[3005][3005];

void recover(int i,int j){
  if(i==0||j==0) return;
  int opt[3]={dp[i-1][j-1]+((S[i]==T[j])?1:-1e9),dp[i-1][j],dp[i][j-1]};
  switch(std::max_element(opt,opt+3)-opt){
  case 0:recover(i-1,j-1);putchar(S[i]);return;
  case 1:recover(i-1,j);return;
  case 2:recover(i,j-1);return;
  }
}

int main(){
  scanf("%s %s",S+1,T+1);
  for(int i=1;S[i];i++){
    for(int j=1;T[j];j++){
      dp[i][j]=std::max(dp[i-1][j-1]+(S[i]==T[j]),
			std::max(dp[i-1][j],dp[i][j-1]));
    }
  }
  recover(strlen(S+1),strlen(T+1));
  printf("\n");
  return 0;
}


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

#define int long long
#define vc vector<char>
#define vi vector<int>
#define vs vector<string>
#define si set<int>
#define pii pair<int,int>
#define SORT(c) sort(c.begin(),c.end())
#define SORTC(c, cmp) sort(c.begin(),c.end(),cmp)
#define mapii map<int,int>
#define pb push_back
#define F first
#define S second
#define rep(i, j, k) for (int i=j;i<k;i++)
#define repb(i, j, k) for (int i=j;i>=k;i--)
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define ar array

using namespace std;

#define fast ios::sync_with_stdio(false); cin.tie(0)


const int mxN = 2e5;


void solve() {
    int n;
    cin >> n;
    int ac = 0, wa = 0, tle = 0, re = 0;
    rep(i, 0, n) {
        string s;
        cin >> s;
        if (s == "AC") {
            ac++;
        }
        else if (s == "WA") {
            wa++;
        }
        else if (s == "TLE") {
            tle++;
        }
        else {
            re++;
        }
    }
    cout << "AC x " << ac << '\n';
    cout << "WA x " << wa << '\n';
    cout << "TLE x " << tle << '\n';
    cout << "RE x " << re<< '\n';
}

int32_t main() {
    fast;

    int tt{1};
//    cin >> tt;
    while (tt--) {
        solve();
        cout << endl;
    }
    return 0;

}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>

using namespace std;
typedef long long ll;

ll N, A, B, C, D;
char S[200010] = {};
bool flag = true;
bool flag2 = false;

int main() {
	cin >> N >> A >> B >> C >> D;
	cin >> S;
	for (int i = A; i < C - 2; i++) {
		if (S[i] == '#' && S[i + 1] == '#')flag = false;
	}
	for (int i = B; i < D - 2; i++) {
		if (S[i] == '#' && S[i + 1] == '#')flag = false;
	}
	if (D < C && flag) {
		for (int i = B - 1; i <= D - 1; i++) {
			if (S[i] == '.' && S[i - 1] == '.' && S[i + 1] == '.')flag2 = true;
		}
		if (!flag2)flag = false;
	}
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <list>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <numeric>
#include <unordered_set>
#include <unordered_map>
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long

// pair<ll, ll> arr[9];
vector<pair<ll,ll>> arr;
 
int main() {
 
    ios::sync_with_stdio(false);
    cin.tie(0);



    int N; cin >> N;
    // long double sum = 0;
    for (int i = 0; i < N; i++) {
        long long x,y; cin >> x >> y;
        arr.emplace_back(x,y);
    }

    int cnt = 1; int t = N;
    while (t) {
        cnt *= t; t--;
    }

    long double sum = 0;
    for (int i = 0; i < cnt; i++) {
        for (int j = 0; j < arr.size() - 1; j++) {
            sum += sqrt((arr[j].first - arr[j+1].first) * (arr[j].first - arr[j+1].first) + (arr[j].second - arr[j+1].second) * (arr[j].second - arr[j+1].second));
        }
        next_permutation(arr.begin(), arr.end());
    }

    sum /= cnt;

    
    //     arr[i] = make_pair(x,y);
    //     for (int j = i-1; j >= 0; j--) {
    //         sum += sqrt((x - arr[j].first) * (x - arr[j].first) + (y - arr[j].second) * (y - arr[j].second)) * (N-1)*2;
    //         cout << sum << endl;
    //     }
    // }
    // while (N) {
    //     sum /= N;
    //     N--;
    // }

    printf("%.15Lf", sum);

    
}


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


int main(){
    int n,d,x;
    cin >> n >> d >> x;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin >> a.at(i);
    }
    int count =0;
    int count1 =0;
    for(int i=0;i<n;i++){
        count1 = (d-1) / a.at(i);
        count += count1;
    }
    cout << count + n + x << endl;
    return 0;
}

Measured memory_bytes: 3596
N, K, Q = map(int, input().split())
a = [int(input()) for i in range(Q)]
p = [K for j in range(N)]
for n in a:
    p[n-1] = p[n-1] - 1
if K > Q:
    for h in range(N):
        print('Yes')
else:
    for d in p:
        if d <= K-(Q-K+1):
            print('Yes')
        else:
            print('No')

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

int main() {
	int n;
	cin >> n;
	int m = 0;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		m += a % 2;
	}
	cout << (m % 2 ? "NO" : "YES") << endl;
	return 0;
}


Measured memory_bytes: 256
n, x = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

B = A[:]
ans = sum(A)

for i in range(1, n):
    B = [min(B[j], A[j-i]) for j in range(n)]
    ans = min(ans, sum(B) + i * x)

print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <assert.h>
#include <queue>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define fi first
#define sc second
#define mp make_pair
typedef pair<int,int> P;
typedef pair<int,P> Q;
typedef pair<int,Q> R;

bool dist[(1<<24)];
int n;
int x[30],y[30],r[30],c[30];
vector<int>col[4];
int up[30];
int main(){
	
	while(1){
		cin>>n;if(n==0)return 0;
		rep(i,4) col[i].clear();
		rep(i,n){
			cin>>x[i]>>y[i]>>r[i]>>c[i]; c[i]--;
			col[c[i]].pb(i);
		}
		rep(i,n){
			up[i] = 0;
			for(int j=0;j<i;j++){
				long long dist = 1LL*(x[i]-x[j])*(x[i]-x[j])+1LL*(y[i]-y[j])*(y[i]-y[j]);
				long long d2 = 1LL*(r[i]+r[j])*(r[i]+r[j]);
				if(dist < d2) up[i] |= (1<<j);
			}
		}
		rep(i,(1<<n)) dist[i] = 0;
		dist[0] = 1;
		rep(i,(1<<n)){
			if(dist[i] == false) continue;
			rep(j,4){
				rep(k,col[j].size()) for(int q=k+1;q<col[j].size();q++){
					int a = col[j][k], b = col[j][q];
					if(((i>>a)&1)) continue;
					if(((i>>b)&1)) continue;
					if(a > b) swap(a,b);
					if(((up[b]>>a)&1)) continue;
					if( (up[a]&i) == up[a] && (up[b]&i) == up[b] ){
						dist[i|(1<<a)|(1<<b)] = 1;
					}
				}
			}
		}
		int ans = 0;
		rep(i,(1<<n)) if(dist[i]) ans = max(ans,__builtin_popcount(i));
		cout << ans << endl;
	}
}
		
			



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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#ifdef MAROON_LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%"  SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

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

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

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

signed main(){
	int n=read(),x=read();
	vi a(n);
	REP(i,n)a[i]=read();
	sort(ALL(a));
	int ans=0;
	REP(i,n){
		if(i<n-1){
			if(a[i]<=x){
				x-=a[i];
				ans++;
			}
		}else{
			if(a[i]==x)
				ans++;
		}
	}
	print(ans);
}


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


int main()
{
  int n;
  cin >> n;
  int ans = 0;
  vector<int> a(n+1);
  vector<int> c(n+1);

  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; ++i) {
    int b;
    cin >> b;
    ans += b;
  }
  for (int i = 1; i < n; ++i) {
    cin >> c[i];
  }
  for (int i = 1; i < n; ++i) {
    if (a[i] + 1 == a[i+1]) {
      ans += c[a[i]];
    }
  }
  cout << ans;
  
  return 0;
}




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

using namespace std;

int main() {
    int n ; scanf("%d", &n);
    vector<int>v(n);
    int mx = -1 , mn = INT_MAX;
    for(int& i : v){
        scanf("%d", &i);
    }
    long long ans = 1e18;
    //cerr<<mx<<" "<<mn<<endl;
    for(int i = 1 ; i <= 100; ++i){
        long long temp = 0;
        for(int& j : v){
            temp += (i - j) * (i - j);
        }
        ans = min(ans , temp);
    }
  
    printf("%lld\n" , ans);
    
}

Measured memory_bytes: 256
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}
function lowerBound(ary,v,l,r){--l;for(var c;1<r-l;)ary[c=l+r>>1]<v?l=c:r=c;return r;}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var s = nextstr();
  var n = s.length;
  var map = new Map();
  var x = 0;
  for(var i = 0; i < n; i++){
    x ^= 1 << (s[i].charCodeAt()-97);
    if(map.has(x))map.get(x).push(i+1);
    else map.set(x,[i+1]);
  }
  var dp = xArray(1e9,n+1);
  dp[0] = 0, x = 0;
  var map2 = new Map();
  for(var i = 0; i < n; i++){
    if(map2.has(x)){
      if(map2.get(x) > dp[i])map2.set(x,dp[i]);
    }else map2.set(x,dp[i]);
    x ^= 1 << (s[i].charCodeAt()-97);
    solve(x,i+1);
    for(var j = 0; j < 26; j++){
      solve(x ^ (1 << j),i+1);
    }
  }
  return dp[n];

  function solve(bit,i){
    if(map2.has(bit)){
      if(map2.get(bit) + 1 < dp[i])
      dp[i] = map2.get(bit) + 1;
    }
  }
}

Measured memory_bytes: 81792
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説どおりに作成したソースコード（二次元累積和使用）
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), m = scanner.nextInt(), q = scanner.nextInt();
			int[][] p = new int[n + 1][n + 1];
			IntStream.range(0, n + 1).forEach(i -> Arrays.fill(p[i], 0));
			IntStream.range(0, m).forEach(i -> p[scanner.nextInt()][scanner.nextInt()]++);
			IntStream.rangeClosed(1, n).forEach(i -> IntStream.rangeClosed(1, n).forEach(j -> p[i][j] += p[i - 1][j]));
			IntStream.rangeClosed(1, n).forEach(i -> IntStream.rangeClosed(1, n).forEach(j -> p[i][j] += p[i][j - 1]));
			IntStream.range(0, q).forEach(i -> {
				int l = scanner.nextInt(), r = scanner.nextInt();
				System.out.println(p[r][r] + p[l - 1][l - 1] - p[r][l - 1] - p[l - 1][r]);
			});
		}
	}
}


Measured memory_bytes: 61856
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
int main()
{
  int n,k;
  cin >> n >> k;
  vector<ll> h(n);
  rep(i,n){
    cin >> h[i];
  }
  int z = max(0,n-k);
  ll res = 0;
  sort(h.begin(), h.end());
  rep(i,z){
    res += h[i];
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String s = br.readLine();
		String[] array = s.split(" ");

		char a = (array[0]).charAt(0);
		char b = (array[1]).charAt(0);
		char c = (array[2]).charAt(0);

		String x = String.valueOf(a) + String.valueOf(b) + String.valueOf(c);

		System.out.println(x.toUpperCase());

	}
}

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

int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  for(int i=0; i<n; i++){
    int x;
    cin >> x;
    vec.at(i)=x;
  }
  vector<int> count(100,0);
  for(int i=1; i<=100; i++){
    int tairyoku=0;
    for(int j=0; j<n; j++){
      int k=0;
      k=(vec.at(j)-i)*(vec.at(j)-i);
      tairyoku += k;
    }
    count.at(i-1)=tairyoku;
  }
  sort(count.begin(),count.end());
  cout << count.at(0) << endl;
}

Measured memory_bytes: 256
# F - Intervals on Tree

# Σ連結成分の個数＝Σ頂点の個数 − Σ辺の個数

N = int(input())
V = 0
E = 0

for _ in range(N-1):
    u, v = map(int, input().split())
    if v < u:
        u, v = v, u
    E += u * (N-v+1)

for i in range(1, N+1):
    V += i * (N+1-i)

print(V - E)

Measured memory_bytes: 9200
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
ll inf = 100000000;
ll w[205];
ll v[205];
ll x[20000005];
ll a[10005], b[10005];
ll dp[10005][10005];
typedef pair<ll, ll> P;

P p(ll x) {
	ll a = x % 10;
	ll b = 0;
	while (x) {
		
		b = x;
		x = x / 10;
	}
	return P(a, b);
}

int main(void) {
	int n;
	cin >> n;
	map<P, ll>mp;
	for (int i = 1; i <= n; i++) {
		 P a = p(i);
		 mp[a]++;
	}
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		P a = p(i);
		P q(a.second, a.first);
		ans += mp[q];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(s: chars, t: chars);
    for t in t {
        puts!("{}", t);
    }
    for s in s {
        puts!("{}", s);
    }
    puts!("\n");
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

def main():
	n = int(input())
	k = int(input())
	
	ans_list = []
	
	for i in range(2 ** n):
		a = "list('{:0" + str(n) + "b}'.format(i))"
		temp = 1
		lists = [int(x) for x in eval(a)]
		for j in lists:
			if j == 0:
				temp += k
			else:
				temp *= 2
		ans_list.append(temp)

	print(min(ans_list))

if __name__ == '__main__':
    main()

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

d = {}
for i in range(N):
    d[a[i]] = 0

for i in range(N):
    d[a[i]] += 1

cnt = 0
cntt = 0
for i in d.keys():
    if d[i] % 2 == 0:
        d[i] = 2
        cntt += 1
    else:
        d[i] = 1
        cnt += 1

if cntt % 2 != 0:
    cntt -= 1

print(cnt + cntt)


Measured memory_bytes: 61548
#include<stdio.h>
typedef struct
{
  char suit;
  int value;
}Card;

void bubble(Card A[], int N);
void selection(Card A[], int N);
void print(Card A[], int N);
int isStable(Card C1[],Card C2[], int N);

int main(){
  Card C1[100],C2[100];
  int N,i;

  scanf("%d",&N);
  for(i=0;i<N;i++) scanf(" %c %d",&C1[i].suit,&C1[i].value);
  for(i=0;i<N;i++) C2[i]=C1[i];
  
  bubble(C1,N);
  selection(C2,N);
  
  print(C1,N);
  printf("Stable\n");
  print(C2,N);
  if(isStable(C1,C2,N)==1){
    printf("Stable\n");
  }
  else{
    printf("Not stable\n");
  }
  return 0;
}

void bubble( Card A[], int N){
  int i,j;
  Card a;
  for(i=0;i<N;i++){
    for(j=N-1;j>=i+1;j--){
      if(A[j].value<A[j-1].value){
	a=A[j];
	A[j]=A[j-1];
	A[j-1]=a;
      }
    }
  }
}

void selection(Card A[], int N){
  int i,j,minj;
  Card a;
  for(i=0;i<N;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(A[j].value<A[minj].value) minj=j;
    }
    a=A[i];
    A[i]=A[minj];
    A[minj]=a;
  }
}

void print(Card A[], int N){
  int i;
  for(i=0;i<N;i++){
      if(i>0) printf(" ");
      printf("%c%d",A[i].suit,A[i].value);
    }
  printf("\n");
}

int isStable(Card C1[],Card C2[], int N){
  int i;
  for(i=0;i<N;i++){
    if(C1[i].suit!=C2[i].suit) return 0;
  }
  return 1;
}


Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
char a[101000];
int main()
{
    int i,j,k,m,n;
    cin>>a;
    int ansp=0,ansg=0;
    int cnt=0,ans=0;
    n=strlen(a);
    for(i=0; i<n; i++)
    {
        if(i==0)
        {
            ansg++;
            if(a[i]=='p')
                cnt--;
        }
        else
        {
            if(a[i]=='g')
            {
                ansg++;
            }
            else if(a[i]=='p')
            {
                if(ansp<ansg)
                {
                    ansp++;
                }
                else
                {
                    ansg++;
                    cnt--;
                }
            }
        }
    }
    cout<<(ansg-ansp)/2+cnt<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stdio.h>
#include <map>

using namespace std;
int main(void)
{
	int n,l;
	
	char s[105][105];
	char tmp[105];
	char ans[10100];
	
	cin >> n >> l;
	
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	
	for (int i = 1; i < n; i++) {
		for (int j = 1; j < n; j++) {
			if (strcmp(s[j-1], s[j]) > 0) {
				strcpy(tmp, s[j-1]);
				strcpy(s[j-1],s[j]);
				strcpy(s[j],tmp);
			}
		}
	}	
	
	for (int i = 0; i < n; i++) {
		strcat(ans, s[i]);
	}
	
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef vector<vector<int> > Graph;
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 double INF = 1e9;

//input
ll n;
vector<ll>a;
bool all_plus,all_minus;

void input(){
    cin >> n;
    a.resize(n);
    rep(i,n)cin>>a[i];
}

void sign_check(){
    all_plus=true;
    all_minus=true;
    rep(i,n){
        if(a[i]==0)continue;
        if(a[i]>0)all_minus=false;
        else all_plus=false;
    }
}

void solve_all_plus(){
    sort(a.begin(),a.end());
    ll x = a[0];
    vector<P>ans;
    for(int i=1;i<n-1;i++){
        ll y = a[i];
        ans.push_back({x,y});
        x -= y;
    }
    ans.push_back({a[n-1],x});
    x = a[n-1]-x;
    cout << x << endl;
    rep(i,ans.size()){
        cout << ans[i].first << " " << ans[i].second << endl;
    }
    return;
}

void slove_all_minus(){
    sort(a.rbegin(),a.rend());
    vector<P>ans;
    ll x = a[0];
    for(int i=1;i<n;i++){
        ll y = a[i];
        ans.push_back({x,y});
        x -= y;
    }
    cout << x << endl;
    rep(i,ans.size()){
        cout << ans[i].first << " " << ans[i].second << endl;
    }
    return;
}

void solve(){
    sort(a.begin(),a.end());
    vector<P>ans;
    ll x = a[0];
    for(int i=n-2;i>0;i--){
        if(a[i]<0)break;
        ll y = a[i];
        ans.push_back({x,y});
        x -= y;
    }
    ans.push_back({a[n-1],x});
    x = a[n-1]-x;
    for(int i=1;i<n;i++){
        if(a[i]>=0)break;
        ll y = a[i];
        ans.push_back({x,y});
        x -= y;
    }
    cout << x << endl;
    rep(i,ans.size()){
        cout << ans[i].first << " " << ans[i].second << endl;
    }
}


int main(){
    input();
    sign_check();
    if(all_plus)solve_all_plus();
    else if(all_minus)slove_all_minus();
    else solve();
    return 0;
}



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

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

  int N, a, b, counter = 0;
  cin >> N;

  vector<int> P(N), Q(N), S(N);
  iota(S.begin(), S.end(), 1);
  for (int i = 0; i < N; i++) cin >> P[i];
  for (int i = 0; i < N; i++) cin >> Q[i];
  
  do
  {
    if(S == P) a = counter;
    if(S == Q) b = counter;
    counter++;
  } while (next_permutation(S.begin(), S.end()));
  
  cout << abs(b-a) << endl;
  return 0;
}

Measured memory_bytes: 3604
import sys
input = sys.stdin.readline

h, w, m = map(int, input().split())
hw = [list(map(int, input().split())) for _ in range(m)]

ch = [[0, i] for i in range(h)]
cw = [[0, i] for i in range(w)]
ngh = {}
ngw = {}

for h, w in hw:
    ch[h-1][0] += 1
    cw[w-1][0] += 1

ch.sort(key=lambda x: x[0], reverse=True)
cw.sort(key=lambda x: x[0], reverse=True)
mch = ch[0][0]
mcw = cw[0][0]

for cnt, i in ch:
    if cnt == mch:
        ngh[i] = 1
    else:
        break

for cnt, i in cw:
    if cnt == mcw:
        ngw[i] = 1
    else:
        break

cnt = 0
for h, w in hw:
    if h-1 in ngh and w-1 in ngw:
        cnt += 1

lenh = len(list(ngh.keys()))
lenw = len(list(ngw.keys()))

if lenh * lenw == cnt:
    print(mch + mcw -1)
else:
    print(mch + mcw)





Measured memory_bytes: 165256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int N;

int main(){
	while(1){
		cin>>N;
		if(!N) break;
		int ans=0;
		vvc field(N,vc(N));
		vvi dp(N+1,vi(N+1));
		for(int i=0;i<N;i++) for(int j=0;j<N;j++) cin>>field[i][j];
		for(int i=1;i<=N;i++) for(int j=1;j<=N;j++){
			if(field[i-1][j-1]=='.') dp[i][j]=min(dp[i-1][j-1]+1,min(dp[i-1][j]+1,dp[i][j-1]+1));
			else dp[i][j]=0;
			ans=max(ans,dp[i][j]);
		}
		cout<<ans<<endl;
	}
}

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

int main(){
  string str;
  cin >> str;
  int k = str.size();
  if(str.at(k-1)=='s'){
    cout << str + "es" << endl;
  }
  else{
    cout << str + 's' << endl;
  }
}

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

using namespace std;


void solve() {
    int n; cin >> n;
    deque<int> a;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        if (i&1) a.push_back(x);
        else a.push_front(x);
    }
    if (!(n&1)) reverse(a.begin(), a.end());
    for (auto& x: a) {
        cout << x << ' ';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

int main() {
  std::cout << std::fixed << std::setprecision(10);

  ll a;
  scanf("%lld", &a);
  cout << (a * 2 * 3.1415926535) << endl;
}


Measured memory_bytes: 3852
n,m = map(int,input().split())
ab = []
for _ in range(m):
  ab.append(list(map(lambda x:int(x)-1, input().split())))
ab.reverse()
pre = [i for i in range(n)]
num = [1 for _ in range(n)]
ans = n * (n-1) // 2
out = []
for i in range(m):
  out.append(ans)
  x,y = ab[i]
  X = []
  while pre[x] != x:
    X.append(x)
    x = pre[x]
  Y = []
  while pre[y] != y:
    Y.append(y)
    y = pre[y]
  if x != y:
    ans -= num[x] * num[y]
    if num[x] >= num[y]:
      win = x
      pre[y] = x
      num[x] += num[y]
    else:
      win = y
      pre[x] = y
      num[y] += num[x]
    for xx in X:
      pre[xx] = win
    for yy in Y:
      pre[yy] = win
out.reverse()
for o in out:
  print(o)

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

#define N 100005
vector<pair<L, L> > path[N];
L par[N], dep[N], siz[N], hev[N];
L cst[N];
void dfs(L a){
    siz[a]=1;
    for(L i=0; i<path[a].size(); i++){
        L 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;
    }
}
  
L k;
L add[N];
L edgecost(L a){
    L ret=add[a]+add[par[a]]+cst[a];
    return ret%k ? ret : 0;
}
  
L pos[N];
L hl_par[N];
  
L bit[N];
L sum(L i){
    L ret=0;
    while(i){
        ret+=bit[i];
        i-=i&-i;
    }
    return ret;
}
void S(L i, L x){
    x-=sum(i+1)-sum(i);
    i++;
    while(i<N){
        bit[i]+=x;
        i+=i&-i;
    }
}
  
L cost(L a, L b){
    L 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);
}

main(){
    L n;
    cin >> n >> k;
    for(L i=0; i<n-1; i++){
        L a, b;
        L c;
        cin >> a >> b >> c;
        path[a].push_back(make_pair(b, c));
        path[b].push_back(make_pair(a, c));
    }
    for(L i=0; i<n; i++) hev[i]=0;
    par[0]=dep[0]=cst[0]=0;
    dfs(0);
  
    for(L i=0; i<n; i++) add[i]=0;
  
    L cnt=0;
    for(L i=0; i<n; i++){
        if(i && hev[par[i]]==i) continue;
        L j=i;
        do{
            pos[j]=cnt++;
            hl_par[j]=i;
        }while(j=hev[j]);
    }
 
    for(L i=0; i<N; i++) bit[i]=0;
    for(L i=0; i<n; i++)
        S(pos[i], edgecost(hev[i]));
      
    L q;
    cin >> q;
    for(L i=0; i<q; i++){
        string s;
        L a, b;
        cin >> s >> a >> b;
        if(s[0]=='a'){
            add[a]+=b;
            S(pos[a], edgecost(hev[a]));
            if(a) S(pos[a]-1, edgecost(a));
        }else{
            cout << cost(a, b) << endl;
        }
    }
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int _i=(first);_i<(last);++_i){cout<<#a<<"["<<_i<<"] = "<<(a)[_i]<<endl;}
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#define dprintf(...) printf(__VA_ARGS__)
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTI(a,i)
#define dprintf(...)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
//#define MOD 998244353

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

template <class T, class U>
std::ostream& operator<<(std::ostream &os, const std::pair<T, U> &p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}
 
template <class T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v) {
    os << "[";
	for (int i = 0; i < v.size(); ++i) {
        if (i) {
            if (i % 5 == 0) {
                os << ",\n ";
            } else {
                os << ", ";
            }
        }
		os << v[i];
	}
	os << "]";
	return os;
}

template <class T>
using vec2 = vector<vector<T>>;

template <class T>
using vec3 = vector<vector<vector<T>>>;

template <class T>
vec2<T> vec2_init(int n0, int n1, T x = 0) {
    return vec2<T>(n0, vector<T>(n1, x));
}

template <class T>
vec3<T> vec3_init(int n0, int n1, int n2, T x = 0) {
    return vec3<T>(n0, vec2_init(n1, n2, x));
}

/*
 *           U P
 *           - x
 *            ^
 *            |
 * LEFT -y <--+--> +y RIGHT
 *            |
 *            v
 *           + x
 *         D O W N
 */

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

enum {
    DOWN,
    RIGHT,
    UP,
    LEFT,
};

constexpr double inf = numeric_limits<double>::infinity();

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

    int x;
    cin >> x;
    cout << (x ? 0 : 1) << endl;

    return 0;
}


Measured memory_bytes: 3600