akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
#include <sstream> 
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define endl "\n"
#define CPrint(c)  for(auto i:(c)) { cout<<i<<" "; } nl 
#define eb   emplace_back
#define ef   emplace_front
#define pb   push_back
#define pf   push_front
#define popb pop_back
#define popf pop_front
#define mp   make_pair
//debuggers
#define trace2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define trace3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define trace4(w,x,y,z) cout<<#w<<"="<<w<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
typedef long long ll;
const int INF=1e9+5;
using namespace std;
 
int main()
{
	FAST_IO;
	int n;
	cin >> n;
	vector<int> h(n);
	for(int i=0;i<n;i++)
	{
		cin >> h[i];
	}
	vector<int> dp(n,INF);//stores cost incurred to reach n
	dp[0] = 0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<=i+2;j++)
		{
			dp[j] = min(dp[j],dp[i]+abs(h[j]-h[i]));
		}
	}
	cout << dp[n-1] << endl;
}

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

#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define setIO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
#define trav(e, x) for (auto &(e) : (x))
#define pb(x) push_back(x)
#define eb(x...) emplace_back(x)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
#define lc(i) 2*i
#define rc(i) 2*i+1
//#define int long long
using namespace std;
using vi = vector<int>;
using ii = pair<int, int>;

const int MAXN = 1e5, INF = 1e9 + 5, MOD = 1e9 + 7;

signed main() {
    FAST_IO;
//    setIO("input.txt", "output.txt");

    string s;
    cin >> s;
    int sum = 0;
    trav(x, s) sum += x - '0';
    cout << (sum % 9 == 0 ? "Yes" : "No");
}


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

int main(){
    int a[12];
    for(int i=0;i<12;i++){
        cin>>a[i];
    }
    sort(a,a+12);
    for(int i=0;i<12;i+=2){
        if(a[i]!=a[i+1]){
            cout<<"no"<<endl;
            return 0;
        }
    }
    cout<<"yes"<<endl;
    return 0;
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
long double arr[100000];
int main()
{
	long double i,n,ans,a;
	ans=0;
	cin>>n;
	cout<<fixed<<setprecision(10);
	for (i=0;i<n;i++)
	{
		cin>>a;
		ans+=(1.0/a);
	}
	ans=(1.0/ans);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
/*https://atcoder.jp/contests/dp/tasks/dp_d*/
#include <iostream>
#include <vector>
using namespace std;
int max(int a, int b){
	return a > b ? a : b;
}
int main(){
	int n, W;
	cin >> n >> W;
	vector<long long>w(n), v(n);
	for (int i = 0; i < n; i++)
		cin >> w[i] >> v[i];
	vector<vector<long long>> dp(n + 1, vector<long long>(W + 1, 0));
	for (int i = 0; i < n; i++){
		for (int j = 0; j <= W; j++){
			dp[i + 1][j] = dp[i][j];
			if (j - w[i] >= 0)
				dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
		}
	}
	cout << dp[n][W];
}

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

using namespace std;

typedef long long ll;

const int N = 200200;

ll a[N];
ll pre[N];

int main() {
	int n; ll l;
	scanf("%lld %d", &l, &n);
	
	for (int i = 0; i < n; ++i) {
		scanf("%lld", a + i);
		pre[i + 1] = pre[i] + a[i];
	}
	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		
		{
			int k = min(i, n - i - 1);
			ll now = a[i];
			now += (pre[i] - pre[i - k]) * 2;
			if (i + k + 1 < n) ++k;
			now += ((ll) (k * l) - pre[i + k + 1] + pre[i + 1]) * 2;
			ans = max(ans, now);
		}
		
		{
			int k = min(i, n - i - 1);
			ll now = l - a[i];
			now += ((ll) (l * k) - pre[i + k + 1] + pre[i + 1]) * 2;
			if (i > k) ++k;
			now += (pre[i] - pre[i - k]) * 2;
			ans = max(ans, now);
		}
	}
	
	printf("%lld\n", ans);
}

Measured memory_bytes: 3456
/************
< 주소 >      :
*************
< 해결방안 >   :


*************
< 오답노트 >   :

*************/

#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL_BOOKNU
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// ........................macro.......................... //
#define FOR(i, f, n) for(int (i) = (f); (i) < (int)(n); ++(i))
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (int)(n); --(i))
#define pb push_back
#define emb emplace_back
#define fi first
#define se second
#define ENDL '\n'
#define sz(A) (int)(A).size()
#define ALL(A) A.begin(), A.end()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())
#define next next9876
#define prev prev1234
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef long long i64;
typedef unsigned long long ui64;
// inline i64 GCD(i64 a, i64 b) { if(b == 0) return a; return GCD(b, a % b); }
inline int getidx(const vi& ar, int x) { return lower_bound(ALL(ar), x) - ar.begin(); } // 좌표 압축에 사용: 정렬된 ar에서 x의 idx를 찾음
inline i64 GCD(i64 a, i64 b) { i64 n; if(a < b) swap(a, b); while(b != 0) { n = a % b; a = b; b = n; } return a; }
inline i64 LCM(i64 a, i64 b) { if(a == 0 || b == 0) return GCD(a, b); return a / GCD(a, b) * b; }
inline i64 CEIL(i64 n, i64 d) { return n / d + (i64)(n % d != 0); } // 음수일 때 이상하게 작동할 수 있음.
inline i64 ROUND(i64 n, i64 d) { return n / d + (i64)((n % d) * 2 >= d); }
inline i64 POW(i64 a, i64 n) {
	assert(0 <= n);
	i64 ret;
	for(ret = 1; n; a = a*a, n /= 2) { if(n%2) ret *= a; }
	return ret;
}
template <class T> ostream& operator<<(ostream& os, vector<T> v) {
	os << "[";
	int cnt = 0;
	for(auto vv : v) { os << vv; if(++cnt < v.size()) os << ","; }
	return os << "]";
}
template <class T> ostream& operator<<(ostream& os, set<T> v) {
	os << "[";
	int cnt = 0;
	for(auto vv : v) { os << vv; if(++cnt < v.size()) os << ","; }
	return os << "]";
}
template <class L, class R> ostream& operator<<(ostream& os, pair<L, R> p) { return os << "(" << p.fi << "," << p.se << ")"; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H, debug_out(T...); }
// ....................................................... //

