akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int main()
{
	long long int n, a[5],num[6];
	cin >> n >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
	long long int min=a[0],kaisu=4;
	for (int i = 1; i < 5; i++) {
		if (min > a[i]) {
			min = a[i];
		}
	}
	if (n%min == 0) {
		kaisu += n / min;
	}
	else {
		kaisu += ((n - 1) / min) + 1;
	}
	//kaisu += ceilf((long double)n / (long double)min);
	//kaisu += ceilf(n / min);
	cout << kaisu << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int a[100000];

int main(void)
{
	int n, i, j;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", a + i);
	}
	for (i = 0, j = 0; i < n; j++) {
		if (j != i) a[j] = a[i];
		while (i < n && a[i] == a[j]) ++i;
	}
	n = j;
	for (i = 0; i < n; i++) {
		printf("%d%c", a[i], " \n"[i + 1 == n]);
	}
	return 0;
}



Measured memory_bytes: 2184
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define IOS {ios :: sync_with_stdio(false); cin.tie(0);cout.tie(0); }
#define F first
#define S second
#define pb push_back
typedef long double ld;
#define deci(n) cout << fixed << setprecision(n);
typedef long long ll;

#define mem0(x)  memset(x,0,sizeof(x));
#define memm1(x) memset(x,-1,sizeof(x));
#define all(a) a.begin(), a.end()
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define fori2(n) for(ll i=1;i<=n;i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define forj2(n) for(ll j=1;j<=n;j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define fork2(n) for(ll k=1;k<=n;k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
const ll md = 1e9 + 7;

#define BSET(a, p) ((a) | (1ll << (p)))
#define BCHK(a, p) ((a) & (1ll << (p)))
#define BXOR(a, p) ((a) ^ (1ll << (p)));
#define BREM(a, p) (BCHK(a, p)?(BXOR(a, p)):(a))
#define BSHO(a, N) (bitset<N>(a))
// const ll N = 100005;
// ll fac[N] = {1};
// #define calfac for(ll i=1  ;i<N;i++) fac[i] = (fac[i-1]*i)%md;
// ll C[N+1][M+1]; 
// void  ncr(){
//     ll n = N,k = M; 
//     for (ll i = 0; i <= n; i++) { 
//         for (ll j = 0; j <= min(i, k); j++) { 
//             if (j == 0 || j == i)  C[i][j] = 1; 
//             else C[i][j] = C[i - 1][j - 1] +  C[i - 1][j]; 
//         } 
//     } 
// } 


#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 
// Ordered set docs:
// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
 
ll po(ll x,ll n){
    if(n==0) return 1;
    if(n%2==1) return (x*po(x,n-1))%md;
    else {
        ll k=po(x,n/2);
        return (k*k)%md;
    }
}
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}
ll modInv(ll a)
{
    return po(a,md-2);
}
 
// ll nCr(ll n,ll r)
// {
//     return (fac[n]*modInv((fac[r]*fac[n-r])%md))%md;
// }

 
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
}
 
int32_t main(){
    IOS;
    ll x;
    cin >> x;
    if(x==0) cout << "1\n";
    else cout <<"0\n";
} 

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

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define all(x) x.begin(), x.end()
#define vvi vector<vector<int>>
#define vvii vector<vector<pair<int, int>>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

constexpr int INF = 2e18;
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

// #define MULTIPLE_TEST_CASES
void solve() {
  int n;
  cin >> n;

  string s;
  cin >> s;

  for (char &c : s) {
    c -= 'A';
    c += n;
    c %= 26;
    c += 'A';
  }

  cout << s << endl;
}

signed main() {
  // freopen(".in", "r", stdin);
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);

  int t = 1;
#ifdef MULTIPLE_TEST_CASES
  cin >> t;
#endif
  while (t--)
    solve();
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main()
{
	fast;
	ll n,l,flag=0,sum=0,min=INT_MAX;
	cin>>n>>l;
	ll arr[n];
	for(int i=0;i<n;i++)
	{
		arr[i]=l+i;
		sum+=arr[i];
		if(arr[i]==0)
			flag=1;
	}
	if(flag==1)
	{
		cout<<sum;
		return 0;
	}
	for(int i=0;i<n;i++)
		if(abs(arr[i])<abs(min))
			min=arr[i];
	cout<<sum-min;
	return 0;
}


Measured memory_bytes: 3676
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


#define INF 1e9+7
#define LLINF 1e18+7
#define N 2500000
ll MOD=1e9+7;

main(){
    int n=in();
    vec v;
    rep(i,n){
        v.pb(in());
    }
    int now=0;
    ll ans=1;
    rep(i,n){
        while(now<n-1 and v[now]>=(now-i)*2+1) now++;
        ans= ans*(ll)(1+now-i)%MOD;
        // cout<<1+now-i<<endl;
    }
    cout<<ans<<endl;
}

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

int main(void){
    long long N,T;cin>>N>>T;
    vector<long long>t(N);for(long long i=0;i<N;i++)cin>>t[i];
    long long ans=T;
    for(long long i=1;i<N;i++){
        if(t[i]-t[i-1]<T){
            ans+=t[i]-t[i-1];
        }
        else{
            ans+=T;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N, A, B; cin >> N >> A >> B;
        cout << min(A, B) << " " << max(0, A + B - N) << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,pair<ll,ll> >
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 402;
ll i,j,k,cnt,ans,n,m,x,y,b,w;
char c;
ii u;
ll dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
ll a[N][N];
bool visit[N][N];
queue<ii> q;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n>>m;
    rep(i,0,n) rep(j,0,m){
        cin>>c;
        a[i][j] = (c == '.' ? 0 : 1);
    }
    rep(i,0,n) rep(j,0,m) if(!visit[i][j]){
        q.push({i,{j,a[i][j]}});
        b = w = 0;
        visit[i][j] = 1;
        while(!q.empty()){
            u = q.front();
            q.pop();
            if(u.se.se == a[i][j])
                w += 1;
            else
                b += 1;
            rep(k,0,4){
                x = u.f + dx[k];
                y = u.se.f + dy[k];
                if(x >= 0 && x < n && y >= 0 && y < m && !visit[x][y] && a[x][y] == 1 - u.se.se){
                    visit[x][y] = 1;
                    q.push({x,{y,a[x][y]}});
                }
            }
        }
        ans += b * w;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1664
#include <math.h>
#include <utility>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main(){
	string s;
	cin >> s;
	string m;
	m = s;
	for ( int i = 0; i < s.size(); i++ ) {
		if ( s[i] <= 'C' ) {
			m[i] = s[i] + 23;
		}else {
			m[i] = s[i] - 3;
		}
	}
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long maxx=0;
    long long t=0;
    long long n;
    char c;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>c;
        if(c=='I') t++;
        if(c=='D') t--;
        maxx=max(maxx,t);
    }
    cout<<maxx;
	return 0;
}


Measured memory_bytes: 256
// Made by Luis Miguel Baez
// es.luismiguelbaez@gmail.com
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define precise(n,k) fixed << setprecision(k) << n
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
 
#define uint  unsigned int
#define ll    long long
#define ull   unsigned long long
#define ld    long double
 
#define pii   pair<int, int>
#define piii  pair<int, pair<int, int>>
#define pll   pair<ll, ll>
 
#define F  first
#define S  second
#define PB push_back
#define MP make_pair
 
#define debug(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
string to_string(string s) {
    return '"' + s + '"';
}
 
string to_string(bool b) {
    return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename T>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const T &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string((T)x);
    }
    res += "}";
    return res;
}
 
// add templates here
 
template<class T>
void println(const vector<T> &data) {
    cout << to_string<vector<T>, T>(data) <<endl;
}
 
template<class T>
void println(const T &data) {
    cout << to_string((T)data) << endl;
}
 
const int MOD = int(1e9+7);
const int oo  = int(1e9 + 20);
const ll lloo  = (ll)(1e18 + 10);
const int N = 1e5 + 10;
vector<int> values;

vector<int> memo(N, -1);

int solve(int d) {
    if(d==1) return 0;
    if(memo[d] != -1) return memo[d];
    memo[d] = solve(d-1) + values[d - 1];
    return memo[d];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n, k;
    cin >> n >> k;
    values.resize(n+1, 0);
    for(int i = 1; i <= n ; ++i) {
        cin >> values[i];
    }
    
    int ans = 0;
    for(int i = 1; i <= n+1; ++i) {
        if(solve(i) <= k) {
            ans++;
        }
    }
    cout << ans << endl;
 
    return 0;
}

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

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define ll long long
#define pii pair<int, int>
#define is insert
#define er erase

using namespace std;

const int MAX_N = 5;

int solve();

#define TASK ""

int main()
{
    #ifdef DEBUG
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
        //freopen(TASK".in", "r", stdin);
        //freopen(TASK".out", "w", stdout);
    #endif // DEBUG
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

vector<int> g[MAX_N];

int solve()
{
    for (int i = 0; i < 3; ++i)
    {
        int a;
        int b;
        cin >> a >> b;
        g[a].pb(b);
        g[b].pb(a);
    }
    for (int i = 1; i <= 4; ++i)
    {
        if ((int)g[i].size() > 2)
        {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
    return 0;
}




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

#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

#define debug(x) cout << "> " << #x << " = " << x << endl;
#define debug_at(arr, at) cout << "> " << #arr << "[" << at << "] = " << arr[at] << endl;
#define debug_pair(p) cout << "> " << #p << " = (" << p.first << ", " << p.second << ")" << endl;

using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);

    ll n;
    cin >> n;

    ll ans = 0;
    for(ll i = 0; i <= n; i++) {
        ll cur = i * i;
        if(cur <= n) {
            ans = cur;
        }
        else {
            break;
        }
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

main(){
  int n, i;
  int A[100001];
  scanf("%d", &n);
  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);

  for ( i = 1; i <= n; i++ ) {
    printf("node %d: key = %d, ", i, A[i]);
    if ( i / 2 >= 1 )printf("parent key = %d, ", A[i/2]);
    if ( i*2 <= n ) printf("left key = %d, ", A[i*2]);
    if ( i*2+1 <= n ) printf("right key = %d, ", A[i*2+1]);
    printf("\n");
  }
  
  return 0;
}



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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  if(N % 2 == 0)
    cout << N << endl;
  else
    cout << N * 2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
  string s;
  cin >> s;
  if(s=="RRR") cout << 3 << endl;
  else if(s.substr(0,2)=="RR") cout << 2 << endl;
  else if(s.substr(1,2)=="RR") cout << 2 << endl;
  else if(s[0]=='R'||s[1]=='R'||s[2]=='R') cout << 1 << endl;
  else cout << 0 << endl;
  
 
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 3636
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main()
{
  ll N; cin>>N; if(N==1) {cout<<1<<endl; return 0;}
  vector<pair<ll,ll>> grid(N); rep(i,N) cin>>grid[i].first>>grid[i].second;
  
  sort(grid.begin(),grid.end());
  
  map<pair<ll,ll>,ll> mp;
  rep(i,N){
    for(int j=i+1;j<N;j++){
      ll p=grid[j].first-grid[i].first,q=grid[j].second-grid[i].second;
      if(p==0&&q==0) continue;
      mp[{p,q}]++;
    }
  }
  
  ll MAX=-INF;
  for(auto p:mp) chmax(MAX,p.second);
  
  cout<<N-MAX<<endl;
  
  return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9 + 7, A = 1e3 + 2;
int n, m, k;
bool a[11][A];
int col_acc[11][A], rec_acc[11][A];
void pre()
{
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            col_acc[i][j] = a[i][j] + (i ? col_acc[i - 1][j] : 0);
            rec_acc[i][j] = col_acc[i][j] + (j ? rec_acc[i][j - 1] : 0);
        }
    }
}
int get_cnt(int i, int j, int lst_i, int lst_j)
{
    int cnt = rec_acc[i][j];
    if (~lst_i) cnt -= rec_acc[lst_i][j];
    if (~lst_j) cnt -= rec_acc[i][lst_j];
    if (~lst_i && ~lst_j) cnt += rec_acc[lst_i][lst_j];
    return cnt;
}
int solve()
{
    int ans = 1e9;
    for (int row_mask = 0; row_mask < (1 << (n - 1)); row_mask++)
    {
        int col_mask = 0, lst_col = -1;
        bool valid = 1;
        int val_col = 0;
        for (int j = 0; j < m; j++)
        {
            int lst_row = -1;
            bool done = 0;
            for (int i = 0; i < n; i++)
            {
                if ((row_mask >> i & 1) || i == n - 1)
                {
                    if (get_cnt(i, j, lst_row, lst_col) > k && j > 0)
                        done = 1;
                    if (get_cnt(i, j, lst_row, j - 1) > k)
                        valid = 0;
                    lst_row = i;
                }
            }
            if (done) lst_col = j - 1, val_col++;
        }
        if (valid) ans = min(ans, __builtin_popcount(row_mask) + val_col);
    }
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++)
    {
        string s; cin >> s;
        for (int j = 0; j < m; j++)
            a[i][j] = (s[j] == '0' ? 0 : 1);
    }
    pre();
    cout << solve();
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
namespace my_std {
using namespace std;
#define reg register
#define Rint register int
#define FOR(i, a, b) for (register int i = (a), ed_##i = (b); i <= ed_##i; ++i)
#define ROF(i, a, b) for (register int i = (a), ed_##i = (b); i >= ed_##i; --i)
#define pb push_back
typedef long long i64;
#define Templ(T) template <typename T>
inline int read() {
    reg int ans = 0, f = 1;
    reg char c = getchar();
    while (!isdigit(c)) f ^= (c == '-'), c = getchar();
    for (; isdigit(c); c = getchar()) ans = (ans << 1) + (ans << 3) + (c ^ 48);
    return f ? ans : -ans;
}
Templ(_Tp) inline int chkmin(_Tp &x, _Tp y) { return x > y ? x = y, 1 : 0; }
Templ(_Tp) inline int chkmax(_Tp &x, _Tp y) { return x < y ? x = y, 1 : 0; }
#define mod 998244353
inline void inc(int &x, const int &y) { x += y; if (x >= mod) x -= mod; }
inline void dec(int &x, const int &y) { x -= y; if (x < 0) x += mod; }
inline void qmo(int &x){ x += (x >> 31) & mod; }
} // namespace my_std
using namespace my_std;

#define N 100010
#define BN 610
const i64 V = i64(1e18) % mod;

int n;
struct Graph{
    vector<int> E[N];
    int sg[N], n, m, val[BN], mxsg;
    inline void build(){
        n = ::n, m = read();
        Rint u, v;
        FOR(i, 1, m){
            u = read(), v = read();
            if(u > v) u ^= v ^= u ^= v;
            E[u].pb(v);
        }
    }
    inline void topo(){
        int *c = new int[BN];
        mxsg = 0;
        memset(c, 0, sizeof(int) * BN);
        ROF(u, n, 1){
            for(Rint v: E[u]) c[sg[v]] = 1;
            Rint t(0);
            while(c[t]) ++t;
            chkmax(mxsg, sg[u] = t);
            for(Rint v: E[u]) c[sg[v]] = 0;
        }
        delete c;
        Rint x(V);
        FOR(i, 1, n){
            qmo(val[sg[i]] += x - mod);
            x = V * x % mod;
        }
    }
}G[3];

int main() {
    n = read();
    FOR(i, 0, 2) G[i].build(), G[i].topo();
    Rint ans(0);
    FOR(i, 0, G[0].mxsg) FOR(j, 0, G[1].mxsg){
        qmo(ans += ((i64)G[0].val[i] * G[1].val[j] % mod
            * G[2].val[i ^ j] % mod) - mod);
    }
    printf("%d", ans);
    return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){

    int k;
    string s;
    cin>>k>>s;

    if(s.length()<=k)cout<<s<<"\n";
    else cout<<s.substr(0,k)<<"...\n";

    return 0;

}

Measured memory_bytes: 3632
# def print_sheet(sheet):
#     for i in range(3):
#         print(sheet[3*i:3*(i+1)])

sheet = []
for i in range(3):
    sheet += list(map(int, input().split()))
answer = [False for i in range(9)]

# print_sheet(sheet)
# print_sheet(answer)

n = int(input())

# print("n, ", n)

bs = [int(input()) for i in range(n)]

# print("B: ", bs)

for b in bs:
    for i in range(9):
        if sheet[i] == b:
            answer[i] = True

# print_sheet(answer)

res = "No"

for i in range(3):
    if answer[i] and answer[i+3] and answer[i+6]:
        res = "Yes"
    elif answer[3*i] and answer[1+3*i] and answer[2+3*i]:
        res = "Yes"

if answer[0] and answer[4] and answer[8]:
    res= "Yes"
if answer[2] and answer[4] and answer[6]:
    res = "Yes"

print(res)

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

using ll = long long;
ll N, K, Q;

int main(){
    cin >> N >> K >> Q;
    vector<ll> cha(N, K-Q);
    ll buf;
    for(int i = 0; i<Q; i++){
        cin >> buf;
        cha.at(buf-1)++;
    }
    ll cou = 0;
    for(ll xx : cha){
        if(xx > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }

}


Measured memory_bytes: 1408
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



def comb(n, r):
    if r > n: return 0
    fact = 1
    for i in range(n-r+1, n+1):
        fact *= i


    divisor = 1
    for j in range(1, r+1):
        divisor *= j


    return fact // divisor




n, p = LI()
L = [i%2 for i in LI()]
ans = 0
odd_cnt = L.count(1)
even_cnt = L.count(0)
for k in range(p, odd_cnt+1, 2):
    ans += comb(odd_cnt, k) * 2 ** even_cnt



print(ans)

Measured memory_bytes: 39152
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;

class Main {
	public static void main (String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int k = sc.nextInt();
	    int n = sc.nextInt();
	    int arr[]=new int[n];
	    for(int i=0;i<n;i++) arr[i]=sc.nextInt();
	    long res= k+arr[0]-arr[n-1];
	    for(int i=1;i<n;i++) res=Math.max(res,arr[i]-arr[i-1]);
		System.out.println(k-res);
	}
}

Measured memory_bytes: 77776
class Dice
	TOP=0
	FRONT=1
	RIGHT=2
	LEFT=3
	BACK=4
	BOTTOM=5
	
	def initialize( nums )
		@face = nums
	end
	
	def rolltoTopIndex( faceindex )
		case faceindex
		when FRONT
			roll( "N" )
		when RIGHT
			roll( "W" )
		when LEFT
			roll( "E" )
		when BACK
			roll( "S" )
		when BOTTOM
			roll( "NN" )
		when TOP
		end
	end
	
	def roll( actions )
		for i in ( 0 ... actions.length )
			t = 0
			case actions[i]
			when "E"
				t =   @face[ TOP  ]
				@face[ TOP  ] =   @face[ LEFT  ]
				@face[ LEFT  ] =   @face[ BOTTOM  ]
				@face[ BOTTOM  ] =   @face[ RIGHT  ]
				@face[ RIGHT  ] = t
			when "N"
				t =   @face[ TOP  ]
				@face[ TOP  ] =   @face[ FRONT  ]
				@face[ FRONT  ] =   @face[ BOTTOM  ]
				@face[ BOTTOM  ] =   @face[ BACK  ]
				@face[ BACK  ] = t
			when "S"
				t =  @face[ TOP  ]
				@face[ TOP  ] =  @face[ BACK  ]
				@face[ BACK  ] =  @face[ BOTTOM  ]
				@face[ BOTTOM  ] =  @face[ FRONT  ]
				@face[ FRONT  ] = t	
			when "W"
				t =  @face[ TOP  ]
				@face[ TOP  ] =  @face[ RIGHT  ]
				@face[ RIGHT  ] =  @face[ BOTTOM  ]
				@face[ BOTTOM  ] =  @face[ LEFT  ]
				@face[ LEFT  ] = t	
			when "M"
				t =  @face[ FRONT  ]
				@face[ FRONT  ] =  @face[ RIGHT  ]
				@face[ RIGHT  ] =  @face[ BACK  ]
				@face[ BACK  ] =  @face[ LEFT  ]
				@face[ LEFT  ] = t				
			end
		end
	end
	attr_accessor :face
end

diceface = gets.split( " " ).map { |val| val.to_i }
dice1 = Dice.new( diceface )
diceface = gets.split( " " ).map { |val| val.to_i }
dice2 = Dice.new( diceface )

cnt = 0
catch ( :samedice ) do
	for i in ( Dice::TOP .. Dice::BOTTOM )
		if dice1.face[Dice::TOP] == dice2.face[i]
			dice2.rolltoTopIndex( i )
			for j in ( Dice::FRONT .. Dice::BACK )
				if dice1.face[Dice::FRONT] == dice2.face[Dice::FRONT]
					cnt = 0
					for k in ( Dice::TOP .. Dice::BOTTOM )
						if dice1.face[k] == dice2.face[k]
							cnt += 1
						end
					end
					throw :samedice if cnt == 6
				end
				dice2.roll( "M" )
			end
		end
		dice2.face = diceface
	end
end

if cnt == 6
	puts( "Yes" )
else
	puts( "No" )
end

Measured memory_bytes: 6148
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int a[][] = new int[M][2];
		for(int i = 0; i < M; i++) {
			a[i][0] = sc.nextInt() - 1;
			a[i][1] = sc.nextInt() - 1;
		}
		LinkedList list[] = new LinkedList[N];
		for(int i = 0; i < N; i++) {
			list[i] = new LinkedList();
		}
		for(int i = 0; i < M; i++) {
			list[a[i][0]].add(a[i][1]);
			list[a[i][1]].add(a[i][0]);
		}
		
		Boolean flag[] = new Boolean[list.length];
		for(int i = 0; i < list.length; i++) {
			flag[i] = false;
		}
		int ans = 0;
		ans = GraphDFS(list, 0 , flag, ans);
		System.out.println(ans);
	}
	
	public static int GraphDFS(LinkedList list[], int now, Boolean flag[], int ans) {
		flag[now] = true;	
		for(int i = 0; i < list[now].size(); i++) {
			if(!flag[list[now].get(i)]) {
				ans = GraphDFS(list, list[now].get(i), flag, ans);
			}
		}
		
		if(!Arrays.asList(flag).contains(false)) {
			ans++;
		}
		
		flag[now] = false;
		return ans;
	}
}

class LinkedList {
	ArrayList<Integer> link = new ArrayList<Integer>();
	public void add(int vertex) {
		link.add(vertex);
	}

	public int get(int i){
		return link.get(i);
	}
	
	public void remove(int vertex) {
	}
	
	public void view() {
		for(int i = 0; i < link.size(); i++) {
			System.out.println(link.get(i));
		}
	}
	
	public boolean linked(int vertex) {
		if(link.contains(vertex)){
			return true;
		} else {
			return false;
		}
	}

	public int size() {
		return link.size();
	}
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long 
#define mod 1000000007 
#define mod2 998244353
void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}



int main() {
   fast();
   int n;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++){
    cin>>a[i];
   }
   int cnt[100005]={0};
   int c[100005]={0};
   for(int i=0;i<n;i++){
     if(i%2==0){
      cnt[a[i]]++;
     }else{
      c[a[i]]++;
     }
   }
   int count=n/2;
   int maxcnt=0;
   for(int i=0;i<=100000;i++){
    if(cnt[i]>cnt[maxcnt]){
      maxcnt=i;
    }
   }
   int maxc=0;
   for(int i=0;i<=100000;i++){
    if(c[i]>c[maxc]){
      maxc=i;
    }
   }
   if(maxcnt==maxc){
    if(cnt[maxcnt]>cnt[maxc]){
      int l=0;
      for(int i=0;i<=100000;i++){
        if(i!=maxc){
          l=max(c[i],l);
        }
      }
      cout<<n/2-cnt[maxcnt]+n/2-l<<"\n";
    }
    if(cnt[maxcnt]==cnt[maxc]){
      int l=0;
      for(int i=0;i<=100000;i++){
        if(i!=maxc){
          l=max(c[i],l);
        }
      }
      int k=0;
      for(int i=0;i<=100000;i++){
        if(i!=maxcnt){
          k=max(cnt[i],k);
        }
      }
      cout<<min(n/2-cnt[maxcnt]+n/2-l,n/2-c[maxc]+n/2-k)<<"\n";
    }
    if(cnt[maxcnt]<cnt[maxc]){
      int k=0;
      for(int i=0;i<=100000;i++){
        if(i!=maxc){
          k=max(c[i],k);
        }
      }
      cout<<n/2-c[maxc]+n/2-k<<"\n";
    }

   }else{
       
       
       cout<<n/2-cnt[maxcnt]+n/2-c[maxc]<<"\n";
   }




}


Measured memory_bytes: 4732
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); ++i)
int dx[] = {1, 0};
int dy[] = {0, 1};

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    rep(i, h) cin >> a[i];
    int cnt = 0;
    rep(i, h) {
        rep(j, w) {
            if (a[i][j] == '#') cnt++;
        }
    }
    bool ans = (cnt == h+w-1);
    cout << (ans ? "Possible" : "Impossible") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
