akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

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

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<int> a(n);
    cin >> a;
    int cnt = a[0];
    for (int i = 0; i + 1 < a.size(); ++i) {
      cnt += max(0, a[i + 1] - a[i]);
    }
    cout << cnt << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var t = long.Parse(line[0]);
        var a = long.Parse(line[1]);
        for (int i = 1; i < n; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var nt = long.Parse(line[0]);
            var na = long.Parse(line[1]);
            if (nt >= t && na >= a) { t = nt; a = na; }
            else
            {
                var w = getAns(t, a, nt, na);
                t = nt * w;
                a = na * w;
            }
        }
        Console.WriteLine(t + a);
    }
    public static long getAns(long t, long a, long nt, long na)
    {
        var r1 = 0L; var r2 = 0L;
        if (nt < t) r1 = (t + nt - 1) / nt;
        if (na < a) r2 = (a + na - 1) / na;
        return r1 > r2 ? r1 : r2;
    }
}

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

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
const ll mod = 1000000007LL;

int main()
{
    int n,a;
    cin>>n>>a;
    cout<<(n%500<=a?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
s = input()

if s == "SAT":
    print(1)
elif s == "FRI":
    print(2)
elif s == "THU":
    print(3)
elif s == "WED":
    print(4)
elif s == "TUE":
    print(5)
elif s == "MON":
    print(6)
elif s == "SUN":
    print(7)


Measured memory_bytes: 2940
N, M = [ int(i) for i in input().split() ]
A = [ input() for i in range(N) ]
B = [ input() for i in range(M) ]
for i in range(N-M+1):
    for j in range(N-M+1):
        C = [ A[j+k][i:i+M] for k in range(M) ]
        if B==C:
             print("Yes")
             exit()
print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int x=0,N=S.size();
  if(S.at(0)!='A'){
    cout<<"WA"<<endl;
    return 0;
  }
  for(int i=1;i<N;i++){
    if((int)S.at(i)<=90){
      if(S.at(i)=='C' && i>=2 && i<=N-2)
        x++;
      else
        x=2;
    }
  }
  if(x==1)
    cout<<"AC"<<endl;
  else
    cout<<"WA"<<endl;
}

Measured memory_bytes: 256
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define int long long
#define sz(x) (int)x.size()
int h[1000 * 100 + 5];
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> h[i];
	int ans = 0, maxi = 0;
	for(int i = n - 2; i >= 0; i--){
		if(h[i] >= h[i + 1])
			ans++;
		else
			ans = 0;
		maxi = max(maxi , ans);
	}
	cout << maxi << endl;
	return 0;
}


Measured memory_bytes: 1024
K,N = map(int,input().split())
A = [int(x) for x in input().split()]

buf_1 = 0
buf_2 = 0
for i in range(1,N) :
    buf_1 = max(buf_1,A[i] - A[i-1])

buf_2 = max(buf_1,A[0] + K - A[N-1])

if buf_2 > buf_1 :
    print(A[N-1] - A[0])
else :
    print(K - buf_1)

Measured memory_bytes: 26436
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
#define int long long
#define MOD 1e9+7
typedef pair<int,int> P;
typedef pair<int,P> PP;

struct WF{
  int v;
  vector<vector<int> > d;
  const int INF = 1LL<<60; 
  WF(int n):
    v(n),
    d(n,vector<int>(n))
  {
    for(int i=0;i<v;i++){
	 for(int j=0;j<v;j++){
	   if(i==j)d[i][j]=0;
	   else d[i][j]=INF;
	 }
    }
  }

  void add(int s,int t,int cost){
    d[s][t]=min(d[s][t],cost);
  }

  void wf(){
    for(int k=0;k<v;k++){
	 for(int i=0;i<v;i++){
	   for(int j=0;j<v;j++){
		if(d[i][k]!=INF&&d[k][j]!=INF)
		  d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
	   }
	 }
    }
  }

  int get(int i,int j){
    return d[i][j];
  }
};

