akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n, x, c;

    while(true) {
      n = scanner.nextInt();
      x = scanner.nextInt();
      if (n == 0 && x == 0) break;
      c = 0;

      for (int i = 1; i <= n - 2; ++i) {
        for (int j = i + 1; j <= n - 1; ++j) {
          for (int k = j + 1; k <= n; ++k) {
            if (i + j + k == x) ++c;
          }
        }
      }

      System.out.println(c);
    }
  }
}


Measured memory_bytes: 26676
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 1e6 + 10;

int cnt[N];

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	int ans = 0;
	for(int i = 0; i < n; i++) {
		cnt[a[i]]--;
		for(int j = 1; j * j <= a[i]; j++) {
			if(a[i] % j == 0) {
				if(cnt[j] || cnt[a[i] / j]) {
					ans++;
					break;
				}
			}
		}
		cnt[a[i]]++;
	}
	cout << (n - ans);

	return 0;
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int N, M;
int sport[1000], vote[1000];
int score[1000];

int main() {
	scanf("%d %d", &N, &M);
	rep(i, N) scanf("%d", &sport[i]);
	rep(i, M) scanf("%d", &vote[i]);
	rep(i, M) {
		rep(j, N) {
			if(sport[j] <= vote[i]) {
				++score[j];
				break;
			}
		}
	}
	int res = 0;
	int ans;
	rep(i, N) if(res < score[i]) {
		res = score[i];
		ans = i;
	}
	printf("%d\n", ans + 1);
	return 0;
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  string S, T;
  int A, B;
  string U;

  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  
  if(U == S) {
    A--;
  } else {
    B--;
  }

  cout << A << " " << B << endl;

  return 0;
}


Measured memory_bytes: 256
// Problem : F - LIS on Tree
// Contest : AtCoder - AtCoder Beginner Contest 165
// URL : https://atcoder.jp/contests/abc165/tasks/abc165_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define testing 0
#define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
#define DEC(i,s,e) for(ll i = s; i >= (ll)e; --i)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << "\n"
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << "\n"
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"\n"
#define dbv(v) cerr << #v << ":"; for (auto ite : v) cerr << ite << ' '; cerr <<"\n"
#define dbvp(v) cerr << #v << ":"; for (auto ite : v) cerr << "{"  << ite.f << ',' << ite.s << "} "; cerr << "\n"
#define dba(a,ss,ee) cerr << #a << ":"; FOR(ite,ss,ee) cerr << a[ite] << ' '; cerr << "\n"
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "LINE: " << __LINE__ << "\n";
typedef pair <ll, ll> pi;
typedef tuple<ll,ll,ll> ti3;
string cts(char x) {string t(1,x); return t;}
ll rand(ll a, ll b) { return a + rng() % (b-a+1); }
const int MOD = 1e9 + 7;
const int inf = (int)1e9 + 500;
const long long oo = (ll)1e18 + 500;
template <typename T> void chmax(T& a, T b) { a = max(a, b); }
template <typename T> void chmin(T& a, T b) { a = min(a, b); }
const int MAXN = 2e5+5;
#if !testing
#define cerr if(0)cout
#endif

struct node {
	int s,e,m,val;
	node *l, *r;
	node (int _s, int _e) {
		s = _s, e = _e;
		m = (s+e)/2;
		val = 0;
		if (s!=e) {
			l = new node(s,m);
			r = new node(m+1,e);
		} 
	}
	void set(int x, int nval) {
		if(s==e) {
			val=nval;
			return;
		}
		if(x<=m)l->set(x,nval);
		else r->set(x,nval);
		val = max(l->val,r->val);
	}
	int query(int x, int y) {
		//db2(x,y);
		if(s==x&&e==y) {
			return val;
		}
		if(x>m)return r->query(x,y);
		else if(y<=m)return l->query(x,y);
		else return max(l->query(x,m),r->query(m+1,y));
	}
} *seg;
int n, out[MAXN];
vector<int> v;
vector<int>V[MAXN];
stack<int>maxstack;
vector<int>discretize(vector<int> dis) {
	vector<int> vv = dis;
	sort(all(dis));
	dis.resize(unique(all(dis))-dis.begin());
	FOR(i,0,vv.size()-1) {
		vv[i]=lower_bound(all(dis),vv[i]) - dis.begin() + 1;
	}
	return vv;
}

void dfs(int x, int p) {
	//db2(x,p);
	int reset = seg->query(v[x],v[x]);
	//db(reset);
	int val = seg->query(0,v[x]-1) + 1;
	//db(seg->query(1,1));
	out[x] = val;
	if(maxstack.size())out[x] = max(val,maxstack.top());
	maxstack.push(out[x]);
	seg->set(v[x],val);
	for(auto i:V[x]) if(i!=p) {
		dfs(i,x);
	}
	seg->set(v[x],reset);
	maxstack.pop();
}