//printf("%.12Lf\n",c);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int yakuwa(int n){
	int sum=0;
	rep(1,i,sqrt(n+1)){
		if(n%i==0)sum+=i+n/i;
		if(i*i==n)sum-=i;
	}
	return sum;
}	
bool hei(int n){
	rep(0,i,100){
		if(i*i==n){
			return true;
		}
	}
	return false;
}		
int a[114514],b[114514];
string ss[114514];
signed main(){
	ic(n) ic(l) ic(m)
	c(n/(l+m)*l+min(l,n%(l+m)))
}	

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

int main(){

	int k, t;
	cin >> k >> t;
	vector<int> a(t);
	for(int i=0; i<t; i++) cin >> a[i];

	if( t == 1 ){
		cout << k-1 << endl;
		return 0;
	}

	int m = *max_element(a.begin(), a.end());

	int sum = accumulate(a.begin(), a.end(), 0);

	int ans = 2*m - sum - 1; 
	// cout << 2*m - sum << endl;

	if( ans <= 0 ) cout << 0 << endl;
	else cout << ans << endl;


	return 0;

}

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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>; 

int main(){
    string s,t;
    cin>>s>>t;
    cout<<t<<s<<endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))

def check(l):
    t = 0
    for i in a:
        t += -(-i // l) - 1
    return t <= k

l, r = 0, 10 ** 9 + 1
while r - l > 1:
    mid = (l + r) // 2 + (l + r) % 2
    if check(mid):
        r = mid
    else:
        l = mid

print(r)

Measured memory_bytes: 94056
#include <iostream>
#include <stdio.h>
#include <string.h>
#define MAX_N 100005

using namespace std;

int n,mx=0,md=0;
int a[MAX_N];

void read()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		mx=max(mx,a[i]);
	}
}

