akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
S = input()

s1 = S[0]
s2 = S[2:-1]
s3 = S.replace("A","a").replace("C","c")

if s1 == "A" and s2.count("C") == 1 and S.lower() == s3:
    print("AC")
else:
    print("WA")

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

int main(){
    int a,b,k,cnt;
    cin>>a>>b>>k;
    cnt=0;
    for (int i=min(a,b);i>=1;--i){
        if (a %i==0 && b%i==0){
            cnt++;
            if (cnt==k){
                cout<<i<<endl;
                return 0;
            }
        }
    }
return 0;

}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int main()
{
	int i,ans=0;
	int t[5];
	int min = 0;
	for (i = 0; i < 5; i++) {
		cin >> t[i];
		if (t[i]%10!=0&&t[i] % 10 < t[min]%10) {
			min = i;
		}
	}
	for (i = 0; i < 5; i++) {
		if (i != min) {
			ans += (((t[i] - 1) / 10) + 1) * 10;
		}
		else {
			ans += t[i];
		}
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while (1) {
    c -= b;
    if (c <= 0) break;
    a -= d;
    if (a <= 0) break;
  }
  if (a > 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3636
using System;
using System.Linq;
using System.Security.Cryptography.X509Certificates;

class Project3
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray();
        var N = input[0];
        var Y = input[1];

        int xv = -1;
        int yv = -1;
        int zv = -1;

        for (int i = 0; i <= N; i++)
        {
            for (int j = 0; j <= N-i; j++)
            {
                var z = N - i - j;

                if ((10000 * i + 5000 * j + 1000 * z) == Y)
                {
                    xv = i;
                    yv = j;
                    zv = z;
                }
                
                
            }
        }

        Console.WriteLine($"{xv} {yv} {zv}");


        
    }
    
}

Measured memory_bytes: 28108
import math
import sys
n = int(input())

yakusuu = []

for i in range(1,int(n**0.5)+1):
    if n%i == 0:
        yakusuu.append((i, n/i))

ans = yakusuu[0][0]+yakusuu[0][1]
for i in range(len(yakusuu)):
    wa = yakusuu[i][0]+yakusuu[i][1]
    ans = min(wa, ans)
print(int(ans)-2)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
int n;
int d[1000000];

string check2(){
  int nowpos=n-1;
  int canhop=n-1;
  int minhop=n-1;

  for(int j=0;j<300000;j++){
    canhop=nowpos-d[nowpos]/10;
    minhop=canhop;
    if(canhop<=0)return "yes";

    for(int i=nowpos;i>=canhop;i--){
      if(i-d[i]/10<minhop){
        nowpos=i;
        minhop=i-d[i]/10;
      }
    }


  }
  return "no";
}

string check1(){
  int nowpos=0;
  int canhop=0;
  int maxhop=0;

  for(int j=0;j<300000;j++){
    canhop=d[nowpos]/10+nowpos;
    maxhop=canhop;
    if(canhop>=n-1)return check2();

    for(int i=nowpos;i<=canhop;i++){
      if(d[i]/10+i>=maxhop){
        nowpos=i;
        maxhop=d[i]/10+i;
      }
    }
  }
  return "no";
}

int main(){
  cin >>n;
  for(int i=0;i<n;i++){
    cin>>d[i];
    int sub=d[i]%10;
    d[i]-=sub;
  }
  cout <<check1()<<endl;
  return 0;
}

Measured memory_bytes: 4332
import numpy as np
def gcd(a, b):
	if a < b:
		a, b = b, a
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
n = int(input())
a = np.array([int(x) for x in input().split()])
np.sort(a)
l = np.zeros(n + 1)
r = np.zeros(n + 1)
m = np.zeros(n)
for i in range(n):
	l[i + 1] = gcd(l[i], a[i])
for i in reversed(range(n)):
	r[i] = gcd(r[i + 1], a[i])
for i in range(n):
	m[i] = gcd(l[i], r[i + 1])
print(int(np.max(m)))


Measured memory_bytes: 23084
#include<iostream>
#include<cstdio>
#include<stack>
using namespace std;
#define int long long
signed main(){
	stack<int> q;
	int a;
	while( scanf("%lld", &a) != EOF ){
		if(a==0){ cout << q.top() << endl; q.pop();}
		else q.push(a);
	}
	return 0;
}

Measured memory_bytes: 3032
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

ll ans = 0;

int main(void){
	int k; cin >> k;
	string s; cin >> s;
	if(s.length() <= k) cout << s;
	else{
		string t;
		for(int i=0; i<k; i++){
			cout << s[i];
		}
		cout <<"...";
	}
	return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}

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 kosuu(ll a){
    ll sum=0;
    for(ll i=1;i*i<=a;i++){
        if(a%i==0){
            if(a!=1&&i*i!=a){
            sum+=2;
            }else{
             sum++;   
            }
        }
    }
    return sum;
}
ll ans=-1000000000;



int main()
{
 double n;
 cin>>n;
 double a=n/3.0;
 cout<<fixed<<setprecision(10)<<a*a*a<<endl;
}



Measured memory_bytes: 3760
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
long long N,tmp;
cin>>N;
vector<long long> A;
vector<long long> B;
for(long long i=0;i<N;++i){
  cin>>tmp;
  A.push_back(tmp);
}
for(long long j=0;j<N;++j){
  cin>>tmp;
  B.push_back(tmp);
}
long long S,T,eq;
S=0;
T=0;
eq=0;
vector<long long> V;
long long target=0;
long long cum=0;
long long ans=0;
long long low=0;
long long high=0;
long long result;
for(int k=0;k<N;++k){
  if(B[k]==A[k]){
    eq+=1;
  }
  //B>Aの時の(A-B)、つまり後どのくらい熟練度が必要かの総和(Sとする)を求める
  else if(B[k]>A[k]){
    S+=(B[k]-A[k]);
    low+=1;
  }
  //B<Aの時の(A-B)をベクトル(v)にして入れておき総和をTとする、昇順に並べる
  else if(B[k]<A[k]){
    T+=(A[k]-B[k]);
    V.push_back(A[k]-B[k]);
    high+=1;
  }
}
//そもそも合計が足りてない
if(S>T){
  cout<<-1;
}
//すでにクリアしてる
else if(S==0){
  cout<<0;
}
else{
  sort(V.begin(),V.end(),greater<int>());
  target=S;
//前から足していって、総和がSを超える値を出す
  for(long long k=0;k<high;++k){
    cum+=V[k];
    ans+=1;
    if(cum>target){
      break;
    }
    }
  result=low+ans;
cout<<result;}
return 0;
}