int32_t main() 
{
	IAMSPEED
	cin >> n;
	seg = new node(0,n);
	FOR(i,0,n-1) {
		int x; cin >> x;
		v.pb(x);
	}
	v=discretize(v);
	dbv(v);
	FOR(i,1,n-1) {
		int x,y; cin >> x >> y;
		--x,--y;
		V[x].pb(y);
		V[y].pb(x);
	}
	dfs(0,-1);
	FOR(i,0,n-1)cout<<out[i]<<'\n';
}



Measured memory_bytes: 69580
s=int(input())
fn=s
l=[int(s)]
m=1
for i in range(2,1000001):
    if fn%2==0:
        if (int(fn/2) in l)==1:  
            m+=1
            break
        else:
            l.append(int(fn/2))
            fn=fn/2
            m+=1
            
    else:
        if (int(fn*3+1) in l)==1:
            m+=1
            break
        else:
            l.append(int(fn*3+1))
            fn=fn*3+1
            m+=1
print(m)

Measured memory_bytes: 3188
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<ll, ll>;
 
#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << #i <<" "<<i<<std::endl;
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;


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

  ll n,m;
  std::cin>>n>>m;

  std::vector<std::vector<bool>> graph(n,std::vector<bool>(n,true));

  rep(i,0,n)graph[i][i]=false;

  rep(i,0,m){
    ll a,b;
    std::cin>>a>>b;
    a--;b--;
    graph[a][b]=false;
    graph[b][a]=false;
  }

  std::vector<P> compo;

  std::vector<ll> color(n,-1);

  rep(i,0,n){
    if(color[i]==-1){
      ll a=0,b=0;

      std::stack<P> que;

      que.push({i,0});

      while(!que.empty()){
        P e=que.top();que.pop();

        if(color[e.first]!=-1)continue;

        color[e.first]=e.second;
        if(e.second==0)a++;
        else b++;

        rep(j,0,n){
          if(graph[e.first][j]){
            if(color[j]==-1){
              que.push({j,e.second^1});
            }else if(!(color[j]^e.second)){
                std::cout<<-1;
                return 0;
              
            }
          }
        }
      }

      compo.push_back({a,b});
    }
  }

  std::vector<std::vector<bool>> dp(compo.size()+1,std::vector<bool>(n+1,false));

  dp[0][0]=true;

  rep(i,0,compo.size()){
    rep(j,0,n+1){
      dp[i+1][j]=((j>=compo[i].first)&&dp[i][j-compo[i].first])|((j>=compo[i].second)&&dp[i][j-compo[i].second]);
    }
  }

  ll ans=LLONG_MAX;

  rep(i,0,n){
    if(dp[compo.size()][i]){
      chmin(ans,(i*(i-1)/2)+((n-i)*(n-i-1)/2));
    }
  }

  std::cout<<ans;

  return 0;
}





Measured memory_bytes: 1280
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;

int main(){
  int N, K, ans = 0, check ;
  cin >> N >> K ;
  int A[N] ;
  for(int i=0;i<N;i++){
    cin >> A[i] ;
  }
  sort(A,A+N) ;
  for(int i=0;i<K;i++){
    ans += A[i] ;
  }

  cout << ans << endl ;
  return 0 ;
}  

Measured memory_bytes: 3592
a, b, c, d = map(int, input().split(" "))

ab_min = min(a, b)
ab_max = max(a, b)
cd_min = min(c, d)
cd_max = max(c, d)

which = []
which.append(ab_max * cd_max)
which.append(ab_max * cd_min)
which.append(ab_min * cd_max)
which.append(ab_min * cd_min)

print(max(which))


Measured memory_bytes: 9148
module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){n(1)(n(2).readFileSync("/dev/stdin","UTF-8"))},function(e,t){e.exports=function(e){var t=e.split("\n"),n=Number(t[0]),r=t[1];n>=3200?console.log(r):console.log("red")}},function(e,t){e.exports=require("fs")}]);

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

int main() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  rep(i, n) {
    cout << s.at(i) << t.at(i);
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const int Inf = 1e9;
const ll INF = 9223372036854775807;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

ll dp[100010][2];
int main() {
    int N,P;
    cin >> N >> P;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    dp[0][0] = 1;
    dp[0][1] = 0;
    for(int i = 0;i < N;i++) {
        if(vec.at(i) % 2 == 0) {
            dp[i + 1][0] = dp[i][0] * 2;
            dp[i + 1][1] = dp[i][1] * 2;
        }
        else {
            dp[i + 1][0] = dp[i][0] + dp[i][1];
            dp[i + 1][1] = dp[i][0] + dp[i][1];
        }
    }
    cout << dp[N][P] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#define INF 1000000000
using namespace std;
int main(){
  int n,k,dp[100001];
  fill(dp,dp+100001,INF);
  cin >> n>> k;
  int h[n];
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  dp[0]=0;
  for(int i=1;i<n;i++){
    for(int j=1;j<=k;j++){
      if(i-j<0)break;
      dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]),dp[i]);
    }
  }
  cout << dp[n-1]<<endl;
}


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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;