void work()
{
	for(int i=1;i<=n;i++)
	{
		if(a[i]!=mx && min(a[i],mx-a[i])>min(md,mx-md)) md=a[i];
	}
	printf("%d %d\n",mx,md);
}

int main()
{
	read();
	work();
}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main(){
    unsigned X, Y, Z, K;
    scanf("%u %u %u %u", &X, &Y, &Z, &K);
    ull A[X];
    for(int i = 0; i < X; ++i){
        scanf("%llu", A + i);
    }
    ull B[Y];
    for(int i = 0; i < Y; ++i){
        scanf("%llu", B + i);
    }
    ull C[Z];
    for(int i = 0; i < Z; ++i){
        scanf("%llu", C + i);
    }
    if(X > K){
        nth_element(A, A + K - 1, A + X, greater<ull>());
        X = K;
    }
    if(Y > K){
        nth_element(B, B + K - 1, B + Y, greater<ull>());
        Y = K;
    }
    if(Z > K){
        nth_element(C, C + K - 1, C + Z, greater<ull>());
        Z = K;
    }
    ull ab[X*Y];
    for (size_t i = 0; i < X; i++){
        for (size_t j = 0; j < Y; j++){
            ab[i*Y + j] = A[i] + B[j];
        }
    }
    if(X*Y > K){
        nth_element(ab, ab + K - 1, ab + X*Y, greater<ull>());
    }
    unsigned product = min(X*Y, K);
    ull answer[product*Z];
    for (size_t i = 0; i < Z; i++){
        for (size_t j = 0; j < product; j++){
            answer[i*product + j] = C[i] + ab[j];
        }
    }
    partial_sort(answer, answer + K, answer + product*Z, greater<ull>());
    for (size_t i = 0; i < K; i++){
        printf("%llu\n", answer[i]);
    }
	return 0;
}

