akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int INF = 1e9;
int n, rt = -1;
char s[maxn];
vector<int> G[maxn], E[maxn];
bool has[maxn], a[maxn];
int fa[maxn], dp[maxn][2];
int ans, sum;
void reGraph(int x)
{
	has[x] = a[x];
	for(auto v : G[x])
		if(v != fa[x])
		{
			fa[v] = x;
			reGraph(v);
			has[x] |= has[v];
		}
	if(has[x])
		E[fa[x]].push_back(x);
}
void init(int x)
{
	a[x] ^= (E[x].size() + (x != rt)) & 1;
	sum += a[x];
}
void dfs(int x)
{
	init(x);
	for(auto v : E[x])
	{
		dfs(v);
		sum += 2;
		ans = max(ans, max(dp[v][0] + 2 * a[x] + dp[x][1], dp[v][1] + 2 * a[v] + dp[x][0]));
		dp[x][0] = max(dp[x][0], dp[v][0] + 2 * a[x]);
		dp[x][1] = max(dp[x][1], dp[v][1] + 2 * a[v]);
	}
}
int main()
{
	scanf("%d", &n);
	for(int i = 1; i < n; ++i)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
	scanf("%s", s + 1);
	for(int i = 1; i <= n; ++i)
	{
		a[i] = s[i] == 'B' ? 0 : 1; 
		if(a[i]) rt = i; 
	}
	if(rt == -1)
	{
		puts("0");
		return 0;
	}
	reGraph(rt);
	dfs(rt);
	printf("%d\n", sum - ans);
	return 0;
}

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

ll sum(ll n){
    return ((n + 1)*n)/2;
}
int main() {
    ll n, k, mod = 1e9 + 7, ans = 0;
    cin >> n >> k;
    ll lb = sum(k), ub = 0;
    for(int i = k; i <= n + 1; i++){
        ans += sum(n) - sum(n - i) - sum(i - 1) + 1;
		ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <string>
#include <stdio.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
using namespace std;

int main(void) {
    long long int N, M;
    cin>>N>>M;

    if((N==1)&&(M==1)){
      cout<<1<<endl;
      return 0;
    }
    if((M==1)&&(N>=2)){
      cout<<N-2<<endl;
        return 0;
    }
    if((N==1)&&(M>=2)){
      cout<<M-2<<endl;
        return 0;
    }
  if((N>=2)&&(M>=2)){
      cout<<(N-2)*(M-2)<<endl;
  return 0;
    }
    return 0;
}


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

int q;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin >> q;
	while(q){
		long long a, b, r, e;
		cin >> a >> b;
      
		e = 1LL * a * b;
		r = sqrt(e);

		cout << 2 * r - (1 + ((1LL * r * r == e && r != a) + (1LL * r * (r + 1) >= e))) << '\n';
		q--;
	}	
}


Measured memory_bytes: 384
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  ll H,W,m;
  cin >> H >> W >> m;
  vector<ll> h(m),w(m);
  vector<vector<ll>> hp(H),wp(W);
  vector<P> hlst;
  set<P> st;
  for(int i=0;i<m;i++){
    cin >> h[i] >> w[i];
    h[i]--;
    w[i]--;
    hp[h[i]].push_back(i);
    wp[w[i]].push_back(i);
    st.insert(P(h[i],w[i]));
  }
  ll ans = 1;
  for(int i=0;i<H;i++){
    hlst.push_back(P(hp[i].size(),i));
  }
  sort(hlst.begin(),hlst.end(),greater<>());
  ll k = min((ll)4,(ll)hlst.size());
  for(int i=0;i<W;i++){
    ll base = wp[i].size();
    if(base+hlst[0].first<=ans) continue;
    for(int j=0;j<k;j++){
      ll tmp = base + hlst[j].first;
      if(st.find(P(hlst[j].second,i))!=st.end()){
        tmp--;
      }
      ans = max(ans,tmp);
    }
  }
  k = hlst.size();
  for(int i=0;i<W;i++){
    ll base = wp[i].size();
    if(base+hlst[0].first<=ans) continue;
    for(int j=0;j<k;j++){
      ll tmp = base + hlst[j].first;
      if(tmp<ans) break;
      if(st.find(P(hlst[j].second,i))!=st.end()){
        tmp--;
      }
      ans = max(ans,tmp);
    }
  }
  cout << ans << endl;
}


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

int main(){
     string number;
     while(1){
          cin>>number;
          if(number[0]-'0'==0) break;
          int sum=0;
          for(int i=0;i<number.size();i++){
          sum+=number[i]-'0';
          }
          cout<<sum<<endl;
          }
}
          
     
     

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