lli n,k;
vll a;
vll b;
vll uni;
lli ans = 0;

class bit {
private:
	vll* v;
	lli n;
public:
	bit (lli n) {
		this->v = new vll(n+1);
		this->n = n;
	}
	void add(lli i,lli val){
		for(;i <= n;i += i&-i) this->v->at(i) += val;
	}
	lli sum(lli i){
		lli ret = 0;
		for(;i > 0;i -= i&-i) ret += this->v->at(i);
		return ret;
	}
};


bit* bi;

int main(){
  cin >> n >> k;
  a = vll(n+1);
  b = vll(n+1);
  for(lli i = 1;i <= n;i++) cin >> a[i];
  for(lli i = 1;i <= n;i++) a[i] += a[i-1];
  for(lli i = 0;i <= n;i++) b[i] = a[i]-i*k;
  uni = vll(b);
  sort(uni.begin(),uni.end());
  uni.erase(unique(uni.begin(),uni.end()),uni.end());
  bi = new bit(uni.size());
  for(lli i = 0;i <= n;i++){
    lli x = upper_bound(uni.begin(),uni.end(),b[i])-uni.begin();
    ans += bi->sum(x);
    bi->add(x,1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n, m, c;
    cin >> n >> m >> c;
    int a[n][m], b[m], sum[n];
    for(int i = 0; i < m; i++) cin >> b[i];
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++)
        {
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < n; i++)
    {
        sum[i] = 0;
        for(int j = 0; j < m; j++)
        {
            sum[i] += a[i][j] * b[j];
        }
    }
    int count = 0;
    for(int i = 0; i < n; i++)
    {
        if (sum[i] + c > 0) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
ABCD = input()

ops = ['+', '-']

for i in range(2**3):

    ans = int(ABCD[0])
    op = []
    for j in range(3):
        if ops[i % 2] == '+':
            ans += int(ABCD[j+1])
        else:
            ans -= int(ABCD[j+1])
        op.append(ops[i%2])
        i //= 2

    if ans == 7:
        print(ABCD[0] + op[0] + ABCD[1] + op[1] + ABCD[2] + op[2] + ABCD[3] + '=7')
        break

    
        

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

typedef pair<int, int> node;
typedef vector<node> Adj_list;
typedef vector<Adj_list> Adj_lists;

class less_cost{
public:
  bool operator()(const pair<int, int> lhs, const pair<int, int> rhs) const{
    return lhs.second > rhs.second;
  }
};

int main(){

  int n;
  scanf("%d", &n);

  Adj_lists adj_lists(n);

  // read weigts
  for(int i=0; i<n; i++){
    int u, k;
    scanf("%d %d", &u, &k);
    for(int j=0; j<k; j++){
      int v,c;
      scanf("%d %d", &v, &c);
      adj_lists.at(u).push_back(node(v, c));
    }
  }

  // initialize cost
  vector<int> d(n, INT_MAX);
  d.at(0) = 0;
  priority_queue<node, vector<node>, less_cost> pq;
  pq.push(node(0, d.at(0)));
  vector<bool> is_belong_to_sssp(n, false);

  //dijkstra's algorithm
  while(!pq.empty()){
    // extract node u in V-S that has minimum cost
    const node u = pq.top();
    pq.pop();

    // if u's cost is larger than d[u],
    // than ignore this one
    if(u.second > d.at(u.first)) continue;


    is_belong_to_sssp.at(u.first) = true;

    // update node in V-S and adjacent to u
    for(const node& v : adj_lists.at(u.first)){
      if(!is_belong_to_sssp.at(v.first) && d.at(u.first) + v.second < d.at(v.first)){
        d.at(v.first) = d.at(u.first) + v.second;
        pq.push(node(v.first, d.at(v.first)));
      }
    }
  }

  // output
  for(int i=0; i<n; i++){
    printf("%d %d\n", i, d.at(i));
  }

  return 0;
}



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

using namespace std;

const int Maxn = 1000 + 10;

int A[Maxn][Maxn];
int N, M, a, b;

inline void Check()
{
	if (!a && !b)
	{
		printf("YES\n");
		for (int i = 1; i <= N; ++i)
			for (int j = 1; j <= M; ++j)
			{
				if (!A[i][j]) cout<<".";
				if (A[i][j] == 1) cout<<"<";
				if (A[i][j] == 2) cout<<">";
				if (A[i][j] == 3) cout<<"^";
				if (A[i][j] == 4) cout<<"v";
				if (j == M) puts("");
			}
		puts("");
		exit(0);
	}
}

int main()
{
#ifdef hk_cnyali
	freopen("C.in", "r", stdin);
	freopen("C.out", "w", stdout);
#endif
	int now = clock();
	scanf("%d%d%d%d", &N, &M, &a, &b);

	if (2 * a + 2 * b > N * M)
	{
		puts("NO");
		return 0;
	}

	if (M & 1)
	{
		for (int i = 1; i < N; i += 2)
		{
			if (b) A[i][M] = 3, A[i + 1][M] = 4, b--;
			else break;
		}
	}
	
	if ((N & 1) && (b & 1) && N > 1 && M > 2)
		A[N - 1][M - 2] = 3, A[N][M - 2] = 4, b--;

	for (int i = 1; i < N; i ++)
		for (int j = 1; j <= M; ++j)
			if (b)
			{
				if (!A[i][j] && !A[i + 1][j]) A[i][j] = 3, A[i + 1][j] = 4, b--;
			}
			else break;

	for (int i = 1; i <= N; i ++)
		for (int j = 1; j < M; ++j)
			if (a)
			{
				if (!A[i][j] && !A[i][j + 1]) A[i][j] = 1, A[i][j + 1] = 2, a--;
			}
			else break;

	Check();
	puts("NO");
	return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n, a, b;
    cin >> n >> a >> b;
    if(n > 1 && b >= a || n == 1 && a == b){
    	cout << (n-2) * (b-a) + 1 << endl;
	}
    else cout << 0 << endl; 
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 2 * int(1e5);
int n;
ll a[MAX_N];

void solve() {
    ll b[n];
    REP(i, n) {
        if (i % 2 == 0) b[i / 2] = a[n - 1 - i];
        else b[n - 1 - i / 2] = a[n - 1 - i];
    }
    REP(i, n) printf("%lli ", b[i]);
}

int main() {
    cin >> n;
    REP(i, n) cin >> a[i];
    solve();
    return 0;
}

Measured memory_bytes: 5248
#include<stdio.h>

int main(){
    int p, q, r;
    scanf("%d %d %d", &p, &q, &r);
    int a = p + q;
    int b = q + r;
    int c = r + p;
    int min = a;
    if(b < min){
        min = b;
    }
    if(c < min){
        min = c;
    }
    printf("%d", min);
}

Measured memory_bytes: 128
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as VU
import Data.Char

solve vec t = (fst $ VU.foldl' step (0, 0) $ VU.tail vec) + t
    where
        step (a, b) v
            | b + t < v = (a + t, v)
            | otherwise = (a + a', v)
                where
                    a' = t - ((b + t) - v)

main = do
    [n, t] <- map read . words <$> getLine :: IO [Int]
    ts <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
    print $ solve ts t

Measured memory_bytes: 4988
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
void sort2(vector<pair<ll, ll> >& pairs,ll n){
     // b順にソート
    sort(pairs.begin(),pairs.end(), compare_by_b);
for(ll i=0; i<n; i++){
    
}}


int main()
{
//回答が整数の場合
ll ans=0;
//整数値の入力
ll n,m;
cin >> n>>m;

vector<pair<ll, ll> > pairs(n);

// 入力
for(ll i=0; i<n; i++){
    ll a, b;
    cin >> a >> b;
    pairs[i] = make_pair(b, a);
}
sort2(pairs,n);
ll buy=0;
for(ll i=0; i<n; i++){
   // cout << pairs[i].first << " "<<pairs[i].second <<" "<< buy << " "<<ans<< endl;
    if(buy+pairs[i].first>=m){ans=ans+(pairs[i].second*(m-buy));break;}
    else{ans=ans+(pairs[i].first*pairs[i].second);buy=buy+pairs[i].first;}
}

//回答
cout << ans << endl;
return 0;
}





Measured memory_bytes: 1792
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(map(lambda x: x*(-1), A))
heapq.heapify(A)

for _ in range(M):
    a = ((heapq.heappop(A)*-1)//2)*-1
    if a != 0:
        heapq.heappush(A, a)

    if len(A) == 0:
        break

print(sum(A)*-1)


Measured memory_bytes: 20300
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;

int main(){
    long long x;
    cin >> x;
    long long money = 100;
    int year = 0;
    while(money < x){
        money *= 1.01;
        year++;
    }

    cout << year << endl;
    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
int main(){
    int n,a,b,c,l[20],x[8],ans1=1e9+7;
    cin>>n>>a>>b>>c;
    rep(i,n) cin>>l[i];
    rep(i,pow(4,n)){
        int p=i,A=0,B=0,C=0,m=0,d[3]={0};
        rep(j,n) x[j]=p%4,p=p/4;
        rep(j,n){
            if(x[j]==1){A+=l[j],d[0]++;if(d[0]>1) m+=10;}
            if(x[j]==2){B+=l[j],d[1]++;if(d[1]>1) m+=10;}
            if(x[j]==3){C+=l[j],d[2]++;if(d[2]>1) m+=10;}
        }
        if(A==0||B==0||C==0) continue;
        m+=abs(A-a)+abs(B-b)+abs(C-c);
        if(ans1>m) ans1=m;
    }
    cout<<ans1;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a;
  cin >> a;
  //if(a % 3 == 0){
    cout << a / 3 << "\n";
  //  return 0;
  //}
  //cout << a / 3 
}
  
  
  

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
using namespace std;
int N;
vector <pair <int, int> > G[200005];
int root, Cost[200005], A[200005];
bool ok = 1;
void Read()
{
    cin >> N;
    for(int i = 1; i <= N; i++)
        cin >> A[i];
    for(int i = 1; i < N; i++)
    {
        int x, y;
        cin >> x >> y;
        G[x].push_back(make_pair(y, i));
        G[y].push_back(make_pair(x, i));
        //E[i] = make_pair(x, y);
    }
}
void precalcRoot()
{
    for(int i = 1; i <= N; i++)
    {
        if(G[i].size() >= 2)
        {
            root = i;
            break;
        }
    }
}
void DFS(int node, int father, int e)
{
    int val = A[node];
    if(G[node].size() > 1)
    {
        val *= 2;
    }
    for(int i = 0; i < G[node].size(); i++)
    {
        int neighb = G[node][i].first, edge = G[node][i].second;
        if(neighb == father)
            continue;
        DFS(neighb, node, edge);
        val -= Cost[edge];
    }
    Cost[e] = val;
    if(Cost[e] < 0)
    {
        ok = 0;
        return;
    }
}
void Solve()
{
    DFS(root, 0, 0);
    if(ok == 0)
        return;
    if(Cost[0] != 0)
    {
        ok = 0;
        return;
    }
    for(int i = 1; i <= N; i++)
    {
        if(G[i].size() == 1)
            continue;
        int sum = 0;
        for(int j = 0; j < G[i].size(); j++)
        {
            int neighb = G[i][j].first, edge = G[i][j].second;
            sum += Cost[edge];
        }
        if(sum % 2 == 1)
        {
            ok = 0;
            return;
        }
        for(int j = 0; j < G[i].size(); j++)
        {
            int neighb = G[i][j].first, edge = G[i][j].second;
            if(sum / 2 < Cost[edge])
            {
                ok = 0;
                return;
            }
        }
    }
}
int main()
{
    Read();
    if(N == 2)
    {
        if(A[1] == A[2])
        {
            cout << "YES\n";
            return 0;
        }
        cout << "NO\n";
        return 0;
    }
    precalcRoot();
    Solve();
    if(ok == 0)
    {
        cout << "NO\n";

    }
    else
        cout << "YES\n";
    return 0;
}


Measured memory_bytes: 15488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

char ncolor(char a,char b){
    if(a != 'R' && b != 'R'){
        return 'R';
    }
    else if(a != 'G' && b != 'G'){
        return 'G';
    }
    else{
        return 'B';
    }
}

ll conum(char col){
    if(col == 'R'){
        return 0;
    }
    else if(col == 'G'){
        return 1;
    }
    else{
        return 2;
    }
}

int main(void)
{
    ll n;
    string s;
    cin >> n;
    cin >> s;

    vector<vector<ll>> ccnt(3, vector<ll>(n, 0));

    REP(j,3){
        if(conum(s[0]) == j){
            ccnt[j][0] = 1;
        }
    }

    FOR(i,1,n){
        REP(j,3){
            if(conum(s[i]) == j){
                ccnt[j][i] = ccnt[j][i - 1] + 1;
            }
            else{
                ccnt[j][i] = ccnt[j][i - 1];
            }
        }
    }

    ll ans = 0;

    REP(i,n){
        FOR(j,i+1,n){
            if(s[i] != s[j]){
                char nco = ncolor(s[i], s[j]);
                ll nconum = conum(nco);
                ans += ccnt[nconum][n - 1] - ccnt[nconum][j];
                if(j + j - i < n){
                    if(s[i] != s[j + j - i] && s[j] != s[j + j -i]){
                        ans--;
                    }
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3704
import math

N = int(input())
end = math.floor(math.sqrt(N))

count = float('inf')
for i in range(1, end + 1):
    if N % i == 0:
        b = str(int(N / i))
        a = str(i)
        c = max(len(a), len(b))
        count = min(c, count)
    else:
        count = count
print(count)

Measured memory_bytes: 3060
// -*- coding: utf-8 -*-
//import java.awt.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    InputStream inputStream;
    if (args.length > 0 && args[0].equals("devTesting")) {
      try {
        inputStream = new FileInputStream(args[1]);
      } catch(FileNotFoundException e) {
        throw new RuntimeException(e);
      }
    } else {
      inputStream = System.in;
    }
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    TaskA solver = new TaskA();
    solver.solve(1, in, out);
    out.close();
  }
  
  static class TaskA {    
    int n;
    String s, t;
    
    void solve(int testNumber, InputReader in, PrintWriter out) {
      n = in.nextInt();
      s = in.next();
      t = in.next();
      int ans = n + n;
      for (int k = n; ans == n + n && k >= 1; --k)
        if (s.substring(n - k, n).equals(t.substring(0, k)))
          ans = n + n - k;
      out.println(ans);
    }
    
  }
      
  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream));
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }
    
    public String nextLine() {
      try {
        return reader.readLine();
      } catch(IOException e) {
        throw new RuntimeException(e);
      }
    }

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

    public long nextLong() {
      return Long.parseLong(next());
    }
    
    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public boolean hasInput() {
      try {
        if (tokenizer != null && tokenizer.hasMoreTokens()) {
          return true;
        }
        reader.mark(1);
        int ch = reader.read();
        if (ch != -1) {
          reader.reset();
          return true;
        }
        return false;
      } catch(IOException e) {
        throw new RuntimeException(e);
      }
    }
    
  }
}


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

#define int long long
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359
/*

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace __gnu_pbds;
typedef tree<pii,null_type,less <pii>,rb_tree_tag,tree_order_statistics_node_update>ind_set;
*/
///*X.find_by_order("index")
///X.order_of_key("key")



#define deb(x) cerr<<#x<< " : " <<x<<"\n";
#ifndef local
	#define deb(x) ;
#endif
///----------------------------------------------------------------------------------


map<char,int> M;
void solve()
{
	string a;cin>>a;
	for(char x:a)M[x]++;
	if (M.size()!=2 || (M.begin()->ss)!=2)cout<<"No";
	else cout<<"Yes";

}

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);

    #ifdef local
    ///freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    clock_t qwertyuiop = clock();
    #endif


    int t=1;
    //cin>>t;
    
    rep(a,0,t)
    {
        ///cout<<"Case #"<<a+1<<": ";
        solve();
    }
    #ifdef local
	{qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define	int ll
typedef vector<int> vi;
typedef pair<int,int> pii;

signed main(void) {
  int i,j;
  int p,q;
  cin>>p>>q;
  q=q/__gcd(p,q);
  ll ans=1;
  for(i=2;i*i<=q;i++)if(q%i==0){
      ans*=i;
      while(q%i==0)q/=i;
    }
  cout<<ans*q<<endl;
}

Measured memory_bytes: 3076
/* Selection Sort */

#include <stdio.h>

int main(void)
{
    int N;
    scanf("%d", &N);

    int i;
    int A[N];
    for (i = 0; i < N; i++)
        scanf("%d", &A[i]);

    int j, cnt = 0;
    for(i = 0; i < N - 1; i++) {
        int min_i = i;
        for (j = i + 1; j < N; j++) {
            if (A[j] < A[min_i])
                min_i = j;
        }
        if (min_i != i) {
            int temp = A[i];
            A[i] = A[min_i];
            A[min_i] = temp;
            cnt++;
        }
    }

    for (i = 0; i < N - 1; i++)
        printf("%d ", A[i]);
    printf("%d\n", A[N - 1]);

    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 600
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

int n;
string s;

char shift(char a)
{
	int t = a - 'A';

	t = (t+n) % 26;

	return 'A' + t;
}

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n >> s;	

	for (int i = 0; i < s.size(); ++i)
		cout << shift(s[i]);
}

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

int main()
{
    ll n;
    cin >> n;
    ll count = 0;
    ll i = 1;
    if (n % 2 == 0)
    {
        while (n >= (pow(5, i) * 2))
        {
            count += n / (ll)((pow(5, i) * 2));
            i++;
        }

        cout << count << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}

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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> mii;
typedef map<ll,int> mli;

///*********************************** C o n s t ***********************************///

int const N=1e6+3;
const double PI = acos(-1);
const ll MOD=1000000007;  ///1e9+7

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}

///************************************************ C o d e ************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///



void _case()
{
    ll n;
    cin>>n;
    cout<<n+n*n+n*n*n el;

}

main()
{
///    test
///    while(1)
        _case();

}


///Thank you.


///Brainless_Loco Terminates Here!



Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

bool reach[MAX_N];
vector<int> edge[MAX_N];

void dfs(int now){ //連結成分の数を数える
    if(reach[now]) return;
    reach[now]=true;
    rep(i,edge[now].size()) dfs(edge[now][i]);
}

int main(void){
    int N;
    cin >> N;
    int A[N+1],B[N+1];
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];
    A[N]=0,B[N]=0;
    rep(i,N) A[N]=A[N]^A[i],B[N]=B[N]^B[i];
    multiset<int> a,b;
    rep(i,N+1) a.insert(A[i]),b.insert(B[i]);
    if(a!=b){
        cout << -1 << endl;
        return 0;
    }
    int ans=N;
    if(A[N]!=B[N]){ //XORが異なる場合
        ans++;
        rep(i,N) if(A[i]!=B[i] && A[N]==B[i]){ //XORを等しくしておく　操作1回分
            swap(A[i],A[N]);
            break;
        }
    }
    rep(i,N) if(A[i]!=B[i] && A[N]==B[i]){ //XORが目標の数列にあるかつ元々揃ってない場合1回少なくて済む
        ans--;
        break;
    }
    map<int,int> V;
    pint P[N+1];
    rep(i,N+1) P[i].fi=A[i],P[i].se=i;
    sort(P,P+N+1);
    rep(i,N+1) V[A[i]]=i;
    rep(i,N+1){
        if(A[i]==B[i] &i!=N) ans--; //元から揃ってるところは使わない
        else{
            edge[V[A[i]]].push_back(V[B[i]]);
            edge[V[B[i]]].push_back(V[A[i]]);
        }
    }
    rep(i,N) if(P[i].fi==P[i+1].fi){ //同じ数字は同じ連結成分
        edge[P[i].se].push_back(P[i+1].se);
        edge[P[i+1].se].push_back(P[i].se);
    }
    rep(i,N+1) if(!reach[i]) if(A[i]!=B[i]) dfs(i),ans++;
    cout << ans << endl;
}

Measured memory_bytes: 26624
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,a,p=0;
    cin>>N;
    for(int i=0;;i++){
        if(N<i*i){
            break;
        }
        p++;
    }
    a=(p-1)*(p-1);
    cout<<a<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long ;
int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    ll k;
    cin>>k;
    for(;;)
    {
    if(max(a,b)>=c)c*=2,k--;
    if(a>=b)b*=2,k--;
    if(a<b&&b<c)break;
    //cout<<a<<' '<<b<<' '<<c<<endl;
    }
    if(k>=0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


}
///6+10+3+10+9+15+3


Measured memory_bytes: 3632
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read() for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N = read_a_int()
A = read_col(5, 1)[0]

# 一番小さい人数のところがボトルネック

key = min(A)

if N % key == 0:
    print(N//key+4)
else:
    print(N // key + 5)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

static const long N = 1000;

long lcs(string X, string Y){
	long c[N + 1][N + 1];
	long m = X.size();
	long n = Y.size();
	long maxl = 0;
	X = ' ' + X;
	Y = ' ' + Y;
	for (long i = 1; i <= m; i++) c[i][0] = 0;
	for (long j = 1; j <= n; j++) c[0][j] = 0;

	for (long i = 1; i <= m; i++){
		for (long j = 1; j <= n; j++){
			if (X[i] == Y[j]){
				c[i][j] = c[i - 1][j - 1] + 1;
			}
			else {
				c[i][j] = max(c[i - 1][j], c[i][j - 1]);
			}
			maxl = c[i][j];
		}
	}

	return maxl;
}

int main(){
	string s1, s2;
	long n;
	cin >> n;
	for (long i = 0; i < n; i++){
		cin >> s1 >> s2;
		cout << lcs(s1, s2) << endl;
	}
	return 0;
}

Measured memory_bytes: 9044
import java.io.*; 
import java.math.*;
import java.util.*;
 
public class Main {
	static final long MOD = 998244353;
	//static final long MOD = 1000000007;
	static boolean[] visited;
    public static void main(String[] args) throws IOException {
        FastScanner sc = new FastScanner();
        int N = sc.nextInt();
        double money = 0;
        for (int i = 0; i < N; i++) {
        	double amt = sc.nextDouble();
        	String type = sc.next();
        	if (type.equals("JPY")) {
        		money += amt;
        	} else {
        		money += (380000.0)*amt;
        	}
        }
        System.out.println(money);
    }
    
    public static int[][] sort(int[][] array) {
    	//Sort an array (immune to quicksort TLE)
		Random rgen = new Random();
		for (int i = 0; i< array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    int[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		Arrays.sort(array, new Comparator<int[]>() {
			  @Override
			  public int compare(int[] arr1, int[] arr2) {
				  //Ascending order
				  if (arr1[0] != arr2[0])
					  return arr1[0]-arr2[0];
				  else
					  return arr2[1]-arr1[1];
			  }
		});
		return array;
	}
    
    static class FastScanner { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try { 
                str = br.readLine(); 
            } catch (IOException e) {
                e.printStackTrace(); 
            } 
            return str; 
        }
    }
}

class Node {
	public HashSet<Node> children;
	public int n;
	
	public Node(int n) {
		this.n = n;
		children = new HashSet<Node>();
	}
	
	public void addChild(Node node) {
		children.add(node);
	}
	
	public void removeChild(Node node) {
		children.remove(node);
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		return n;
	}

	@Override
	public boolean equals(Object obj) {
		if (! (obj instanceof Node)) {
			return false;
		} else {
			Node node = (Node) obj;
			return (n == node.n);
		}
	}
	
	public String toString() {
		return (this.n+1)+"";
	}
}

Measured memory_bytes: 20564
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=41 ;
int main()
{
   fast ;
   ll n,w ;
   cin>>n>>w ;
   ll a[n],b[n] ;
   for(ll i=0;i<n;i++)
    cin>>a[i]>>b[i] ;

   vector<ll>v1,v2,v3,v4 ;
   for(ll i=0;i<n;i++)
   {
       if(a[i]==a[0])
       {
           v1.pb(b[i]) ;
       }
       else if(a[i]==a[0]+1)
       {
           v2.pb(b[i]) ;

       }
       else if(a[i]==a[0]+2)
        v3.pb(b[i]) ;
        else
            v4.pb(b[i]) ;
   }
   sort(all(v1)) ;
   sort(all(v2)) ;
   sort(all(v3)) ;
   sort(all(v4)) ;
   reverse(all(v1)) ;
   reverse(all(v2)) ;
   reverse(all(v3)) ;
   reverse(all(v4)) ;

   ll s1[n+1],s2[n+1],s3[n+1],s4[n+1] ;
   memset(s1,0,sizeof(s1)) ;
   memset(s2,0,sizeof(s2)) ;
   memset(s3,0,sizeof(s3)) ;
   memset(s4,0,sizeof(s4)) ;
   for(ll i=1;i<=n;i++)
   {
       if(i-1<v1.size())
       s1[i]=s1[i-1]+v1[i-1] ;
       if(i-1<v2.size())
       s2[i]=s2[i-1]+v2[i-1] ;
       if(i-1<v3.size())
       s3[i]=s3[i-1]+v3[i-1] ;
       if(i-1<v4.size())
       s4[i]=s4[i-1]+v4[i-1] ;
   }
   ll ans=INT_MIN ;

   for(ll i=0;i<=v1.size();i++)
   {
       for(ll j=0;j<=v2.size();j++)
       {
           for(ll k=0;k<=v3.size();k++)
           {
               ll o=i*a[0]+j*(a[0]+1)+k*(a[0]+2) ;
               if(o>w)
                continue ;

               ll l=(w-o)/(a[0]+3) ;

               ans=max(ans,s1[i]+s2[j]+s3[k]+s4[l]) ;


           }
       }
   }

   cout<<ans ;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define add push_back
#define f first
#define s second
#define pw(x) (1ll << (x))
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
const ll INF = (ll)1e9 + 2019;

void mane() {
	string s;
	cin >> s;
	vector <char> st;
	for (char c : s) {
		if (c == 'S') {
			st.add(c);
		} else {
			if (sz(st) && st.back() == 'S') {
				st.pop_back();
			} else {
				st.add(c);
			}
		}
	}
	cout << sz(st);
}

int32_t main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	mane();
#ifdef flaax
	cout << endl; cerr << endl << "\t" << fixed << setprecision(12) << (ld)clock() / CLOCKS_PER_SEC << " sec" << endl;
#endif
}

Measured memory_bytes: 788
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;
vector<ll> sosu;

void generate_sosu(ll max){
    reps(index, 2, max+1){
        bool divided=false;
        rep(j, sosu.size()){
            if(index%sosu[j]==0){
                divided=true;
                continue;
            }
        }
        if(divided==false) sosu.push_back(index);
        //cout<<index<<endl;
    }
}



int main(void){
    ll N, A;
    cin>>N;
    ll kosu[1000001];
    MEMSET(kosu, 0);
    bool pairw=true, setw=true;
    generate_sosu(1001);
    rep(i, N){
        cin>>A;
        rep(j, sosu.size()){
            if(A==1) break;
            if(A<sosu[j]*sosu[j]){
                kosu[A]+=1;
                break;
            }
            ll tat=0;
            while(A%sosu[j]==0){
                A/=sosu[j];
                tat=1;
                
            }
            kosu[sosu[j]]+=tat;
        }
        //cout<<kosu[2]<<sp<<kosu[3]<<sp<<kosu[5]<<endl;
    }
    reps(i, 2, 1000001){
        if(kosu[i]>=2) pairw=false;
        if(kosu[i]==N) setw=false;
    }
    if(pairw) cout<<"pairwise coprime"<<endl;
    else if(setw) cout<<"setwise coprime"<<endl;
    else cout<<"not coprime"<<endl;
    return 0;
}


Measured memory_bytes: 11452
n = int(input())
sa = []
for i in range(n):
  a,b = list(map(int, input().split()))
  if ( a > b ):
    print('No')
    exit()    
  sa.append({'a': a, 'b': b})

sa.sort(key=lambda x: x['b'])

aa = 0
for i in range(n):
  aa = aa + sa[i]['a']
  if (aa > sa[i]['b']):
    print('No')
    exit()

print('Yes')



Measured memory_bytes: 72188