akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e8;
const int Nmax = 1<<20;
int N;
int P[Nmax];
pair<int, int> st[2][2*Nmax];

void init(){
	for(int i=0; i<Nmax; i++){
		st[0][Nmax+i-1] = make_pair(INF, INF);
		st[1][Nmax+i-1] = make_pair(INF, INF);
	}
	for(int i=0; i<N; i++){
		st[i%2][Nmax+i-1] = make_pair(P[i], i);
	}
	for(int i=Nmax-2; i>=0; i--){
		st[0][i] = min(st[0][2*i+1], st[0][2*i+2]);
		st[1][i] = min(st[1][2*i+1], st[1][2*i+2]);
	}
}

pair<int, int> query(bool even, int a, int b, int k, int l, int r){
	int d = even==(a%2==0)?1:0;
	if(a<=l&&r<=b){
		return st[d][k];
	}
	if(b<=l||r<=a){
		return make_pair(INF, INF);
	}
	return min(query(even, a, b, 2*k+1, l, (l+r)/2),
			query(even, a, b, 2*k+2, (l+r)/2, r));
}

int main(){
	cin >> N;
	for(int i=0; i<N; i++) cin >> P[i];

	init();

	priority_queue<pair<int, pair<int, int> >, vector<pair<int, pair<int, int> > >, greater<pair<int, pair<int, int> > > > que;
	que.push(make_pair(query(0, 0, N, 0, 0, Nmax).first, make_pair(0, Nmax)));
	vector<int> ans;
	for(int i=0; i<N/2; i++){
		pair<int, pair<int, int> > a = que.top();
		que.pop();
		pair<int, int> q1 = query(0, a.second.first, a.second.second, 0, 0, Nmax);
		pair<int, int> q2 = query(0, q1.second+1, a.second.second, 0, 0, Nmax);
		que.push(make_pair(query(0, a.second.first, q1.second, 0, 0, Nmax).first,
					make_pair(a.second.first, q1.second)));
		que.push(make_pair(query(0, q1.second+1, q2.second, 0, 0, Nmax).first,
					make_pair(q1.second+1, q2.second)));
		que.push(make_pair(query(0, q2.second+1, a.second.second, 0, 0, Nmax).first,
					make_pair(q2.second+1, a.second.second)));
		ans.push_back(q1.first);
		ans.push_back(q2.first);
	}

	for(int i=0; i<N; i++) cout << ans[i] << (i<N-1?' ':'\n');

	return 0;
}


Measured memory_bytes: 41136
#include<iostream>
#include<cstdio>
using namespace std;
int N;
int X[3000];int Y[3000];
bool F[5000][5000];
int main()
{
	while(true){
		scanf("%d",&N);
		if(N==0)break;
		for(int i=0;i<N;i++){
			scanf("%d%d",&X[i],&Y[i]);
			F[X[i]][Y[i]]=true;
		}
		int ans=0;
		for(int i=0;i<N;i++){
			for(int j=i+1;j<N;j++){
				int x1,y1,x2,y2,x3,y3,x4,y4;
				x1=X[i];y1=Y[i];x2=X[j];y2=Y[j];
				x3=x2+(y2-y1);y3=y2+(x1-x2);
				x4=x3-(x2-x1);y4=y3-(y2-y1);
				if(x3<0||x3>=5000)goto a;
				if(y3<0||y3>=5000)goto a;
				if(x4<0||x4>=5000)goto a;
				if(y4<0||y4>=5000)goto a;
				if(F[x3][y3]&&F[x4][y4])ans=max(ans,(y2-y1)*(y2-y1)+(x2-x1)*(x2-x1));
				a:;
				x3=x2-(y2-y1);y3=y2-(x1-x2);
				x4=x3-(x2-x1);y4=y3-(y2-y1);
				if(x3<0||x3>=5000)goto a1;
				if(y3<0||y3>=5000)goto a1;
				if(x4<0||x4>=5000)goto a1;
				if(y4<0||y4>=5000)goto a1;
				if(F[x3][y3]&&F[x4][y4])ans=max(ans,(y2-y1)*(y2-y1)+(x2-x1)*(x2-x1));
				a1:;
			}
		}
		printf("%d\n",ans);
		for(int i=0;i<N;i++)F[X[i]][Y[i]]=false;
	}
}

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)

int main(){
	int n, k;
	double au = 0; // ぶんし
	double ad = 0; // ぶんぼ

	cin >> n >> k;

	repp(i, n) {
		int u = 0;
		int d = 0;
		int cc = 0; // こいんnじょう
		int ct = i;

		if (i > k) {
			au += (n - i + 1) * ad;
			break;
		}
		while (ct < k) {
			ct *= 2;
			++cc;
		}
		d = pow(2, cc);
		if (i == 1) ad = d;

		au += ad / d;

		cerr << "d:" << d << " u:" << ad / d << " ad:" << ad << endl;
	}

	cerr << au << " " << ad << endl;

	// cout << au / (3.0 * ad) << endl;
	printf("%.16f\n", au / (n * ad));

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner sc = new Scanner(System.in);
		int a[] = new int[2];
		int b[] = new int[2];
		int c[] = new int[2];	
		int d[] = new int[2];

		while(sc.hasNext())
		{
			double le = sc.nextDouble();
			double ri = sc.nextDouble();

			if(le>=1.1 )
				a[0]++;
			else if(le>=0.6 )
				b[0]++;
			else if(le>=0.2 )
				c[0]++;
			else
				d[0]++;

			if(ri>=1.1 )
				a[1]++;
			else if(ri>=0.6 )
				b[1]++;
			else if(ri>=0.2 )
				c[1]++;
			else
				d[1]++;
		}
		System.out.println(a[0]+" "+a[1]);
		System.out.println(b[0]+" "+b[1]);
		System.out.println(c[0]+" "+c[1]);
		System.out.println(d[0]+" "+d[1]);
	}

}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int lli;
#define optimize ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define F first
#define S second
#define forn(i,n) for(int i = 0; i<n; i++)
#define forab(i,a,b) for(int i = a; i<b; i++)
#define forll(i,a,b) for(lli i = a; i<b; i++)
#define mp make_pair
#define pb push_back
#define sortv(v) sort(v.begin(), v.end())
#define debug(x) cout<<#x<<" : "<<x<<endl
#define all(x) x.begin(),x.end()
#define printv(v) for(auto it : v) cout<<it<<" ";cout<<endl;
#define prec(n) fixed<<setprecision(n)
const lli mod = 1000000007;
const int mod2 = 998244353;
const int N = 1e5;