int x, k;
void input() {
	cin >> x >> k;
}

int solve() {
	if((x+1)/2 >= k) cout << "YES" << ENDL;
	else cout << "NO" << ENDL;
	return 0;
}

// ................. main .................. //
void execute() {
	input(), solve();
}

int main(void) {
#ifdef LOCAL_BOOKNU
	freopen("input.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
#endif
	cin.tie(0), ios_base::sync_with_stdio(false);
	execute();
	return 0;
}
// ......................................... //

Measured memory_bytes: 256
#include<stdio.h>
int gcm(int x, int y) {
    int z;
    while (1) {
        z = x % y;
        if (z == 0) return y;
        else return gcm(y, z);
    }
}

int main() {
    int x, y;
    scanf("%d", &x);
    scanf("%d", &y);
    printf("%d\n", gcm(x, y));
}


Measured memory_bytes: 2128
N = int(input())

A = map(int, input().split())
ABI = sorted(((a, max(N-i, i-1)*a, i) for i, a in enumerate(A, 1)), reverse=True)

prev = [0]
for k, (a, b, i) in enumerate(ABI):
  curr = [0]*(k+2)
  for l in range(k+1):
    curr[l] = max(curr[l], prev[l]+abs(N-i-k+l)*a)
    curr[l+1] = prev[l]+abs(i-l-1)*a

  prev = curr

print(max(prev))


Measured memory_bytes: 9496
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	ll a,b,k;cin>>a>>b>>k;
	if(a>=k){
		cout << a-k << ' ' << b << endl;
	}else{
		cout << 0 << ' ' << max((ll)0, b-(k-a)) << endl;
	}
	return 0;
}


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