signed main(){
  int n,m;
  const int INF=1LL<<60;
  while(1){
    cin>>n>>m;
    if(n+m==0)break;
    WF land(n),sea(n);
    for(int i=0;i<m;i++){
	 int x,y,t;
	 char s;
	 cin>>x>>y>>t>>s;
	 x--,y--;
	 if(s=='L'){
	   land.add(x,y,t);
	   land.add(y,x,t);
	 }else{
	   sea.add(x,y,t);
	   sea.add(y,x,t);
	 }
    }
    land.wf();
    sea.wf();
  
    int r;
    cin>>r;
    vector<int> z(r);
    for(int i=0;i<r;i++){
	 cin>>z[i];
	 z[i]--;
    }

    vector<vector<int> > dp(r,vector<int>(n,INF));
    dp[0][z[0]]=0;
    for(int i=0;i<r-1;i++){
	 for(int j=0;j<n;j++){
	   if(dp[i][j]==INF)continue;
	   dp[i+1][j]=min(dp[i+1][j],dp[i][j]+land.get(z[i],z[i+1]));
	   for(int k=0;k<n;k++){
		int cost=land.get(z[i],j)+sea.get(j,k)+land.get(k,z[i+1]);
		dp[i+1][k]=min(dp[i+1][k],dp[i][j]+cost);
	   }
	 }
    }

    int mi=INF;
    for(int i=0;i<n;i++){
	 mi=min(mi,dp[r-1][i]);
    }
    cout<<mi<<endl;
  }
  return 0;
}



Measured memory_bytes: 5188
#include<bits/stdc++.h>
using namespace std;
      	
int main(){
  	int N;
  	int a, b, c, d;
  
  	cin >> N;
  
  	a = N / 1000;
  	b = (N-1000*a) / 100;
  	c = (N-1000*a-100*b) / 10;
  	d = N-1000*a-100*b-10*c;
  
  	if((a == b && b == c) || (b == c && c == d))	cout << "Yes" << endl;
  	else	cout << "No" << endl;
  
  	return 0;
}

Measured memory_bytes: 256
n,y=map(int,input().split())
ans=[0,0,0,0]#左から答えあるか、一万円札、五千円札、1000円札
for i in range(0,n+1):
    for j in range(0,n+1):
        if 10000*i+5000*j+1000*(n-i-j)==y and n-i-j>=0:
          ans=[1,i,j,n-i-j]
if ans[0]==1:
    print(ans[1],ans[2],ans[3])
else:
    print(-1,-1,-1)
#3重配列はn**3なので10**3回ループが10**9回に化ける恐ろしさがある。

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

LL N, K;
bool ok[100001];
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  cin >> N >> K;
  VL xs(N);
  REP(i,N) cin >> xs[i];
  SORT(xs);
  for(int i=0;i<N;++i)
	if(xs[i] >= K){
	  N = i;
	  break;
	}

  int lb = -1, ub = N;
  while(ub-lb>1){
	int j = (ub+lb) / 2;
	fill(begin(ok), end(ok), false);
	ok[0] = true;
	REP(i,N)
	  if(i != j)
		for(int w=10000;w-xs[i]>=0;--w)
		  ok[w] = ok[w] || ok[w-xs[i]];
	bool flag = false;
	for(int w=K-xs[j];w<K;++w)
	  if(ok[w]){
		flag = true;
		break;
	  }
	if(flag)
	  ub = j;
	else
	  lb = j;
  }

  cout << ub << endl;

  return 0;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <fstream>
#include<map>
#include <cassert>
#include<sstream>
using namespace std;
signed main()
{
	int n;
	cin >> n;
	string s[63];
	int t[63];
	for (int i = 0; i < n; i++) {
		cin >> s[i] >> t[i];
	}
	int ans = 0;
	string str;
	cin >> str;
	bool judge = false;
	for (int i = 0; i < n; i++) {
		if (judge)ans += t[i];
		if (str == s[i])judge = true;
	}
	cout << ans;
}


Measured memory_bytes: 256
/*
  Author - KISHAN TIWARI
  Dream bigger. Do bigger.
  Wake up with determination. Go to bed with satisfaction.
*/
//Sometimes later becomes never. Do it now.
#include<bits/stdc++.h>
using namespace std;
#define ll           long long
#define f(i,a,b)     for(ll i=a;i<b;i++)
#define mod          1000000007
#define fi           first
#define se           second
#define pa           pair <ll,ll>
#define mp           make_pair
#define pb           push_back
#define ve           vector<ll>
#define vep          vector< pa >
#define all(a)       a.begin(), a.end()
#define sz(x)        (ll)x.size()
#define c(t)         cout<<t<<"\n"
using namespace std;
void solve()
{  ll n;
cin>>n;
c(3*(pow(n,2)));
}
int main()
{
    ios::sync_with_stdio(true);
   //freopen ("input.txt","r",stdin);
   //freopen ("output.txt","w",stdout);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    //cin>>t;
    while(t--)
    {

        solve();
    }
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main() {
	int N, K;
	cin >> N >> K;
	int h[100010];
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		cin >> h[i];
		if (h[i] >= K)ans++;
	}
	cout << ans;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
#define out(x) cout<<x<<"\n";
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}
 
ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
using namespace std;