int main(){
  int n,k;
  int j=0;
  cin >> n;
  vector<int> v(n);
  for(int i;i<n;i++){
    cin >> v[i];
  }
  for(int i;i<n;i++){
    if(v[i]==i+1){
      j++;
    }
  }
  if(j==n || j==n-2){
    cout << "YES";
  }
  else{
    cout << "NO";
  }
  return 0;
}
    
  
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M1 					1000000007
#define M2 					998244353
#define ll 					long long int
#define pll 				pair<ll,ll>
#define mll 				map<ll,ll>
#define F 					first
#define S 					second
#define PB 					push_back
#define mp 					make_pair
#define lb 					lower_bound
#define ub 					upper_bound
#define V(a) 				vector<a>
#define endl 				'\n'
#define test(t) 			while(t--)
#define PI 					acos(-1.0)
#define rep(i,a,b) 			for(ll i=a;i<b;i++)
#define repp(i,b,a) 		for(ll i=b-1;i>=a;i--)
#define clr(ar, val)		memset(ar, val, sizeof(ar))
#define setbits(x) 			__builtin_popcountll(x)
#define zrobits(x) 			__builtin_ctzll(x)
#define ps(y) 				fixed << setprecision(y)
#define all(x) 				begin(x),end(x)
#define allr(x) 			rbegin(x),rend(x)
const int inf= 				0x3f3f3f3f;
const ll INF= 				0x3f3f3f3f3f3f3f3f;
const int dx[4]= 			{ 0, -1, 0, 1 };
const int dy[4]= 			{ -1, 0, 1, 0 };

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
#define o_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

ll CalculateMex(set<ll> Set){
    ll Mex = 0;
    while(Set.find(Mex)!=Set.end()){
        Mex++;
    }
    return Mex;
}

ll floor_div(ll a, ll b) {
	return a / b - (((a ^ b) < 0) and a % b);
}
ll ceil_div(ll a, ll b){
    return a / b + (((a ^ b) >= 0) and a % b);
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}

ll dp[2005][2005] = {};
void solve()
{
    ll n;
    cin>>n;
    pll a[n+1];
    rep(i,1,n+1) cin >> a[i].F , a[i].S = i;
    sort(a+1,a+n+1,greater<pll>());
    rep(i,1,n+1){
        rep(j,0,i){
            dp[j+1][i-1-j] = max(
                dp[j+1][i-1-j],
                dp[j][i-1-j] + abs(j+1 - a[i].S)*a[i].F
            );
            dp[i-1-j][j+1] = max(
                dp[i-1-j][j+1],
                dp[i-1-j][j] + abs(n - j - a[i].S)*a[i].F
            );
        }
    }
    ll ans = 0;
    rep(i,0,n+1){
        ans = max(ans,dp[i][n-i]);
    }
    cout << ans << endl;

}

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    test(t){
        solve();
    }
    return 0;
}

Measured memory_bytes: 26320
#include <stdio.h>
#include<math.h>
using namespace std;



int main(){
	int n,s,check[10][46];

	for(int i=0; i < 10; i++){
		for(int k=0; k < 46; k++){
			check[i][k] = 0;
		}
	}

	//1?????¨9???
	for(int i=0;i<=9;i++){
		check[1][i]++;
		check[9][45-i]++;
	}

	//2?????¨8???
	for(int i=0;i<=9;i++){
		for(int k=0;k<=9;k++){
			if(i < k){
				check[2][i+k]++;
				check[8][45-(i+k)]++;
			}
		}
	}

	//3?????¨7???
	for(int i=0;i<=9;i++){
		for(int k=0;k<=9;k++){
			for(int p=0;p<=9;p++){
				if(i < k && k < p){
					check[3][i+k+p]++;
					check[7][45-(i+k+p)]++;
				}
			}
		}
	}

	//4?????¨6???
	for(int i=0;i<=9;i++){
		for(int k=0;k<=9;k++){
			for(int p=0;p<=9;p++){
				for(int n=0;n<=9;n++){
					if(i < k && k <  p && p < n){
						check[4][i+k+p+n]++;
						check[6][45-(i+k+p+n)]++;
					}
				}
			}
		}
	}

	//5???
	for(int a=0;a<=9;a++){
		for(int b=0;b <= 9; b++){
			for(int c=0;c<=9;c++){
				for(int d=0;d<=9;d++){
					for(int e=0;e<=9;e++){
						if(a < b && b < c && c < d && d < e){
							check[5][a+b+c+d+e]++;
						}
					}
				}
			}
		}
	}


	while(true){
		scanf("%d %d",&n,&s);
		if(n == 0 && s == 0)break;
		if(s >= 46)printf("0\n");
		else{
			printf("%d\n",check[n][s]);
		}
	}
    return 0;
}