int main()
{
    string s;
    cin>>s;
    int num1 = 10*(s[0]-48);
    num1+=(s[1]-48);
    int num2 = 10*(s[2]-48);
    num2+=(s[3]-48);
    if(num1>12 || num1==0)
    {
        if(num2>12 || num2==0)
            cout<<"NA"<<'\n';
        else
            cout<<"YYMM"<<'\n';
    }
        //cout<<"NA"<<'\n';
    else if(num2>12 || num2==0)
    {
        if(num1>12 || num1==0)
            cout<<"NA"<<'\n';
        else
            cout<<"MMYY"<<'\n';
    }
    else cout<<"AMBIGUOUS"<<'\n';
    return 0;

    //else if(num1==0)

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int ar[1000009];
int pr[1000009];
int main()
{
    int i,n,j,k,z=2,te;
    for(i=4;i<=100009;i+=2){
        ar[i]=1;
    }

    pr[3]=1;
    int sq=sqrt(1000000)+3;
    for(i=3;i<=1000009;i+=2){

            if(ar[i]==0){pr[i+1]=z++;}
            if(i<=1000){
                if(ar[i]==0){
                    for(j=i*i;j<=1000009;j+=2*i){
                        ar[j]=1;
                    }
                }
            }
    }
    for(i=0;i<1000009;i++){
        if(pr[i]!=0){
            te=pr[i];
        }
        pr[i]=te;
    }




    while(scanf("%d",&n)==1){
            if(n>1){printf("%d\n",pr[n+1]);}
            else {
                printf("0\n");
            }
    }
    return 0;

}

Measured memory_bytes: 9008
#include<stdio.h>
#include<string.h>
int main()
{
	int s(char a[],char b[],int,int);
	char a[20],b[20];
	int i,j,t,x=0;
	scanf("%s%s",a,b);
	i=strlen(a);
	j=strlen(b);
	while(s(a,b,i,j))
	{
		for(t=0;t<i;t++)a[t]=a[t]+(a[t]-'0');
		for(t=i-1;t>0;t--)if(a[t]>'9')
		{
			a[t]-=10;
			a[t-1]++;
		}
		if(a[0]>'9')
		{
			a[i+1]='\0';
			for(t=i-1;t>=0;t--)a[t+1]=a[t];
			a[1]-=10;
			a[0]='1';
			i++;
		}
		x++;
	}
	printf("%d\n",x);
	return 0;
}
int s(char a[],char b[],int i,int j)
{
	int t;
	if(i<j)return 1;
	else if(i>j)return 0;
	else for(t=0;t<i;t++)
	{
		if(a[t]>b[t])return 0;
		if(a[t]<b[t])return 1;
	}
	return 1;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

const double pi = 3.141592653589793238;
const double eps = 0.000000001;

double a, b, x;

bool check(double th){
	if(th == 0.0) return true;
	if(th >= 90.0 - eps) return false;
	double tn = tan(th / 180.0 * pi);
	if(b - a * tn >= 0){
		double l = b - a * tn;
		return a * a * l + a * (b - l) * a / 2.0  >= x;
	}

	double l = b / tn;
	return  b * l * a / 2.0  >= x;
}

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


	cin >> a >> b >> x;

	// if(x == a * a * b){
	// 	cout << 0.0 << endl;
	// 	return 0;
	// }
	double l = 0.0, r = 90.0;
	for(int i = 0; i < 100000; i++){
		double mid = (l + r) / 2.0;
		if(check(mid)){
			l = mid;
		}else{
			r = mid;
		}
	}

	cout << fixed << setprecision(10);
	cout << l << endl;

}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  string s, t;
  cin >> s >> t;
  cout << t << s;
}
#endif


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1<<16+3;
ll dp[N],add[20][20];
int n;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			cin>>add[i][j];
	for(int i=1;i<(1<<n);i++)
	{
		for(int j=0;j<n;j++)
		{
			if((i>>j)&1)
			{
				dp[i]=dp[i-(1<<j)];
				for(int k=0;k<n;k++)
				{
					if((i>>k)&1)
					{
						dp[i]+=add[k+1][j+1];
					}
				}
				break;
			}
		}
	}
	for(int i=0;i<(1<<n);i++)
	{
//		cout<<i<<":";
		for(int j=i;j!=0;j=(j-1)&i)
		{
			dp[i]=max(dp[i],dp[j]+dp[i^j]);
//			cout<<j<<' ';
		}
//		cout<<"\n";
		
	}
	cout<<dp[(1<<n)-1];
	return 0;
}

Measured memory_bytes: 768
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
const int MOD = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime MOD
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
ostream& operator<< (ostream& os, const mint& value) {
  os << value.x;
  return os;
}

#pragma endregion library

int main(){
    int n,s; cin >> n >> s;
    vi a(n); rep(i,n) cin >> a[i];
    vector<mint> f(s+1);
    mint ans=0;
    rep(i,n){
        f[0]+=1;
        rrep(j,s+1){
            if(j+a[i]<s+1) f[j+a[i]]+=f[j];
        }
        ans+=f[s];
    }
    cout << ans << '\n';
    
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    if (a<b){
        cout<<"a"<<" "<<"<"<<" "<<"b"<<endl;
        }
    else if(a>b){
        cout<<"a"<<" "<<">"<<" "<<"b"<<endl;
        }
    else{
        cout<<"a"<<" "<<"=="<<" "<<"b"<<endl;
        }
    return 0;
}


Measured memory_bytes: 3076
n = int(input())
ps = []
ms = []
xs = []
ys = []
for i in range(n):
    x,y = map(int, input().split())
    ps.append(x+y)
    ms.append(x-y)
    xs.append(x)
    ys.append(y)
ps.sort()
ms.sort()
a1 = ps[-1]-ps[0]
a2 = ms[-1]-ms[0]
print(max(a1,a2))