Measured memory_bytes: 2676
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
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; }

int main(){
    int N,K;
    string S;
    cin>>N>>K>>S;
    if(S[K-1]=='A') S[K-1]='a';
    else if(S[K-1]=='B') S[K-1]='b';
    else if(S[K-1]=='C') S[K-1]='c';
    cout<<S<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef long long ll;
typedef pair<int,int>P;
#define MAX 1e9
struct edge{int to,cost;};

int main() {
  int a,b,c,d;
  cin >>a>>b>>c>>d;
  int flag=0;
  for(int i=0;i<=100;i++){
  		c=c-b;
  		a=a-d;
    	if(c<=0){flag=1;break;}
    	else if(a<=0){flag=2;break;}
  }
  if(flag==1)cout<<"Yes"<<endl;
  if(flag==2)cout<<"No"<<endl;
  
  
}


Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

template<typename T> bool chmax( T &a, const T &b ) { if ( a <= b ) { a = b; return ( true ); } else { return ( false ); } }
template<typename T> bool chmin( T &a, const T &b ) { if ( a >= b ) { a = b; return ( true ); } else { return ( false ); } }

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

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

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par.resize( n ); siz.resize( n ); par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


int main()
{
	int P, Q, R;
	cin >> P >> Q >> R;

	cout << P + Q + R - max( { P, Q, R } ) << endl;

	return ( 0 );
}


Measured memory_bytes: 888
#include<stdio.h>
#include<stdlib.h>
int merge(int *,int,int,int);
int mergeSort(int *,int,int);
int main(){
  int i,n,*A,count;
  scanf("%d",&n);
  A = (int*)malloc(n * sizeof(int));
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  count = mergeSort(A,0,n);
  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(!(i==n-1)) printf(" ");
      }
  printf("\n%d\n",count);
  return 0;
}