void solve()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll cur = 1;
    ll ans = 0;
    rep(i, n)
    {
        ans += (a[i] - 1) / cur;
        if(i==0)
            ++cur;
        else if (a[i] == cur)
            ++cur;
    }
    cout << ans << "\n";
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>

using namespace std;
#define ff(i,n,m) for(int i=n;i<m;i++)
#define i64 int64_t
#define tos(x) to_string(x)

int main() {
	string s;
	cin >> s;
	int acta = 0;
	int actz = 0;
	int f = 0;
	int l = 0;
	int ans;
	ff(i, 0, s.size()) {
		if (acta == 0 && s.at(i) == 'A') {
			acta++;
			f = i;
		}
		if (actz == 0 && s.at(s.size() - 1 - i) == 'Z') {
			actz++;
			l = s.size() - 1 - i;
		}
		if (actz == 1 && acta == 1) {
			break;
		}
	}
	ans = l - f + 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  if(N==1){
    cout << "Hello World"<< endl;
  }
  if(N==2){
    int A,B;
    cin >> A >> B;
    cout << A+B << endl;
  }
}

  

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int h1,h2,k1,k2,a,b,c,d ;
    cin>> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d ;
    
    if(h1*a + h2*b + h1/10*c + h2/20*d > k1*a + k2*b + k1/10*c + k2/20*d){
        cout << "hiroshi" <<endl;
    }else if
        (h1*a + h2*b + h1/10*c + h2/20*d < k1*a + k2*b + k1/10*c + k2/20*d){
        cout << "kenjiro" <<endl;
    }else{
        cout << "even" <<endl;
    }
    
}



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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl







void relax(int &x, int y) {
    x=min(x,y);
}



const int N = 18;
const int inf = 1e9 + 10;


int n;
int dp[1<<N][N]; // # of swaps if mask of cards placed, last card placed is i
int a[N], b[N];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>n;
    for (int i=0; i<n; i++) {
	cin>>a[i];
    }
    for (int i=0; i<n; i++) {
	cin>>b[i];
    }

    for (int mask=0; mask<1<<n; mask++) {
	for (int i=0; i<n; i++) {
	    dp[mask][i]=inf;    
	}
    }
    
    for (int i=0; i<n; i++) {
	dp[1<<i][i]=0;
    }

    for (int mask=1; mask<1<<n; mask++) {
	for (int i=0; i<n; i++) {
	    int pre = __builtin_popcount(mask);
	    // odd distance means card is flipped, even vice versa
	    int x = (i%2==(pre-1)%2 ? a[i] : b[i]);

	    for (int j=0; j<n; j++) {
		if (mask>>j&1) continue;
		int y = (j%2==pre%2 ? a[j] : b[j]);
		if (y<x) continue;
		
		// # of inversions with j: # of elems < y that have idx > j.
		int cost = dp[mask][i] + __builtin_popcount(mask>>j);
		relax(dp[mask|(1<<j)][j], cost);
	    }
	}
    }

    int res=inf;
    for (int i=0; i<n; i++) {
	relax(res, dp[(1<<n)-1][i]);
    }

    if (res==inf) res=-1;
    cout<<res<<endl;
    
    return 0;
}


Measured memory_bytes: 22028
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){
int N;
cin>>N;
multimap<long long,int>L;
multimap<long long,int>R;
long long diff[N];

long long l[N],r[N];
long long ans=0;
rep(i,N){
    cin>>l[i]>>r[i];
    r[i]++;
    diff[i]=r[i]-l[i];
    L.insert(make_pair(-l[i],i));
    R.insert(make_pair(r[i],i));
}


auto left=L.begin();
auto right=R.begin();
long long p=-(left->first);//もっとも右のLi
long long q=right->first;//もっとも左のRi
long long z=0;
//pとqを同じ集合に入れる時
long long maxd=0;
//if(left->second==right->second || p>q){
    rep(i,N){
        maxd=max(diff[i],maxd);
    }
    ans=max((q-p),z)+maxd;
    //cout<<ans<<endl;
    //return 0;



multimap<long long,int>a;
multimap<long long,int>b;

rep(i,N){
    a.insert(make_pair(max(r[i]-p,z),i));
    b.insert(make_pair(max(q-l[i],z),i));
}
auto ait=a.end();
auto bit=b.begin();
bool div[N]={};
ait--;
//long long amin=ait->first;

while(ait!=a.begin()){
    div[ait->second]=true;//要素番号 (ait->second)が集合sに入っている
    //cout<<ait->second<<" ";
    while(1){
        if(!div[bit->second]){
        break;//bの最小がaに入っていない場合
        }
        bit++;//bの最小がaに入っていないところまでイテレータを進める
    }
    //cout<<bit->second<<" "<<endl;;
    ans=max(ait->first+bit->first,ans);
    ait--;
}

cout<<ans<<endl;
 return 0;
}
/*
4
4 7
1 4
5 8
2 5

6

4
1 20
2 19
3 18
4 17

34

10
457835016 996058008
456475528 529149798
455108441 512701454
455817105 523506955
457368248 814532746
455073228 459494089
456651538 774276744
457667152 974637457
457293701 800549465
456580262 636471526

540049931
*/