Measured memory_bytes: 31488
import java.util.Scanner;

public class Main {

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

		char c = sc.next().charAt(0);

		String ans;

		switch (c) {
		case 'a':
		case 'e':
		case 'i':
		case 'o':
		case 'u':
			ans = "vowel";
			break;
		default:
			ans = "consonant";
			break;
		}

		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 21204
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

enum direction{
  UP    = 0,
  RIGHT = 1,
  DOWN  = 2,
  LEFT  = 3
};

/*
 *   6
 *   2
 * 3 1 4
 *   5
 */

/* top and RIGHT */
int next_top[7][7][4];
int next_right[7][7][4];
int front[7][7];

void initDie(){
  front[1][3] = 2; front[1][2] = 4; front[1][4] = 5; front[1][5] = 3;
  front[2][1] = 3; front[2][3] = 6; front[2][4] = 1; front[2][6] = 4;
  front[3][1] = 5; front[3][2] = 1; front[3][5] = 6; front[3][6] = 2;
  for(int i = 4; i < 7; i++){
    for(int j = 1; j < 7; j++){
      if(i == j || i + j == 7) continue;
      int t = 7 - i;
      int l = 7 - j;
      front[i][j] = front[t][l];
    }
  }

  for(int t = 1; t < 7; t++){
    for(int r = 1; r < 7; r++){
      if(t == r || t + r == 7) continue;

      next_top[t][r][UP]     = front[t][r];
      next_top[t][r][LEFT]   = r;
      next_top[t][r][RIGHT]  = 7 - r;
      next_top[t][r][DOWN]   = 7 - front[t][r];

      next_right[t][r][UP]    = r;
      next_right[t][r][LEFT]  = 7 - t;
      next_right[t][r][RIGHT] = t;
      next_right[t][r][DOWN]  = r;
    }
  }
}

int main(){
  int n;

  initDie();

  while(scanf("%d", &n), n){
    char buff[10];

    int top = 1;
    int right = 3;
    int ans = 1;


    REP(i,n){
      int dir;

      scanf("%s", buff);
      switch(buff[0]){
      case 'N':
	dir = UP;
	break;
      case 'E':
	dir = RIGHT;
	break;
      case 'S':
	dir = DOWN;
	break;
      case 'W':
	dir = LEFT;
	break;
      case 'R':
      case 'L':
	ans += top;
	if(buff[0] == 'R'){
	  right = 7 - front[top][right];
	}else{
	  right = front[top][right];
	}
	continue;
      }

      int ntop  = next_top[top][right][dir];
      int nright = next_right[top][right][dir];

      top = ntop; right = nright;
      ans += top;
    }

    print(ans);
  }

  return 0;
}

Measured memory_bytes: 0
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#include <deque>
#include <cstring>
#include <functional>
#include <climits>
#include <list>
#include <ctime>
#include <complex>

#define F1(x,y,z) for(int x=(y);x<(z);x++)
#define F2(x,y,z) for(int x=(y);x<=(z);x++)
#define F3(x,y,z) for(int x=(y);x>(z);x--)
#define F4(x,y,z) for(int x=(y);x>=(z);x--)
#define mp make_pair
#define pb push_back
#define LL long long
#define co complex<double>
#define fi first
#define se second

#define MAX 100005
#define AMAX 53
#define MOD 1000000007

#define f(c,d) ((1<<(c))*(d))

using namespace std;

LL ans;
int n,m,x[MAX];

int main(){
	scanf("%d%d",&n,&m);
	F1(a,0,n){
		scanf("%d",x+a);
		if(a==0&&x[a]>m){
			ans+=x[a]-m;
			x[a]=m;
		}
		if(a&&x[a]+x[a-1]>m){
			ans+=x[a]+x[a-1]-m;
			x[a]=m-x[a-1];
		}
	}
	printf("%lld\n",ans);
	#ifdef LOCAL_PROJECT
	system("pause");
	#endif
	return 0;
}


Measured memory_bytes: 512
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        long ans = 0;
        PriorityQueue<Integer> queue = new PriorityQueue<>();
        for (int i = 0; i < n; i++) {
            queue.add(sc.nextInt());
        }
        for (int i = 0; i <= n / 2; i++) {
            if (queue.isEmpty()) {
                break;
            }
            long v1 = queue.poll();
            if (queue.isEmpty()) {
                ans += v1;
            } else {
                long v2 = queue.poll();
                long vs = v1 + v2;
                ans += Math.abs(vs);
            }
        }