Measured memory_bytes: 126324
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
template<class T> 
inline void read(T& x)
{
	char c = getchar(); T p = 1, n = 0;
	while(c < '0' || c > '9'){if(c == '-') p = -1; c = getchar();}
	while(c >= '0' && c <= '9'){n = n * 10 + c - '0'; c = getchar();}
	x = p * n;
}
template<class T, class U>
inline void read(T& x, U& y){read(x), read(y);}
template<class T, class U, class V>
inline void read(T& x, U& y, V& z){read(x), read(y), read(z);}
const int maxn = 5e5 + 100;
int D; int n, root; 
struct Point
{
	int d[2], l, r, num;
	Point(){l = 0, r = 0;}
	int& operator[](int i){return d[i];}
	bool operator<(const Point& p)const{return d[D] < p.d[D];}
} P[maxn], t[maxn];
int tc = 1;
int build(int L = 0, int R = n - 1, int d = 0)
{
	int M = (L + R) >> 1;
	D = d;
	nth_element(P + L, P + M, P + R + 1);
	int o = tc++;
	t[o] = P[M];
	if(L < M) t[o].l = build(L, M - 1, d ^ 1);
	if(M < R) t[o].r = build(M + 1, R, d ^ 1);
	return o;
}
int sx, tx, sy, ty; vector<int> ans;
void find(int o = root, int d = 0)
{
	if(sx <= t[o].d[0] && t[o].d[0] <= tx && sy <= t[o].d[1] && t[o].d[1] <= ty)
		ans.push_back(t[o].num);
	if(d == 0)
	{
		if(t[o].l && sx <= t[o][0]) find(t[o].l, d ^ 1);
		if(t[o].r && t[o][0] <= tx) find(t[o].r, d ^ 1);
	}
	else
	{
		if(t[o].l && sy <= t[o][1]) find(t[o].l, d ^ 1);
		if(t[o].r && t[o][1] <= ty) find(t[o].r, d ^ 1);
	}
}
int main()
{
	read(n);
	for(int i = 0; i < n; ++i) read(P[i][0], P[i][1]), P[i].num = i;
	root = build();
	int q; read(q);
	while(q--)
	{
		ans.clear();
		read(sx, tx), read(sy, ty);
		find();
		sort(ans.begin(), ans.end());
		for(int i = 0; i < ans.size(); ++i) printf("%d\n", ans[i]);
		puts("");
	}
	return 0;
}

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