Measured memory_bytes: 27648
#include <stdio.h>
int main(void)
{
	int t,n,i,a;
	for(i=1;i<=4;i++){
	scanf("%d %d",&t,&n);
	if(t==1){
	a=6000*n;
	}
	else if(t==2){
	a=4000*n;
	}
	else if(t==3){
	a=3000*n;
	}
	else if(t==4){
	a=2000*n;
	}
	printf("%d\n",a);
	}
	return 0;
}

Measured memory_bytes: 600
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x!=NIL){ // zを挿入する位置を探索
        y = x;
        if(z->key < x->key){ // 左部分木
            x = x->left;
        }
        else{   // 右部分木
            x = x->right;
        }
    }
    z->parent = y;
    if(y==NIL){
        root = z;
    }
    else{
        if(z->key < y->key){
            y->left = z;
        }
        else{
            y->right = z;
        }
    }
}
void inorder(Node *u){
    if(u ==NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}
void preorder(Node *u){
    if(u ==NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(int argc, char const *argv[])
{
    int n;
    scanf("%d", &n);

    string com;
    int x;
    for(int i=0; i<n;i++){
        cin >> com;
        if(com == "insert"){
            scanf("%d", &x);
            insert(x);
        }
        else if(com == "print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}



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

int main() {
  string s[7]={"mon","tue","wed","thu","fri","sat","sun"};
  int k=5,x;
  cin >> x;
  if(x<9) for(int i=9; i>x; i--) k=(k+6)%7;
  else for(int i=9; i<x; i++) k=(k+1)%7;
  cout << s[k] << endl;
  return 0;
}


Measured memory_bytes: 3168
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main solution = new Main();
		Scanner scanner = new Scanner(System.in);
		String input = scanner.next();
		String ans = solution.decision(input);
		
		System.out.println(ans);
		scanner.close();
	}
	
	
	public String decision(String input) {
		String res = "No";
		int count = 0;
		
		for (int i = 0; i < input.length()-1; i++) {
			String s = input.substring(i, i+1);
			String next = input.substring(i+1,i+2);
			if (s.equals(next)) {
				count++;
				if (count>=2) {
					res="Yes";
					}
			}else{
				count=0;
			}
		}
		return res;
	}
}


Measured memory_bytes: 23380
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int n,i,j,x,y;
    scanf("%d",&n);
    int a[n],b[n];
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    if(n%2==0)
        for(i=0,j=n-1,x=n/2,y=0;j>0||y<n;i++,j-=2,x++,y+=2)
    {
         if(j>0)b[i]=a[j];
         if(y<n)b[x]=a[y];
    }
    else
        for(i=0,j=n-1,x=n/2+1,y=1;j>=0||y<n;i++,j-=2,x++,y+=2)
    {
        if(j>=0)b[i]=a[j];
        if(y<n)b[x]=a[y];
    }
    for(i=0;i<n;i++)
        cout<<b[i]<<" ";
    return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
	string A; cin >> A;
	int N = A.size();
	vector<int> num(26);
	ll ans = 1;
	int sum = 0;
	rep(i,N){
		ans += sum - num[A[i]-'a'];
		num[A[i]-'a']++;
		sum++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 640
<?php

fscanf(STDIN, "%d", $n);

if ($n == 1) {
    echo 0, PHP_EOL;
    return;
}

$primes = [];
for ($i = 2; $i <= sqrt($n); ++$i) {
    if ($n % $i == 0) {
        $ex = 0;

        while ($n % $i == 0) {
            ++$ex;
            $n /= $i;
        }

        $primes[] = [$i, $ex];
    }
}
if ($n !== 1) {
    $primes[] = [$n, 1];
}

$res = 0;
foreach ($primes as $prime) {
    $e = $prime[1];
    $cnt = 0;
    $cur = 1;
    while ($e >= $cur) {
        $e -= $cur;
        ++$cur;
        ++$cnt;
    }

/* echo "e: $e, cnt: $cnt", PHP_EOL; */
    $res += $cnt;
}
echo $res;


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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

// #define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline void chmax(T& a,T const& b){a=max(a,b);}
template<class T> inline void chmin(T& a,T const& b){a=min(a,b);}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60; 

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N ;
  vl a(N); ll x; cin >> x ;
  rep(i,N) cin >> a[i] ;
  sort(ALL(a));
  int sum = 0;
  rep(i,N-1){
    if(x>=a[i]){
      x -= a[i];
      sum++;
    }else break;
  }
  if(x==a[N-1]) sum++;
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
from operator import itemgetter
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
s = input()
if s == 'BBB' or s == 'AAA':
    print('No')
    exit()
print('Yes')


Measured memory_bytes: 38768
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

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

    cout << (N - 1) / 2 << endl;

    return 0;
}


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

#define M_PI 3.14159265358979323846

using namespace std;

//typedef
//-------------------------#include <bits/stdc++.h>

#define M_PI 3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s)
{
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x)
{
    ostringstream sout;
    sout << x;
    return sout.str();
}
inline int readInt()
{
    int x;
    scanf("%d", &x);
    return x;
}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a) * (a))
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

//repetition
//------------------------------------------
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
//#define MOD 1000000007

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-8;

#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const int INF = 2147483647;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    double d;
    cin >> d;

    cout << max(d * sqrt(2), (double)(1 + (int)d)) << endl;
    return 0;
}



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

long long int N, a[114514], b;

long long mbp(int i){
    long long r = 1, a = 2;
    while(i){
        if(i & 1){
            r *= a;
            r %= 1000000007;
        }
        a *= a;
        a %= 1000000007;
        i /= 2;
    }
    return r;
}

int main(){
    scanf("%lld", &N);
    for(int i = 0; i < N; ++i){
        scanf("%lld", &b);
        if((b + N) & 1 == 0)return 0 & puts("0");
        ++a[b];
        if(a[b] > 2)return 0 & puts("0");
    }
    if(*a > 1)return 0 & puts("0");
    cout << mbp(N / 2) << endl;
    return 0;
}


Measured memory_bytes: 1024
N=gets.to_i
x = []
y = []
h = []

tmpx = 0
tmpy = 0
tmph = 0
N.times do
    xx,yy,hh = gets.chomp.split.map(&:to_i)
    x << xx
    y << yy
    h << hh
    if hh > 0
        tmpx = xx
        tmpy = yy
        tmph = hh
    end
end


0.upto(100) do |i|
    0.upto(100) do |j|
        hh = tmph + (tmpx - i).abs + (tmpy - j).abs

        flag = true;
        0.upto(N-1) do |k|
            if h[k] != [0, hh -  (x[k] - i).abs - (y[k] - j).abs].max
                flag = false
            end
        end      

        if flag == true
            printf("%d %d %d\n", i, j, hh)
            exit
        end
    end
end



Measured memory_bytes: 3836
from itertools import accumulate

N, K = map(int,input().split())
S = input()

nums = []
tmp = "1" #はじめに0が入ったら、0からスタートというのがわかる。
count = 0
for s in S:
    if tmp == s:
        count += 1
    else:
        nums.append(count)
        count = 1
        tmp = s
nums.append(count)
if tmp == "0":
    nums.append(0) #エッジの条件

# print(nums)
# 累積和表示にする(listって足し算できるのね)
# これによって、各文字最初の値が明らかになる
acc = [0]+list(accumulate(nums))
# print(acc)
n = len(nums)
w = 2*K + 1

if len(nums) <= w:
    print(N)
else:
    ans = 0
    for i in range(0,n-w+1,2): #2個飛ばし
        ans = max(ans,acc[i+w]-acc[i])

    print(ans)

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

int N, a[100005], dp[100005];

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

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		dp[i] = a[i];
	}

	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]) + dp[0];
	for (int i = 2; i < N; i++)
		dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
	cout << dp[N - 1] << endl;

}

