akhauriyash/Code-Regression huggingface dataset:
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using D = double;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_num(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int m, f, b;

int main() {
	cin >> m >> f >> b;
	if (m + f < b) {
		cout << "NA" << endl;
	}
	else {
		cout << max(0, b - m) << endl;
	}
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
int n;
long long a[51],mem[51][51][101];
long long dp(int l,int r,int k)
{
    if(k<0){return INT_MIN;}
    if(k==0 || l>r)return 0;
    long long &ret=mem[l][r][k];
    if(ret!=-1){return ret;}
    long long x=max(dp(l+1,r,k-1)+a[l] , dp(l,r-1,k-1)+a[r]);
    long long y=max(dp(l+1,r,k-2) , dp(l,r-1,k-2));
    return ret=max(x,max(y,(long long)0));

}
int main()
{
    int k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>a[i];
    memset(mem,-1,sizeof mem);
    long long ans=dp(1,n,k);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2304
#include <vector>
#include <iostream>
#include <string>
#include <sstream>      // std::ostringstream
using namespace std;
int main(){
	int n;
	float sum;
	cin >>n;
	for(int i=0; i<n;i++){
		float x;
		string y;
		cin >> x>>y;
		if(y.compare("JPY")==0){
			sum+=x;
		}else{
			sum+=x*380000;
		}
	}
	cout << sum <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	1000000007

ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	while (ll r = a % b)
		a = b, b = r;
	return b;
}

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

	ll modinv(ll a)
	{
		ll b = max, u = 1, v = 0;
		while (b)
		{
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= max;
		if (u < 0)
			u += max;
		return u;
	}

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

struct p
{
	ll a;
	int b;
	int c;
};

int main()
{
	string s;
	cin >> s;
	if (s[0] == s[1] && s[0] == s[2])
		printf("No");
	else printf("Yes");

	return 0;
}


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

int main() {
	int m,x,a[10000];
	cin >> m >> x;
	int min = 999999;
	for(int i=0; i!=m; i++){
		cin >> a[i];
		x = x - a[i];
		if(a[i] < min){
			min = a[i];
		}
	}
	int ans;
	ans = m + x / min;
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please




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


	int N, M, S, T;
	cin >> N >> M >> S >> T;

	vector<pair<int, ll>> A[100001], B[100001];
	rep(i, M) {
		int u, v, a, b;
		cin >> u >> v >> a >> b;
		A[u].pb(mp(v, a));
		A[v].pb(mp(u, a));
		B[u].pb(mp(v, b));
		B[v].pb(mp(u, b));
	}

	ll D1[100001], D2[100001];
	rep(i, N + 1) D1[i] = -1;
	rep(i, N + 1) D2[i] = -1;

	vector<pair<int, ll>> que;
	que.pb(mp(S, 0));
	while (que.size()) {
		vector<pair<int, ll>> que2;		
		for (auto i : que) {
			int p = i.first;
			ll q = i.second;
			if (D1[p] == -1 || D1[p] > q) {
				D1[p] = q;
				for (auto j : A[p]) que2.pb(mp(j.first, j.second + q));
			}
		}
		que = que2;
	}
	que.pb(mp(T, 0));
	while (que.size()) {
		vector<pair<int, ll>> que2;
		for (auto i : que) {
			int p = i.first;
			ll q = i.second;
			if (D2[p] == -1 || D2[p] > q) {
				D2[p] = q;
				for (auto j : B[p]) que2.pb(mp(j.first, j.second + q));
			}
		}
		que = que2;
	}

	ll kotae[100001];
	ll saishou = 1e18;
	for (int i = N - 1; i >= 0; i--) {
		saishou = min(saishou, D1[i + 1] + D2[i + 1]);
		kotae[i] = (ll)1e15 - saishou;
	}
	rep(i, N) co(kotae[i]);

	Would you please return 0;
}

Measured memory_bytes: 57032
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

int N, C;
int D[50][50], c[1000][1000];

signed main(){
    cin >> N >> C;
    REP(i, C) REP(j, C) cin >> D[i][j];
    REP(i, N) REP(j, N) {cin >> c[i][j]; c[i][j]--;}
    map<int, int> mp[3];
    REP(i, N) REP(j, N) mp[(i + j) % 3][c[i][j]]++;
    int ans = INT32_MAX;
    REP(i, C){
        REP(j, C){
            REP(k, C){
                if(i == j || j == k || k == i) continue;
                int cost = 0;
                for(auto p : mp[0]) cost += D[p.first][i] * p.second;
                for(auto p : mp[1]) cost += D[p.first][j] * p.second;
                for(auto p : mp[2]) cost += D[p.first][k] * p.second;
                ans = min(ans, cost);
            }
        }
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 2176
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts("");
#define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");}
#define bitcount(b) __builtin_popcount(b)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)

#define delete(a,n) a.erase(remove(all(a),n),a.end())
template<typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; }
template<typename T> void operator>>(vector<T>& a, int b) {while(b--)if(!a.empty())a.pop_back();}
bool isprime(int n){ if(n<2)return false;  for(int i=2;i*i<=n;i++)if(n%i==0)return false;  return true;} 
ll b_pow(ll x,ll n){return n ? b_pow(x*x,n/2)*(n%2?x:1) : 1ll;}
string itos(int n){stringstream ss;ss << n;return ss.str();}

int dp[101000][2];

#define INF (1<<21)

int x[] = {-10,-1,0,1,-1,0,1,-1,0,1};

int main(){
	string s;
	while(cin >> s && s != "#"){
		rep(i,101000)rep(j,2) dp[i][j] = 9999999;
		dp[0][0] = 0;
		dp[0][1] = 0;
		for(int i = 0 ; i < s.size() ; i++) s[i] -= '0';
		//cout << x[1] << endl;
		for(int i = 1 ; i < s.size() ; i++){
			for(int j = 0 ; j < 2 ; j++){
				for(int k = 0 ; k < 2 ; k++){
					if(j == k){
						dp[i][k] = min(dp[i][k],dp[i-1][j]+1);
					}else{
						if( j == 0 && x[s[i-1]] > x[s[i]] ) continue;
						if( j == 1 && x[s[i-1]] < x[s[i]] ) continue;
						dp[i][k] = min(dp[i][k],dp[i-1][j]);
					}
				}
			}
		}
		cout << min(dp[s.size()-1][0],dp[s.size()-1][1]) << endl;
	}
}

Measured memory_bytes: 1928
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fr(i,j,n)   for(int i=j;i<(n);++i)
#define bk(i,j,n)   for(int i=j;i>=n;--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define MOD 1000000007
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;

#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>

typedef long long  ll;
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}


int main()
{
    run;
    ll n;
    cin>>n;
    ll a[n];
    fr(i,0,n)
    {
        cin>>a[i];

    }
    sort(a,a+n);
    ll ans=INT_MAX;
    fr(i,1,101)
    {
        ll s=0;
        fr(j,0,n)
        {
            s+=(a[j]-i)*(a[j]-i);
                    }
                    if(s<ans)
                    {
                        ans=s;
                    }
    }

    cout<<ans;

    return 0;
}


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

using namespace std;
#define ull unsigned long long
#define ll long long
const double inf = 2e9;
const int MAXN = 2e5 + 10;
ll mod = 998244353;

void solve () {
    string s;
    cin>>s;
    int ans=0;
    int n=s.size();
    for(int i=0;i<n/2;i++) {
        if(i>=n-i-1) break;
        if(s[i]!=s[n-i-1]) ans++;
    }
    cout<<ans;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n=1;
    for(int i=0;i<n;i++) solve();
    return 0;
}

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

/* #pragma */
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int GCD(int a,int b){return b?GCD(b,a%b):a;}
long long GCD(long long a, long long b){return b ? GCD(b, a%b) : a;}
int LCM(int a, int b){return a * b / GCD(a, b);}
long long LCM(long long a, long long b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

//#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

signed main()
{
    int n; cin >> n;
    vector<int> w(n,0);
    for(int i = 0, i_len = (int)n; i < i_len; ++i) cin >> w[i];

    int msa = INF;

    for(int i = 1, i_len = (int)n; i < i_len; ++i){
        int left{};int right{};
        //iまでの和（まずは１番のとき、次に二番までの時）
        for(int j = 0, j_len = (int)i; j < j_len; ++j){
            left += w[j];
        }
        for(int j = i, j_len = (int)n; j < j_len; ++j){
            right += w[j];
        }
        int sa = (int)abs(right - left);
        amin(msa, sa);
    }

    cout << msa << endl;
	return 0;
}








    
/*    vector<int> left(n+1, 0), right(n+1, 0);
    for (int i = 0; i < n; ++i) left[i+1] = left[i] + v[i];
    for (int i = n-1; i >= 0; --i) right[i] = GCD(right[i+1], a[i]);    
*/
//配列をソートしてから後ろ半分を逆ソート
/* 
sort(w.begin(), w.end());
sort(w.begin()+w.size()/2, w.end(), greater<int>());
*/
 /*   vector<int> left(n+1, 0), right(n+1, 0);
    for (int i = 0; i < n; ++i) left[i+1] = left[i] + v[i];
    for (int i = n-1; i >= 0; --i) right[i] = GCD(right[i+1], a[i]);    
*/
/*
sort(w.begin(), w.end());
    int sum1{};
    for(int i = 0, i_len = (n/2)+1; i < i_len; ++i){
        sum1 += w[i*2];
    }
    int sum2{};
    for(int i = 0, i_len = (n/2); i < i_len; ++i){
        sum2 += w[i*2+1];
    }

    if(sum1 - sum2 > 0){
        cout << sum1-sum2;
    }
    else if(sum1 - sum2 < 0){
        cout << sum2 - sum1;
    }
    else cout << 0;
*/
   // cout << (int)abs(sum1, sum2) << endl;


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

int main() {
    int N,M,X;
    cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int>> A(N,vector<int>(M));
    for(int i=0; i<N; i++){
        cin >>C.at(i);
        for(int j=0; j<M; j++){
            cin >> A.at(i).at(j);
        }
    }
    int ans=10000000;
    for(int bit=0; bit<(1<<N); bit++){
        vector<int> total(M);
        int money=0;
        for(int i=0; i<N; i++){
            if(bit & (1<<i)){
                money=money+C.at(i);
                for(int j=0; j<M; j++){
                    total.at(j)+=A.at(i).at(j);
                }
            }
        }
        int cnt=0;
        for(int i=0; i<M; i++){
            if(total.at(i)<X) cnt=1;
        }
        if(cnt==0) ans=min(ans,money);
    }
    if(ans==10000000) ans=-1;
    cout << ans << endl;
    

}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j,o;
  ll res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  string s,t;cin>>s;
  for(i=0;i<s.size();i++){
    if(i%2==0)t.push_back(s[i]);
  }
  cout<<t<<endl;



  return 0;
}

Measured memory_bytes: 512
def solve():
    n = int(input())
    li = [int(_) for _ in input().split()]
    for i in range(n):
        for j in range(i+1, n):
            if abs(li[i]-li[j]) % (n-1) == 0:
                print(str(li[i]) + " " + str(li[j]))
                return

solve()


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

int main() {
    while(1) {
        int H, W;
        cin >> H >> W;
        if (H == 0 && W == 0) {
            break;
        }
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (i == 0 || i == H-1 || j == 0 || j == W-1) {
                    cout << '#';
                } else {
                    cout << '.';
                }
            }
            cout << '\n';
        }
        cout << endl;
    }
    return 0;
}



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

ll f(const vector<ll>& a, ll x) {
	ll ret = 0;
	for (auto t : a)
		ret += x ^ t;
	return ret;
}

int main(int argc, char const *argv[])
{
	int n; ll k; cin >> n >> k;
	vector<ll> a(n); rep(i, n) cin >> a[i];

	ll x = 0; {
		for (int i = 40; i >= 0; --i) {
			if ((x | (1ll << i)) > k)
				continue;

			int cnt = 0;
			rep(j, n) {
				if (a[j] & (1ll << i))
					cnt++;
			}
			// printf("cnt %d\n", cnt);
			if (cnt <= n / 2)
				x |= (1ll << i);
		}
	}
	cout << f(a, x) << endl;
	return 0;
}


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

int main(){
    int n,a;
    cin>>n; 
    int x[n]={0};
    rep(i,n-1)cin>>a,x[a-1]++;
    rep(i,n)cout<<x[i]<<endl;
}


Measured memory_bytes: 4416
//#include <iostream>
//#include <string>
//#include <algorithm>
//#include <vector>
//#include <iomanip>
//#include <cmath>

#include <iostream>

#define PI 3.1415926535897

typedef long long ll;

using namespace std;



int main() {
    double r;
    cin >> r;

    cout << r * 2 * PI;
   

    return 0;
}

Measured memory_bytes: 3804
N, A, B, C, D = [int(i) - 1 for i in input().strip().split(' ')]
N += 1
S = [c for c in input().strip()]
S += '#'


def check(current, dest):
  i = current + 1
  while True:
    if i >= dest:
      return True
    elif S[i] == '.':
      i = i + 1
    elif S[i + 1] == '.':
      i = i + 2
    else:
      return False


def passable():
  i = B
  while True:
    if i > D:
      return False
    elif S[i - 1] == '.' and S[i] == '.' and S[i + 1] == '.':
      return True
    else:
      i = i + 1


def main():
  if D > C:
    return check(B, D) and check(A, C)
  else:
    return passable() and check(A, C)


print('Yes' if main() else 'No')

Measured memory_bytes: 4924
#include<bits/stdc++.h>
#define MOD 1000000007
#define EPS (1e-10)
#define INF 0x3f3f3f3f
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int main() {
	string s; cin >> s;
	int cnt = 0;
	int goo = 0, paa = 0;
	rep(i, s.size()) {
		if (s[i] == 'g') {
			if (paa < goo) {
				paa++;
				cnt++;
			}
			else {
				goo++;
			}
		}
		else {
			if (paa < goo) {
				paa++;
			}
			else {
				goo++;
				cnt--;
			}
		}
	}
	printf("%d\n", cnt);
}

Measured memory_bytes: 512
import kotlin.math.abs

data class Rational(val numerator: Long, val denominator: Long) {
    // 有理数クラス
    // 分子numerator, 分母denominator
    companion object Factory {
        private tailrec fun gcd(a: Long, b: Long): Long =
            when {
                b > a -> gcd(b, a)
                b == 0L -> a
                else -> gcd(b, a % b)
            }

        // 常に分子が正となるようなファクトリ
        fun create(numerator: Long, denominator: Long): Rational {
            val gcd = gcd(abs(numerator), abs(denominator))
            return if (numerator < 0) {
                Rational(numerator * -1L / gcd, denominator * -1L / gcd)
            } else {
                Rational(numerator / gcd, denominator / gcd)
            }
        }
    }
}

fun main() {
    val builder = StringBuilder()

    val mod = 1000000007L

    val n = readInputLine().toInt()

    val pow = LongArray(n + 1)
    pow[0] = 1L

    for (i in 1..n) {
        pow[i] = pow[i - 1] * 2L % mod
    }

    val cnt = mutableMapOf<Rational, Int>()

    var zeroCnt = 0L

    repeat(n) {
        val (a, b) = readInputLine().split(" ").map { it.toLong() }

        if (a == 0L && b == 0L) {
            zeroCnt++
        } else {
            val tmp = when {
                a == 0L -> Rational(0L, 1L)
                b == 0L -> Rational(1L, 0L)
                else -> Rational.create(a, b)
            }
            cnt[tmp] = (cnt[tmp] ?: 0) + 1
        }
    }

    val checked = mutableSetOf<Rational>()

    var ans = 1L

    for ((r, c) in cnt) {
        if (checked.contains(r)) {
            continue
        }
        val other = Rational.create(r.denominator * -1L, r.numerator)

        if (cnt.containsKey(other)) {
            ans = ans * (pow[c] + pow[cnt[other]!!] - 1) % mod
        } else {
            ans = ans * pow[c] % mod
        }

        checked.add(r)
        checked.add(other)
    }

    builder.appendln((ans + zeroCnt + mod - 1L) % mod)

    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 107000
#include <stdio.h>

int main(void) {
  long ret = 0;
  while(1) {
    char c;
    scanf("%c", &c);
    if(c < '0' || c > '9') break;
    c -= '0';
    ret += c;
  }
  printf(ret % 9 == 0 ? "Yes" : "No");
  puts("");
  return 0;
}

Measured memory_bytes: 2084
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i > 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    int N,M,X,ans = INF;
    cin >> N >> M >> X;
    vector<int> C(N);
    int A[N][M];

    rep(i, N){
        cin >> C[i];
        rep(j, M){
            cin >> A[i][j];
        }
    }

    int money;
    bool flag;
    for(int bit = 0; bit < (1 << N); bit++){
        flag = true;
        money = 0;
        vector<int> skill(M);

        rep(i, N){
            if(bit & (1 << i)){
                money += C[i];
                rep(j, M){
                    skill[j] += A[i][j];
                }
            }
        }

        rep(i, M){
            if(skill[i] < X){
                flag = false;
            }
        }

        if(flag){
            ans = min(ans, money);
        }
    }

    if(ans == INF){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 3620
import std.stdio, std.string, std.range, std.algorithm, std.math, std.typecons, std.conv;

long[] weights, values;
long N;
long W;
long w0;
long[][][] memo;
void main() {
  auto inp = readln.split.to!(long[]);
  N = inp[0];
  W = inp[1];
  weights = new long[N];
  values = new long[N];
  foreach (i; 0..N) {
    inp = readln.split.to!(long[]);
    auto w = inp[0], v = inp[1];
    weights[i] = w;
    values[i] = v;
  }
  w0 = weights[0];
  foreach (i; 0..N) {
    weights[i] -= w0;
  }
  memo = new long[][][](N,weights.sum+1,N);
  func(0, 0, 0).writeln;
}

long func(int i, long w, int count) {
  if (i == N) return 0;
  if (memo[i][w][count] > 0) return memo[i][w][count];
  auto cand1 = func(i+1, w, count);
  if (w + weights[i] > W - (count+1) * w0) return memo[i][w][count] = cand1;
  auto cand2 = func(i+1, w + weights[i], count+1) + values[i];
  return memo[i][w][count] = max(cand1, cand2);
}


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

int main()
{
  vector<vector<char>> a(2, vector<char>(3));
  for (int i = 0; i < 2; i++)
  {
    for (int j = 0; j < 3; j++)
      cin >> a[i][j];
  }
  cout << (a[0][0] == a[1][2] && a[0][1] == a[1][1] && a[0][2] == a[1][0] ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
n=int(input());s=input()
for i in range(4):
    a=[i%2,i//2];i=1
    while i<=n:a.append(a[-2]^a[-1]^(s[i%n]=='x'));i+=1
    if a[:2]==a[-2:]:
        for i in range(n):print('SW'[a[i]],end='')
        exit()
print(-1)

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

int main() {


	int N;
	cin >> N;
	vector<int> A;
	int temp;

	for (int i = 0; i < N-1; i++) {
		A.push_back(0);
		cin >> temp;
		A[temp-1]++;
	}

	for (int i = 0; i < N - 1; i++) {
		cout << A[i] << endl;
	}
	cout << 0 << endl;
}


Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a>=0){
        if(d>=0) cout << d*b;
        else{
            cout << a*d;
        }
    }
    else if(b>=0){
        long long int ans = a*c > b*d ? a*c : b*d;
        cout << ans;
    }
    else{ // b < 0
        if(c>=0) cout << c*b;
        else{
            cout << a*c;
        }
    }
    return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ll)(1e9)+7)

int main(){
	int n;
	cin >> n;

	ll cnt[60];
	fill(cnt, cnt+60, 0);
	for(int i=0; i<n; i++){
		ll a;
		cin >> a;
		for(int j=0; j<60; j++){
			if(a&(1ll<<j)) cnt[j]++;
		}
	}

	ll ans=0;
	for(int i=0; i<60; i++){
		ll t=cnt[i]*(n-cnt[i])%mod;
		ans+=t*((1ll<<i)%mod)%mod;
		ans%=mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);//高速化、endlは使わない

  int x1,y1,x2,y2,x3,y3,x4,y4;

  cin >> x1 >> y1 >> x2 >> y2;

  int dx = x2 - x1;
  int dy = y2 - y1;

  x3 = x2 - dy; y3 = y2 + dx;
  x4 = x1 - dy; y4 = y1 + dx;

  cout << x3 << " " << y3 << " " << x4 << " " << y4 << "\n";
}


Measured memory_bytes: 256
#include <cstdio>
#include <stack>
#include <algorithm>

using namespace std;

struct Rectangle{ int height; int pos;};

int func(int size, int buffer[]){
  stack<Rectangle> S;
  int maxv = 0;
  buffer[size] = 0;

  for(int i = 0; i <= size; ++i){
    Rectangle rect;
    rect.height = buffer[i];
    rect.pos = i;
    if(S.empty()){
      S.push(rect);
    }else{
      if(S.top().height < rect.height){
	S.push(rect);
      }else if(S.top().height > rect.height){
	int target = i;
	while(!S.empty() && S.top().height >= rect.height){
	  Rectangle pre = S.top(); S.pop();
	  int area = pre.height * (i - pre.pos);
	  maxv = max(maxv, area);
	  target = pre.pos;
	}
	rect.pos = target;
	S.push(rect);
      }
    }
  }
  return maxv;
}

int main(){
  int H, W, map[501][501], i, j;
  char in[501];
  while(scanf("%d%d", &H, &W) && H && W){
    for(i = 0; i < H; ++i){
      scanf("%s", in);
      for(j = 0; j < W; ++j) map[i][j] = in[j] == '*' ? 0 : 1;
    }

    for(i = 1; i < H; ++i)
      for(j = 0; j < W; ++j)
	if(map[i][j])
	  map[i][j] = map[i - 1][j] + 1;

    int maxv = 0;
    for(i = 0; i < H; ++i)
      maxv = max(maxv, func(W, map[i]));
		  
    printf("%d\n", maxv);   
  }
  return 0;
}

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

#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#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 INF 1000000000
#define ll long long int
#define eps (1e-8)
#define sq(x) ( (x)*(x) )
#define all(x) x.begin(),x.end()
#define flog2(n) 64 - __builtin_clzll(n) - 1
#define popcnt(n) __builtin_popcountll(n)

using namespace std;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

ll st[4 * 200005];
ll h[200005], a[200005];

void update(int id, int l, int r, int u, ll v) {
	if (l == r) {
		st[id] = v;
		return;
	}

	int mid = (l + r) / 2;

	if (u <= mid) update(id * 2, l, mid, u, v);
	else update(id * 2 + 1, mid + 1, r, u, v);

	st[id] = max(st[id * 2], st[id * 2 + 1]);

}

ll getMax(int id, int l, int r, int u, int v) {
	if (v < l || r < u) return 0;

	if (u <= l && r <= v) return st[id];

	int mid = (l + r) / 2;

	return max(getMax(id * 2, l, mid, u, v), getMax(id * 2 + 1, mid + 1, r, u, v));
}

ll d[200005];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    
    int n;
    cin >> n;

    FOR (i, 1, n) {
    	cin >> h[i];
    }
    FOR (i, 1, n) {
    	cin >> a[i];
    }

    d[1] = a[1];
    update(1, 1, n, h[1], d[1]);
    
    ll res = d[1];

    FOR (i, 2, n) {
    	d[i] = getMax(1, 1, n, 1, h[i]) + a[i];	
    	update(1, 1, n, h[i], d[i]);

    	//FOR (j, 1, n) cout << getMax(1, 1, n, j, j) << " "; cout << endl;
    	res = max(res, d[i]);
    }

    cout << res << endl;
    
	
    return 0;
}

Measured memory_bytes: 10496
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n, k;
ll ans;
int a, b, c;
int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt","w",stdout);
    scanf("%d%d%d",&a,&b,&c);
    if(a + b >= c) printf("Yes\n");
    else printf("No\n");
    return 0;
}


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

using namespace std;

#define REP(var, n)  for (int var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<int>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pii;

#define all(c) begin(c),end(c)

#define D(x) do { std::cerr << x << " "; } while (0)
#define D2(x) do { std::cerr << #x << ": " << x << std::endl; } while (0)


template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


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

struct UnionFind {
    vector<int> data;

    UnionFind(int sz) {
        data.assign(sz, -1);
    }

    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return (false);
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int find(int k) {
        if (data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }

    int size(int k) {
        return (-data[find(k)]);
    }
};

auto solve() {
    int N, M;
    cin >> N >> M;
    vector<pii> AB(M);
    for (auto &&e:AB) {
        cin >> e.first >> e.second;
        e.first--;
        e.second--;
    }

    ll size = (ll) N * (N - 1) / 2;
    vll res(M, 0);
    UnionFind uf(N);

    RREP(i, M) {
        res[i] = size;
        if (!uf.same(AB[i].first, AB[i].second)) {
            size -= (ll) uf.size(AB[i].first) * uf.size(AB[i].second);
        }

        uf.unite(AB[i].first, AB[i].second);
    }

    REP(i, M) {
        cout << res[i] << endl;
    }
}


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

//    cout << (solve() ? "Heisei" : "TBD") << endl;
//    cout << (solve() ? "YES" : "NO") << endl;
//    cout << solve() << endl;
    solve();

    return 0;
}

Measured memory_bytes: 3328
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let S: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };
    let K: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };

    let N = S.len();
    let ans = if S.iter().collect::<std::collections::HashSet<_>>().len() == 1 {
        N * K / 2
    } else if S[0] == S[N - 1] {
        let c = S[0];
        let l = (0..N).take_while(|&i| S[i] == c).count();
        let r = (0..N).rev().take_while(|&i| S[i] == c).count();
        let (m, _) = (l..(N - r)).fold((0, '-'), |(res, prev), i| if S[i] == prev { (res + 1, '-') } else { (res, S[i]) });
        l / 2 + m * K + (l + r) / 2 * (K - 1) + r / 2
    } else {
        let (m, _) = (0..N).fold((0, '-'), |(res, prev), i| if S[i] == prev { (res + 1, '-') } else { (res, S[i]) });
        m * K
    };

    println!("{}", ans);
}