        System.out.println(ans);
    }
}

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

namespace ABC125
{
    class B
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] v = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] c = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] d = new int[n];
            for (int i = 0; i < n; i++)
            {
                d[i] = v[i] - c[i];
            }
            Array.Sort(d);
            Array.Reverse(d);
            int ans = 0;
            for (int i = 0; i < n; i++)
            {
                ans += d[i] >= 0 ? d[i] : 0;
            }
            Console.WriteLine(ans);
        }
    }
}


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

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    sort(a.begin(), a.end(), greater<>());

    vector<ll> b;
    b.push_back(a[0]);
    for (int i = 1; i < n; ++i) {
        b.push_back(a[i]); b.push_back(a[i]);
    }

    ll ans = 0;
    rep(i,n-1) ans += b[i];

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 8932
import sys


def main():
    _ = int(input())
    A = list(map(int,input().split()))

    M = set()
    lenA = len(A)
    for i in range(len(A))[::-1]:
        if i > lenA/2:
            if A[i] == 1:
                M.add(i+1)
        else:
            bai = set([x*(i+1) for x in range(1, int(lenA/(i+1))+1)])
            num = len(M&bai) % 2
            if A[i] != num:
                M.add(i+1)
    
    print(len(M))
    if len(M) > 0:
        print(*M)