Measured memory_bytes: 4424
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>

int N , A, B, C;
int ans = 900000000;
std::vector<int > l(8);

void Calc(std::vector<int > input){
  int count1=0;
  int count2=0;
  int count3=0;
  int val;
  int length1=0;
  int length2=0;
  int length3=0;
  for (int i=0; i<input.size(); i++){
    if (input[i]==1){
      count1++;
      length1+=l[i];
    } else if (input[i]==2){
      count2++;
      length2+=l[i];
    } else if (input[i]==3){
      count3++;
      length3+=l[i];
    }
  }
  if (count1*count2*count3==0){
    return;
  } else {
    val = 10*((count1-1)+(count2-1)+(count3-1));
    val += abs(A-length1)+abs(B-length2)+abs(C-length3);
  }
  ans = std::min(ans, val);
  return;
}

void loop(std::vector<int > input){
  //printf("loop called (size=%d)\n",input.size());
  if (input.size()==N){
    Calc(input);
    return;
  } else {
    for (int i=0; i<4; i++){
      std::vector<int > temp(input.size());
      std::copy(input.begin(), input.end(), temp.begin());      
      temp.push_back(i);
      loop(temp);
    }
  }
}

int main(){
  scanf("%d", &N);
  scanf("%d", &A);
  scanf("%d", &B);
  scanf("%d", &C);
  for (int i=0; i<N; i++){
    scanf("%d", &l[i]);
  }
  std::vector<int > take;
  loop(take);
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graph_utility.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;

typedef
    boost::adjacency_list<
                boost::vecS,
                boost::vecS,
                boost::undirectedS,
                boost::no_property,
                boost::property<boost::edge_weight_t,int>
        >
Graph;

typedef std::pair<int,int> Edge;

typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;

int N,M,R;
vector<int> r;

vector<vector<Vertex>> table;
vector<vector<size_t>> dist;

int distance(vector<int> v){
    int sum=0;
    for(int i=0;i<v.size()-1;i++){
        int d=dist[v[i]][v[i+1]];
        sum+=d;
    }
    return sum;
}

int search(){
    vector<int> v(r.begin(),r.end());
    sort(v.begin(),v.end());
    int min=distance(v);
    while(std::next_permutation(v.begin(),v.end())){
        min=std::min(min,distance(v));
    }
    return min;
}

void make_table(Graph g){
    table=vector<vector<Vertex>>(N,vector<Vertex>(boost::num_vertices(g)));
    dist=vector<vector<size_t>>(N,vector<size_t>(boost::num_vertices(g)));
    for(int from:r){
        boost::dijkstra_shortest_paths(g,from,
                boost::predecessor_map(&table[from][0]).distance_map(&dist[from][0]));
    }
}

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

    for(int i=0;i<R;i++){
        int _r;
        cin >> _r;
        _r--;
        r.push_back(_r);
    }

    vector<Edge> edge;
    vector<int> weight;

    for(int i=0;i<M;i++){
        int a,b,c;
        cin >> a >> b >> c;
        a--;
        b--;
        edge.push_back(Edge(a,b));
        weight.push_back(c);
    }

    Graph graph(edge.begin(),edge.end(),weight.begin(),M);

    make_table(graph);
    
    cout << search() << endl;

    return 0;
}