template <typename T>
T power(T base, T exp)
{
    T res = 1;
    while(exp > 0)
    {
        if(exp & 1)
        	res=(res%mod * base%mod)%mod;
        
        base = (base%mod * base%mod)%mod;
        exp >>= 1;
    }
    return res;
}


int main()
{
	optimize

	#ifndef ONLINE_JUDGE
	freopen("inputf.in", "r", stdin);
	freopen("outputf.in", "w", stdout);
	#endif

	int n;
	cin>>n;
	vi d;
	int u,v;
	forn(i,n)
	{
		cin>>u>>v;
		if(u == v)
			d.pb(i);
	}

	int ans = 0;
	if(d.size()>=3)
	{
		for(int i = 1; i<d.size()-1; i++)
		{
			if(d[i-1] == d[i]-1 && d[i]+1 == d[i+1])
				ans = 1;
		}
	}

	if(ans)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 3652
string = list(input())
times = int(input())
for i in range(times):
    order = input().split()
    if order[0] == "print":
        print("".join(string[int(order[1]):int(order[2]) + 1]))
    elif order[0] == "replace":
        string[int(order[1]):int(order[2]) + 1] = order[3]
    else:
        string[int(order[1]):int(order[2]) + 1] = list(reversed(string[int(order[1]):int(order[2]) + 1]))

Measured memory_bytes: 7732
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int n;
  scan(n);
  int r = 0;
  rep (i, n) {
    char tmp;
    scan(tmp);
    if (tmp == 'R') {
      r += 1;
    }
  }
  int b = n - r;
  if (r > b) {
    print("Yes");
  } else {
    print("No");
  }
  return 0;
}


Measured memory_bytes: 888
N = int(input())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
AA = [A[i] ^ A[i-1] for i in range(N)]
BB = [B[i] ^ B[i-1] for i in range(N)]
P = 8128812881288171
K = 8128
invK = pow(K, P-2, P)
KN = pow(K, N, P)

s = 0
for i in range(N):
    s = (s * K + AA[i]) % P

t = 0
for b in BB:
    t = (t * K + b) % P
ans = 0
for i in range(N)[::-1]:
    if t == s:
        j = N - 1 - i
        print(j, A[j] ^ B[0])
    t = (t + BB[i] * (KN - 1)) * invK % P


Measured memory_bytes: 128208
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>

using namespace std;

#define rep(i,n,m) for(int i=n;i<(int)(m);i++)


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

	vector<string>word(n);

	rep(i, 0, n)cin >> word[i];

	vector<vector<int>>spl(n, vector<int>(26, 0));
	vector<int>ans(26, 0);


	rep(i, 0, n) {
		rep(j, 0, (int)word[i].size()) {
			spl[i][word[i][j] - 'a']++;
		}
	}

	rep(i, 0, 26) {
		int cnt = 0;
		while (spl[cnt][i] > 0) {
			spl[cnt][i]--;
			if (cnt == n - 1) {
				ans[i]++;
				cnt = 0;
			}
			else cnt++;

		}
	}

	rep(i, 0, 26) {
		char c = 'a' + i;
		while (ans[i] > 0) {
			cout << c;
			ans[i]--;
		}

	}
	cout << endl;

	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#include <cstring>
#include <queue>

#define unless(c) if (!(c))
#define each(i, c) for (auto& i: c)

using namespace std;

class State {
public:
  int x, y, d, p, cost;

  State() {}
  State(int x, int y, int d, int p, int cost):
    x(x), y(y), d(d), p(p), cost(cost) {}

  bool operator<(const State &st) const {
    return cost > st.cost;
  }
};

char t[32][32];
bool closed[32][32][4][4];
int h, w;
int sx, sy, gx, gy;

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