if __name__=='__main__':
    main()

Measured memory_bytes: 42352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	t=1;
	//cin>>t;
	while(t--)
	{
		ll arr[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
		ll o;
		cin>>o;
		cout<<arr[o-1];
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

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

	int n, h;
	cin >> n >> h;

	vector<pair<int, int> > katanas(n);
	int a, b;
	int max_damage = -1;
	for (int i = 0; i < n; ++i) {
		cin >> a >> b;
		katanas[i] = {b, a};
		max_damage = max(max_damage, a);
	}

	sort(katanas.rbegin(), katanas.rend());

	int attacks = 0;
	int i = 0;
	while (i < n && katanas[i].first > max_damage) {
		h -= katanas[i].first;
		++attacks;
		if (h <= 0) {
			cout << attacks << "\n";
			return 0;
		}

		++i;
	}

	attacks += ceil((double) h / max_damage);

	cout << attacks << "\n";

	return 0;

}

Measured memory_bytes: 1024
x, n = map(int, input().split())
if n==0:
  print(x)
else:
    l1 = list(map(int,input().split()))	
    l2 = list(range(-150, 200))
    diff = set(l1) ^ set(l2)
    diff = list(diff)
    def sorting(numbers_array):
      return sorted(numbers_array, key=abs)
    sl = map(lambda a: a - x, diff)
    print(sorting(sl)[0]+x)

Measured memory_bytes: 9248
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  string s;
  cin>>s;
  ll ans=0,l=1<<s.size();
  for(ll i=s.size()-1;i>=0;i--){
    ans+=l*(s[i]-'0')/2;
    l=(l*10+(1<<s.size()))/2;
  }
  cout << ans << endl;
}