Measured memory_bytes: 67700
#include<bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = (a), i##_end_ = (b); i <= i##_end_; ++i)
#define drep(i, a, b) for(int i = (a), i##_end_ = (b); i >= i##_end_; --i)
#define clear(a, b) memset((a), (b), sizeof((a))
typedef long long LL;
int read(){
	int x = 0, flag = 1;
	char ch = getchar();
	while(!isdigit(ch)) {
		if(ch == '-') flag = -1;
		ch = getchar();
	}
	while(isdigit(ch)) {
		x = x * 10 + ch - 48;
		ch = getchar();
	}
	return x * flag;
}

#define Maxn 109
int n, l[Maxn * 2];
int main(){
	n = read();
	rep(i, 1, 2 * n) l[i] = read();
	sort(l + 1, l + 2 * n + 1);
	int ans = 0;
	rep(i, 1, n) 
		ans += l[2 * i - 1]; 
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include<ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
typedef    complex<ld>   P;
#define    X   real()
#define    Y   imag()
ld restant(P p){return abs(p);}
//polar(x,y) mag=l,arg=y
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pair<ll,ll> >   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pair<int,int> >   vpi;
typedef    vector<pair<double,double> >   vpd;
typedef    pair<double,double>   pd;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf   1000000000000000001
#define    ninf   -1000000000000000001
#define    ima   1000000001
#define    imi   -1000000001
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define all(x) x.be(),x.en()
#define    eps   1e-9
const    ld   PI=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return((a-b+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}

int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{	
string s;
cin>>s;
int fr[26]={0};
for(int i=0;i<s.length();i++)
{
	int k=int(s[i])-97;
	fr[k]++;
}

bool f=true;
for(int i=0;i<26;i++)
{
	if(fr[i]%2==1)
	{
		f=false;
		break;
	}
}

if(f)
cout<<"Yes";
else
cout<<"No";

}return 0;}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int n,i,a[100010];
  long s=0,h1=0,h2=0;
  cin >> n;
  for (i=0;i<n;i++) cin >> a[i];
  for (i=0;i<n;i++){
    s+=a[i];
    if (i%2 && s>=0){
      h1+=s+1;
      s=-1;
    }
    if (i%2==0 && s<=0){
      h1+=1-s;
      s=1;
    }
  }
  s=0;
  for (i=0;i<n;i++){
    s+=a[i];
    if (i%2==0 && s>=0){
      h2+=s+1;
      s=-1;
    }
    if (i%2 && s<=0){
      h2+=1-s;
      s=1;
    }
  }
  cout << min(h1,h2) << endl;
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	char n; cin >> n;
	if (n == 'A') {
		cout << 'T' << endl;
	}
	if (n == 'T') {
		cout << 'A' << endl;
	}
	if (n == 'C') {
		cout << 'G' << endl;
	}
	if (n == 'G') {
		cout << 'C' << endl;
	}
	cin >> n;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
int n , l = 1 , r ;
const int N = 2e5 + 10 ;
int a[N << 1] ;
int vis[N << 1] ;
inline int getl() {
  while(l <= r && vis[l]) ++ l ; vis[l] = 1 ; return l ;
}
inline int getr() {
  while(l <= r && vis[r]) -- r ; vis[r] = 1 ; return r ;
}
signed main() {
  ios :: sync_with_stdio(false) ;
  cin.tie(nullptr) ;
  cout.tie(nullptr) ;
  cin >> n ; int x ;
  cin >> x ; r = n << 1 , r -- ;
  if(n == 1) return cout << x << '\n' , 0 ;
  if(x == 1 || x == 2 * n - 1) return cout << "No" << '\n' , 0 ;
  a[n] = x ; vis[x] = 1 ;
  a[n + 1] = getr() ;
  a[n - 1] = getl() ;
  if(x == 1) a[n - 2] = getr() ;
  else a[n + 2] = getl() ;
  for(register int i = 1 ; i <= (n << 1) - 1 ; i ++)
    if(! a[i]) a[i] = getl() ;
  cout << "Yes" << '\n' ;
  for(register int i = 1 ; i <= (n << 1) - 1 ; i ++)
    cout << a[i] << '\n' ;
  return 0 ;
}


Measured memory_bytes: 3072
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var L = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        L = L.OrderByDescending(x => x).ToArray();

        int count = 0;

        for (var i = 0; i < N; i++)
        {
            for (var j = i + 1; j < N; j++)
            {
                for (var k = N - 1; k > j; k--)
                {
                    if (L[i] < L[j] + L[k])
                    {
                        count = count + k - j;
                        break;
                    }
                }
            }
        }

        Console.WriteLine(count);
    }
}


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