int merge(int *A,int left,int mid,int right){
  int n1,n2,i,j,k;
  int *L,*R;
  static int count;
  n1 = mid - left;
  n2 = right - mid;
  L = (int*)malloc((n1+1) * sizeof(int));
  R = (int*)malloc((n2+1) * sizeof(int));
  for(i=0;i<n1;i++) L[i]=A[left+i];
  for(i=0;i<n2;i++) R[i]=A[mid+i];
  L[n1]=2147483647;
  R[n2]=2147483647;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    count++;
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
    }
    else{
      A[k]=R[j];
      j++;
    }
  }
  return count;
}

int mergeSort(int *A,int left,int right){
  int count,mid;
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    count = merge(A,left,mid,right);
  }
  return count;
}



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

int main()
{
  int S,W;
  cin >> S >> W;
  if(S <= W) cout << "unsafe" << endl;
  else cout << "safe" << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <string>
#include <sstream>
#include <cstring>
#include <cmath>

using namespace std;

#ifdef DEBUG
#define LOG(args) cout << args << "\n"
#define debug(x) x
#else
#define LOG(args)
#define debug(x)
#endif

#define vi vector<int>
#define ii pair<int, int>
#define vii vector< ii >
#define vvi vector< vi >
#define mp make_pair
#define pb push_back
#define sz(x) (int)(x).size()
#define ms(x, v) memset(x, v, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define REP(x, n) for(int x = 0; x < n; x++)
#define REPS(x, n, s) for(int x = 0; x < n; x += s)
#define REPV(x, v, n) for(int x = v; x < n; x++)
#define REVE(x, n) for(int x = n; x >= 0; x--)

typedef long long ll;

ll N, K;

const ll Mod = (ll)1e9 + 7;

ll mod(ll a)
{
	return (a % Mod + Mod) % Mod;
}

ll mul(ll a, ll b)
{
	return mod(mod(a) * mod(b));
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> N >> K;
	vector<ll> pos, neg;
	ll x;
	REP(i, N)
	{
		cin >> x;
		if(x > 0)
			pos.pb(x);
		else
			neg.pb(x);
	}
	ll ans = 1;
	if(sz(pos) > 0)
	{
		sort(all(pos), greater<>()), sort(all(neg));
		if(K & 1)
		{	
			ans = mul(ans, pos.front());
			pos.erase(pos.begin());
			--K;
		}
		vector<ll> two;
		REPS(i, sz(pos) - 1, 2)
			two.pb(pos[i] * pos[i + 1]);
		REPS(i, sz(neg) - 1, 2)
			two.pb(neg[i] * neg[i + 1]);
		if(sz(pos) & 1 && sz(neg) & 1)
			two.pb(pos.back() * neg.back());
		sort(all(two), greater<>());
		K >>= 1;
		REP(i, K)
			ans = mul(ans, two[i]);
		cout << ans << "\n";
	}
	else
	{
		if(K & 1)
			sort(all(neg), greater<>());
		else
			sort(all(neg));
		REP(i, K)
			ans = mul(ans, neg[i]);
		cout << ans << "\n";
	}
	return 0;
}













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

int main() {
	int tmp[3], ans;
	for (int i = 0; i < 3; ++i) cin >> tmp[i];
	sort(tmp, tmp + 3);
	tmp[0] += tmp[2] - tmp[1];
	ans = tmp[2] - tmp[1];
	if ((tmp[2] - tmp[0]) % 2) ans += (tmp[2] - tmp[0]) / 2 + 2;
	else ans += (tmp[2] - tmp[0]) / 2;
	cout << ans;
}

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

int main(){
    ll N, P;
    cin >> N >> P;

    ll ans = 1;

    if(N == 1){
        cout << P << endl;
        return 0;
    }

    for(ll d = 2; d*d <= P; d++){
        int cnt = 0;
        while(P%d == 0){
            P /= d;
            cnt++;
        }

        if(cnt){
            ll k = cnt / N;
            for(int i = 1; i <= k; i++){
                ans *= d;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

int n,a,cnt[105],ret=0;

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    memset(cnt,0,sizeof(cnt));
    cin>>n;
    for(int i=0;i<n;i++) {
    	cin>>a;
    	if(cnt[a]==0)
    		ret++;
    	cnt[a]++;
	}
	cout<<ret<<endl;
}

Measured memory_bytes: 256
/* Search I */
#include<stdio.h>
int main(){
  int n,q; /* n: S, q: T */
  int S[10001],T[501]; /* n<=10000, q<=500 */
  int i,j,counter=0;

  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d", &S[i]);
  }
  scanf("%d", &q);
  for(i=0;i<q;i++){
    scanf("%d", &T[i]);
  }

  /* Linear Search */
  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(T[i]==S[j]){
        counter++;
        break;
      }
    }
  }

  printf("%d\n",counter);
  return 0;
}

Measured memory_bytes: 0
def main():
    a = int(input())
    l = list(map(int, input().split()))
    temp = [0]*100

    #集会の場所
    for p in range(1,101):
        #各人の消費体力
        for score in l:
            temp[p-1] += (score-p)**2
    print(min(temp))
            

if __name__ == '__main__' :
    main()

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

struct edge {int to, w, rev;};


int main()
{
  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int xor_sum = 0;
  int r = 0;

  ll ans = 0;
  rep(l, n) {
    while(r < n && !(xor_sum & a[r])) {
      xor_sum += a[r];
      ++r;
    }
    ans += r-l;
    if(r==l) ++r;
    else xor_sum ^= a[l];
  }
  cout << ans << endl;
}

Measured memory_bytes: 4004
#include<stdio.h>

int main(void){
  
  int a,b,c,d,e,k;
  int biggest,smallest;
  
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&d);
  scanf("%d",&e);
  scanf("%d",&k);
  
  if(e - a > k){
    printf(":(");
  }else{
    printf("Yay!");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

int main() {
    int n; cin >> n;
    int a; cin >> a;
    rep(i, n - 1) {
        int tmp; cin >> tmp;
        if (a < tmp) swap(a, tmp);
        a = gcd(a, tmp);
    }
    out(a);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(i, n) a[idx][i] = v[i]; idx++; PER = a;} while(next_permutation(ALL(v)));} while(0); // int fact(), VVI PERを宣言しておく
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

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

void END(){cout << 1 << endl; exit(0);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  REP(i, s.size()) cout << 'x';

  return 0;
}


Measured memory_bytes: 256
X, Y, A, B, C = map(int, input().split(' '))

P = sorted(list(map(int, input().split(' '))), reverse=True)[:X]
Q = sorted(list(map(int, input().split(' '))), reverse=True)[:Y]
R = sorted(list(map(int, input().split(' '))), reverse=True)

apples = sorted(P + Q + R, reverse=True)[:X + Y]

print(sum(apples))


Measured memory_bytes: 28448
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define fi first;
#define se second;
#define print(x,y) (cout << (x) << (y))
#define inf INT_MAX
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,bool> pib;
typedef vector<pii> vii;
typedef vector<pib> vib;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<string,string> pss;
typedef vector<pss> vss;
const int MOD = 1e9 + 7; //998244353;
bool isPal(string s){
    string rev = s;
    reverse(all(s));
    return s == rev;
}
int main(){
    boost;
    string s;
    cin >> s;
    if(isPal(s) && isPal(s.substr(0,(s.length()-1)/2)) && isPal(s.substr((s.length()+3)/2-1 , s.length() ))){
        cout << "Yes";
    }
    else cout << "No";
}



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

int main(){
    int x,m;
    cin>>x>>m;
   vector<string>v(x);
   for(int i=0;i<x;i++){
    cin>>v[i];
   }
sort(v.begin(),v.end());
for(int i=0;i<x;i++){
cout<<v[i];
}
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    int n;
    cin >> n;
    vector<ll> v(n + 1), w(n + 1);
    rep(i, n) cin >> v[i + 1] >> w[i + 1];

    vector<pair<int, int>> x, y[10001];
    vector<int> a, b;

    y[0].emplace_back(0, 0);
    for(int i = 1; i <= min(n, 10000); i++) {
        x.clear();
        for(auto [p, q] : y[i >> 1]) {
            x.emplace_back(p, q);
            if(p + w[i] <= 100000) x.emplace_back(p + w[i], q + v[i]);
        }
        sort(ALL(x));
        int mx = -1;
        for(auto p : x)
            if(chmax(mx, p.second)) y[i].push_back(p);
    }

    int m;
    cin >> m;
    rep(_, m) {
        int q, l;
        cin >> q >> l;
        if(q <= 10000)
            cout << (upper_bound(ALL(y[q]), make_pair(l, 1 << 30)) - 1)->second
                 << "\n";
        else {
            a.clear();
            b.clear();
            int N = 0;
            for(; q > 10000; q >>= 1) {
                a.push_back(v[q]);
                b.push_back(w[q]);
                N++;
            }
            int ret = -1;
            rep(i, 1 << N) {
                int sumv = 0, sumw = 0;
                rep(j, N) if(i >> j & 1) {
                    sumv += a[j];
                    sumw += b[j];
                }
                if(sumw <= l) {
                    chmax(ret,
                          sumv + (upper_bound(ALL(y[q]),
                                              make_pair(l - sumw, 1 << 30)) -
                                  1)
                                     ->second);
                }
            }
            cout << ret << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 411888
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
int n,m,d;
int cnt;
int main()
{
	scanf("%d%d%d",&n,&m,&d);
	if(!d)cnt=n;else cnt=(n-d)*2;
	printf("%.10lf",(double)cnt/n/n*(m-1));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#define MOD 1000000007
#define ll long long

using namespace std;

ll gcd(ll m, ll n){
    ll o = m%n;
    if(!o){
        return n;
    }else{
        return gcd(n,o);
    }
}
int main() {
    vector<ll> a;
    int n;
    cin >> n;
    for(int i = 0;i<n;i++){
        ll x;
        cin >> x;
        a.push_back(x);
    }
    
    ll ans = a[0];
    for(int i=0;i<n-1;i++){
        ans = ans / gcd(ans,a[i+1]) * a[i+1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N, K, Q = list(map(int, input().split()))

ans = [K-Q] * N

A = [0] * Q
for _ in range(Q):
    A[_] = int(input()) - 1
    ans[A[_]] += 1

for answer in ans:
    if answer > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 10416
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main
{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String args[])
    {
        FastReader obj = new FastReader();
        String s = obj.next();
        long n=0;
        for(int i=0;i<s.length();i++)
            n+=(s.charAt(i)-'0');
        System.out.println((n%9==0)?"Yes":"No");
    }
}


Measured memory_bytes: 35676
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp
#include <bits/stdc++.h>
using namespace std;

int main(){
  int n;

  while(cin>>n&&n!=0){
    vector<int> score(n);
    for(int i=0;i<n;++i)
      cin>>score[i];

    sort(score.begin(), score.end());

    cout<<accumulate(score.begin()+1,score.end()-1,0)/(score.size()-2)<<endl;
  }

  return EXIT_SUCCESS;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,l,ans=0;
	cin>>n>>l;
	if(l>0)
	{
		for(int i=l+1;i<=l+n-1;i++)ans+=i;
	}
	else if(l+n-1<0)
	{
		for(int i=l;i<l+n-1;i++)ans+=i;
	}
	else
	{
		for(int i=l;i<l+n;i++)ans+=i;
	}
	cout<<ans;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    int count = 0;
    int ans = 0;
    for (int i = 0; i < 3; i++) {
      if(a.charAt(i) == 'R') {
        count++;
        ans = Math.max(ans, count);
      } else {
        count = 0;
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 35560
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	
	ll N, M;
	cin >> N >> M;
	if (N < M) {
		swap(N, M);
	}
	if (M == 1) {
		if (N == 1) {
			cout << 1 << endl;
		}
		else {
			cout << max(ll(0), N - 2) << endl;
		}
	}
	else  {
		cout << (N - 2) * (M - 2) << endl;
	}
	
		
}

Measured memory_bytes: 3620
from math import floor


# calculation process
def check_pass(ps):
    for i in range(len(ps) - 1):
        dif = ps[i] - ps[i + 1]
        if dif == 0:
            print("Bad")
            return ""
    print("Good")
    return ""


# input process
inputData = input()
ps = [int(x) for x in inputData]

check_pass(ps)


Measured memory_bytes: 2940
#include<iostream>
#include<string>
using namespace std;
int main(){
    string str;
    int res[26]={};
    while(getline(cin,str)){
        for(int i=0;i<(int)str.size();i++){
            if(str[i]>='a'&&str[i]<='z')res[str[i]-'a']++;
            else if(str[i]>='A'&&str[i]<='Z')res[str[i]-'A']++;
        }
    }
    for(int i=0;i<26;i++)cout<<(char)('a'+i)<<" : "<<res[i]<<endl;
}


Measured memory_bytes: 3140
#include<stdio.h>
#include <string.h>

int heap[2000001];
int have;

void up(int k)
{
	int save;
	while(k>1&&heap[k/2]<heap[k])
	{
		save=heap[k];
		heap[k]=heap[k/2];
		heap[k/2]=save;
		k=k/2;
	}
}

void down(int k)
{
	int i,save;
	while(2*k<=have)
	{
		i=2*k;
		if(i<have&&heap[i]<heap[i+1])
		{
			i++;
		}
		if(heap[k]>=heap[i])
		{
			break;
		}
		else
		{
			save=heap[k];
			heap[k]=heap[i];
			heap[i]=save;
			k=i;
		}
	}
}

void insert(int a)
{
	have++;
	heap[have]=a;
	up(have);
}

void extract()
{
	int save;
	if(have<1)
	{
		return;
	}
	save=heap[1];
	heap[1]=heap[have];
	heap[have]=save;
	have--;
	down(1);
	printf("%d\n",heap[have+1]);
	return;
}

int main(void)
{
	int N;
	int num;
	char get[10];
	have=0;

	while(1)
	{
		scanf("%s",get);
		if(strcmp(get,"end")==0)
		{
			break;
		}
		if(strcmp(get,"insert")==0)
		{
			scanf("%d",&num);
			insert(num);
		}
		if(strcmp(get,"extract")==0)
		{
			extract();
		}
	}


	return 0;
}



Measured memory_bytes: 5688
#include <stdio.h>
#include <string.h>

int main(void){
	unsigned int i, j, ans, c[4];
	char kupc[5] = {"KUPC"}, s[302];
	scanf("%s",s);
	memset(c,0,sizeof(c));
	for(i = 0;i < strlen(s);i++){
		for(j = 0;j < 4;j++){
			if(kupc[j] == s[i]) c[j]++;
		}
	}
	ans = 500;
	for(i = 0;i < 4;i++)
		if(ans > c[i]) ans = c[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 968
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pi=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
void Yes(bool c) { if (c)print("Yes"); else print("No"); };
void YES(bool c) { if (c)print("YES"); else print("NO"); };

void solve() {
    int n,x,ans;
    while(1){
        cin >> n >> x;
        if(n==0 && x==0) break;
        
        ans = 0;
        rng(i,1,n-1){
            rng(j,i+1,n){
                rng(k,j+1,n+1){
                    if(i+j+k==x) ans++;
                }
            }
        }
        print(ans);
    }

}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}


Measured memory_bytes: 3148
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int N = in.nextInt();

    int ans = 0;
    if (N < 10) {
      ans = N;
    } else if (N < 100) {
      ans = 9;
    } else if (N < 1000) {
      ans = 9;
      ans += N - 99;
    } else if (N < 10000) {
      ans = 909;
    } else if (N < 100000) {
      ans = 909;
      ans += N - 9999;
    } else if (N < 1000000) {
      ans = 90909;
    }

    System.out.println(ans);
  }
}

Measured memory_bytes: 23636
#include <iostream>
#include <vector>
using namespace std;
using ll = long long int;

namespace MY {
template<typename T>
T min(T a, T b) {
  if (a < b) {return a;}
  else {return b;}
}
template<typename T>
T max(T a, T b) {
  if (a > b) {return a;}
  else {return b;}
}
}

int main() {
  ll N;
  cin >> N;
  
  vector<ll> monster;
  for (int i = 0; i <= N; i++) {
  	ll ai;
    cin >> ai;
    monster.push_back(ai);
  }
  vector<ll> brave;
  for (int i = 0; i < N; i++) {
    ll bi;
    cin >> bi;
  	brave.push_back(bi);
  }
  
  ll sum = 0;
  for (int i = 0; i < N; i++) {
  	sum += MY::min(monster[i], brave[i]);
    brave[i] -= MY::min(monster[i], brave[i]);
    
    sum += MY::min(monster[i + 1], brave[i]);
    monster[i + 1] -= MY::min(monster[i + 1], brave[i]);
  }
  cout << sum << endl;
}

Measured memory_bytes: 5576
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
sum_satisfaction = sum(b)

for i in range(0,n-1):
    if(a[i+1] - a[i] == 1 ):
        sum_satisfaction = sum_satisfaction + c[a[i]-1]
   
print(sum_satisfaction)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
	static int mod=1000000007;
	static Scanner scan=new Scanner(System.in);
	static long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}
	static long lcm (long a, long b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
			}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	static String reverce(String str) {
		String strr="";
		for(int i=str.length()-1;i>=0;i--) {
			strr+=str.charAt(i);
		}
		return strr;
	}
	static long modpow(long a,long n) {
		if(n==0) return 1;
		else if(n==1)return a;
		long tmp=modpow(a,n/2);
		tmp%=mod;
		tmp*=tmp;
		tmp%=mod;
		if(n%2==0)return tmp;
		else return (tmp*a)%mod;
	}
	public static void main(String[] args){
		String str=scan.next();
		System.out.println(str.substring(0,str.length()-8));
	}
}


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

int main()
{
    int q;
    cin>>q;
    vector<ll> run;
        priority_queue<ll, vector<ll>, greater<ll>> minheap;
    priority_queue<ll> maxheap;
    ll a, b,over=0;
    ll old_median=0;
    ll temp;
    cin>>temp;
    cin>>a>>b;
    if(a>0)
    minheap.push(a);
    else
    maxheap.push(a);
    run.push_back(a);
    over+=b;
        ll median = 0;

    old_median=a;
    median=a;
    ll min_value=0;





    for(int i=1; i<q; i++)
    {
        ll e;
        cin>>e;
        if(e==1)
        {

            ll ae, be;
            cin>>ae>>be;
            over+=be;
            run.push_back(ae);
            if (ae <= median)
            {
                maxheap.push(ae);
            }
            else
            {
                minheap.push(ae);
            }

            if (minheap.size() > maxheap.size()+1)
            {
                maxheap.push(minheap.top());
                minheap.pop();
            }
            if (maxheap.size() > minheap.size()+1)
            {
                minheap.push(maxheap.top());
                maxheap.pop();
            }

            if (minheap.size() == maxheap.size())
            {
                median = min(minheap.top(),maxheap.top());
            }
            else if(minheap.size() > maxheap.size())
            {
                median = minheap.top();
            }
            else if (minheap.size() < maxheap.size())
            {
                median = maxheap.top();
            }
            if(run.size()%2==0)
            {
                min_value+=abs(old_median-median)+abs(ae-median);
            }
            else
                min_value+=abs(ae-median);
            old_median=median;
        }
        else
            cout<<(ll)(median)<<" "<<(ll)(min_value+over)<<"\n";
    }
}


Measured memory_bytes: 4856
N,K = map(int,input().split())

A = list(map(int,input().split()))

LL = []
RR = []

for a in A:
    if a<0:
        LL.append(a*(-1))
    else:
        RR.append(a)

Llen = len(LL)
min_ans = sum(LL)+sum(RR)
for i in range(N-K+1):
    ans = 0
    #左完結
    if i+K<=Llen: ans = LL[i]
    #右完結
    elif i>=Llen: ans = RR[K-1]
    #それ以外
    else:
        #print(i)
        lr = [LL[i],RR[i+K-Llen-1]]
        ans = max(lr)+min(lr)*2
            
    #print(ans)
    if ans<min_ans:min_ans = ans
        
print(min_ans)

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

namespace ConsoleApp2
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] strings = Console.ReadLine().Split(' ');

            int currentH = 0;

            for (int i = 0; i < N; i++)
            {
                int nextH = int.Parse(strings[i]);
                if (currentH < nextH) nextH--;
                else if(currentH>nextH)
                {
                    Console.WriteLine("No");
                    Console.ReadLine();

                    return;
                }
                currentH = nextH;
            }

            Console.WriteLine("Yes");
            Console.ReadLine();
        }

    }


}


Measured memory_bytes: 26336
open System

let N = Console.ReadLine() |> int
let S = Console.ReadLine() |> string

let mutable slimes = 1
let mutable x = S.[0]

for i in [ 1 .. N-1 ] do
    if x <> S.[i] then
        x <- S.[i]
        slimes <- slimes + 1

printfn "%d" slimes

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

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int gcd(int a, int b) {
  if (a == b) {
    return a;
  }
  else if (a > b) {
    return gcd(a - b, b);
  }
  else {
    return gcd(a, b - a);
  }
}

long divcount(long a, long b, long c) {
  long first;
  if (a % c == 0) {
    first = a;
  }
  else {
    first = a - a % c + c;
  }
  long last = b - b % c;
  return (last - first) / c + 1;
}

int main() {
  std::cout << std::setprecision(9);
  long a, b, c, d;
  cin >> a >> b >> c >> d;

  long div_c = divcount(a, b, c);
  long div_d = divcount(a, b, d);
  long div_cd = divcount(a, b, c * d / gcd(c, d));
  cout << b - a + 1 - div_c - div_d + div_cd << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int w,h,n;
	int x1=0,x2,y1=0,y2;
	int x,y,a;
	cin>>w>>h>>n;
	x2=w;
	y2=h;
	for(int i=0;i<n;i++){
		cin>>x>>y>>a;
		if(a==1){
			if(x>=x2){
				cout<<0<<endl;
				return 0;
			}
			if(x>x1) x1=x;
		}
		else if (a==2){
			if(x<=x1){
				cout<<0<<endl;
				return 0;
			}
			if(x<x2) x2=x;
		}else if (a==3){
			if(y>=y2){
				cout<<0<<endl;
				return 0;
			}
			if(y>y1) y1=y;
		}else{
			if(y<=y1){
				cout<<0<<endl;
				return 0;
			}
			if (y<y2) y2=y;
		}
	}
	cout<<(x2-x1)*(y2-y1)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const int INF = 1e9;

signed main(){
  int N, M; cin >> N >> M;
  vector<int> cost(M);
  vector<int> type(M, 0);
  for(int i = 0; i < M; i++){
    int t; cin >> cost[i] >> t;
    for(int j = 0; j < t; j++){
      int x; cin >> x; type[i] += (1 << (x - 1));
    }
  }
  vector<vector<int> > dp(M + 1, vector<int> (1 << N, INF));
  dp[0][0] = 0;
  for(int i = 0; i < M; i++){
    for(int j = 0; j < (1 << N); j++){
      dp[i + 1][j] = min(dp[i][j], dp[i + 1][j]);
      dp[i + 1][j | type[i]] = min(dp[i + 1][j | type[i]], dp[i][j] + cost[i]);
    }
  }
  int ans = dp[M][(1 << N) - 1];
  if(ans == INF) cout << -1 << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 16384
#include"bits/stdc++.h"
using namespace std;
int main(){
	int x;
	vector<int> y;
	cin>>x;
	int temp;
	for(int i=0;i!=x;++i){
		cin>>temp;
		y.push_back(temp);
	}
	sort(y.begin(),y.end());
	cout<<y.back()-y.front();
}

Measured memory_bytes: 256