void solve() {
  priority_queue<State> open;
  memset(closed, 0, sizeof(closed));
  open.push(State(sx, sy, 0, 0, 0));

  while (!open.empty()) {
    State st = open.top();
    open.pop();

    if (closed[st.y][st.x][st.d][st.p]) continue;
    closed[st.y][st.x][st.d][st.p] = true;

    if (st.x == gx && st.y == gy) {
      cout << st.cost << endl;
      return;
    }

    for (int nd = 0; nd < 4; nd++) {
      for (int sumiFlg = 0; sumiFlg < 2; sumiFlg++) {
	int nx = st.x + dx[nd];
	int ny = st.y + dy[nd];

	if (nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
	if (t[ny][nx] == '#') continue;

	if (sumiFlg || nd == st.d && st.p > 0) {
	  int np = sumiFlg ? 2 : st.p - 1;
	  int ncost = st.cost + (sumiFlg ? 3 : 1);
	  open.push(State(nx, ny, nd, np, ncost));
	}
	else if (t[ny][nx] == 'o') {
	  int np = 0;
	  int ncost = st.cost + 1;
	  open.push(State(nx, ny, nd, np, ncost));
	}
	else if (t[ny][nx] == '.') {
	  int np = 0;
	  int ncost = st.cost + 2;
	  open.push(State(nx, ny, nd, np, ncost));
	}
      }
    }
  }

  while(1){}
}

int main(void)
{
  while (cin >> h >> w) {
    for (int i = 0; i < h; i++) {
      cin >> t[i];

      for (int j = 0; j < w; j++) {
	if (t[i][j] == 'S') {
	  t[i][j] = '.';
	  sx = j;
	  sy = i;
	} else if (t[i][j] == 'G') {
	  t[i][j] = '.';
	  gx = j;
	  gy = i;
	}
      }
    }

    solve();
  }

}

Measured memory_bytes: 1308
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

set<char> getChars(string s){
  set<char> temp;
  F0R(i,s.length()){
    temp.insert(s[i]);
  }
  return temp;
}

vl getOccurs(string s, char m){
  vl ans;
  F0R(i,s.length()){
    if(s[i] == m){
      ans.pb(i);
    }
  }
  return ans;
}

set<string> getSmallestK(string s, ll k){
  set<string> ans;
  set<char> lone = getChars(s);
  for (auto it = lone.begin(); it != lone.end(); it++) {
    vl temp = getOccurs(s,*it);
    ans.insert(string(1,*it));
    F0R(i,temp.size()){
      FOR(j,1,k)
        if(temp[i]+j < s.length())
          ans.insert(s.substr(temp[i],j+1));
    }
    if(sz(ans) >= k) return ans;
    else k -=sz(ans);
  }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    string s;
    cin >> s;
    ll k;
    cin >> k;
    set<string> ans = getSmallestK(s,k);
    ll mycount = 1;
    for (auto it = ans.begin(); it != ans.end(); it++) {
      if(mycount == k)
        cout << *it << endl;
      mycount++;
    }
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
int main(){
  int N;
  cin >> N;
  if (N == 3){
    cout << 61 << endl;
  } else {
    vector<vector<vector<vector<vector<long long>>>>> dp(N - 3, vector<vector<vector<vector<long long>>>>(4, vector<vector<vector<long long>>>(4, vector<vector<long long>>(4, vector<long long>(4, 0)))));
    for (int i = 0; i < 4; i++){
      for (int j = 0; j < 4; j++){
        for (int k = 0; k < 4; k++){
          for (int l = 0; l < 4; l++){
            if (!(i == 0 && j == 2 && k == 1)){
              if (!(i == 2 && j == 0 && k == 1)){
                if (!(i == 0 && j == 1 && k == 2)){
                  if (!(j == 0 && k == 2 && l == 1)){
                    if (!(j == 2 && k == 0 && l == 1)){
                      if (!(j == 0 && k == 1 && l == 2)){
                        if (!(i == 0 && k == 2 && l == 1)){
                          if (!(i == 0 && j == 2 && l == 1)){
                            dp[0][i][j][k][l] = 1;
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    for (int i = 0; i < N - 4; i++){
      for (int j = 0; j < 4; j++){
        for (int k = 0; k < 4; k++){
          for (int l = 0; l < 4; l++){
            for (int m = 0; m < 4; m++){
              for (int n = 0; n < 4; n++){
                if (!(k == 0 && l == 2 && m == 1)){
                  if (!(k == 2 && l == 0 && m == 1)){
                    if (!(k == 0 && l == 1 && m == 2)){
                      if (!(l == 0 && m == 2 && n == 1)){
                        if (!(l == 2 && m == 0 && n == 1)){
                          if (!(l == 0 && m == 1 && n == 2)){
                            if (!(k == 0 && m == 2 && n == 1)){
                              if (!(k == 0 && l == 2 && n == 1)){
                                dp[i + 1][k][l][m][n] += dp[i][j][k][l][m];
                                dp[i + 1][k][l][m][n] %= MOD;
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    long long ans = 0;
    for (int i = 0; i < 4; i++){
      for (int j = 0; j < 4; j++){
        for (int k = 0; k < 4; k++){
          for (int l = 0; l < 4; l++){
            ans += dp[N - 4][i][j][k][l];
          }
        }
      }
    }
    ans %= MOD;
    cout << ans << endl;
  }
}

Measured memory_bytes: 4096
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
	int a[5],b[5],c[5][5];
	int d[14];
	int i,j,sum=0;
	for (i=1;i<4;i++) 
	for (j=1;j<4;j++) {
		cin>>c[i][j];
		sum+=c[i][j];
	}
	if (sum%3!=0) cout<<"No"<<endl;
	else 	{
		i=0;
		d[++i]=c[1][1]-c[1][2];d[++i]=c[2][1]-c[2][2];d[++i]=c[3][1]-c[3][2];
		d[++i]=c[1][2]-c[1][3];d[++i]=c[2][2]-c[2][3];d[++i]=c[3][2]-c[3][3];
		d[++i]=c[1][1]-c[2][1];d[++i]=c[1][2]-c[2][2];d[++i]=c[1][3]-c[2][3];
		d[++i]=c[2][1]-c[3][1];d[++i]=c[2][2]-c[3][2];d[++i]=c[2][3]-c[3][3];
		if (d[1]==d[2]&&d[1]==d[3]&&d[4]==d[5]&&d[4]==d[6]&&d[7]==d[8]&&d[7]==d[9]&&d[10]==d[11]&&d[10]==d[12]) 
			cout<<"Yes"<<endl;
		else	cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
def selection_sort(num_list):
    cnt = 0

    for i in range(len(num_list)-1):
        min_idx = i
        for j in range(i,len(num_list)):
            if num_list[j] < num_list[min_idx]:
                min_idx = j
        if i != min_idx:
            num_list[i],num_list[min_idx] = num_list[min_idx],num_list[i]
            cnt += 1
    return cnt

n = int(input())
num_list = list(map(int,input().split()))
ans = selection_sort(num_list)
ans_list = [str(i) for i in num_list]

print(' '.join(ans_list))
print(ans)


Measured memory_bytes: 5604
import numpy as np
N = int(input())
a = []
b = []

a = np.array([int(num) for num in input().split(" ")])
b = np.array([int(num) for num in input().split(" ")])

flag = False
M = sum(b) - sum(a)

a_count = 0
b_count = 0
c = b - a
for i in range(N):
    if c[i] < 0:
        b_count -= c[i]
    if c[i] > 0:
        count = c[i] % 2
        a_count += count
        b_count += count
        a_count += c[i] // 2
        
if M - b_count == (M - a_count) * 2:
        flag = True
if a_count > M or b_count > M:
    flag = False
if flag:
    print("Yes")
else:
    print("No")

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


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    a = int(input())

    return a + a**2 + a**3


if __name__ == "__main__":
    print(main())


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

int main() {
  int n,m;
  cin>>n>>m;
  vector<int> a(n);
  int cnt=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    cnt+=a[i];
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(a[i]*4*m>=cnt)ans++;
  }
  if(ans>=m)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <math.h>
#include <bitset>
#include <queue>

using namespace std;

void solve() {
    int a, b;
    cin >> a >> b;
    vector<string> tmp(2);
    tmp[0] = "";
    tmp[1] = "";
    for(int i = 0; i < b; i++){
        tmp[0] += to_string(a);
    }
    for(int i = 0; i < a; i++){
        tmp[1] += to_string(b);
    }
    sort(tmp.begin(), tmp.end());

    cout << tmp[0];

}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

int a = 0, b = 0;

bool yymm() {
	return (b >= 1 && b <= 12);
}

bool mmyy() {
	return (a >= 1 && a <= 12);
	
}

void solve() {
	for(int i = 0; i < 2; i++) {
		char c;
		cin >> c;
		if(i == 0) a += (c - '0') * 10;
		if(i == 1) a += (c - '0');
	}
	
	
	for(int i = 0; i < 2; i++) {
		char c;
		cin >> c;
		if(i == 0) b += (c - '0') * 10;
		if(i == 1) b += (c - '0');
	}
	
	if(yymm() && mmyy()) cout << "AMBIGUOUS" << endl;
	else if(yymm()) cout << "YYMM" << endl;
	else if(mmyy()) cout << "MMYY" << endl;
	else cout << "NA" << endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n;cin >> n;
    int mmax = 0;
    int sum = 0;
    inc(i, 0, n){
        int p;cin >> p;
        mmax = max(mmax, p);
        sum += p;
    }
    cout << sum-mmax/2 << endl;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  int ans=0;
  
  if(n>=10){
    if(n>=1000){
      if(n>=10000 && n!=100000){
        ans += n-9999;
        ans += 909;
      } else if(n==100000){
        ans = 90909;
      } else {
        ans += 909;
      }
    } else if(n>=100){
      ans += n-99;
      ans += 9;
    } else {
      ans = 9;
    }
  } else {
    ans = n;
  }
  
  cout << ans << endl;
  
}


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

#define rep(i, n) for(int (i) = 0; i < (n); ++(i))

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int N;
  std::cin >> N;

  double sum = 0.0;
  rep(i, N) {
    int a;
    std::cin >> a;
    sum += 1.0 / a;
  }

  std::cout << std::fixed;
  std::cout << std::setprecision(10) << 1.0 / sum << '\n';
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    string S;
    cin >> S;
    
    long long N = S.size();
    long long M = N-1;
    string s;
    long long sum = 0;
    //1 2 5
    // 0 0  125 
    // 0 1  12+5
    // 1 0  1+25
    // 1 1  1+2+5
    for(long long bit = 0; bit < (1<<M);bit++){
        s = "";
        
        for(long long i = 0; i < N; i++){
            
            s += S.substr(i,1);
            
            if(bit & (1<<i)){
                //cout << s << endl;
                if(s!="")sum += stoll(s);    
                s = "";
            }   
            
        }
        //cout <<"a"<< s << endl;
        if(s!="")sum += stoll(s);
        
    }
    
    cout << sum << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[103];
int main(){
	int n, m, p, x;
	int sum=0;
	scanf("%d", &n);
	for(int i=0; i<n; ++i){
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	
	scanf("%d",&m);
	for(int i=0; i<m; ++i){
		scanf("%d %d",&p ,&x);
		if(x<a[p-1]){
			printf("%d\n", sum-(a[p-1]-x));
		}
		else{
			printf("%d\n", sum+(x-a[p-1]));
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
const int maxn = 2e6+100;
using namespace std;
typedef long long ll;
int main()
{
	ll a;
	string b;
	cin>>a>>b;
	ll sum=(ll)(a*(ll)((ll)(b[0]-'0')*100+(ll)(b[2]-'0')*10+(ll)(b[3]-'0')));
	sum/=100;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
//long long int i,j,k,n,m,a,b,c,d,p,q,r,l,t=1;
//long long int sum,counted,ans;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
void sample()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
long long int* read(long long int n)
{
    long long int* arr=new long long int[n];

    for(int i=0;i<n;i++)
        cin>>arr[i];

    return arr;
}

void solve()
{
    long long int n,i,j,k,ans,m,o;

    cin>>n;

    long long int ar[n];

    //long long int* ar=read(n);

    for(i=0;i<n;i++)
    {
        int a,b;
        cin>>a>>b;
        ar[i]=a-b;
        //cout<<ar[i]<<endl;
    }

    for(i=2;i<n;i++)
    {
        if(ar[i]==0 && ar[i-1]==0 && ar[i-2]==0)
        {
            cout<<"Yes"<<endl;
            return;
        }
    }

    cout<<"No"<<endl;



    return;
}





int main()
{
    fast();
    sample();
    long long int i, j, k, n, m, a, b, c, d, p, q, r, l, t = 1;
    long long int sum, count = 0, ans = 0;

    //cin >> t;
    while (t--)
    {
        solve();

    }

    return 0;
}


Measured memory_bytes: 3696
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main(void){
	int n;
	int flag=0;

	scanf("%d",&n);

	int sq=(sqrt((double)n)+1);
	printf("%d:",n);
	while(1){
		if(n<=1){
			break;
		}
		flag=0;
		for(int i=2;i<sq;i++){
			if(n%i==0){
				printf(" %d",i);
				n/=i;
				flag=1;
				break;
			}
		}
		if(flag==0){
			printf(" %d",n);
			break;
		}
	}
	
	printf("\n");

    return 0;
}


Measured memory_bytes: 2108
#include<stdio.h>

int main(){
	int n,p,kouho[50],i,j,flag,q;
	
	while(0<=scanf("%d%d",&n,&p)){
		if(n==0 && p==0){
			break;
		}
		q=p;
		for(i=0;i<50;i++){
			kouho[i]=0;
		}
		flag=0;
		i=0;
		while(flag==0){
			if(p>0){
				kouho[i%n]++;
				p--;
			}else{
				p=kouho[i%n];
				kouho[i%n]=0;
			}
			if(kouho[i]==q){
				break;
			}
			
			i=(i+1)%n;
		}
		
		printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 404
#include<bits/stdc++.h>
using namespace std;
long long n,i,ans;
int main() {
	cin >> n;
	if (n % 2 == 0) {
		n = n / 2;
		while(n >= 5) {
			n /= 5;
			ans += n;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
s=input()


ans=10000
l=len(s)
for x in range(l-2):
    c=abs(753-(int(s[x])*100+int(s[x+1])*10+int(s[x+2])))
    if(x==0):
        ans=c
    elif(ans>c):
        ans=c


        
print(ans)



Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
	public static void main (String args[]) {
		Scanner scan = new Scanner(System.in);
		String c = scan.next();
		String s[] = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
		
		for(int i = 0; i < s.length; i++) {
			if(s[i].equals(c)) {
				System.out.println(s[i+1]);
				return;
			}
		}
	}
}

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

int main() {
    int N, X;
    cin >> N >> X;
    int x[N];
    rep(i, N) {
        cin >> x[i];
        x[i] -= X;
        x[i] = abs(x[i]);
    }
    if (N > 1) {
        int ans = __gcd(x[0], x[1]);
        REP(i, 2, N) {
            ans = __gcd(ans, x[i]);
        }
        cout << ans << endl;
    } else {
        cout << x[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int a,b,c,s;
void f(int i,int n,int d){
  if(d==b){
    if(n==s)c++;
    return;
  }
  for(i++;i<=a;i++){
    if(n+i>s)break;
    f(i,i+n,d+1);
  }
  return;
}
int main(){
  while(scanf("%d %d %d",&a,&b,&s),a||b||s){
    f(c=0,0,0);
    printf("%d\n",c);
  }
  return 0;
}

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

using namespace std;
typedef long long int ll;

#define INF (1e9)

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

    vector<int> x(N), y(N), h(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i] >> h[i];
    }

    int cx, cy;
    for (cx = 0; cx < 101; cx++) {
        for (cy = 0; cy < 101; cy++) {
            int H;
            for (int i = 0; i < N; i++) {
                if (h[i] > 0) {
                    H = abs(x[i] - cx) + abs(y[i] - cy) + h[i];
                    break;
                }
            }

            bool flag = true;
            for (int i = 0; i < N; i++) {
                int h_ = H - abs(x[i] - cx) - abs(y[i] - cy);
                if (h[i] != max(0, h_)) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                cout << cx << ' '
                     << cy << ' '
                     << H << endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2);
        if(y%2==0)
         return (p*p)%hell;
        else
        return (x*((p*p)%hell))%hell;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    ll m=0,c=0;
    ll n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        ll x;
        cin>>x;
        if(x>=m)
        c++;
        m=max(m,x);
    }
    cout<<c;}

Measured memory_bytes: 3640
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;
 
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x) % M;
        x=(x*x)% M;
        n=n/2;
    }
    return result % M;
}

int dp[405][405] = {0};
int tc[405][405] = {0};

signed main()
{
    tezz

    int n;
    cin>>n;
    vi v(n);
    for(int &x:v) cin>>x;

    for(int i=0;i<n;i++) for(int j=0;j<n;j++) {dp[i][j] = MAX, tc[i][j] = MAX;}

    for(int size=0;size<n;size++){
        for(int i=0,j=size;j<n;i++,j++){
            if(i==j) {dp[i][j] = v[i]; tc[i][j] = 0;}
            else if(j-i==1) {dp[i][j] = v[i]+v[j]; tc[i][j] = v[i]+v[j];}
            else{
                for(int k=i;k<j;k++){
                    if(tc[i][j] > tc[i][k] + tc[k+1][j] + dp[i][k] + dp[k+1][j]){
                        dp[i][j] = dp[i][k] + dp[k+1][j];
                        tc[i][j] = tc[i][k] + tc[k+1][j] + dp[i][j];
                        //cout<<i<<' '<<k<<' '<<j<<" ------> "<<tc[i][j]<<endl;
                    }

                    //else cout<<i<<' '<<k<<' '<<j<<"____"<<tc[i][k] + tc[k+1][j] + dp[i][k] + dp[k+1][j]<<endl;

                    /*dp[i][j] = min(dp[i][j], tc[i][k] + tc[k+1][j] + dp[i][k] + dp[k+1][j]);
                    tc[i][j] = dp[i][j];*/
                }
            }
        }
    }
    /*cout<<endl;

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(dp[i][j] == MAX) cout<<0<<' ';
            else cout<<dp[i][j]<<' ';
        }
        cout<<endl;
    }
    cout<<endl;

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(tc[i][j] == MAX) cout<<0<<' ';
            else cout<<tc[i][j]<<' ';
        }
        cout<<endl;
    }*/

    cout<<tc[0][n-1];
}

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

using namespace std;

int main() {
	string S;
	cin >> S;
	int ans = 700;

	if (S[0] == 'o') {
		ans += 100;
	}
	if (S[1] == 'o') {
		ans += 100;
	}
	if (S[2] == 'o') {
		ans += 100;
	}

	cout << ans << endl;

	return 0;
}

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

int main()
{
    string S;
    cin >> S;

    string S_rev = S;
    reverse(S_rev.begin(), S_rev.end());

    string a = S.substr(0, (S.size() - 1) / 2);
    string a_rev = a;
    reverse(a_rev.begin(), a_rev.end());

    string b = S.substr((S.size() + 1) / 2, (S.size() - 1) / 2);
    string b_rev = b;
    reverse(b_rev.begin(), b_rev.end());

    if (S == S_rev && a == a_rev && b == b_rev)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
 
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,cnt[26] = {};
	string s;
	cin >> n;
	for(int i = 0;i < n;i++){
		int c[26] = {};
		cin >> s;
		for(int j = 0;j < s.length();j++){
			c[s[j] - 'a']++;
		}
		for(int j = 0;j < 26;j++){
			cnt[j] = min(cnt[j],c[j]);
			if(i == 0) cnt[j] = c[j];
		}
	}
	for(int i = 0;i < 26;i++){
		for(int j = 0;j < cnt[i];j++) cout << (char)(i + 'a');
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
const int MaxN=410,mod=998244353;
int N,h[MaxN],stk[MaxN],ls[MaxN],rs[MaxN],rt,
	C[MaxN][MaxN],pw2[MaxN],f[MaxN][MaxN],g[MaxN][MaxN][2];
int pw(int a,int n){int b=1;for(;n;n>>=1)n&1?b=1ll*b*a%mod:1,a=1ll*a*a%mod;return b;}
void dfs(int i,int d){
	if(ls[i])dfs(ls[i],h[i]);
	if(rs[i])dfs(rs[i],h[i]);
	for(int j=0;j<=h[i];j++){
		g[i][j][0]=1ll*g[ls[i]][j][0]*g[rs[i]][j][0]%mod*pw2[h[i]-j]%mod;
		g[i][j][1]=1ll*g[ls[i]][j][1]*g[rs[i]][j][1]%mod*(pw2[h[i]-j]-1)%mod;
	}
	for(int j=0;j<=d;j++){
		for(int k=0;k<=h[i]-d;k++){
			int w=(1ll*f[ls[i]][j+k]*(f[rs[i]][j+k]+g[rs[i]][j+k][0])
				+1ll*g[ls[i]][j+k][0]*f[rs[i]][j+k])%mod*pw2[h[i]-j-k]%mod;
			if(k)w=((w+g[i][j+k][0])%mod+mod-g[i][j+k][1])%mod;
			f[i][j]=(f[i][j]+1ll*C[h[i]-d][k]*(k&1?mod-w:w))%mod;
		}
	}
}
int main(){
	scanf("%d",&N);
	int*top=stk;
	for(int i=1;i<=N;i++){
		scanf("%d",h+i);
		int la=0;
		for(;top>stk&&h[*top]>h[i];la=*top--)rs[*top]=la;
		ls[*++top=i]=la;
	}
	for(;top>stk;rt=*top--)rs[*top]=rt;
	for(int i=0;i<=N;i++)
		for(int j=*C[i]=1;j<=i;j++)C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	for(int i=*pw2=1;i<=N;i++)pw2[i]=pw2[i-1]*2%mod;
	for(int i=0;i<=N;i++)g[0][i][0]=g[0][i][1]=1;
	dfs(rt,0);
	printf("%d\n",(f[rt][0]+g[rt][0][0])%mod);
}

Measured memory_bytes: 2816
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))

def main():
    cc = [MII() for _ in range(3)]
    flag = True
    for i in range(2):
        if cc[i][0]-cc[i+1][0] != cc[i][1]-cc[i+1][1]: flag = False
        if cc[i][1]-cc[i+1][1] != cc[i][2]-cc[i+1][2]: flag = False
        if cc[0][i]-cc[0][i+1] != cc[1][i]-cc[1][i+1]: flag = False
        if cc[1][i]-cc[1][i+1] != cc[2][i]-cc[2][i+1]: flag = False
    if flag: print('Yes')
    else: print('No')

if __name__ == '__main__':
    main()


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

int main() {
  int N, M, a;
  cin >> N >> M;
  vector<int> vec(N, 0);
  for(int i=0;i<2*M;i++){
    cin >> a;
    vec.at(a-1)++;
  }
  for(int i=0;i<N;i++){
    cout << vec.at(i) << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if (A+B>C+D) {
    cout << "Left" << endl;
  }
  
  else if (A+B<C+D) {
    cout << "Right" << endl;
  }
  
  else {
    cout << "Balanced" << endl;
  }
  
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

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

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

int main(){
    int N; cin >> N;
    string S; cin >> S;
    bool ok=false;
    if(S.substr(0, N/2) == S.substr(N/2, N)) ok=true;
    cout << (ok ? "Yes":"No") << endl;
    return 0;
}

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

int main() {
    int64_t n, m, k, ans = 0;
    cin >> n >> m >> k;
    vector<int64_t> a(n+1), b(m+1);
    for(int i = 1; i < n + 1; i++){
        cin >> a[i];
    }
    for(int i = 1; i < m + 1; i++){
        cin >> b[i];
    }
    partial_sum(begin(a), end(a), begin(a));
    partial_sum(begin(b), end(b), begin(b));
    for(int64_t i = 0; i < n + 1; i++){
        int64_t l = k - a[i];
        if(l < 0) break;
        int64_t j = upper_bound(begin(b), end(b), l) - begin(b) - 1;
        ans = max(ans, i + j);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    string ans = "APPROVED";
    for(int i=0; i<N; i++){
        if(A[i]%2==0 && (!(A[i]%3==0 || A[i]%5==0))){
            ans = "DENIED";
            break;
        }
    }
    cout << ans << endl;
}

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

public class Main  {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		//int n = sc.nextInt();
		//int k = sc.nextInt();
		//String[] array = new String[h+1];
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		List<Integer> list=new ArrayList<Integer>();

		for(int i=0;n>i;i++) {
			int a=sc.nextInt();
			list.add(a);
		}

		int count=0;
		for(int i=1;n-1>i;i++) {
			int a=list.get(i-1);
			int b=list.get(i);
			int c=list.get(i+1);

			if((b>a&&b<c)||(b<a&&b>c)) {
				count++;
			}
		}

		System.out.println(count);

		}

}



Measured memory_bytes: 23124
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a[4];
	while(cin>>a[0]>>a[1]>>a[2])
	{
		sort(a,a+3);
		if(a[0]+a[1]==a[2])
			cout<<"Yes";
		else
			cout<<"No";
		cout<<endl;
	}
return 0;
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

const int MOD = 1'000'000'007;

// 素因数を列挙
vector<pair<long long, long long>> enumeratePrimeFactors(long long n) {
  vector<pair<long long, long long>> res;
  for (long long a = 2; a * a <= n; a++) {
    if (n % a != 0) {
      continue;
    }
    long long ex = 0; // 指数
    // 割れるだけ割る
    while (n % a == 0) {
      ++ex;
      n /= a;
    }
    res.emplace_back(a, ex);
  }
  // nが一度も割られなかった場合
  if (n != 1) {
    res.emplace_back(n, 1);
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  map<int, int> mp;
  for (int i = 2; i <= n; i++) {
    auto pfs = enumeratePrimeFactors(i);
    for (auto x : pfs) {
      mp[x.first] += x.second;
    }
  }
  ll res = 1;
  for (auto y : mp) {
    res = res * (y.second + 1) % MOD;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

constexpr int MOD = 1000000007;

int mod(const ll &x){
    return x > 0 ? x % MOD : (x+MOD) % MOD;
}

int modm(const ll &x,const ll &m){
    return (x % MOD) * (m % MOD) % MOD;
}

int modpow(ll x, ll p) {
    int ret = 1;
    while(p > 0) {
        if (p & 1) ret = modm(ret,x);
        x = modm(x,x);
        p >>= 1;
    }
    return ret;
}

// x * modinv(d)
int modd(ll x,ll d) {
    return modm(x,modpow(d,MOD-2));
}

int main(void)
{
    IOS
    constexpr int N = 1000;
    vector<int> prime;
    vector<bool> erato(N+5);
    FOR(i,2,N+1) {
        if (erato[i]) continue;
        prime.push_back(i);
        for(int j = 1; i * j <= N; j++) erato[i*j] = true;
    }

    int n; cin >> n;
    vector<int> v(n);
    map<int,int> mp;
    REP(i,n) {
        cin >> v[i];
        map<int,int> tmp;
        int t = v[i];
        for(auto x:prime) {
            if (t == 1 || x * x > v[i]) break;
            while(t % x == 0) {
                tmp[x]++;
                t /= x;
            }
        }
        if (t != 1) tmp[t]++;
        for(auto x:tmp) {
            mp[x.first] = max(mp[x.first],x.second);
        }
    }

    int l = 1;
    for(auto x:mp) {
        l = modm(l,modpow(x.first,x.second));
    }

    int ans = 0;
    REP(i,n) {
        ans = mod(ans + modd(l,v[i]));
    }

    cout << ans << '\n';


    return 0;
}


Measured memory_bytes: 768
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t N;
	std::cin >> N;
	std::string S;
	std::cin >> S;

	std::vector<int64_t> west(N + 1), east(N + 1);
	west[0] = 0;
	east[0] = 0;
	for (int64_t i = 0; i < N; i++)
	{
		if (S[i] == 'W') west[i + 1] = west[i] + 1;
		else west[i + 1] = west[i];
	}
	for (int64_t i = 0; i < N; i++)
	{
		if (S[i] == 'E') east[i + 1] = east[i] + 1;
		else east[i + 1] = east[i];
	}

	int64_t ans = INT64_MAX;
	for (int64_t i = 0; i < N; i++)
	{
		int64_t change = west[i] + (east[N] - east[i + 1]);
		ans = std::min(ans, change);
	}
	std::cout << ans << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


Measured memory_bytes: 8200
#include <bits/stdc++.h>
#define lli long long int
#define vec2 vector<vector<lli>>
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define FRE freopen("explicit.in","r",stdin);freopen("explicit.out","w",stdout)
#define pll pair <lli,lli>
#define vll vector <lli>
#define vpll vector <pll>
#define f first
#define s second
#define pb push_back
#define priq priority_queue
#define unm unordered_map
#define pf push_front
#define minii LLONG_MAX
#define all(x) x.begin(), x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define ld double
#define eb emplace_back
const long double pi = 3.1415926535898;
//const lli mod=1e9+7;
const lli mod=998244353;
using namespace std;
lli lcm (lli a, lli b) {return ((a*b)/__gcd(a,b));}
lli modpower (lli a,lli b)
{
    if(b==0) return 1;
    lli c=modpower(a,b/2)%mod;
    if (b%2) return (((a*c)%mod)*c)%mod;
    else return (c*c)%mod;
}
lli power (lli a,lli b)
{
    if(b==0) return 1;
    lli c=power(a,b/2);
    if (b%2) return (a*c*c);
    else return c*c;
}
bool prime (lli k)
{
    if (k==1||k==0) return 0;
    bool flag=1;
    lli a=sqrt(k);
    for (int i=2;i<=a;i++)
    {
        if (k%i==0)
        {flag=0;break;}
    }
    return flag;
}
lli sieve (int n)
{
    bool qrr[n+1];
    for (int i=0;i<=n;i++)
    qrr[i]=1;qrr[0]=0;qrr[1]=0;
    for (int i=2;i*i<=n;i++)
    {
        if (qrr[i]==1)
        {
            for (int j=2*i;j<=n;j+=i)
            {qrr[j]=0;}
        }
    }
    return 0;
}
lli dp[200005];
lli tree[1000005];
lli update(lli l,lli r,lli k,lli x)
{
    if (l>x||r<x)
    {
        return 0;
    }
    if (l==r)
    {
        tree[k]=dp[x];
        return 0;
    }
    lli mid=(l+r)/2;
    update(l,mid,2*k+1,x);
    update(mid+1,r,2*k+2,x);
    tree[k]=tree[2*k+1]+tree[2*k+2];
    return 0;
}
lli find(lli l,lli r,lli k,lli p,lli q)
{
    //cout<<l<<" "<<r<<"\n";
    if (l>q||r<p)
    {
        //cout<<"0\n";
        return 0;
    }
    if (p<=l&&r<=q)
    {
        //cout<<tree[k]<<"\n";
        return tree[k];
    }
    lli sum=0;
    lli mid=(l+r)/2;
    sum+=find(l,mid,2*k+1,p,q);
    sum+=find(mid+1,r,2*k+2,p,q);
    //cout<<sum<<"\n";
    return sum;
}
int main()
{
    fio;
    lli n,k;
    cin>>n>>k;
    vpll v;
    lli x,y;
    for (int i=0;i<k;i++)
    {
        cin>>x>>y;
        v.pb({x,y});
    }
    dp[1]=1;
    update(1,n,0,1);
    for (int i=2;i<=n;i++)
    {
        x=0;
        for (int j=0;j<v.size();j++)
        {
            lli p,q;
            p=max(i-v[j].f,0LL);
            q=max(i-v[j].s,0LL);
            //cout<<p<<" "<<q<<"\n";
            x+=find(1,n,0,q,p);
            //cout<<x<<"\n";
            x%=mod;
        }
        dp[i]=x;
        //cout<<dp[i]<<"\n";
        update(1,n,0,i);
    }
    cout<<dp[n];
    return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000
//#define int long long int

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;


// Greatest common divisor
template<class T>
T gcd(T x, T y) {
  if(x < y) {
    std::swap(x, y);
  }
  T r = x % y;
  while(r != 0) {
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

// Least common multiple
template<class T>
T lcm(T x, T y) {
  return x/gcd(x,y) * y;
}

inline LL digit(LL n) {
  return to_string(n).size();
}

LL f(LL a, LL b) {
  return max(digit(a), digit(b));
}
  

int main() {
  LL n;
  cin >> n;
  LL r = sqrt(n);
  LL ans = INF;
  for(LL i = 1; i < r+1; ++i) {
    if(n % i != 0) {
      continue;
    }
    //LL da = digit(i);
    //LL db = digit(n/i);
    LL fab = f(i, n/i);
    eprintf("ans,a,b,fab:%lld,%lld,%lld,%lld\n", ans, i, n/i, fab);
    ans = min(ans, fab);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256