akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

ll a[225816];
bool used[225816];

int main(void){
	int k,n,i,j,ans=0;
	ll s;
	fill(used,used+225816,false);
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	sort(a,a+n);
	for(k=50; k>0; --k){
		s = (1ll<<k);
		i = 0;
		for(j=(n-1); j>=0; --j){
			if(used[j]){
				continue;
			}
			if(i>=j){
				break;
			}
			if(a[j]>=s){
				continue;
			}else if(a[j]*2<s){
				break;
			}
			while(a[i]+a[j]<s && i<j){
				++i;
			}
			while(used[i] && a[i]+a[j]==s && i<j){
				++i;
			}
			if(i<j && a[i]+a[j]==s && (!used[i])){
				++ans;
				used[i] = true;
				used[j] = true;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2048
x = int(input())

a = x//500 #amount of 500yen 2
b = x%500 #reminder after 500yen conversion 24
c = b//5 #amount of 5yen coin from b 4
d = (a*1000) + (c*5) #(a x 1000) + (b x 5)

print (d)

Measured memory_bytes: 2940
//author:pranta
//date: "2020-08-02"
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;
void solve()
{
    int x;
    cin>>x;
    if(x>=30) cout<<"Yes";
    else cout<<"No";
}
int main()
{
    fast;
    int t;
    solve();
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
#define what_is(x) cerr << #x << " is " << x << endl;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 3 * 1e5 + 5;
const ll mod = 998244353;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int main(){
    //freopen("in","r",stdin);
    //freopen("out","w",stdout);
    fin;    
    string s;
    cin >> s;
    if(s[1] == 'B')
        s[1] = 'R';
    else
        s[1] = 'B';
    cout << s << '\n';
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}   

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

using namespace std;

#define MOD ((long long) 1e9+7)

long long dp[1002][1002];
int vis[1002][1002];
pair<int,int> movs[] = {{0,1}, {1,0}};

int main() {
	int n,w;
	int x,y;
	cin >> n >> w;
	vector<string> gr(n);

	memset(dp, 0, sizeof dp);
	memset(vis, 0, sizeof vis);
	for(int i = 0; i < n; i++) cin >> gr[i];

	dp[0][0] = 1;
	queue<pair<int,int> > q;
	q.push({0, 0});

	while(!q.empty()) {
		pair<int,int> f = q.front(); q.pop();
		if((f.first - 1) >= 0)
			dp[f.first][f.second] +=  (dp[f.first - 1][f.second]);
		dp[f.first][f.second] %= MOD;
		if((f.second - 1) >= 0)
			dp[f.first][f.second] +=  (dp[f.first][f.second - 1]);
		dp[f.first][f.second] %= MOD;
		for(int i = 0; i < 2; i++) {
			x = (movs[i].first + f.first);
			y = (movs[i].second + f.second);
			if(x >= n) continue;
			if(y >= w) continue;
			if(gr[x][y] == '#') continue;
			if(vis[x][y]) continue;
			vis[x][y] = 1;
			q.push({x,y});
		}
	}

	cout << dp[n-1][w-1] << endl;
}


Measured memory_bytes: 13056
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n;
  cin >> n;
  vector<ll> a(3*n);
  REP(i, 3*n) cin >> a[i];
  priority_queue<ll, vector<ll>, greater<ll>> f;
  priority_queue<ll> b;
  vector<ll>fsum(n+1, 0), bsum(n+1, 0);
  REP(i, n){
    fsum[0] += a[i];
    f.push(a[i]);
    bsum[n] += a[2*n+i];
    b.push(a[2*n+i]);
  }
  REP(i, n){
    f.push(a[n+i]);
    fsum[i+1] = fsum[i] + a[n+i] - f.top();
    f.pop();
    b.push(a[2*n-1-i]);
    bsum[n-1-i] = bsum[n-i] + a[2*n-1-i] - b.top();
    b.pop();
  }
  ll ans = -(1ll<<60);
  REP(i, n+1){
    chmax(ans, fsum[i]-bsum[i]);
  }
  cout << ans << endl;
  

  return 0;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>

using namespace std;

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

int main() {
  ll N, M;
  scanf("%lld %lld", &N, &M);

  map<ll, ll> m;
  for (ll i = 0; i < N; i++) {
    ll k;
    scanf("%lld", &k);

    for (ll j = 0; j < k; j++) {
      ll f;
      scanf("%lld", &f);

      m[f] += 1;
    }
  }

  auto ite = m.begin();

  ll ans = 0;

  for (; ite != end(m); ite++) {
    if ((*ite).second == N) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
//static const long double pi = 3.1415926535897932;

using namespace std;
using ll = long long int;
using ull = unsigned long long;

char toSmall(char c) { // 大文字を小文字へ
	return (c + 0x20);
}

char toLarge(char c) { // 小文字を大文字へ
	return (c - 0x20);
}

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

ll combination(ll n, ll r) { // nCr の計算
	if (n < 0 || r < 0 || r > n) return -1;

	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> num(r);
	vector<ll> den(r);

	for (ll i = 0; i < r; i++) {
		num[i] = n - r + i + 1;
		den[i] = i + 1;
	}

	for (ll p = 2; p <= r; p++) {
		ll pivot = den[p - 1];
		if (pivot > 1) {
			ll offset = (n - r) % p;
			for (ll k = p - 1; k < r; k += p) {
				num[k - offset] /= pivot;
				den[k] /= pivot;
			}
		}
	}
	ll result = 1;
	for (ll k = 0; k < r; k++) {
		if (num[k] > 1) result *= num[k];
	}
	return result;
}

vector<string> split(const string& src, const char* delim = ",") { //カンマ区切り
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

bool check_int(string str)
{
	if (all_of(str.cbegin(), str.cend(), [](char ch) { return isdigit(ch);}))
	{
		return true;
	}
	return false;
}

struct rest {
	string s;
	int p;
	int num;

	/* -------------------------------------
	sort関数を使用したときのソートの定義をする。
	まずは文字列sでソートする。
	文字列sが同じだった場合、pでソートする。
	この条件を参考演算子で表現(ifでもOK)
	-------------------------------------*/
	bool operator<(const rest& right) const {
		return s == right.s ? p > right.p : s < right.s;
	}
};

int binary_search(int key, vector<ll> a) {
	int left = 0, right = (int)a.size() - 1; // 配列 a の左端と右端
	while (right >= left) {
		int mid = left + (right - left) / 2; // 区間の真ん中
		if (a[mid] == key) return mid;
		else if (a[mid] > key) right = mid - 1;
		else if (a[mid] < key) left = mid + 1;
	}
	return -1;
}

int main() {
	ll n;
	cin >> n;
	vector<ll> a(100000);
	ll sum = 0;
	for (ll i = 0; i <= a.size(); i++) {
		a[i] = 0;
	}
	for (ll i = 0; i < n; i++) {
		ll index = 0;
		cin >> index;
		a[index]++;
		sum += index;
	}
	ll q;
	cin >> q;
	for (ll i = 0; i < q; i++) {
		ll b, c;
		cin >> b >> c;
		sum += (c - b) * a[b];
		a[c] += a[b];
		a[b] = 0;
		cout << sum << endl;
	}
	return 0;
}

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

int main(){
    ll n,x,d,k,ans=0;
    cin>>x>>k>>d;
    x=abs(x);
    if(k <= x/d )cout<< x - k*d;

    else {
        k-=(x/d);
        x%=d;  

        if(k%2)cout<<abs(d-x);
        else cout<<x; 
    }
}

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

using namespace std;

int main(){
  int x , y;
  cin >> x >> y;
  for(int i=0;i<=x;i++){
    if(i*2+(x-i)*4==y){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;

typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 200005, K = 800;
int n, a[N], q, ind[N], dp[N], f[N];
pii query[N], p[N];
vi vec[N];

struct block {
	vector <pii> v, tmp_v;
	vi s, ord, tmp;
	int suf = N, val = -1;
	void add(int x) {
		for (int i = suf; i < (int)v.size(); i++) {
			v[i].F = val;
		}
		suf = N, val = -1;
		int l = p[x].F, r = p[x].S;
		v.pb({r, l});
		s.pb(dp[l - 1] - f[l - 1]);
		for (int i = (int)s.size() - 2; i >= 0; i--) {
			s[i] = min(s[i], s[i + 1]);
		}
	}
	int get(int x) {
		if (v.empty()) {
			return N;
		}
		int L = p[x].F, R = p[x].S;
		int pos = lower_bound(all(v), mp(L - 1, 0)) - v.begin();
		if (pos < suf) {
			if (pos == (int)v.size()) {
				return N;
			}
			suf = pos, val = R;
			return s[pos];
		}	else {
			if (val >= L - 1) {
				val = R;
				return s[suf];
			}	else {
				return N;
			}
		}
	}
	int naive_get(int x) {
		if (v.empty()) {
			return N;
		}
		int L = p[x].F, R = p[x].S, res = N;
		for (int i = 0; i < (int)v.size(); i++) {
			if (i >= suf) {
				v[i].F = val;
			}
			if (v[i].S <= L && v[i].F >= L - 1) {
				res = min(res, dp[v[i].S - 1] - f[v[i].S - 1]);
				v[i].F = R;
				tmp.pb(i);
			}	else {
				ord.pb(i);
			}
		}
		suf = N, val = -1;
		for (int i = 0; i < (int)ord.size(); i++) {
			tmp_v.pb(v[ord[i]]);
		}
		for (int i = 0; i < (int)tmp.size(); i++) {
			tmp_v.pb(v[tmp[i]]);
		}
		v = tmp_v;
		ord.clear();
		tmp.clear();
		tmp_v.clear();
		for (int i = (int)s.size() - 1; i >= 0; i--) {
			if (i == (int)s.size() - 1) {
				s[i] = dp[v[i].S - 1] - f[v[i].S - 1];
			}	else {
				s[i] = min(s[i + 1], dp[v[i].S - 1] - f[v[i].S - 1]);
			}
		}
		return res;
	}
};

block b[N / K];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n;
	int s = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		f[i] = f[i - 1] + (a[i] == 0) - (a[i] == 1);
		s += a[i];
	}
	cin >> q;
	for (int i = 1; i <= q; i++) {
		int l, r;
		cin >> l >> r;
		p[i] = {l, r};
		vec[r].pb(i);
		query[i - 1] = {l, i};
	}
	sort(query, query + q);
	for (int i = 0; i < q; i++) {
		ind[query[i].S] = i;
	}
	for (int i = 1; i <= n; i++) {
		int res = N;
		for (int j : vec[i]) {
			b[ind[j] / K].add(j);
			for (int k = 0; k < N / K; k++) {
				int last = min(q - 1, K * (k + 1) - 1);
				if (query[last].F <= p[j].F && last < q - 1) {
					res = min(res, b[k].get(j));
				}	else {
					res = min(res, b[k].naive_get(j));
					break;
				}
			}
		}
		dp[i] = min(dp[i - 1], res + f[i]);
	}
	cout << dp[n] + s;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
#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 namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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 << ' ';
        }
    }
}

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

    int N, A;
    cin >> N >> A;
    vector<int> v(N);
    for (auto &&i : v) {
        cin >> i;
    }
    vector<vector<vector<ll>>> dp(51,
                                   vector<vector<ll>>(51, vector<ll>(3000)));
    dp[0][0][0] = 1;
    REP(i, N) {
        REP(j, N) {
            REP(k, 2500) {
                if (dp[i][j][k]) {
                    dp[i + 1][j][k] += dp[i][j][k];
                    dp[i + 1][j + 1][k + v[i]] += dp[i][j][k];
                }
            }
        }
    }
    ll ans = 0;
    FOR(i, 1, N + 1) { ans += dp[N][i][i * A]; }
    print(ans);

    return 0;
}

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

int main() {
	int a,b,c,n=0;
	cin >> a >> b >> c;
	for (int x=a;x <= b; x++) {
		if (c%x == 0) {
			n += 1;
		}
	}
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
int main(){
int x1,x2,x3,x4,x5;
  cin>>x1>>x2>>x3>>x4>>x5;
  if(x1==0){
  cout<<"1"<<endl;
  }
  else if(x2==0){
  cout<<"2"<<endl;
  }
  else if (x3==0){
  cout<<"3"<<endl;
  }
  else if (x4==0){
  cout<<"4"<<endl;
  }
  else{
  cout<<"5"<<endl;
  }
  
}

Measured memory_bytes: 3540
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
using P = pair<long long, long long>;

const long long MOD = 1000000007;

int main() {
  long long N, K;
  cin >> N >> K;
  long long ans = 0;
  for(long long i = K; i <= N+1; i++) {
    long long b = i * (N - i + 1);
    b %= MOD;
    b += 1;
    b %= MOD;
    ans += b;
    ans %= MOD;
    // cout << ans << endl;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
import java.util.*;
import java.io.*;
public class Main {
	static ArrayList<Integer> arr[];
	static boolean visited[];
	static int ctr;
	static void dfs(int i) {
		for(int j: arr[i]) {
			if(!visited[j]) {
				visited[j]=true;
				ctr++;
				dfs(j);
			}
		}
	}
	public static void main(String args[]) {
		FastScanner in = new FastScanner();
		int n=in.nextInt();
		int m=in.nextInt();
		arr=new ArrayList[n+1];
		visited=new boolean[n+1];
		for(int i=0;i<=n;i++)
			arr[i]=new ArrayList<>();
		for(int i=0;i<m;i++) {
			int x=in.nextInt();
			int y=in.nextInt();
			arr[x].add(y);
			arr[y].add(x);
		}
		
		int ans=Integer.MIN_VALUE;
		for(int i=1;i<=n;i++) {
			if(!visited[i]) {
				ctr=1;
				visited[i]=true;
				dfs(i);
				ans=Math.max(ans, ctr);
			}
		}
		System.out.println(ans);
	}

	///////////////////////////
	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}
}


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

using namespace std;

using ll = long long;

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

  const int MAX_N = 200010;
  vector<vector<ll>> dp(MAX_N, vector<ll>(3, -1e15));
  vector<ll> a(MAX_N);
  int n;
  cin >> n;
  const int offset = 1;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = -1; i <= 1; i++) {
    int index = 2 * 1 + i;
    dp[1][i + offset] = a[index];
  }
  for (int i = 1; i < n; i++) {
    for (int j = -1; j <= 1; j++) {
      for (int k = -1; k <= 1; k++) {
        int cur = 2 * i + j, nxt = 2 * (i + 1) + k;
        if (nxt <= cur + 1) continue;
        if (n < nxt) continue;
        dp[i + 1][k + offset] =
            max(dp[i + 1][k + offset], dp[i][j + offset] + a[nxt]);
      }
    }
  }
  cout << max({dp[n / 2][0], dp[n / 2][1], dp[n / 2][2]}) << endl;
}


Measured memory_bytes: 15868
#include <iostream>
#include <string>

int main()
{
    std::string in;
    std::cin >> in;

    int maxRainCount = 0;
    int rainCount = 0;
    for (const auto& val : in)
    {
        if (val == 'R')
        {
            ++rainCount;
            if (rainCount > maxRainCount)
            {
                maxRainCount = rainCount;
            }
        }
        else
        {
            rainCount = 0;
        }
    }
    std::cout << maxRainCount;

    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	VI A(N);
	REP(i, N)cin >> A[i];
	SORT(A);
	int ans = 0;

	REP(i, N) {
		FOR(j, i + 1, N) {
			int tmp = A[i] + A[j];
			//cout << tmp << " ";
			//cout << LB(A,tmp+1) << endl;
			//int cnt = A.end() - LB(A,tmp+1);
			int cnt = UB(A, tmp - 1) - A.begin();
			cnt -= j;
			cnt--;
			//cout << cnt << endl;
			ans += cnt;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <time.h>

#include <string>

long long pow_mod(long long x, long long n, long long mod_num) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) { res = (res * x) % mod_num; }
        x = (x * x) % mod_num;
        n = (n >> 1);
    }
    return res;
}

class Combi_Num {
    public:
    long long mod_num;
    std::vector<long long> fac, den;
    Combi_Num() {}
    Combi_Num(const int n, const int mod_num_in) {
        mod_num = mod_num_in;
        fac.resize(n+1, 0);
        den.resize(n+1, 0);
        fac[0] = 1;
        den[0] = 1;
        for (int i = 1; i <= n; i++) {
            fac[i] = (fac[i-1] * i) % mod_num;
            den[i] = (den[i-1] * pow_mod(i, mod_num - 2, mod_num)) % mod_num;
        }
    }

    long long calc(const int n, const int r) {
        return (fac[n] * ((den[r] * den[n-r]) % mod_num)) % mod_num;
    }
};

const long long MAX_N = 300050;
const long long MOD = 998244353;
long long N, A, B, K;

Combi_Num combi_num = Combi_Num(MAX_N, MOD);

int main(int argc, char **argv) {
    std::cin >> N >> A >> B >> K;

    long long ret = 0;
    for (long long rnum = 0; rnum <= N; rnum++) {
        if (A * rnum <= K && (K - A * rnum) % B == 0) {
            long long bnum = (K - A * rnum) / B;
            if (bnum <= N) {
                long long tmp = (combi_num.calc(N, rnum) * combi_num.calc(N, bnum)) % MOD;
                ret = (ret + tmp) % MOD;
            }
        }
    }
    
    std::cout << ret << std::endl;
    
    return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int a, b, c, x, y;
  int ans = 0;

  cin >> a >> b >> c >> x >> y;

  int maxn = max(x, y);

  int ansmin = a*x+b*y+c*x+c*y;
  int tmp = 0;

  for(int ic = 0; ic<= maxn; ic++){
    int xx = (x - ic)>0 ? (x - ic) : 0;
    int yy = (y - ic)>0 ? (y - ic) : 0;
    tmp += ic*2*c;
    tmp += xx*a;
    tmp += yy*b;
    ansmin = min(ansmin, tmp);
    tmp = 0;
  }
  ans = ansmin;

  cout << ans << endl;

}


Measured memory_bytes: 256
days=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']
import calendar
while True:
    try:
        try:
            (m,d)=map(int,raw_input().split())
        except: break
        if m==0 and d==0: break
        print days[calendar.weekday(2004,m,d)]
    except EOFError: break

Measured memory_bytes: 4928
#include "bits/stdc++.h"
#define int ll

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)


pii f(int h,int w){
    if(h%2==0 || w%2==0){
        return pii(h*w/2,h*w/2);
    }
    
    if(h<w)swap(h,w);
    
    return pii((int)(h/2)*w, (int)((h+1)/2)*w);
}

signed main(){
    int h,w;
    cin>>h>>w;
    
    int ans = INF;
    for(int i=1;i<h;i++){
        int orig = w*i;
        pii res = f(h-i,w);
        
        ans = min(ans, max<ll>({orig,res.first,res.second}) - min<ll>({orig,res.first,res.second}));
    }

    for(int i=1;i<w;i++){
        int orig = h*i;
        pii res = f(h,w-i);
        
        ans = min(ans, max<ll>({orig,res.first,res.second}) - min<ll>({orig,res.first,res.second}));
    }
    cout<<ans<<endl;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    rep(i, N) a[i]--;
    vector<int> s(N + 1);
    rep(i, N) {
        s[i + 1] = (s[i] + a[i]) % K;
    }

    map<int, int> mp;
    ll ans = 0;
    queue<int> q;
    rep(j, N + 1) {
        ans += mp[s[j]];
        mp[s[j]]++;
        q.push(s[j]);
        if (q.size() == K) {
            mp[q.front()]--;
            q.pop();
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 12032
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

//nCr mod m
#define MOD 1000000007
#define M 1000000
vector<ll> fact;
bool h=false;
void init(){
	h=true;
	fact=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
}
// a^b mod MOD
ll powmod(ll a,ll b,ll m=MOD){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
//nCr
ll nCr(ll n,ll r,ll m=MOD){
	if(!h)init();
	if(n<0||r<0||n<r)return 0;//??????
	ll out=fact[n]*powmod(fact[r]*fact[n-r]%m,m-2,m)%m;
	return out;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n,m;
	cin>>n>>m;
	rep(i,m)
		cout<<nCr(m-1,i)*nCr(n-m+1,i+1)%MOD<<endl;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i,a,b) for(int i=(a);i<=(b);++i)
#define FD(i,b,a) for(int i=(b);i>=(a);--i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;
constexpr int inv(LL x, int m) { return x > m ? inv(x % m, m) : x > 1 ? inv(m % x, m) * (m - m / x) % m : x; }
constexpr int mpow(LL a, LL k, int m) { int r(1); for (a %= m; k; k >>= 1, a = a * a % m) if (k & 1)r = r * a % m; return r; }

const int N = 5005;
int n, A[N];
vector<int> G[N];
vector<LL> F[N], H[N];
LL INF = 1LL << 60;

void dfs(int u, int p) {
    F[u].push_back(INF);
    F[u].push_back(A[u] < 0 ? INF : A[u]);
    H[u].push_back(INF);
    H[u].push_back(A[u]);
    for (auto v : G[u]) if (v != p) {
            dfs(v, u);
            vector<LL> TF(F[u].size() + F[v].size(), INF), TH(TF);
            for (auto i = 1u; i < F[u].size(); i++) {
                for (auto j = 1u; j < F[v].size(); j++) {
                    TF[i + j - 1] = min(TF[i + j - 1], F[u][i] + F[v][j]);
                    TH[i + j - 1] = min(TH[i + j - 1], H[u][i] + H[v][j]);
                    if (F[v][j] < INF || H[v][j] < 0) {
                        TF[i + j] = min(TF[i + j], F[u][i]);
                        TH[i + j] = min(TH[i + j], H[u][i]);
                    }
                }
            }
            F[u] = TF, H[u] = TH;
            F[v].clear(), H[v].clear();
        }
}
int main() {
    cin >> n;
    FI(i, 1, n) scanf("%d", A + i);
    for (int i = 2, u, v; i <= n; i++)
        scanf("%d%d", &u, &v), G[u].push_back(v), G[v].push_back(u);
    dfs(1, -1);
    FI(i, 1, n) {
        // printf("%d, %lld, %lld\n", i, F[1][i], H[1][i]);
        if (F[1][i] < INF || H[1][i] < 0) return !printf("%d\n", i - 1);
    }
}


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

#define FOR(i,a,n) for (int i = a; i < (int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = int_fast64_t;

constexpr ll INF = (1e18);
constexpr ll MOD = (1e9+7);

int main() {
  ll n; cin >> n;
  string s; cin >> s;
  vector<ll> cw(n+1, 0);
  vector<ll> ce(n+1, 0);
  FOR(i,1,n+1) {
    cw[i] += cw[i-1];
    ce[i] += ce[i-1];
    if (s[i-1] == 'W') cw[i]++;
    else ce[i]++;
  }
  ll ans = INF;
  REP(i,n) {
    ll sum = cw[i];
    sum += ce[n]-ce[i+1];
    chmin(ans, sum);
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;

int main() {
  long long d,n;
  cin >> d >> n;
  if(n==100){
    n=101;
  }
  int x = pow(100,d);
  cout << x*n << endl;
  
}

Measured memory_bytes: 3788
#include <iostream>
using namespace std;
using ll = long long;

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

ll lcm(ll a, ll b){
    ll g = gcd(a, b);
    return a / g * b;
}


int main(void){
    int N;
    cin >> N;
    
    ll ans = 1LL;
    
    for(int i = 0; i < N; ++i){
        ll T;
        cin >> T;
        ans = lcm(ans, T);
    }
    
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
I = int(input())
L = list(map(int, input().split()))

cnt = 0

for i in range(len(L) - 2):
  if L[i+1] > L[i] and L[i+1] < L[i+2]:
    cnt += 1
  elif L[i+1] < L[i] and L[i+1] > L[i+2]:
    cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	int n;cin >> n;
	vector<ll> v;
	REP(i,n)
	{
		ll tmp;cin >> tmp;v.PB(tmp);
	}
	
	ll ans = 1000000000000000;
	
	REP(q,2)
	{
		ll ret = 0;
		ll now = 0;
		REP(i,n)
		{
			now += v[i];
			if((i+q)%2 == 0)
			{
				if(now >= 0)
				{
					ret += now + 1;
					now = -1;
				}
			}
			else
			{
				if(now <= 0)
				{
					ret -= now - 1;
					now = 1;
				}
			}
		}
		
		ans = min(ret,ans);
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1400
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,x,t,s;
	scanf("%d %d %d",&n,&x,&t);
	s=n/x;
	if(n%x!=0) s=s+1;
	printf("%d\n",s*t);
	return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);
using namespace std;

/*void solve(){
  int n,q;cin>>n>>q;
  unordered_map<char,int>cnt;
  string s;cin>>s;
  int ma=0;
  for(int i=0;i<s.size();i++)
  {
    cnt[s[i]]++;
    if(cnt[s[i]]>ma)ma=cnt[s[i]];
  }
    int dp[ma+1]={0};
 for(auto u:cnt)
 {
     int x=u.second;
     for(int i=1;i<=x;i++)
        dp[i]++;
 }
 for(int i=1;i<ma;i++)dp[i]+=dp[i-1];
while(q--)
{
    int c;cin>>c;
    if(c>=ma)cout<<"0"<<endl;
    else cout<<n-dp[c]<<endl;
}
return;
}*/

int main(){
    fast
long long x;cin>>x;
long long  ans=0,n=100;
while(n<x)
{
    n+=n/100;
    ans++;
}
cout<<ans;
return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int a[26];

int main(){
	a['y'-'a']++;
	a['h'-'a']++;
	a['n'-'a']++;
	a['u'-'a']++;
	a['j'-'a']++;
	a['m'-'a']++;
	a['i'-'a']++;
	a['k'-'a']++;
	a['o'-'a']++;
	a['l'-'a']++;
	a['p'-'a']++;
	while(1){
		string s;
		cin>>s;
		if(s=="#") break;
		int res=0,n=s.size();
		for(int i=0;i<n-1;i++) if(a[s[i]-'a']!=a[s[i+1]-'a']) res++;
		cout<<res<<endl;
	}
}


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

int st[100], sh[100];
int n,m;
int main(){
  while( cin >> n >> m ){
    if( !n && !m ) break;
    int sumt=0, sumh=0;

    //cout << "\ntaro :";
    for( int i=0;i<n;i++ ){
      cin >> st[i];
      //cout<<" "<<st[i];
      sumt += st[i];
    }
    //cout<< endl;
    //cout << "hana :";
    for( int i=0;i<m;i++ ){
      cin >> sh[i];
      //cout << " "<<sh[i];
      sumh+= sh[i];
    }
    //cout << endl;

    int ai=-1, aj=-1;
    for( int i=0;i<n;i++ ){
      for( int j=0;j<m;j++ ){
	if( sumt-st[i]+sh[j]==sumh-sh[j]+st[i] ){
	  if( ai==-1 || st[ai]+sh[aj]>st[i]+sh[j] ){
	    ai=i; aj=j;
	  }
	}
      }
    }
    if( ai!=-1 )
      cout << st[ai]<<" "<<sh[aj] << endl;
    else
      cout << "-1"<< endl;

  }
  return 0;


}

Measured memory_bytes: 0
<?php
list($N) = ints();
$N++;
dfs(10, 0, false);

function dfs($depth, $current, $flag, $str = ""){
    global $N;
    if($depth == 0){
        $N--;
//        o($str);
        if($N == 0){
            echo $str;
            exit;
        }
        return;
    }
    if($flag == false){
        dfs($depth-1, 0, false, $str."");
        for($i = 1; $i <= 9; $i++){
            dfs($depth-1, $i, true, $str.$i);
        }
    }else{
        for($i = max($current - 1, 0); $i <= min($current + 1, 9); $i++){
            dfs($depth-1, $i, true,$str.$i);
        }
    }
}

function str(){return trim(fgets(STDIN));}
function ints(){return array_map('intval',explode(' ',trim(fgets(STDIN))));}
function int(){return intval(trim(fgets(STDIN)));}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}
function popcount($x){$c=0;while($x){$x&=$x-1;++$c;}return$c;}
function o(...$val){
    if(count($val)==1)$val=array_shift($val);
    echo debug_backtrace()[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0)echo "empty array";
        elseif(!is_array(current($val)))echo "array: ",implode(" ", addIndex($val)),"\n";
        else{
            echo "array:array\n";
            if(isCleanArray($val))foreach($val as $row)echo implode(" ", addIndex($row)),"\n";
            else foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row)),"\n";
        }
    }else echo $val."\n";
}
function addIndex($val){if(!isCleanArray($val)){$val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);}return $val;}
function isCleanArray($array){$clean=true;$i = 0;foreach($array as $k=>$v){if($k != $i++)$clean = false;}return $clean;}
// 座圧対象の配列 -> [圧縮された配列,復元用のMap,圧縮用のMap]
function atsu($array){$a = array_flip($array);$fuku=array_flip($a);sort($fuku);$atsu = array_flip($fuku);foreach($array as $i=>$val)$array[$i]=$atsu[$val];return [$array, $fuku, $atsu];}
function gcdAll($array){$gcd=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$gcd=gcd($gcd,$array[$i]);}return $gcd;}
function gcd($m, $n){if(!$n)return $m;return gcd($n, $m % $n);}
function lcmAll($array){$lcm=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$lcm=lcm($lcm,$array[$i]);}return $lcm;}
function lcm($a, $b) {return $a / gcd($a, $b) * $b;}



function loadTree($N = false){
  if($N === false)$N = $GLOBALS['N'];
  return loadGraph($N, $N-1);
}
function loadGraph($N = false, $M = false, $both = true){
  if($N === false)$N = $GLOBALS['N'];
  if($M === false)$N = $GLOBALS['M'];
  $G = array_fill(1, $N, []);
  for($i = 0; $i < $M; $i++){
    $values = ints();
    if(count($values) == 2){
      list($a, $b) = $values;
      $G[$a][] = $b;
      if($both)$G[$b][] = $a;
    }else{
      list($a, $b, $d) = $values;
      $G[$a][] = [$b, $d];
      if($both)$G[$b][] = [$a, $d];
    }
  }
  return $G;
}


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

int k, n, prevA, diff=0, first;

int main(){
    cin >> k >> n >> first;
    diff = max(diff, first);
    prevA = first;
    for(int i=0, a; i<n-1; i++){
        cin >> a;
        diff = max(diff, a-prevA);
        prevA=a;
    }
    diff = max(diff, k-prevA+first);
    cout << k-diff << endl;
}
 


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#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];
  }
  int ma = A[0];
  long long ans = 0;
  for(int i = 1; i < N; ++i){
    ans += max(0,ma-A[i]);
    A[i] = max(ma,A[i]);
    ma = max(ma,A[i]);
  }
  cout << ans << endl;
}


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

int main(){
  int w,h,x,y,r;
  cin>>w>>h>>x>>y>>r;
  if (y+r<=h && x+r<=w && y-r>=0 && x-r>=0) cout<<"Yes"<<endl;
  else cout<< "No" <<endl;

  return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<vector>
using namespace std;
#define int long long
int h[114514];
int n, a, b;

bool eng(int t) {//mahouwoutukaisuu
	vector<int>v;
	for (int i = 0; i < n; i++) {
		if (h[i] > b*t) {
			v.push_back(h[i] - b*t);
		}
	}
	int exd = 0;
	for (int i = 0; i < v.size(); i++) {
		exd += (v[i] + a - b - 1) / (a - b);
	}
	if (exd > t)return false;
	return true;
}
signed main() {
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++)cin >> h[i];

	int lb = -1, ub = 1e10;
	while (ub - lb > 1) {
		int mid = (lb + ub) / 2;
		if (eng(mid)) {
			ub = mid;
		}
		else lb = mid;
	}
	cout << ub << endl;
}

Measured memory_bytes: 2892
#include "bits/stdc++.h"
using namespace std;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    string st;
    for(int i=0;i<n;++i){
        if(s[i]!='B'){
            st.push_back(s[i]);
        }else{
            if(st.size()>0){
                st.pop_back();
            }
        }
    }
    cout << st << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

        int H = sc.nextInt();
        int W = sc.nextInt();
        int[][] a = new int[H][W];
        for (int r = 0; r < H; ++r) {
            for (int c = 0; c < W; ++c) {
                a[r][c] = sc.nextInt();
            }
        }

        System.out.println(solve(a));

        sc.close();
    }

    static String solve(int[][] a) {
        int H = a.length;
        int W = a[0].length;

        List<String> operations = new ArrayList<>();
        int r = 0;
        int c = 0;
        int offsetC = 1;
        while (r != H) {
            int nextR = r;
            int nextC = c + offsetC;
            if (nextC == -1 || nextC == W) {
                ++nextR;
                offsetC *= -1;
                nextC += offsetC;
            }

            if (a[r][c] % 2 != 0) {
                --a[r][c];

                if (nextR != H) {
                    ++a[nextR][nextC];

                    operations.add(String.format("%d %d %d %d", r + 1, c + 1, nextR + 1, nextC + 1));
                }
            }

            r = nextR;
            c = nextC;
        }

        return String.format("%d\n%s", operations.size(), String.join("\n", operations));
    }
}

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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define fork(i, n) for (ll i = 0; i < (n); i++)
#define forn for (ll i = 0; i < (n); i++)
#define fori(i, k, n) for (ll i = k; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}
template <typename T>
void print(vector<T> &a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template <typename T>
void print(deque<T> &a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template <typename T>
void print(vector<vector<T>> &a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

int main()
{
	fast;
	ll n, ans = 0;
	cin >> n;
	vector<int> a(n);
	for (ll i = 1; i <= n; i++)
	{
		for (int j = 1; j * i <= n; j++)
			a[i * j]++;
	}
	for (ll i = 1; i <= n; i++)
	{
		ans += i * a[i];
	}
	cout << ans << en;
}

Measured memory_bytes: 42268
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var (
	sc = bufio.NewScanner(os.Stdin)
)

type Point struct {
	X, Y int
}

type Gem struct {
	ID int
	Point
}

type Map struct {
	Current       *Point
	Gems          map[int]*Gem
	CollectedGems map[int]*Gem
}

func (m *Map) Move(dir string, l int) {
	switch {
	case dir == "N" || dir == "S":
		a := 1
		if dir == "S" {
			a = -1
		}
		for i := 0; i < l; i++ {
			m.Current.Y += a
			for _, g := range m.Gems {
				m.TryToTakeGem(g)
			}
		}
	case dir == "E" || dir == "W":
		a := 1
		if dir == "W" {
			a = -1
		}
		for i := 0; i < l; i++ {
			m.Current.X += a
			for _, g := range m.Gems {
				m.TryToTakeGem(g)
			}
		}
	}
}

func (m *Map) HasCompleted() bool {
	return len(m.Gems) == 0
}

func (m *Map) TryToTakeGem(g *Gem) {
	if m.Current.X == g.X && m.Current.Y == g.Y {
		m.CollectedGems[g.ID] = g
		delete(m.Gems, g.ID)
	}
}

func main() {
	for sc.Scan() {
		n, _ := strconv.Atoi(sc.Text())
		if n == 0 {
			break
		}
		m := &Map{
			Current:       &Point{X: 10, Y: 10},
			Gems:          map[int]*Gem{},
			CollectedGems: map[int]*Gem{},
		}
		for i := 0; i < n; i++ {
			sc.Scan()
			chunks := strings.Split(sc.Text(), " ")
			x, _ := strconv.Atoi(chunks[0])
			y, _ := strconv.Atoi(chunks[1])
			m.Gems[i+1] = &Gem{ID: i + 1, Point: Point{X: x, Y: y}}
		}
		sc.Scan()
		opCnt, _ := strconv.Atoi(sc.Text())
		for i := 0; i < opCnt; i++ {
			sc.Scan()
			chunks := strings.Split(sc.Text(), " ")
			dir := chunks[0]
			v, _ := strconv.Atoi(chunks[1])
			m.Move(dir, v)
		}
		msg := "No"
		if m.HasCompleted() {
			msg = "Yes"
		}
		fmt.Println(msg)
	}
}

Measured memory_bytes: 1616
#include <iostream>
#include <math.h>
using namespace std;
int main() {
	int n,m,a[50],b[50],c[50],d[50];
    cin >> n >> m;
    for(int i=0;i<n;i++)cin >> a[i] >> b[i];
    for(int i=0;i<m;i++)cin >> c[i] >> d[i];
    for(int i=0;i<n;i++){
        int mindist = 300000000;
        int mini = -1;
            for(int j=0;j<m;j++){
             int dist = abs(a[i]-c[j]) + abs(b[i]-d[j]);
                if(mindist > dist){
                mindist = dist;
                mini = j;
                }
            }
      cout << mini +1 << endl;
    }
}

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

int main(){
  int N, x;
  cin >> N >> x;
  vector<int> A;
  for(int i=0; i<N; i++){
    int a; cin >> a;
    A.push_back(a);
  }
  sort(A.begin(), A.end());
  int ans =0;
  while(x>=A[ans]){
    x-=A[ans];
    ans++;
    if(ans==N){
      if(x>0) ans--;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool isPalindrome( string teste, int inicio, int fim){
    int j=0;
    for(int i=inicio; i< (fim-inicio+1)/2;i++){
        if(teste[i] != teste[fim-j]){
            return false;
        }
        j++;
    }
    return true;
}
int main(){
    ios::sync_with_stdio(0);cin.tie(nullptr);
    string teste;
    teste.clear();
    cin>>teste;
    int fim1 = (teste.size()-1)/2;
    fim1--;
    int inicio2 = (teste.size()+3)/2;
    inicio2--;
    if(isPalindrome(teste, 0, teste.size()-1) and isPalindrome(teste, 0, fim1) and isPalindrome(teste, inicio2, teste.size()-1)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

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

int main()
{
  string s;
  char al[26]={};
  long long ans=1;
  vector<long long> v1,v2;
  int a=0,b=0,c;

  cin>>s;

  for(int i=0;i<s.length();i++)al[(s[i]-'a')]++;

  for(int i=0;i<26;i++){
    if(al[i]%2==0){
      a+=al[i]/2;
      c=al[i]/2;
      while(c>1){
	v2.push_back(c);
	c--;
      }
    }
    else {
      b++;
      a+=(al[i]-1)/2;
      c=al[i]/2;
      while(c>1){
	v2.push_back(c);
	c--;
      }
    }
  }
  if(b>1){
    cout<<0<<endl;
  }
  else {
    while(a>1){
      v1.push_back(a);
      a--;
    }
    for(int i=0;i<v2.size();i++){
      while(v2[i]!=1){
	for(int j=0;j<v1.size();j++){
	  if(v1[j]%v2[i]==0){
	    v1[j]/=v2[i];
	    v2[i]=1;
	  }
	}
      }
    }
    for(int i=0;i<v1.size();i++)ans*=v1[i];
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
	
int main(){
	int N;
	cin >> N;
	vector<int> a(N);
	rep(i, N) cin >> a[i];
	sort(a.begin(), a.end());
	int ans = abs(a[N - 1] - a[0]);
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
S = []
def add(a):
    if a > 3234566667:
        return
    x = a % 10
    if x != 0:
        S.append(a * 10 + x - 1)
        add(a * 10 + x - 1)
    S.append(a * 10 + x)
    add(a * 10 + x)
    if x != 9:
        S.append(a * 10 + x + 1)
        add(a * 10 + x + 1)
for i in range(9):
    S.append(i+1)
    add(i+1)
S.sort()
print(S[int(input())-1])


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define repr(i,k,n) for(int i = (k); i < (n); i++)
#define rep(i,n) repr(i,0,n)
#define ALL(a) begin(a),end(a)
const int INF = 114514810;
const int MOD = 1000000007;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int X,max=1,ex,cnt;
	bool can = false;
	cin >> X;
	repr(i,2,X){
		ex=i;
		cnt = 0;
		while(ex<=X){
			cnt++;
			ex*=i;
		}
		ex = ex/i;
		if (max<ex&&cnt>=2){
			max=ex;
		}
	}
	cout << max << endl;
}

Measured memory_bytes: 256