Measured memory_bytes: 256
#include<iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
//#include <bits/stdc++.h>//atcoderでsqrtを使うときに必要
#define fi(p) for(int i=0;i<(p);i++)
#define ce(d) cout<<d<<endl;
#define ll long long
#define sorts(c) sort((c).begin(),(c).end());

using namespace std;

void solve() {
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) {
		ce("Yes")
	}
	else {
		ce("No")
	}
}

int main()
{
	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

Measured memory_bytes: 256
class measure:
    def __init__(self, init, station_count):
        self.init = init
        self.station_count = station_count
    def clockwise(self, pos):
        return (self.station_count - self.init + pos) % self.station_count
    def anticlockwise(self, pos):
        return (self.station_count + self.init - pos) % self.station_count
    
import sys
from bisect import bisect

f = sys.stdin


n, _, init = map(int, f.readline().split())
d = sorted(list(map(int, f)))


m = measure(init, n)

dist = []

n_pos = bisect(d, init) if d[0] < init < d[-1] else 0
dist.append(m.anticlockwise(d[n_pos]))

p_pos = n_pos - 1
dist.append(m.clockwise(d[p_pos]))

for di, dj in zip(d, d[-1:] + d[:-1]):
    dist.append(m.anticlockwise(di) * 2 + m.clockwise(dj))
    dist.append(m.anticlockwise(di) + 2 * m.clockwise(dj))

print(min(dist) * 100)

Measured memory_bytes: 8040