Measured memory_bytes: 4352
import java.util.*;
import static java.lang.System.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int rectangle = 0;
		int diamond = 0;
		int a,b,c;
		String[] s = new String[3];
		while (sc.hasNext()) {
			String temp = sc.next();
			s = temp.split(",");
			a = Integer.parseInt(s[0]);
			b = Integer.parseInt(s[1]);
			c = Integer.parseInt(s[2]);
			if (c*c == (a*a)+(b*b)) {rectangle++;}
			else if (a==b) {diamond++;}
		}
		out.println(rectangle+"\n"+diamond);
	}
}


Measured memory_bytes: 26072
#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,K=MI()
    xy=[[0,0] for _ in range(N)]
    y=[0]*N
    
    for i in range(N):
        xy[i][0],xy[i][1]=MI()
        y[i]=xy[i][1]
        
    xy.sort()
    y.sort()
    
    def count(l,r,d,u):
        cnt=0
        for i in range(N):
            if l<=xy[i][0]<=r:
                if d<=xy[i][1]<=u:
                    cnt+=1
        return cnt
    
    ans=10**20
    for i in range(N):
        for j in range(i+1,N):
            for ii in range(N):
                for jj in range(ii+1,N):
                    l=xy[i][0]
                    r=xy[j][0]
                    d=y[ii]
                    u=y[jj]
                    if count(l,r,d,u)==K:
                        ans=min(ans,(r-l)*(u-d))
    print(ans)