Measured memory_bytes: 2692
/*
    When you are not practicing someone else is,
    and the day u meet them u will Lose.

    So, all you need is Practice, Practice and Practice.
*/
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,a,b)       for(i=a;i<=b;i++)
#define FOR(i,a,b)      for(i=a;i>=b;i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define sz(v)           (int)v.size()
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p) {int ans=1;x%=mod;while(p>0){if(p&1)ans=(ans*x)%mod;p=p>>1;x=(x*x)%mod;}return ans;}
int inv(int x){return po(x,mod-2)%mod;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
/**********************************************************************************/



const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f,q;








void sol()
{   
    cin>>n;
    in(a,n);
    c=0;
    fo1(i,n-1)
    {
        if(a[i-1]>a[i])
        {
            c+=a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }
    
    
    
    cout<< c <<endl;
}





int32_t main()
{   
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //pre();
    //sp(10);
    // w(t)
    sol();
    return 0;
}


Measured memory_bytes: 4700
#include<bits/stdc++.h>
#define int long long
#define wyhsb signed
using namespace std;
int n,a[101101],ans;
wyhsb main()
{
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i++) if(a[i]==a[i-1])ans++;
    if(ans&1)ans++;
    cout<<n-ans<<"\n";
    exit(0);
}

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

int main() {
  int N;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    
    if (s == "Y") {
      cout << "Four" << endl;
      break;
    }
    
    else if (i != N - 1) {
      continue;
    }
    
    else {
      cout << "Three" << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

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

  int DP[N][2];
  DP[0][0] = 1; DP[0][1] = 1;

  for (int i = 1; i < N; i++){
    if (A[i - 1] == A[i]){
      DP[i][0] = DP[i - 1][0];
      DP[i][1] = DP[i - 1][1];
      continue;
    }

    if (A[i - 1] < A[i]){
      DP[i][0] = min(DP[i - 1][0], DP[i - 1][1] + 1);
      DP[i][1] = min(DP[i - 1][0], DP[i - 1][1]) + 1;
    }else{
      DP[i][0] = min(DP[i - 1][0], DP[i - 1][1]) + 1;
      DP[i][1] = min(DP[i - 1][0] + 1, DP[i - 1][1]);
    }
  }
  cout << min(DP[N - 1][0], DP[N - 1][1]) << endl;

  return 0;
}


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

int main(){
  long long N;
  cin>>N;
  map<char,long long> A;
  for(long long i=0;i<N;i++){
    string S;
    cin>>S;
    A[S[0]]++;
  }
  vector<string> B={"MAR","MAC","MAH","MRC","MRH","MCH","ARC","ARH","ACH","RCH"};
  long long j=0;
  for(string s:B)
    j+=A[s[0]]*A[s[1]]*A[s[2]];
  cout<<j<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
int main() {
  int N;
  int K;
  int C = 0;
  int min = 1000000001;
  cin >> N;
  cin >> K;
  int h[N];

  for(int i = 0; i < N; ++i){
    cin >> h[i];
  }
  sort(h, h+N);
  for(int i = 0; i <= N - K; ++i){
   C = h[i + K - 1] - h[i];
   if(C < min)
     min = C;
  } 
  cout << min << endl;    
}

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

using namespace std;
double maxSum(vector<double> arr, int n, int k)
{


    // Compute sum of first window of size k
    double res = 0;
    for (int i=0; i<k; i++)
       res += arr[i];

    // Compute sums of remaining windows by
    // removing first element of previous
    // window and adding last element of
    // current window.
   double curr_sum = res;
    for (int i=k; i<n; i++)
    {
       curr_sum += arr[i] - arr[i-k];
       res = max(res, curr_sum);
    }

    return res;
}
int main()
{
   int n,k;
   cin>>n>>k;
   double p;
   vector<double> a;
   for(int i=0; i<n; i++)
   {
       cin>>p;
       p = double((p+1)/2.0);
       a.push_back(p);
   }

   double m = maxSum(a, n, k) ;
   cout<<fixed<<setprecision(12)<<m<<"\n";
    return 0;
}


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

int main() {
  ll n;
  cin >> n;
  ll a = 0, b = 0, c = 0, d = 0;
  rep(i,n) {
    string s;
    cin >> s;
    if (s=="AC") a++;
    if (s=="WA") b++;
    if (s=="TLE") c++;
    if (s=="RE") d++;
  }
  
  cout << "AC x " << a << endl;
  cout << "WA x " << b << endl;
  cout << "TLE x " << c << endl;
  cout << "RE x " << d << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ld x, y;
    cin>>x>>y;
    ll ans = 0;
    while(y >= x){
        y /= 2;
        ans++;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <functional>
#include <set>
using namespace std;
int main() {
	long D, N;
	cin >> D >> N;
	long answer;
	long a=1;
	if (D == 0){
	    if(N==100)
	        answer=N+1;
        else
            answer=N;
	}
	else {
		for (int i = 0; i < D; i++)
			a = a * 100;
		if (N == 100)
			answer = (N + 1)*a;
		else
			answer = N * a;
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 256
x = int(input())
dp = [0]*(x + 105 + 1)
dp[100] = 1 
dp[101] = 1
dp[102] = 1
dp[103] = 1
dp[104] = 1
dp[105] = 1

for i in range(100,x-105+100):
    for j in range(100,106):
        dp[i+j] = max(dp[i] , dp[i+j])

print(dp[x])

Measured memory_bytes: 9528
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define ull unsigned long long
#define ll long long
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}


int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int N;
	cin >> N;
	vector<ll> A(N), B(N), C(N), cnt(N);
	rep(i,0,N) cin >> A[i];
	rep(i,0,N) cin >> B[i];
	rep(i,0,N) cin >> C[i];
	sort(A.begin(),A.end()); sort(B.begin(),B.end()); sort(C.begin(),C.end());
	int j=0;
	rep(i,0,N) {
		while(j<N && C[j] <= B[i]) ++j;
		cnt[i] = N-j;
	}

	vector<ll> cum_cnt(N+1,0);
	per(i,0,N) {
		cum_cnt[i] = cum_cnt[i+1]+cnt[i];
	}
	
	ll res = 0;
	j=0;
	rep(i,0,N) {
		while(j<N && B[j] <= A[i]) ++j;
		res += cum_cnt[j];
	}
	cout << res << endl;
}

Measured memory_bytes: 4224
n, k = map(int, input().split())

max_alpha = 2 * n // k
if k % 2 == 0:
    if max_alpha % 2 == 0:
        ans = 2 * ((max_alpha / 2) ** 3)
    else:
        ans = ((max_alpha + 1) /2) ** 3 + ((max_alpha - 1) /2) ** 3
else:
    ans = (max_alpha // 2) ** 3
print(int(ans))


Measured memory_bytes: 38256
#include <stdio.h>
#include <stdint.h>
#include <math.h>

int main(void)
{
    int64_t N;
    int64_t sum = 0;
    scanf("%ld", &N);
    for (int64_t i = 1; i <= N; i++)
    {
        if (!(i % 3 == 0 || i % 5 == 0))
        {
            sum += i;
        }
    }
    printf("%ld\n", sum);
    return 0;
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	string S;
	cin>>S;
	int maxi=0;
	for(int x=2;x<S.size()-1;x+=2){
		int y=x/2;
  		string s=S.substr(0,y);
  		string t=S.substr(y,y);
  		if(s==t){
          int k=s.size()*2;
          maxi=max(maxi,k);
        }
	}
	ce(maxi)
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
	int n;
	
	while(cin >> n && n){
		int num[7] = {0};
		int tmp;
		for(int i=0;i<n;i++){
			cin >> tmp;
			if(tmp >= 60){
				num[6]++;
			}else{
				num[tmp/10]++;
			}
		}
		for(int i=0;i<7;i++){
			cout << num[i] << endl;
		}
	}
}

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

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int r;
  cin >> r;
  cout << 3 * r * r << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
  int x;
  cin >> x;
  if (360 % x == 0) cout << 360 / x << '\n';
  else
  {
   long long a = 360; 
   while (a % x != 0)
   {
    a += 360;
   }
   cout << a / x << '\n';
  }
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
vector<int> ve[N];
priority_queue<int> qe;
int main()
{
	int n,m,sum=0;
	cin>>n>>m;
	int a,b;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		if(m-a+1<1) continue;
		ve[m-a+1].push_back(b);
	}
	for(int i=m;i>=1;i--){
		for(int j=0;j<ve[i].size();j++){
			qe.push(ve[i][j]);
		}
		 if(!qe.empty()){
		 	sum+=qe.top();qe.pop();
		 }
	}
	cout<<sum<<"\n";
	return 0;
}

Measured memory_bytes: 8932
#include <bits/stdc++.h>
#define fi first
#define se second

using namespace std;

typedef pair<int,int> pii;

int main(){
	int n, x, maxi = 0;
	pii arr[100100];
	cin >> n >> x;
	for (int i = 0; i < n; i++){
		cin >> arr[i].se >> arr[i].fi;
		maxi = max(maxi, arr[i].se);
	}
	sort(arr, arr + n);
	int idx = n - 1;
	while (x > 0 && idx >= 0 && arr[idx].fi > maxi){
		x -= arr[idx--].fi;
	}

	int cnt = n - idx - 1;

	if (x > 0){
		cnt += (x + maxi - 1) / maxi;
	}

	cout << cnt << "\n";
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define IL inline
#define _ 524288
#define ll long long
using namespace std;

IL ll gi(){
	ll data=0,fu=1; char ch=0; while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')fu=-1,ch=getchar();
	while('0'<=ch&&ch<='9')data=(data<<1)+(data<<3)+(ch^48),ch=getchar(); return data*fu;
}

int main(){
	int n,m;
	cin>>n>>m;
	cout<<n%m<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>

#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
#define INF 10000000
using namespace std;

int main(){
	int n,m;
	int tmp;
	vector<int> c;
	vector<int> use_c;
	cin >> n >> m;
	int dp[50001];
	rep(i,0,m){
		cin >> tmp;
		c.push_back(tmp);
	}
	rep(i,0,n+1){
		dp[i] = INF;
	}
	sort(c.begin(),c.end());
	dp[0] = 0;
	
	rep(i,0,n){
		rep(j,0,m){
			if(i+c[j]>n) break;
			dp[i+c[j]] = min(dp[i+c[j]],dp[i]+1);
		}
	}
	cout << dp[n] << endl;

}



Measured memory_bytes: 3352
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
        int coin500 = n / 500;
        int hapiness500 = coin500 * 1000;
        int coin5 = (n % 500) / 5;
        int hapiness5 = coin5 * 5;
        System.out.println(hapiness500 + hapiness5);
    }
}

Measured memory_bytes: 35664
A, B = map(int, input().split())

for X in range(1, max(A * 13, B * 10) + 1):
    A_tmp = X * 8 // 100
    B_tmp = X * 10 // 100
    if A_tmp == A and B_tmp == B:
        ans = X
        break
else:
    ans = -1

print(ans)


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

using namespace std;

//#define FILE_IO

typedef long long LL;

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    LL N;
    cin >> N;

    if(N <= 1000)
    {
        LL mx = 0;
        for(LL i = 1; i <= N; i++)
        {
            LL aux = i;
            LL s = 0;
            while(aux)
            {
                s += aux % 10;
                aux /= 10;
            }
            mx = max(mx, s);
        }
        cout << mx;
        exit(0);
    }

    LL c = 0;
    LL aux = N;
    LL s = 0;
    LL d = 0;
    while(aux)
    {
        d = aux % 10;
        s += d;
        c++;
        aux /= 10;
    }

    LL ans = (c - 1) * 9 + (d - 1);
    ans = max(ans, s);
    cout << ans;


    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;
double eps = 1e-11;

int main() {
    while (true) {
        int n, m;
        cin >> n >> m;
        if (n == 0) {
            break;
        }
        int a[n];
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        int max = -1;
        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                if (max < a[i] + a[j] && a[i] + a[j] <= m) {
                    max = a[i] + a[j];
                }
            }
        }
        if (max != -1) {
            cout << max << endl;
        } else {
            cout << "NONE" << endl;
        }
    }
}



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

#define ff first
#define ss second
using namespace std;
#define maxn 2000006
#define pb push_back
#define ll long long
#define lll __int128
#define vll vector<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define pll pair<ll,ll>
#define ull unsigned long long
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
inline void fastio() {ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);}

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



int main() {
	fastio();

	ll a, b; cin >> a >> b;

	mll cmmn;
	ll lmt1 = sqrt(a);
	f(i, 1, lmt1) {
		if (a % i == 0) {
			if ((a / i) == i) cmmn[i]++;
			else {
				cmmn[i]++;
				cmmn[(a / i)]++;
			}
		}
	}
	ll lmt2 = sqrt(b);
	f(i, 1, lmt2) {
		if (b % i == 0) {
			if ((b / i) == i) cmmn[i]++;
			else {
				cmmn[i]++;
				cmmn[(b / i)]++;
			}
		}
	}
	vll v;
	for (auto i : cmmn) {
		if (i.ss > 1)
			v.pb(i.ff);
	}


	ll n = v.size();

	vector<bool> is_prst(n, true);

	f(i, 0, n - 1) {
		if (is_prst[i] == true and v[i] != 1) {
			f(j, i + 1, n - 1) {
				if ((v[j] % v[i]) == 0) is_prst[j] = false;
			}
		}
	}
	ll ans = 0;
	f(i, 0, n - 1) {
		if (is_prst[i] == true) ans++;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 768
from itertools import product

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

for i in range(n):
    for j in range(int(input())):
        xy[i].append(list(map(int, input().split())))

ans = 0
for bit in product([0, 1], repeat=n):
    f = 0
    for i, j in enumerate(bit):
        if j == 1:
            for x, y in xy[i]:
                if bit[x - 1] != y:
                    f = 1
    if f == 0:
        ans = max(ans, sum(bit))
print(ans)

Measured memory_bytes: 9232
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n; cin>>n;
	int k; cin>>k;
	vi v(n);
	rep(i,0,n){
		cin>>v[i];
	}
	sort(all(v));
	int ans=0;
	rep(i,0,k) ans+=v[i];
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
#define MIN(x, y) (((x) < (y)) ? (x) : (y))

int main(void) {
  int N;
  scanf("%d",&N);
  int array[N];
  int min =array[0];

  for (int i=0;i<N;i++){
    scanf("%d",&array[i]);
    min= MIN(min, array[i]);
  }
  for (int i=1;i<N;i++){
        if (array[i]>array[i-1]) array[i]--;
  }
 int count =0;
  for (int i=0;i<N-1;i++){
    if (array[i]<=array[i+1]) count++;
  }
  if (count==N-1)printf("Yes");
  else printf("No");
 return EXIT_SUCCESS;
}

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

public class Main {
	Scanner scan = new Scanner(System.in);
	
	private void compute() {
		int N = scan.nextInt();
		
		
		for (int i=0;i<N;i++) {
			for (int j=i+1;j<N;j++) {
				int d = j - i;
				int num = 1;
				while (d % 2 == 0) {
					d /= 2;
					num++;
				}
				System.out.print(num + (j == N-1 ? "" : " "));
			}
			System.out.println();
		}
		
		
	}
	
	public static void main(String...arg) {
		new Main().compute();
	}

}


Measured memory_bytes: 37568
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int N;
    cin >> N;

    if (N == 3) {
        cout << "2 5 63" << endl;
        return 0;
    }
    if (N == 4) {
        cout << "2 5 20 63" << endl;
        return 0;
    }

    vector<int> two;
    vector<int> three;
    vector<int> six;
    FOR(i, 1, 30000) {
        if (i % 6 == 0) continue;
        if (i % 2 == 0) {
            two.push_back(i);
        }
    }
    FOR(i, 1, 30000) {
        if (i % 6 == 0) continue;
        if (i % 3 == 0) {
            three.push_back(i);
        }
    }
    FOR(i, 1, 30000) {
        if (i % 6 == 0) {
            six.push_back(i);
        }
    }

    vector<int> ans;

    int cnt = 0;
    for (int i = 0; i < two.size(); i += 2) {
        ans.push_back(two[i]);
        ans.push_back(two[i + 1]);
        cnt += 2;
        if (cnt + 2 >= N - 2) break;
    }
    for (int i = 0; i < three.size(); i += 2) {
        ans.push_back(three[i]);
        ans.push_back(three[i + 1]);
        cnt += 2;
        if (cnt + 2 > N) break;
    }
    REP(i, six.size()) {
        if (cnt == N) {
            break;
        }
        ans.push_back(six[i]);
        cnt++;
    }
    sort(ans.begin(), ans.end());

    REP(i, ans.size()) {
        if (i != 0) cout << " ";
        cout << ans[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 896
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    ArrayList<Integer> kingaku = new ArrayList<Integer>();
    kingaku.add(1);
    for(int i = 1; i < 100; i++) {
      int a = (int)Math.pow(6, i);
      if(a > 100000) break;
      kingaku.add(a);
    }
    for(int i = 1; i < 100; i++) {
      int b = (int)Math.pow(9, i);
      if(b > 100000) break;
      kingaku.add(b);
    }
    Collections.sort(kingaku);
    int[] dp = new int[n + 1];
    dp[1] = 1;
    for(int i = 2; i <= n; i++) {
      int t = i;
      for(int j = 0; j <= kingaku.size() - 1; j++) {
        if(i >= kingaku.get(j)) t = Math.min(t, dp[i - kingaku.get(j)] + 1);
      }
      dp[i] = t;
    }
    System.out.println(dp[n]);
  }
}

Measured memory_bytes: 24276
#include<iostream>
#include<algorithm>

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

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

    int res = 0;
    rep(i, K+1) {
        rep(j, K+1) {
            if (i + j > S) break;
            if (S - i - j <= K) res++;
        }
    }

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


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<stdlib.h>

using namespace std;

int minana(int a,int b){
  if(a<b){
    return a;
  }
  else if(a>b){
    return b;
  }
  else return a;
}


int main(){
  int n;
  cin>>n;
  int r[100];
  int m[101][101];
  int j;
  int q=0;
  //int c[n];
  for(int i=1;i<=n;i++){
    cin>>r[i-1]>>r[i];
  }
  for(int i=1;i<=n;i++){
    m[i][i]=0;
  }
  for(int l=2;l<=n;l++){
    for(int i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=(1<<21);
      for(int k=i;k<j;k++){
	q=m[i][k]+m[k+1][j]+r[i-1]*r[k]*r[j];
	m[i][j]=minana(m[i][j],q);
      }
    }
  }
  
  cout<<m[1][n]<<endl;
  return 0;
}



Measured memory_bytes: 3168
#!/usr/local/bin/ruby
num = Hash.new(0);
max = 0
while (n=gets.to_i)!=0
#while (n=gets)
 num[n.to_i] += 1
end
v = num.values.max
res = []
num.keys.each do |k|
 res << k if num[k] ==v
end
puts res.sort

Measured memory_bytes: 6092
a, b, c, x, y = list(map(int, input().split()))

p = 0

z1 = a * x + b * y
z2 = 2 * c * min(x, y) + a * max(x-y, 0) + b * max(y-x, 0)
z3 = 2 * c * max(x, y)

print(min(z1, z2, z3))

Measured memory_bytes: 9124
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	int n,k,ans;
	cin>>n>>k;
	ans=1;
	for(int i=0;i<n;i++){
		ans=min(ans*2,ans+k);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
idx = 1
S = [idx]
ed = set([idx])

for i in range(1, K+1):
    idx = A[idx-1]
    if idx in ed:
        start = S.index(idx)
        end = len(S)
        n = start + (K - start) % (end - start)
        print(S[n])
        break
    else:
        S.append(idx)
        ed.add(idx)
        continue
else:
    print(idx)

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

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

class SegTree {
public:
	
  ////////////////////////////////////////////////////////

  // monoid
  using X = long long;
  X X_dot_X(const X &v1, const X &v2) {
    return v1 + v2;
  }
  const X X_unit = 0;
  
  ////////////////////////////////////////////////////////
  typedef size_t idx_type;
  
  vector<X> data;

  idx_type n;
	
  SegTree(idx_type n_) {
    n = 1;
    while(n <= size_t(n_)) {
      n *= 2;
    }
    data.resize(n * 2 - 1, X_unit);
  }
  ~SegTree() {}
  
  X query(idx_type a, idx_type b, idx_type k, idx_type l, idx_type r) {
    if(r <= a || b <= l) {
      return X_unit;
    }
		
    if(a <= l && r <= b) {
      return data[k];
    }
    else {
      X vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
      X vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
      return X_dot_X(vl, vr);
    }
  }
  
  X query(idx_type a, idx_type b) {
    return query(a, b, 0, 0, n);
  }
	
  void update(idx_type i, X x) {
    i += n - 1;
    data[i] = x;
    while(i > 0) {
      i = (i - 1) / 2;
      data[i] = X_dot_X(data[i*2+1], data[i*2+2]);
    }
  }
};


int main(int argc, char *argv[]) {

  i64 N, Q, i;
  cin >> N >> Q;
  SegTree tree(N);
  REP(0, N, i) {
    i64 a;
    cin >> a;
    tree.update(i, a);
  }

  REP(0, Q, i) {
    i64 p, q, r;
    cin >> p >> q >> r;
    if(p == 0) {
      i64 cur = tree.query(q, q+1);
      tree.update(q, cur+r);
    }
    else {      
      cout << tree.query(q, r) << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 12512
#include <iostream>
#include <vector>
#include <algorithm>

struct Card
{
    char    suit;
    int     num;

    bool operator==(const Card& other)
    {
        return suit == other.suit && num == other.num;
    }

    bool operator!=(const Card& other)
    {
        return !operator==(other);
    }
};

std::istream& operator>>(std::istream& is, Card& value)
{
    is >> value.suit >> value.num;
    return is;
}

std::ostream& operator<<(std::ostream& os, const Card& value)
{
    os << value.suit << " " << value.num;
    return os;
}

using vc = std::vector<Card>;

void solve();
void QuickSort(vc& target, int iP, int iR);
int Partition(vc& target, int iP, int iR);

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


void solve()
{
    using namespace std;

    int n;
    cin >> n;
    vc v(n);

    for (auto& x : v)
        cin >> x;

    auto vs = v;

    QuickSort(v, 0, v.size() - 1);
    stable_sort(vs.begin(), vs.end(), 
        [](Card c1, Card c2)
    {
        return c1.num < c2.num;
    });


    bool stable = true;
    for (int i = 0; i < v.size(); ++i)
    {
        if (v[i] != vs[i])
        {
            stable = false;
            break;
        }
    }

    cout << (stable ? "Stable" : "Not stable") << endl;

    //for (int i = 0; i < v.size(); ++i)
    //{
    //    cout << v[i];
    //    if (i + 1 != v.size())
    //        cout << endl;
    //}

    for (const auto& c : v)
    {
        cout << c << endl;
    }
}

void QuickSort(vc& target, int iP, int iR)
{
    if (iP < iR)
    {
        int q = Partition(target, iP, iR);
        QuickSort(target, iP, q - 1);
        QuickSort(target, q + 1, iR);
    }
}

int Partition(vc& target, int iP, int iR)
{
    using namespace std;

    int x = target[iR].num;
    int i = iP - 1;

    for (int j = iP; j < iR; ++j)
    {
        if (target[j].num <= x)
        {
            swap(target[++i], target[j]);
        }
    }

    swap(target[++i], target[iR]);

    return i;
}


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

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int a[1001][1001];
int b[1001];
int main()
{
    int n,m,c;
    cin>>n>>m>>c;
    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];
    int k=0;
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        k=0;
        for(int j=0;j<m;j++)
        {
            k+=a[i][j]*b[j];
        }
        k+=c;
        if(k>0)
            cnt++;
    }
    cout<<cnt;
    return 0;
}



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

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

  int k[31];
  int a[31];
  int buckets[40] = {0};
  for (int i = 0; i < n; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> a[j];
      buckets[a[j]] += 1;
    }
  }

  int ans = 0;
  for (int i = 0; i < 31; i++) {
    if (buckets[i] == n) {
      ans++;
    }
  }

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

Measured memory_bytes: 256
s=require("fs").readFileSync("/dev/stdin","utf8").split('\n')
console.log(
	[...Array(s[0] | 0)]
	.map((_, i) => s[i + 1] | 0)
	.sort((a, b) => b - a)
	.map((n, i) => !i ? n / 2 : n)
	.reduce((c, n) => c + n)
)

Measured memory_bytes: 7372
#include<iostream>
#include<string>

using namespace std;

int main() {

	string S;
	cin >> S;
	int ans = 0;
	char c = S[0];
	for (int i = 1; i < S.size(); i++) {
		if (S[i] != c)c = S[i], ans++;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

//#define _FILES
#define PB push_back
#define MP make_pair
#define X first
#define Y second

const int MAXN = 3005;

int sb[MAXN][MAXN], sw[MAXN][MAXN], fb[MAXN][MAXN], fw[MAXN][MAXN], k, dp[MAXN][MAXN][2];

int getCnt(int x, int y, int color)
{
    if (!color)
    {
        if ((x <= k) && (y <= k))
        {
            return sb[x][y];
        }
        else if (x <= k)
        {
            return sb[x][y] - sb[x][y - k];
        }
        else if (y <= k)
        {
            return sb[x][y] - sb[x - k][y];
        }
        else
        {
            return sb[x][y] - sb[x][y - k] - sb[x - k][y] + sb[x - k][y - k];
        }
    }
    else
    {
        if ((x <= k) && (y <= k))
        {
            return sw[x][y];
        }
        else if (x <= k)
        {
            return sw[x][y] - sw[x][y - k];
        }
        else if (y <= k)
        {
            return sw[x][y] - sw[x - k][y];
        }
        else
        {
            return sw[x][y] - sw[x][y - k] - sw[x - k][y] + sw[x - k][y - k];
        }
    }

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

    #ifdef _FILES
        freopen("","r",stdin);
        freopen("","w",stdout);
    #endif // _FILES
    int n;
    cin >> n >> k;
    for (int i=0;i<n;i++)
    {
        int x, y;
        char c;
        cin >> x >> y >> c;
        x %= 2 * k;
        x++;
        y %= 2 * k;
        y++;
        if (c == 'B')
        {
           fb[x][y]++;
        }
        else
        {
            fw[x][y]++;
        }

    }

    for (int i=1;i<=3*k;i++)
    {
        for (int j=1;j<=3*k;j++)
        {
            sb[i][j] = fb[i][j] + sb[i-1][j] + sb[i][j-1] - sb[i-1][j-1];
            sw[i][j] = fw[i][j] + sw[i-1][j] + sw[i][j-1] - sw[i-1][j-1];
        }
    }

    int ans = 0;
    for (int i=1;i<=3*k;i++)
    {
        for (int j=1;j<=3*k;j++)
        {
            //0
            dp[i][j][0] = getCnt(i, j, 0);
            if (i > k)
            {
                dp[i][j][0] += dp[i - k][j][1];
            }

            if (j > k)
            {
                dp[i][j][0] += dp[i][j - k][1];
            }

            if ((i > k) && (j > k))
            {
                dp[i][j][0] -= dp[i - k][j - k][0];
            }

            //1

            dp[i][j][1] = getCnt(i, j, 1);
            if (i > k)
            {
                dp[i][j][1] += dp[i - k][j][0];
            }

            if (j > k)
            {
                dp[i][j][1] += dp[i][j - k][0];
            }

            if ((i > k) && (j > k))
            {
                dp[i][j][1] -= dp[i - k][j - k][1];
            }

            ans = max(ans, dp[i][j][0]);
            ans = max(ans, dp[i][j][1]);
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 193408
h, w = map(int, input().split())
t = [list(map(int, input().split())) for _ in range(h)]
kisu = []
kisu_count = 0
i = j = 0
dj = 1
ans = []
ido = 0
while i < h:
    if t[i][j] % 2:
        if ido:
            stog[2:4] = [i + 1, j + 1]
            log += [stog]
            ans += log
            ido = 0
        else:
            ido = 1
            stog = [i + 1, j + 1, 0, 0]
            log = []
    else:
        if ido:
            stog[2:4] = [i + 1, j + 1]
            log += [stog]
            stog = [i + 1, j + 1, 0, 0]
    j += dj
    if j == w or j == -1:
        i += 1
        dj *= -1
        j += dj
print(len(ans))
for x in ans:
    print(*x)


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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> void chmax(T& a,const T& b){if(a < b) a = b;}
template<typename T> void chmin(T& a,const T& b){if(b < a) a = b;}
typedef long long ll;

int N;
string S;

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

	cin >> S;
	N = S.size();

	int ans = N / 2 - count(ALL(S),'p');
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repq(i,a,n) for(int i=a; i<=n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

// Binary Indexed Tree (BIT)
template <typename T>
struct BIT{
private:
    vector<T> array;
    const int n;

public:
    BIT(int _n) : array(_n + 1, 0), n(_n + 1) {}

    // 1???????????? i???????????§????´???????????±???????
    T sum(int i) {
        T s = 0;
        while(i > 0) {
            s += array[i]; i -= i & -i;
        }
        return s;
    }

    // [i, j] ???????´??????????
    T sum(int i, int j) {
        T ret_i = sum(i-1);
        T ret_j = sum(j);
        return ret_j - ret_i;
    }

    // i ????????? ????´? x ?????????
    void add(int i, T x) {
        while(i <= n) {
            array[i] += x; i += i & -i;
        }
    }
};

signed main() {
    int n, q; cin >> n >> q;
    int c, x, y;
    BIT<int> bit(n);
    rep(i,0,q) {
        cin >> c >> x >> y;
        if(c == 0) bit.add(x, y);
        else cout << bit.sum(x, y) << endl;
    }
    return 0;
}

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

#define INFTY (1 << 30);
typedef long long ll;

int main(void) {
  int N, M;
  ll A[100000];
  map<ll, int> B;

  cin >> N >> M;
  ll tmp_A, tmp_B;
  for (int i = 0; i < N; i++) {
    cin >> tmp_A >> tmp_B;
    A[i] = tmp_A;
    if (B.count(tmp_A) == 0)
      B[tmp_A] = tmp_B;
    else
      B[tmp_A] += tmp_B;
  }

  sort(A, A+N);

  ll num_sum, bill_sum;
  num_sum = 0;
  bill_sum = 0;
  for (int i = 0; i < N; i++) {
    if (i > 0) {
      if (A[i] == A[i-1]) continue;
    }
    
    ll num = B[A[i]];
    num = min(M-num_sum, num);
    bill_sum += (A[i] * num);
    num_sum += num;
    if (num_sum == M) break;
  }

  cout << bill_sum << endl;
  
  
  return 0;
}


Measured memory_bytes: 7296