int main(){
	int n, m, k, like[32], pre, ans;
	for(int i = 0;i < 33;i ++) like[i] = 0;
	cin >> n >> m;
	for(int i = 0;i < n;i ++){
		cin >> k;
		for(int j = 0;j < k;j ++){
			cin >> pre;
			like[pre]++;
		}
	}
	ans = 0;
	for(int i = 1;i < 32;i ++){
		if(like[i] == n) ans ++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let c: Vec<char> = sc.chars();
    if c.iter().all(|&c| c == 'W') || c.iter().all(|&c| c == 'R') {
        println!("0");
        return;
    }
    let mut ans = 0;
    let mut l = 0;
    let mut r = N-1;
    while l < r {
        while c[l] == 'R' {
            l += 1;
        }
        while c[r] == 'W' {
            r -= 1;
        }
        if l >= r {
            break;
        }
        ans += 1;
        l += 1; r -= 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ul;
#define all(x) (x).begin(), (x).end()
#define pi 3.1415926536

struct TreeNode {
    int val;
    TreeNode* left;
    TreeNode* right;

    TreeNode(int x): val(x), left(NULL), right(NULL){}
};

struct ListNode {
    int val;
    ListNode* next;

    ListNode(int x): val(x), next(NULL){}
};

int nxt(){
    int x;
    cin>>x;
    return x;
}

ll nxtLong(){
    ll x;
    cin>>x;
    return x;
}

string nxtStr(){
    string x;
    cin>>x;
    return x;
}

char nxtChar(){
    char x;
    cin>>x;
    return x;
}

double nxtDouble(){
    double x;
    cin>>x;
    return x;
}

ld nxtLDouble(){
    ld x;
    cin>>x;
    return x;
}

TreeNode* makeTree(int n){
    queue<TreeNode*> tree_nodes;
    TreeNode* root;
    if(n){
        root = new TreeNode(nxt());
        tree_nodes.push(root);
    }else{
        return NULL;
    }
    while(!tree_nodes.empty()){
        TreeNode* node = tree_nodes.front();
        tree_nodes.pop();
        bool left;
        cin>>left;
        if(left){
            node->left = new TreeNode(nxt());
            tree_nodes.push(node->left);
        }
        bool right;
        cin>>right;
        if(right){
            node->right = new TreeNode(nxt());
            tree_nodes.push(node->right);
        }
    }
    return root;
}

ListNode* makeLinkedList(int n){
    ListNode* list = new ListNode(0);
    ListNode* dummy = list;

    for(int i=0;i<n;++i){
        list->next = new ListNode(nxt());
        list = list->next;
    }

    return dummy->next;
}

void solve(){
    int n = nxt(), m = nxt(), k = nxt();

    vector<ll> a(n+1), b(m+1);

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

    for(int i=1;i<=m;++i){
        cin>>b[i];
        b[i] += b[i-1];
    }

    int ans = 0;
    int j = m;
    for(int i=0;i<=n;++i){
        if(a[i] > k){
            break;
        }

        while(b[j] > k-a[i]){
            j--;
        }
        ans = max(ans, i+j);
    }

    cout<<ans<<endl;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout<<fixed<<setprecision(9);
    //ll t;
    //cin>>t;
    //while(t--){
    //    solve();
    //}
    solve();
    return 0;
}


Measured memory_bytes: 6364
#include <iostream>
#include <vector>
#include <iomanip>
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
template<class T> inline void chmax(T& a, T b) {if (a<b) a=b; }
using namespace std;
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;

int main() { 
    int N; cin >> N;
    int A[101] = {0};
    int B[N-1];
    REP(i, N-1) cin >> B[i];
    ll ct = 0;

    A[0]=B[0];
    // cout << A[0] << endl;
    ct += B[0];
    for(int i=1; i<N-1; i++) {
        // cout << "i=" << i << endl;
        // cout << "max" << B[i-1] << ", " << A[i-1] << endl;;
        A[i] = min(max(B[i-1], A[i-1]), B[i]);
        // cout << A[i] << endl;
        ct += A[i];
    }
    ct += max(B[N-2], A[N-1]);

    cout << ct << endl;

    
    return 0;
}

Measured memory_bytes: 888
n=int(input())
#a,b=map(int,input().split())
l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

import bisect

l.sort()
ans=0
for i in range(n):
    for j in range(i+1,n):
        a=l[i]
        b=l[j]
        index=bisect.bisect_left(l,a+b)
        ans+=max(index-(j+1),0)
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)
#define digit(N) cout << fixed << setprecision((N))
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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

	int sz = 60;
	vector<vector<int>> next(sz + 1, vector<int>(N, -1));
	for (int i = 0; i < N; i++)
	{
		cin >> a[i];
		a[i]--;
		next[0][i] = a[i];
	}

	for (int k = 0; k < sz; k++)
	{
		for (int i = 0; i < N; i++)
		{
			if (next[k][i] == -1)
				continue;
			next[k + 1][i] = next[k][next[k][i]];
		}
	}

	int ans = 0;

	for (int k = 0; K > 0; k++)
	{
		if (K & 1)
			ans = next[k][ans];
		K >>= 1;
	}

	cout << ans + 1 << "\n";
}

Measured memory_bytes: 52624
#include <iostream>
#include <vector>
using namespace std;
typedef long long llong;

int n, k;
const long MAX = 100000;
long long T[MAX];

int check(llong p){
	int i = 0;
	for (int j = 0; j < k; j++){
		llong s = 0;
		while (s + T[i] <= p){
			s += T[i];
			i++;
			if (i == n) return n;
		}
	}
	return i;
}

int solve(){
	llong left = 0;
	llong right = 100000 * 10000;
	llong mid;
	while (right - left > 1){
		mid = (left + right) / 2;
		int v = check(mid);
		if (v >= n) right = mid;
		else left = mid;
	}
	return right;
}

main(){
	cin >> n >> k;
	for (int i = 0; i < n; i++) cin >> T[i];
	llong ans = solve();
	cout << ans << endl;
}

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

using std::cin;
using std::cout;
using std::endl;
using std::sort;
using std::string;
using std::vector;

int
main()
{
  int N;
  cin >> N;
  vector<string> s(N);
  for (int n = 0; n < N; n++)
  {
    cin >> s[n];
    sort(s[n].begin(), s[n].end());
  }
  sort(s.begin(), s.end());
  long count = 0;
  int top = 0;
  while (top < N)
  {
    int bot = top + 1;
    for (; bot < N && s[top] == s[bot]; bot++)
    {
    }
    int x = bot - top;
    if (1 < x)
    {
      count += (long(x - 1) * x) / 2;
    }
    top = bot;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 7296
#include<iostream>
#include<string>
#include <vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
#define PI 3.141592653589793
using vll = vector<ll>;
using Graph = vii;
const ll MOD = 1e9 + 7;

int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<ll, ll>> p(n);
	rep(i, n) {
		ll a, b;
		cin >> a >> b;
		p[i] = make_pair(a, b);
	}
	vsort(p);
	int cnt = 0;
	ll ans = 0;
	rep(i, n) {
		if (m >= cnt + p[i].second) {
			ans += p[i].first * p[i].second;
			cnt += p[i].second;
		}
		else {
			ans += p[i].first * (m - cnt);
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val x = sc.nextLine.toInt
    println((1 to math.sqrt(x).toInt).map(i => (1 to 10).map(k => math.pow(i, k)).filter(_ <= x).max).max.toInt)
  }
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
ll cal(ll a)
{
    return a * (a - 1) / 2;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    ll a, b;
    cin >> a >> b;
    cout << cal(a) + cal(b);
    return 0;
}


Measured memory_bytes: 256
N=int(input())
N_list=list(map(int,input().split()))
S=int(input())
S_list=list(map(int,input().split()))
def search(target):
    left=-1
    right=N
    while(left<right):
        middle = (left + right) // 2
        mid=N_list[middle]
        if mid==target:
            return True
        if target>mid:
            left=middle+1
            middle =(left + right) // 2
        else:
            right=middle
            middle = (left + right) // 2
    return False
count=0
for s in S_list:
    if search(s):
        count+=1
print(count)


Measured memory_bytes: 16708
from collections import Counter 

a,b = map(int,input().split())
l = ''
for i in range(a):
    t = input()
    l+=t
c = Counter(list(l))
dp = [0,0,0]
for i in c:
    if c[i]%2 ==1:
        dp[0] +=1
    elif c[i]%4 == 0:
        dp[2] += 1
    elif c[i]%2 == 0:
        dp[1] += 1
ans = 'No'
A = 0
if a%2 ==1 and b%2 ==1:
    A = 1
    B = (a+b-2)//2
elif  a%2 ==0 and b%2 ==0:
    B= 0
elif a%2 ==0 and b%2 ==1:
    B = a//2
else:
    B= b//2
if A >= dp[0] and B >= dp[1]:
    ans = 'Yes'
print(ans)


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

int main(){
    int n;cin>>n;int a[n],ans=1000000;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=-100;i<101;i++){
        int sum=0;
        for(int k=0;k<n;k++){
            sum+=pow(i-a[k],2);
        }
        ans=min(ans,sum);
    }
    cout<<ans<<endl;
}

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

int main(){
	int n;
	cin >> n;
	REP(i, n){
		stack<int> a,b,ret;
		string p,q;
		cin>>p>>q;
		REP(j, p.length()) a.push(p[j]-'0');
		REP(j, q.length()) b.push(q[j]-'0');
		int k = 0;
		while(a.size() || b.size() || k){
			int buf = k;
			if (a.size()){
				buf += a.top();
				a.pop();
			}
			if(b.size()){
				buf += b.top();
				b.pop();
			}
			ret.push(buf % 10);
			k = buf / 10;
		}
		if (ret.size() > 80){
			cout<<"overflow"<<endl;
		}
		else{
			while(ret.size()) {
				cout<<ret.top();
				ret.pop();
			}
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
int ar[15];
int main(){
	int n;cin>>n;for(int i=1;i<=n;i++)cin>>ar[i];sort(ar+1,ar+n+1);
  	cout<<accumulate(ar+1,ar+n,0)+ar[n]/2;
}

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

// 型名の省略
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> P;
typedef pair<lint, lint> Plint;
 
const int MOD = 1e9+7;
const int INF = 1<<18;
const lint INFLINT = 1LL<<60;
const double PI=acos(-1.0);
 
// cinとcoutの高速化
#define endl "\n"
struct cinacc{cinacc(){cin.tie(0);ios::sync_with_stdio(false);}}cinaccc;
struct coutacc{coutacc(){cout.setf(ios::fixed);cout.precision(12);}}coutaccc;
 
// 繰り返し
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define reps(i,n) for(lint i=0;i<=(lint)(n);i++)
#define rrep(i,n) for(lint i=(lint)(n)-1;i>0;i--)
#define rreps(i,n) for(lint i=(lint)(n)-1;i>=0;i--)

#define pb push_back

#define ALL(s) (s.begin(), s.end())
#define SZ(s) (s.size())

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

// Union-Find-Tree
class UnionFind {
	vector<int> par;
	UnionFind(int n):par(n){rep(i,n)par[i]=i;}
	int root(int x){if(par[x]==x)return x;return par[x]=root(par[x]);}
	void unite(int x,int y){int rx=root(x);int ry=root(y);if(rx==ry)return;par[rx]=ry;}
	bool same(int x,int y){return root(x)==root(y);}
};

// Final Weapon!
// #define int lint

using Graph = vector<vector<int>>;

int main() {
    int n, m, a, b;
    cin >> n >> m;
    Graph G(n);
    rep(i, m) {
        cin >> a >> b;
        a--; b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    
    vector<int> d(n, -1);
    queue<int> que;
    vector<int> ans(n);
    
    d[0] = 0;
    que.push(0);
    
    while(!que.empty()) {
        int v = que.front();
        que.pop();
        
        for(int nv : G[v]) {
            if(d[nv] != -1) continue;
            ans[nv] = v;
            d[nv] = d[v] + 1;
            que.push(nv);
        }
    }
    
    for(int i = 1; i < n; i++) {
        if(d[i] == -1) {
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    for(int i = 1; i < n; i++) cout << ans[i] + 1 << endl;
    
    return 0;
}


Measured memory_bytes: 10648
#include<bits/stdc++.h>
using namespace std;
int x[105],y[105],h[105];
int main()
{
    int n,pos;
    cin >> n;
    for(int i=1;i<=n;++i)
    {
        cin >> x[i] >> y[i] >> h[i];
        if(h[i])pos = i;
    }

    for(int cx=0;cx<=100;++cx)
    {
        for(int cy=0;cy<=100;++cy)
        {
            int H = h[pos] + abs(x[pos]-cx) + abs(y[pos]-cy);
            bool ok = 1;
            for(int i=1;i<=n;++i)
            {
                if(h[i])
                {
                    if(H!=h[i]+abs(x[i]-cx)+abs(y[i]-cy))
                    {
                        ok = 0;
                        break;
                    }
                }
                else
                {
                    if(abs(x[i]-cx)+abs(y[i]-cy)<H)
                    {
                        ok = 0;
                        break;
                    }
                }
            }
            if(ok)
            {
                cout << cx << ' ' << cy << ' ' << H <<  endl;
                return 0;
            }
        }
    }

    return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

string s;

int main() {
	cin >> s;
	if (s.length()>=4 && s.substr(0,4)=="YAKI") cout << "Yes" << ln;
	else cout << "No" << ln;
}

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

class Word{
public:
  string name;
  int cnt, pos;
  Word(string name, int cnt, int pos):name(name), cnt(cnt), pos(pos){ cnt = 0; pos = 0;}
  bool operator < ( const Word &w ) const{
    //    if ( cnt == w.cnt ) return  pos > w.pos;
    //    return cnt > w.cnt;
    if ( cnt == w.cnt ) return  name < w.name;
  return cnt > w.cnt;
  }
};

main(){
  int n;
  string line, word;
  char ch;
  while(1){
    cin >> n;
    if ( n == 0 ) break;
    getline(cin, line);
    vector<string> tmp;
    map<string, int> post, cntt;
    set<string> buffer;
    vector<Word> W;
    for ( int i = 0; i < n; i++ ){
      getline(cin, line);
      stringstream sin(line);
      while( sin >> word ) {
	tmp.push_back(word);
      }
    }
    cin >> ch;
    
    for ( int i = 0; i < tmp.size(); i++ ){
      if ( tmp[i][0] == ch ) {
	buffer.insert(tmp[i]);
	post[tmp[i]] = i;
	cntt[tmp[i]]++;
      }
    }

    for ( set<string>::iterator it = buffer.begin(); it != buffer.end(); it++ ){
      W.push_back(Word(*it, cntt[*it], post[*it]));
    }

    sort(W.begin(), W.end());
    getline(cin, line);

    if ( W.size() == 0 ){
      cout << "NA" << endl;
    } else {
      for ( int i = 0; i < min(5, (int)W.size()); i++ ) {
	if (i ) cout << " ";
	cout << W[i].name;
      }
      cout << endl;
    }

  }
}

Measured memory_bytes: 1260
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 2*(10**6)+5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
    
K=int(input())
s=input()
S=len(s)

ans=0
for i in range(K+1):
    ans+=(cmb(i+S-1,S-1,mod)*pow(25,i,mod)*pow(26,K-i,mod))%mod
    ans%=mod
print(ans)
    


Measured memory_bytes: 186304
#include<stdio.h>
int main(void)
{
    int N,d[51],Ans=0;
    scanf("%d",&N);
    for(int i=1;i<=N;i++)
    {
        scanf("%d",&d[i]);
    }
    for(int i=1;i<=N;i++)
    {
        for(int j=i+1;j<=N;j++)
        {
            Ans=Ans+d[i]*d[j];
        }
    }
    printf("%d\n",Ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N; cin >> N;
    vec<lint> A_list(N);
    range(i, 0, N) cin >> A_list.at(i);
    lint res = 0;
    range(i, 0, N - 1) {
        lint q = A_list.at(i) / 2;
        res += q;
        A_list.at(i) %= 2;
        if (A_list.at(i) and A_list.at(i + 1)) {
            A_list.at(i) -= 1;
            A_list.at(i + 1) -= 1;
            res += 1;
        }
    }
    res += A_list.at(N - 1) / 2;
    cout << res << "\n";
}

Measured memory_bytes: 1024
require 'pp'

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

A, B, N = gets_i_list

if B <= N
  x = B - 1
  puts (A * x /  B).floor - A * (x / B).floor
else
  x = N
  puts (A * x /  B).floor - A * (x / B).floor
end

Measured memory_bytes: 14520
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=998244353,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

ll mod_pow(ll x,ll n,ll mod){
  if(!n)return 1;
  ll res=mod_pow(x*x%mod,n/2,mod);
  if(n&1)res=res*x%mod;
  return res;
}

void Main() {
  ll n;
  R n;
  ll d[n+1];
  d[0]=1;
  REP(i,1,n+1) d[i]=d[i-1]*2%MAX;
  ll a[n];
  rep(i,n) R a[i];
  ll ans=0;
  rep(i,n) {
    ans+=a[i]*mod_pow(a[i]+1,i,MAX)%MAX*d[n-i-1];
    ans%=MAX;
  }
  pr(ans);
}

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



Measured memory_bytes: 18684
#include <string.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
// #include <unordered_map>
// #include <unordered_set>
#include <utility>
#include <vector>

#define pb push_back
#define mp make_pair

#ifdef ONLINE_JUDGE
#define link renamelink
#define next renamenext
#define prev renameprev
#endif

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef long double ld;

inline void EnableFileIO(const string& fileName, bool local = 0) {
  if (fileName.empty()) return;
  if (local) {
    freopen((fileName + ".in").c_str(), "r", stdin);
    freopen((fileName + ".out").c_str(), "w", stdout);
    return;
  }
#ifdef ONLINE_JUDGE
  freopen((fileName + ".in").c_str(), "r", stdin);
  freopen((fileName + ".out").c_str(), "w", stdout);
#endif
}

const int INF = (1 << 30) - 1;
const LL LINF = (1LL << 61) - 1;
const double EPS = 1e-10, PI = acos(-1);

int n, m;
string s;
map<char, int> ap;

int main() {
  // srand((int)time(0));
  // printf("Hello, world!\n");
  // EnableFileIO("");

  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < m; j++) {
      ap[s[j]]++;
    }
  }
  int c4, c2, c1;

  if ((n & 1) && (m & 1)) {
    c2 = n + m - 1;
    c1 = 1;
  } else if (n & 1) {
    c2 = m;
    c1 = 0;
  } else if (m & 1) {
    c2 = n;
    c1 = 0;
  } else {
    c2 = 0, c1 = 0;
  }
  c4 = n * m - c2 - c1;
  // cout<<c1<<' '<<c2<<' '<<c4<<endl;
  bool ok = 1;
  for (auto it : ap) {
    int k = it.second;
    // cout<<it.first<<' '<<it.second<<endl;
    if (k & 1) {
      if (c1) {
        c1 = 0;
        k--;
      } else {
        ok = 0;
      }
    }
    if(k%4==2) {
      if(c2>=2) {
        c2-=2;
        k-=2;
      } else {
        ok=0;
      }
    }
    if (k % 4 == 0) {
      if (k <= c4) {
        c4 -= k;
      } else {
        k -= c4;
        c4 = 0;
        if (k <= c2) {
          c2 -= k;
        } else {
          ok = 0;
        }
      }
    }
  }
  puts(ok?"Yes":"No");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = (ll)1e18;
const int N = 2e5 + 5;
const ll MOD = 1e9+7;
 
int parent[N];
 
int gcd(int a, int b) { 
    if (a == 0) 
        return b;  
    return gcd(b%a, a);  
} 
   
int lcm(int a, int b) {  
    return (a*b)/gcd(a,b);  
} 
 
ll pow(ll x, ll y, ll p) {
    if(y == 0) return 1;
    ll res = 1;
    x %= p;
    if(x == 0) return 0LL;
    while(y > 0) {
        if(y & 1) res = (res*x) % p;
        y >>= 1;
        x = (x*x) % p;
    }
    return res;
}
 
int find(int x) {
    return x == parent[x] ? x : parent[x] = find(parent[x]);
}
 
void Union(int x, int y) {
    int xPar = find(x), yPar = find(y);
    if(xPar != yPar) parent[xPar] = yPar;
}
 
ll nCr(ll n, ll r) {
    ll res = 1;
    for(ll i=1;i<=r;i++) {
        res = res * (n - r + i) / i;
        // is different from
        // res *= (n -r + i) / i;
    }
    return res;
}
 
int ask(int i, int j) {
    cout << "? " << i + 1 << ' ' << j + 1 << endl;
    int v;
    cin >> v;
    return v;
}

void solve() {
    int n, m;
    cin >> n >> m;
    for(int i=1;i<=n;i++) parent[i] = i;
    for(int i=0;i<m;i++) {
        int a, b;
        cin >> a >> b;
        Union(a, b);
    }
    vector<int> cnt(n + 1);
    int res = 0;
    for(int i=1;i<=n;i++) {
        res = max(res, ++cnt[find(i)]);
    }
    cout << res << endl;
    return;
} 

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


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

using namespace std;

#define RANGE(i, lo, hi) for (int (i) = (lo); (i) < (hi); ++(i))
#define LOOP(i, n) for (int (i) = 0; (i) < int(n); ++i)
#define READALL(v) for (auto &e : (v)) { cin >> e; }
#define PRINTALL(v) for (auto &e : (v)) { cout << e << " "; }
#define ADDEDGE(adj, u, v) {(adj)[(u)].push_back((v));(adj)[(v)].push_back((u));}

template <typename T>
using V = vector<T>;
template <typename T>
using VV = vector<vector<T>>;
template <typename T>
using VVV = vector<vector<vector<T>>>;

int popset(multiset<int> &s) {
	int top = *s.rbegin();
	auto it = s.end();
	--it;
	s.erase(it);
	return top;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N;
	cin >> N;
	multiset<int> A;
	LOOP(i, 3*N) {
		int in;
		cin >> in;
		A.insert(in);
	}
	int64_t sum = 0;
	while (A.size()) {
		int64_t top1 = popset(A), top2 = popset(A);
		int64_t bottom = *A.begin();
		// cout << top1 << " " << top2 << " " << bottom << endl;
		auto it = A.begin();
		A.erase(it);
		sum += top2;
	}
	cout << sum << endl;
}

Measured memory_bytes: 14336