main()


Measured memory_bytes: 46812
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){ 
    int a,b,c;
    cin>>a>>b>>c;
    if (b-a == c-b) cout << "YES" << endl;
    else cout << "NO" << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 256
// Why am I so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

int arr[200005];

ll ans;

int n;

void solve() {                   
	scanf("%d", &n);

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

	if (arr[1] != 0) {
		printf("-1\n");
		return;
	}

	for (int i = n, cur = 0; i > 0; --i) {
		if (arr[i] < cur) {
			printf("-1\n");
			return;
		}

		if (arr[i] != cur) {
			ans += arr[i];
			cur = arr[i];
		}

		--cur;
	}
    
    printf("%lld\n", ans);
}

int main() {    
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys


def solve(N: int, W: int, w: "List[int]", v: "List[int]"):

    dp = []
    for _ in range(N):
        l = [0]*(W + 1)
        dp.append(l)
    
    # dp[0][]だけ初期化
    for j in range(W + 1):
        dp[0][j] = v[0] if j >= w[0] else 0

    for i in range(1, N):
        for j in range(W + 1):
            if j >= w[i]:
                dp[i][j] = max(dp[i - 1][j - w[i]] + v[i], dp[i - 1][j])
            else:
                dp[i][j] = dp[i - 1][j]
                
    print(dp[N - 1][W])
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    w = [int()] * (N)  # type: "List[int]"
    v = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        w[i] = int(next(tokens))
        v[i] = int(next(tokens))
    solve(N, W, w, v)

if __name__ == '__main__':
    main()


Measured memory_bytes: 118768
//ALDS1_7_C:Tree Walk
#include <stdio.h>
#define MAX 10000
#define NIL -1
struct Node{int p,l,r;};
struct Node T[MAX];
int n;
/*前序遍?*/
void preParse(int u){
    if(u==NIL)return;
    printf(" %d",u);
    preParse(T[u].l);
    preParse(T[u].r);
}
/*中序遍?*/
void inParse(int u){
    if(u==NIL)return;
    inParse(T[u].l);
    printf(" %d",u);
    inParse(T[u].r);
}
/*后序遍?*/ 
void postParse(int u){
    if(u==NIL)return;
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d",u);
}
int main(){
    int i,v,l,r,root;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        T[i].p=NIL;
    }
    for(i=0;i<n;i++){
        scanf("%d %d %d",&v,&l,&r);
        T[v].l=l;
        T[v].r=r;
        if(l!=NIL)T[l].p=v;
        if(r!=NIL)T[r].p=v;
    }
    for(i=0;i<n;i++)if(T[i].p==NIL)root=i;
    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");
    return 0;
}

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

const int N = 2e5 + 5;
int a[N], pre[N], val[N];
int n, m;
int find(int x) {
    return pre[x] == x ? x : pre[x] = find(pre[x]);
}
int main() {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        pre[i] = i;
        val[i] = 1;
    }
    for (int i = 1; i <= m; i++) {
        int x, y;
        cin >> x >> y;
        int prex = find(x);
        int prey = find(y);
        if (prex == prey) continue;
        pre[prex] = prey;
        val[prey] += val[prex];
    }
    int ans = 1;
    for (int i = 1; i <= n; i++) {
        ans = max(ans, val[find(i)]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 11388
from itertools import permutations
import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    n,l=MI()
    ss=[SI() for _ in range(n)]
    ss.sort()
    print("".join(ss))

main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(int i=m;i<n;i++)
#define OKawaiiKoto ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const ll INF=2*1e18;
const ld PI=3.14159265358979323846;
int main()
{
    OKawaiiKoto
    ll a;
    cin>>a;
    cout<<a+a*a+a*a*a;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
	
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define per(i , j , n) for(ll i = j ; i >= n ; i--)


int main(){
	ll n;
	cin >> n;
	ll x = 100;
	ll i = 0;
	while(x < n){
		x = x + (x/100);
		i++;
	}
	cout << i;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
ll inf = (ll)1e9 + 7;
ll a[900009];
ll sum[20];
int dx[] = { 0,-1,-2,0,-1,-2,0,-1,-2 };
int dy[] = { 0,0,0,-1,-1,-1,-2,-2,-2 };
int main()
{
	ll h, m, n;
	scanf("%lld%lld%lld", &h, &m, &n);
	ll x, y;
	int k = 0;
	ll zo = (h - 2) * (m - 2);
	for (ll i = 1; i <= n; i++) {
		scanf("%lld%lld", &x, &y);
		for (ll j = 0; j < 9; j++) {
			ll xn = x + dx[j], yn = y + dy[j];
			if (xn<1 || xn>h - 2 || yn < 1 || yn>m - 2)continue;
			a[k++] = inf * xn + yn;
		}
	}
	sort(a, a + k);
	ll t = 1;
	for (int i = 0; i < k; i++) {
		if (a[i] == a[i + 1])t++;
		else {
			sum[t]++; t = 1;
			zo--;
		}
	}
	printf("%lld\n", zo);
	for (int i = 1; i <= 9; i++)
		printf("%lld\n", sum[i]);
	return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <cmath>
#include <string>
using namespace std;

int main(){
    int H,W;
    char a[100][100];
    int sum_H=0;
    int sum_W=0;
    cin >> H >> W;
    sum_H = H * '.';
    sum_W = W * '.';
    int skip_H[100] = {0};
    int skip_W[100] = {0};
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> a[i][j];
        }
    }
    int cnt =0;
    for(int i=0;i<H;i++){
        cnt = 0;
        for(int j=0;j<W;j++){
            cnt += a[i][j];
        }
        if(cnt == sum_W){
            skip_H[i] = 1;
        }        
    }
    for(int i=0;i<W;i++){
        cnt = 0;
        for(int j=0;j<H;j++){
            cnt += a[j][i];
        }
        if(cnt == sum_H){
            skip_W[i] = 1;
        }        
    }        
    for(int i=0;i<H;i++){
        if(skip_H[i] == 1){
            continue;
        }
        for(int j=0;j<W;j++){
            if(skip_W[j] == 1){
                continue;
            }
            cout << a[i][j];
        }
        cout << '\n';
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int inf=100000000;
int main(){
	int n,a,b,acount=0,bcount=0;
	cin>>n>>a>>b;
	vector<char> v(n);
	for(int i=0; i<n; i++){
		cin>>v.at(i);
	}
	for(int i=0; i<n; i++){
		bool Student1=false,Student2=false;
		if(v.at(i)=='a'){
			acount++;
			if(acount+bcount<=a+b) Student1=true;
		}
		else if(v.at(i)=='b'){
			bcount++;
			if(bcount<=b&&acount+bcount<=a+b) Student2=true;
			else bcount--;
		}
		if(Student1||Student2) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
ll MOD = 1e9 + 7;

int main() {
    ll n, k; cin >> n >> k;
    ll sum = 0;
    for(int i = k; i <= n + 1; i++){
        sum += (n - i + 1) * i + 1;
        sum %= MOD;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<math.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, x, n) for (int i = x; i < (n); ++i)
using namespace std;


int main() {
    int S, W;
    cin >> S >> W;

    if (S <= W) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
#define INF 100000000
int N,A,B,C;
vector<int> l;
int calc(vector<int> v){
    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    int merge_count = 0;
    for(size_t i = 0; i < v.size(); i++)
    {
        if(v[i]==0){
            a += l[i];
        }
         if(v[i]==1){
            b += l[i];
        }
         if(v[i]==2){
            c += l[i];
        }
        if(v[i]!=3){
            d++;
        }
    }
    merge_count = d - 3;
    if(a!=0 && b!=0 && c!=0){
        return 10 * merge_count + abs(A-a) + abs(B-b) + abs(C-c);
    }
    else{
        return INF;
    }
}

int dfs(int depth, vector<int> v){
    if(depth == N) return calc(v);
    int premin = INF;
    int opt;
    int i = 0;
    for(i=0; i<4; i++){
        v[depth] = i;
        int tmp =  dfs(depth+1,v);
        if(tmp < premin ){
            premin = tmp;
            opt = i;
        }
    }
    v[depth] = opt;
    return dfs(depth+1,v);
}

int main(){
    cin>>N>>A>>B>>C;
    l.resize(N);
    for(int i = 0; i < N; i++)
    {
        cin>>l[i];
    }
    vector<int> v(N);
    cout<<dfs(0,v)<<endl;
}

Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <cmath>         // sqrt
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;
typedef tuple<ll, ll, string> Tlls;

// Greatest Common Divisor (最大公約数)
ll gcd(ll a, ll b)
{
  // Eucledean algorithm
  while (a)
  {
    if (a < b)
    {
      std::swap(a, b);
    }
    a %= b;
  }
  return b;
}

// Least Common Multiple 最小公倍数
ll lcm(ll a, ll b)
{
  return a / gcd(a, b) * b;
}

// key: value of prime factor素因数分解
// value: number of prime factor
map<ll, ll> prime_factorization(ll n)
{
  map<ll, ll> prime_factors;
  for (ll i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      prime_factors[i]++;
      n /= i;
    }
  }
  if (n != 1)
    prime_factors[n] = 1;
  return prime_factors;
}

// 約数リスト約数の列挙
vector<ll> get_divisors(const ll n)
{
  vector<ll> divs;
  for (ll i = 1; i < (ll)sqrt((ld)n) + 1; i++)
  {
    if (n % i == 0)
    {
      divs.push_back(i);
      if (i != n / i)
      {
        divs.push_back(n / i);
      }
    }
  }

  // 必要に応じてソート
  // sort(divs.begin(), divs.end());

  return divs;
}

int main()
{
  ll K, A, B;
  cin >> K >> A >> B;
  rep2(i, A, B + 1)
  {
    if (i % K == 0)
    {
      cout << "OK" << endl;
      return 0;
    }
  }

  cout << "NG" << endl;

  return 0;
}


Measured memory_bytes: 3620
N,Q=map(int,input().split())
S=input()
L = [None]*Q
for i in range(Q):
    L[i] = list(map(int,input().split()))

rui = [0]*(N)
for i in range(1,N):
    rui[i] = rui[i-1] + (1 if S[i-1:i+1] == 'AC' else 0)

for i in range(Q):
    print(rui[L[i][1]-1]-rui[L[i][0]-1])


Measured memory_bytes: 62936
#include<stdio.h>
main(){
  int a,b,c,n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d%d",&a,&b,&c);
    if(a*a+b*b==c*c || b*b+c*c==a*a || a*a+c*c==b*b){
      printf("YES\n");
    }
    else{
      printf("NO\n");
    }
  }
  return 0;
}

Measured memory_bytes: 580