int main(void){
    int n, a;
    cin >> n >> a;
    if(n%500 <= a){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong();
    long Y = sc.nextLong();
		int ans = 1;
		while (X * 2 <= Y) {
			ans++;
			X *= 2;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  	int N;
  	cin >> N;
  	cout << N*N*N <<endl;
    
  	return 0;
}













Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

// d

int main() {
    ll h; cin >> h;
    ll ans = 0;
    ll n = 1;
    while (h > 0) {
        ans += n;
        h /= 2;
        n *= 2;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int n, m, c;
    cin >> n >> m >> c;
    int b[m], a[n][m];
    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 cnt = 0;
    for (int i = 0; i < n; i++) {
        long long sum = c;
        for (int j = 0; j < m; j++) {
            sum += a[i][j] * b[j];
        }
        if (sum > 0) cnt++;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
s=input()
fr=s[0:2]
ba=s[2:4]
if 1<=int(fr)<=12 and 1<=int(ba)<=12:
    ans="AMBIGUOUS"
elif 1<=int(fr)<=12 and (int(ba)<1 or int(ba)>12):
    ans="MMYY"
elif 1<=int(ba)<=12 and (int(fr)<1 or int(fr)>12):
    ans="YYMM"
elif (int(ba)<1 or int(ba)>12) and (int(ba)<1 or int(ba)>12):
    ans="NA"
print(ans)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
long long solve(){
	int n;
	cin>>n;
	vector<int>H(n);
	vector<long long>V(n);
	for(int i=0;i<n;i++) cin>>H[i];
	for(int i=0;i<n;i++) cin>>V[i];
	map<int,long long>A; //more height means more dp[i]
	long long dp[n];
	dp[0]=V[0];
	A[H[0]]=V[0];
	long long ans=V[0];
	for(int i=1;i<n;i++){
		dp[i]=V[i];
		auto it=A.lower_bound(H[i]);
		if(it!=A.begin()){
			auto it1=it;
			dp[i]=V[i]+(--it1)->second;
		}
		auto it1=it;
		while(it!=A.end() && it->second<=dp[i]) it++;
		A.erase(it1,it);
		A[H[i]]=dp[i];
		ans=max(ans,dp[i]);
	}
	return ans;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<solve();

}

Measured memory_bytes: 19556
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ld = long double;

// ========================================================================



ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a)
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a)
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll sum(ll n) {
	return (1 + n) * n / 2;
}
//1から整数nまでの合計を出す
ll mch(ll n) {
	if (n == 1) return 1;
	else return n * mch(n - 1);
}
//1から整数nまでの階乗を出す(INFで割っていない)
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double m = sqrt(a);
	for (int i = 3; i <= m; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定
ll modpow(ll a, ll n, ll mod) {
	ll hi = 1;
	while (n > 0) {
		if (n & 1) hi = hi * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return hi;
}
//いろいろやります（ただの前座）
ll mg(ll a, ll mod) {
	return modpow(a, mod - 2, mod);
}
//割り算の10^9+7等対策で逆元を出します



// ========================================================================


int main() {
	ll n; cin >> n;
	for (int i = n;; i++) {
		if (prime(i)) {
			cout << i << endl;
			break;
		}
	}

	return 0;
}

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

int main() {
  int a,b,k,count;
  cin>>a>>b>>k;
  vector<int> x(0);*/
    
#include <bits/stdc++.h>
using namespace std;

int main() {
  string s;
  int a,b;
  cin>>s;
  a=b=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='0')a++;
    else b++;
  }
  a=min(a,b);
  cout<<a*2<<endl;
}

Measured memory_bytes: 512
(n, m) = gets.chomp.split(' ').map(&:to_i)
x = gets.chomp.split(' ').map(&:to_i).sort
l = x[m - 1] - x[0]

if n >= m then
  puts 0.to_s
elsif n == 1 then
  puts l.to_s
else
  d = [-1] * (m - 1)
  (m - 1).times do |i|
    d[i] = x[i + 1] - x[i]
  end
  
  puts (l - d.sort{|a, b| b <=> a}[0...(n - 1)].reduce(:+)).to_s
end

Measured memory_bytes: 11896
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
ll MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}
ll modpow(ll x, ll y, ll m) {
    if (y == 0) return 1;
    ll res = modpow(x, y / 2, m);
    return res * res % m * (y & 1 ? x : 1) % m;
}
ll modinv(ll x) { return modpow(x, MOD - 2, MOD); }

int main(){
    ll N; string S; cin >> N >> S;
    ll ans = 0;
    rep(i,N-2) ans += S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C';
    print(ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, count;
  
  count = 0;
  
  cin >> n;
  
  int p[n];
  
  for (int i = 0; i < n; i++ ) cin >> p[i];
  
  for (int j = 0; j < n-2; j++ ) {
      if ((p[j] < p[j+1] && p[j+1] < p[j+2]) || (p[j] > p[j+1] &&  p[j+1] > p[j+2])) {
          count++;
      };
  };
  
  cout << count << endl;
  
  return 0;
}

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

int main() {
    int n, q;
    cin >> n >> q;
    vector<stack<int>> a(n);
    for (int i = 0; i < q; ++i) {
        int p, t;
        cin >> p >> t;
        if (p == 0) {
            int x;
            cin >> x;
            a[t].push(x);
        } else if (p == 1) {
            if (!a[t].empty()) cout << a[t].top() << endl;
        } else {
            if (!a[t].empty()) a[t].pop();
        }    
    }
}



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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    ll X, Y;
    cin >> X >> Y;

    if (abs(X - Y) > 1) {
        cout << "Alice" << endl;
    } else {
        cout << "Brown" << endl;
    }
}

Measured memory_bytes: 256