akhauriyash/Code-Regression huggingface dataset:
/**==============================================================*
*            "Bismillahir Rahmanir Raheem"                       *
*        Author          :  Misbah Uddin Tareq.                  *
*        Semester        :  5(C),CSE                             *
*        University      :  Leading University,Sylhet.           *
*===============================================================**/

#include<bits/stdc++.h>
using namespace std;
#define  ll                     long long
#define  pb                     push_back
#define  pii                    pair<int,int>
#define  pll                    pair<ll,ll>
#define  ff                     first
#define  ss                     second
#define  MX                     100005
#define  endl                   "\n"
#define  mod                    1e9+7
#define  pi                     acos(-1.0)
#define  PQ                     priority_queue
#define  mem(a,b)               memset(a, b, sizeof(a))
#define  bug(a)                 cout<<#a<<":"<<a<<endl
#define  all(x)                 (x).begin(),(x).end()
#define  allr(x)                (x).rbegin(),(x).rend()
#define  double_print(x,a)      cout<<fixed<<setprecision(x)<<a<<endl

ll n,h[MX],dp[MX];

ll fn(ll idx)
{
    if(idx>=n-1)
        return 0;

    ll &ret=dp[idx];
    if(~ret)
        return ret;

    if(idx==n-2)
        ret=abs(h[idx]-h[idx+1])+fn(idx+1);
    else
        ret=min(abs(h[idx]-h[idx+1])+fn(idx+1),abs(h[idx]-h[idx+2])+fn(idx+2));
    return ret;
}

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

    mem(dp,-1);
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>h[i];

    cout<<fn(0)<<endl;

    return 0;
}


Measured memory_bytes: 8312
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define se second
#define fi first
#define pb push_back

int main()
{
  ll n,m,sum=0 ;
  cin >> n >> m ;
  vector<ll> v(m) ;
  for(ll i=0;i<m;i++)
  {
    cin >> v[i] ;
    sum += v[i] ;
  }
  if(sum>n) cout << "-1" << endl;
  else cout << n-sum << endl;


}


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

int main() {
    int a, b;
    cin >> a >> b;
    
    double f = double(a) / double(b);
    int d = a / b;
    int r = a % b;
    
    printf("%d %d %f\n", d, r, f);
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int x;
    cin >> x;

    int sum;
    int count = 0;
    for (int i=0; i<=a; ++i) {
        for (int j=0; j<=b; ++j) {
            for (int k=0; k<=c; ++k) {
                sum = 500*i + 100*j + 50*k;
                if (sum == x) ++count;
            }
        }
    }
    cout << count << endl;
    return 0;
}




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

int main(void) {
	int n;
	int m;
	int b[101];
	int num[101][101];
	int sum[101] = {};

	cin >> n >> m;

	for (int i = 1; i <= n; i++) {
		for (int t = 1; t <= m; t++) {
			cin >> num[i][t];
		}
	}

	for (int i = 1; i <= m; i++) {
		cin >> b[i];
	}

	for (int i = 1; i <= n; i++) {
		for (int t = 1; t <= m; t++) {
			sum[i] += num[i][t] * b[t];
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << sum[i] << "\n";
	}

	return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
/* this code is generated by shikhar verma . Dont try to copy it. You may be booked under plaigarism. */
//int numberofPaths(int h,int w,int a,int b);
int main()
{
    ll n,i,j,len1,b,h,w,t,cnt=0,cnt1=0;
   /* freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	cin>>n;
	ll a[n];
	for(i=0;i<n;i++)
    {
        cin>>a[i];
        cnt+=a[i];
    }

    t=round((float)cnt/n);
   // cout<<t<<endl;
    for(i=0;i<n;i++)
    {
        cnt1+=(t-a[i])*(t-a[i]);
    }
    cout<<cnt1;


    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,n) cin>>a[i];
  sort(a,a+n);
  cout<<a[n-1]-a[0]<<endl;

  return 0;
}





Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  u64 n, a, b;
  cin >> n >> a >> b;
  u64 add = a-b;
  l64 h[n];
  l64 h_max = 0;
  for (u64 i = 0; i < n; ++i) {
    cin >> h[i];
    h_max = max(h_max, h[i]);
  }
  u64 top = (h_max-1) / b + 2;
  u64 bottom = 0;
  u64 tgt = (top+bottom)/2;
  while (true) {
    u64 dmg = 0;
    for (u64 i = 0; i < n; ++i) {
      if (h[i] <= b*tgt) continue;
      dmg += ((h[i]-b*tgt)-1)/add + 1;
    }
    if (dmg <= tgt) {
      top = tgt;
      tgt = (top+bottom)/2;
    } else {
      bottom = tgt;
      tgt = (top+bottom+1)/2;
    }
    if (top-bottom == 1) break;
  }
  cout << top << endl;
  return 0;
}


Measured memory_bytes: 1024
/*input
10 4
40 10 20 70 80 10 20 70 80 60
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k; cin >> n >> k;
    vector<ll> h(n);
    vector<ll> dp(n, INF64);
    dp[0] = 0;
    for(int i = 0; i < n; i++) cin >> h[i];
    for(int i = 1; i < n; i++) for(int j = 1; j <= k; j++) if(i - j > -1) dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
    cout << dp[n - 1];

    return 0;
}

Measured memory_bytes: 1792
N = int(input())
A = list(map(int, input().split()))

ans = float('inf')
for i in range(min(A), max(A)+1):
    ans_temp = 0
    for j in range(N):
        ans_temp += (A[j]-i)**2
    if ans_temp < ans:
        ans = ans_temp
print(ans)

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

const long long MOD = (long long)1e9 + 7;

int dat[65][2];

int main() {
    for (int i=0; i<63; i++) dat[i][0] = dat[i][1] = 0;

    long long res = 0;

    int n; scanf("%d", &n);
    for (int i=1; i<=n; i++) {
        long long a; scanf("%lld", &a);
        for (long long i=0,mast=1; i<(long long)60; i++,mast<<=(long long)1) {
            res = (res + (mast % MOD) * dat[i][a & mast ? 0 : 1]) % MOD;
            dat[i][a & mast ? 1 : 0] += 1;
        }
    }

    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        Long a = in.nextLong();
        Long b = in.nextLong();
        Long c = in.nextLong();
        Long k = in.nextLong();

        if(k % 2 == 0) {
            System.out.println(a-b);
        } else {
            System.out.println(b-a);
        }
    }
}

Measured memory_bytes: 21204
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


const D EPS=1e-7;


int main(){
    ll t;
    cin>>t;
    vector<D> Ex(t+1,0);
    for(int i=0;i<=t;i++){
        ll n,m;
        cin>>n>>m;
        D sum=0;
        vector<pair<int,D>> A(m);
        for(auto &I:A){
            cin>>I.F>>I.S;
            sum+=I.S;
        }
        for(auto &I:A){I.S/=sum;}
        for(auto &I:A){Ex[i]+=I.F*I.S;}
    }
    for(int i=0;i<t;i++){
        if(Ex[i]>Ex[t]+EPS){cout<<"YES"<<endl; return 0;}
    }
    cout<<"NO"<<endl;
    
    
    
    
    return 0;
}



Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int gcd(int a, int b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

int main() {
    int n,X;
    cin >> n >> X;
    int x[n],d[n];
    for(int i=0;i<n;++i) {
        cin >> x[i];
        d[i]=abs(X-x[i]);
    }
    int ans=gcd(d[0],d[1]);
    for(int i=1;i<n-1;++i) {
        ans=gcd(ans,d[i+1]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
int a[6],temp,i,j;

for(i=0;i<5;i++){scanf("%d",&a[i]);}
for(i=0;i<4;i++){
	for(j=i+1;j<5;j++){
		if(a[i]<a[j]){temp=a[i];a[i]=a[j];a[j]=temp;}
	}
}
printf("%d %d %d %d %d\n",a[0],a[1],a[2],a[3],a[4]);
return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
 
using namespace std;
 
int main(){
    int n,m;
    cin>>n>>m;
    string ans(n,'0');
    if(ans.size()!=1) ans.at(0)='1';
    set<char> one,two,three;
    
    for(int i=0;i<m;i++){
        int s;
        cin>>s;
        char c;
        cin>>c;
        ans.at(s-1)=c;
        if(s==1) one.insert(c);
        if(s==2) two.insert(c);
        if(s==3) three.insert(c);
    }
    
    bool ok=false;
    if(one.size()<=1 && two.size()<=1 && three.size()<=1) ok=true;
    
    if(ok && ans.at(0)!='0') cout<<ans<<endl;
    else if(ok && ans.size()==1) cout<<ans<<endl;
    else cout<<-1<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <queue>
#include <stdio.h>
using namespace std;
const int N=1e5+10;
int main(){
    int n,q,t;
    priority_queue<int> pq[N];
    scanf("%d%d",&n,&q);
    while(q--){
        scanf("%d%d",&n,&t);
        if(n==0){
            scanf("%d",&n);
            pq[t].push(n);
        }
        else if(n==1){
            if(!pq[t].empty())printf("%d\n",pq[t].top());
        }
        else if(!pq[t].empty())pq[t].pop();
    }
}


Measured memory_bytes: 6732
def is_fit(str_list,chr_):
    while len(chr_) > 0:
        if   chr_[-7:] in t_list:
            chr_ = chr_[:-7]
        elif chr_[-6:] in t_list:
            chr_ = chr_[:-6]
        elif chr_[-5:] in t_list:
            chr_ = chr_[:-5]
        else:
            return "NO"
    return "YES"

s = input()
t_list = ["dream","dreamer","erase","eraser"]

print(is_fit(t_list,s))


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

int main(){
    int H, W; cin >> H >> W;
    vector<string> s(H);
    rep(i, H){
        cin >> s[i];
    }    
    int dp[H][W];
    rep(i, H){
        rep(j, W){
            dp[i][j] = 0;
        }
    }
    rep(i, H){
        rep(j, W){
            if (i == 0 && j == 0){
                dp[i][j] = s[i][j] == '#' ? 1 : 0;
            }else if(i == 0){
                dp[i][j] = dp[i][j - 1] + (s[i][j] == '#' && s[i][j - 1] != s[i][j] ? 1 : 0);
            }else if (j == 0){
                dp[i][j] = dp[i - 1][j] + (s[i][j] == '#' && s[i - 1][j] != s[i][j] ? 1 : 0);
            }else{
                dp[i][j] = min(dp[i][j - 1] + (s[i][j] == '#' && s[i][j - 1] != s[i][j] ? 1 : 0), dp[i - 1][j] + (s[i][j] == '#' && s[i - 1][j] != s[i][j] ? 1 : 0));
            }
        }
    }
    cout << dp[H - 1][W - 1] << endl; 
    return 0;
}

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

const int Nmax=200010;

int main() {
	int n,A,B,sum=0;
	ll ans=0;
	cin >> n >> A >> B;
	for(int i=1;i <= n;i++){
		int N=i;
		sum =N/10000; N%=10000;
		sum+=N/1000; N%=1000;
		sum+=N/100; N%=100;
		sum+=N/10; N%=10;
		sum+=N;
		if(A <= sum && sum <= B) ans+=i;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int y,m,g;
  char s,t;
  cin>>y>>s>>m>>t>>g;
  if(m<=4){
    cout<<"Heisei"<<endl;
  }
  else{
    cout<<"TBD"<<endl;
  }
}


Measured memory_bytes: 256
#line 1 "../lib/template.hpp"

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>

using namespace std;

#line 2 "tmp.cpp"

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

  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;

  pair<int, int> ans = {a * 100, 0};

  vector<bool> dp(f + 1, false);
  dp[0] = true;
  REP(i, f + 1) {
    if (i - c >= 0)
      dp[i] = dp[i] || dp[i - c];
    if (i - d >= 0)
      dp[i] = dp[i] || dp[i - d];
  }

  for (int i = 0;; i++) {
    if (100 * a * i > f)
      break;
    for (int j = 0;; j++) {
      int w = 100 * (a * i + b * j);
      if (w > f)
        break;
      int ma = min(w / 100 * e, f - w);
      REP(k, ma + 1) {
        if (dp[k] && (w + k) * ans.second < ans.first * k) {
          ans = {w + k, k};
        }
      }
    }
  }
  cout << ans.first << " " << ans.second << endl;

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  for(int i=0; i<14; i++){
    for(int j=0; j<25; j++){
      if(N==i*7+j*4){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int one = 20*5+19*5;
        int three = one*2 + 20*10;
        int whole = three*333;
        
        int n = sc.nextInt();
        for(int i=0;i<n;i++) {
        	int y = sc.nextInt();
        	int m = sc.nextInt();
        	int d = sc.nextInt();
        	
        	int a = three*((y-1)/3) + one*((y-1)%3);
        	int b;
        	if(y%3 == 0) {
        		b = 20*(m-1);
        	}else {
        		b = 39*((m-1)/2) + 20*((m-1)%2);
        	}
        	int c = d-1;
        	
        	System.out.println(whole-(a+b+c));
        }
    }
}


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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

bool dp[303030][4][1010];
string S;
int N;

int main() {
    cin >> N >> S;
    dp[0][0][0] = true;

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= 3; ++j) {
            for (int k = 0; k < 1000; ++k) {
                if (!dp[i][j][k]) continue;

                dp[i+1][j][k] = true;
                if (j <= 2) {
                    dp[i+1][j+1][k*10+(S[i]-'0')] = true;
                }
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < 1000; ++i) {
        if (dp[N][3][i]) ans++;
    }
    cout << ans << endl;
}


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

using ll=long long;
using ld=long double;

const int MOD=1e9+7;

ll power(ll a,ll b){
	ll res=1ll;
	while(b>0){
		if(b%2==1) res=(res*a)%MOD;
		a= (a*a)%MOD;
		b/=2;
	}
	return res;
}

ll divide(ll a,ll b){
	return a*power(b,MOD-2)%MOD;
}


void solve(){
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++){ 
		cin>>a[i];
	}
	ll e=0;
	ll ss=0;
	for(int i=0;i<n;i++){
		e= (e+a[i])%MOD;
		ss= (ss+power(a[i],2ll))%MOD; 
	}
	e=(e*e)%MOD;
	ll ans = ((e-ss)%MOD + MOD)%MOD;
	ans=divide(ans,2);
	cout<<ans%MOD<<'\n'; 
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3968
from collections import defaultdict
n = int(input())
mp = defaultdict(int)
for i in range(n):
    s = input()
    mp[s] += 1

mx = 0

for key in mp.keys():
    if mx < mp[key]:
        mx = mp[key]

ans_list = []

for key in mp.keys():
    if mp[key] == mx:
        ans_list.append(key)

ans_list = sorted(ans_list)

for ans in ans_list:
    print(ans)

Measured memory_bytes: 97112
#include "bits/stdc++.h"
using namespace std;

#define rep(i, n)  for (int i = 0; i < (int) (n); i++)
#define Rrep(i, n) for (int i = ((int) n - 1); i >= 0; i--)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
#define INF 2e15
#define MOD 10e9 + 7

typedef vector <int> vint;
typedef long long    ll;



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

    vector <ll> stick;
    int         n;
    int         cnt = 0;

    cin >> n;
    rep(i, n) {
        ll tmp;
        cin >> tmp;
        stick.push_back(tmp);
    }
    sort(all(stick));
    // stick.erase(unique(all(stick)), stick.end());

    if (stick.size() < 3) { cout << 0 << endl; return 0; }

    for (int i = 0; i < SZ(stick) - 2; i++) {
        for (int j = i + 1; j < SZ(stick) - 1; j++) {
            for (int k = j + 1; k < SZ(stick); k++) {
                if (stick.at(i) + stick.at(j) > stick.at(k)) {
                    if ((stick.at(i) != stick.at(j) && stick.at(j) != stick.at(k) && stick.at(k) != stick.at(i))) {
                        cnt++;
                    }
                }
            }
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <algorithm>
#include <vector>

using int64 = long long;

const int64 inf = 1ll << 60;

int main() {
  int n;
  int64 k;
  scanf("%d%lld", &n, &k);
  std::vector<int64> a(n);
  for (int i = 0; i < n; ++i) scanf("%lld", &a[i]);

  std::sort(a.begin(), a.end());
  auto count = [&](int64 bound) {
    int64 ret = 0;
    for (int i = 0; i + 1 < n; ++i) {
      if (a[i] < 0) {
        if (a[i] * a.back() > bound) continue;
        int l = i + 1, r = n - 1;
        while (l < r) {
          int m = (l + r - 1) >> 1;
          if (a[i] * a[m] <= bound) r = m;
          else l = m + 1;
        }
        ret += n - l;
      } else {
        if (a[i] * a[i + 1] > bound) continue;
        int l = i + 1, r = n - 1;
        while (l < r) {
          int m = (l + r + 1) >> 1;
          if (a[i] * a[m] <= bound) l = m;
          else r = m - 1;
        }
        ret += l - i;
      }
    }
    return ret;
  };

  int64 left = 0, right = 2 * inf;
  while (left < right) {
    int64 mid = (left + right - 1) >> 1;
    if (count(mid - inf) >= k) right = mid;
    else left = mid + 1;
  }
  printf("%lld\n", left - inf);
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
using namespace std;

int main(){ 
  int a=0,b=0,c=0,n,x,y,m;
  cin>>n>>x>>y;
  rep(i,0,n){
    cin>>m;
    if(m<=x) a++;
    else if(m<=y) b++;
    else c++;
  }
  a=min(a,b);
  a=min(a,c);
  co(a);
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int ans;
	int array[3];

	for(int i=0;i<3;i++)cin >>array[i];
	sort(array,array+3);
	ans=array[1]-array[0];
	ans+=array[2]-array[1];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];

  vector<ll> ones(60, 0); // ones[i] Aの右から 第i+1bit にある 1 の数
  rep(i, 60) {
    rep(j, N) {
      if(A[j]%2==1) ones[i]++;
      A[j] = A[j] >> 1;
    }
  }

  // rep(i, 10) {
  //   cout << ones[i] << ' ';
  // }
  // cout << endl;

  ll X = 0;
  ll ans = 0;
  for(int i=59; i>=0; i--) {
    if(ones[i]*2>N) {
      // この桁は0でよい。
      ans = (ans<<1) + ones[i];
    } else {
      // この桁を1にしたい
      if(X+(1LL<<i) > K) {
        // 上限を超えるので 1 にできない。
        ans = (ans<<1) + ones[i];
      } else {
        X += (1LL<<i);
        ans = (ans<<1) + (N-ones[i]);
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	int N = 0, i = 0;
	char S[101] = {0};
	char T[101] = {0};
	scanf("%d", &N);
	scanf("%s", S);
	scanf("%s", T);
	for (i = 0; i < N; i ++) {
		printf("%c%c", S[i], T[i]);
	}
	printf("\n");
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int R = sc.nextInt();
		
		if(R < 1200){
	   		System.out.println("ABC");
		}else if(R < 2800){
	   		System.out.println("ARC");
		}else{
	   		System.out.println("AGC");
		}

		
   		sc.close();
        return ;

    }
    
}



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

int main(){
	int b[4][13]={0},m,n;
	char x;
	cin >> m;
	for(int i = 0; i < m; i++){
		cin >> x;
		cin >> n;
		if(x=='S'){
			b[0][n-1]=1;
		}
		else if(x=='H'){
			b[1][n-1]=1;
		}
		else if(x=='C'){
			b[2][n-1]=1;
		}
		else if(x=='D'){
			b[3][n-1]=1;
		}
	}
		for(int l = 0; l < 13; l++){
			if(b[0][l]==0){
				cout << "S" << " " << l+1 << "\n";
			}
		}
		for(int l = 0; l < 13; l++){
			if(b[1][l]==0){
				cout << "H" << " " << l+1 << "\n";
			}
		}
		for(int l = 0; l < 13; l++){
			if(b[2][l]==0){
				cout << "C" << " " << l+1 << "\n";
			}
		}
		for(int l = 0; l < 13; l++){
			if(b[3][l]==0){
				cout << "D" << " " << l+1 << "\n";
			}
		}



	

	return 0;
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

struct edge {
    int u,v,w;
    bool operator<(const edge& a) const {
        return w < a.w;
    }
};

struct UnionFind {
private:
    vector<int> par,sizes;
public:
    UnionFind (int n) {
        par.resize(n);
        sizes = vector<int>(n,1);
        for (int i = 0;i < n;++i) par[i] = i;
    }

    int find(int x) {
        if (par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x,int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (sizes[x] < sizes[y]) swap(x,y);
        par[y] = x;
        sizes[x] += sizes[y];
    }

    bool same(int x,int y) {
        return find(x) == find(y);
    }

    int size(int x) {
        return sizes[find(x)];
    }
};

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> x(n),t(n,0);
    vector<ll> w(n,0);
    vector<edge> a(m);
    UnionFind uf(n);
    for (int i = 0;i < n;++i) cin >> x[i];
    for (int i = 0;i < n;++i) w[i] = x[i];
    for (int i = 0;i < m;++i) {
        cin >> a[i].u >> a[i].v >> a[i].w;
        a[i].u--;
        a[i].v--;
    }
    sort(a.begin(),a.end());
    for (int i = 0;i < m;++i) {
        int u = uf.find(a[i].u),v = uf.find(a[i].v);
        if (uf.same(u,v)) {
            if (w[u] >= a[i].w) t[u] = 0;
            else t[u]++;
        } else {
            if (uf.size(u) < uf.size(v)) swap(u,v);
            if (w[u]+w[v] >= a[i].w) t[u] = 0;
            else t[u] += t[v]+1;
            w[u] += w[v];
            uf.unite(u,v);
        }
    }
    cout << t[uf.find(0)] << endl;
    return 0;
}

Measured memory_bytes: 3712
def lcs(s1, s2):
    dp = []
    for s2_k in s2:
        bgn_idx = 0
        for i, cur_idx in enumerate(dp):
            chr_idx = s1.find(s2_k, bgn_idx) + 1
            if not chr_idx:
                break
            dp[i] = min(cur_idx, chr_idx)
            bgn_idx = cur_idx
        else:
            chr_idx = s1.find(s2_k, bgn_idx) + 1
            if chr_idx:
                dp.append(chr_idx)
    return len(dp)

n = int(input())
for _ in range(n):
    x = input()
    y = input()
    print(lcs(x, y))



Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define int long long

using namespace std;

vector < int > Lin[300005], Col[300005];
set < int > S;

int32_t main () {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int N, M, Q;
  cin >> N >> M >> Q;
  vector < int > lin(N), col(M);
  while (Q --) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    ++lin[x];
    ++col[y];
    long long val = 1000000 * x + y;
    S.insert(val);
  }
  int ans1 = 0, ans2 = 0;
  vector < int > max_lin, max_col;
  for (int i = 0; i < N; ++i) {
    if (lin[i] > ans1) {
      ans1 = lin[i];
      max_lin.clear();
      max_lin.emplace_back(i);
    }
    else
      if (lin[i] == ans1)
        max_lin.emplace_back(i);
  }
  for (int i = 0; i < M; ++i) {
    if (col[i] > ans2) {
      ans2 = col[i];
      max_col.clear();
      max_col.emplace_back(i);
    }
    else
      if (col[i] == ans2)
        max_col.emplace_back(i);
  }
  int ans = ans1 + ans2;
  bool ok = true;
  for (auto it : max_lin) {
    for (auto i : max_col)
    if (S.find(1000000 * it + i) == S.end()) {
      ok = false;
      break;
    }
    if (!ok)
      break;
  }
  if (ok)
    --ans;
  cout << ans;
}


Measured memory_bytes: 44276
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>

#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>

#include <algorithm>

using namespace std;


int main() {
	
	string s;
	cin >> s;
	int w = 0;
	for (auto ss :s)
		if (ss == 'x')
			w++;
	if (w > 7)
		cout << "NO" << endl;
	else
		cout << "YES" << endl;
}

Measured memory_bytes: 256
import bisect

N = int(input())
A = [int(_) for _ in input().split()]
plusflag = minusflag = False

for i in A:
    if not plusflag and i > 0:
        plusflag = True
    elif not minusflag and i < 0:
        minusflag = True
    
    if plusflag and minusflag:
        break

if not plusflag and not minusflag:
    print(0)
    for i in range(N-1):
        print(0, 0)
elif not plusflag and minusflag:
    A = sorted(A)[::-1]
    print(A[0]-sum(A[1:]))
    tmp = A[0]
    for i in range(N-1):
        x = tmp
        y = A[i+1]
        print(x, y)
        tmp -= y
elif plusflag and not minusflag:
    A = sorted(A)
    print(-A[0]+sum(A[1:]))
    tmp = A[0]
    for i in range(N-2):
        x = tmp
        y = A[i+1]
        print(x, y)
        tmp -= y
    print(A[-1], tmp)
else:
    A = sorted(A)
    zeroindex = bisect.bisect_left(A, 0)
    print(-sum(A[:zeroindex])+sum(A[zeroindex:]))
    if zeroindex != N-1:
        print(A[zeroindex-1], A[zeroindex])
        tmp = A[zeroindex-1] - A[zeroindex]
        for i in range(zeroindex+1, N-1):
            x = tmp
            y = A[i]
            print(x, y)
            tmp -= y
        print(A[-1], tmp)
        tmp = A[-1] - tmp
        for i in range(zeroindex-1):
            x = tmp
            y = A[i]
            print(x, y)
            tmp -= y
    else:
        tmp = A[-1]
        for i in range(N-1):
            x = tmp
            y = A[i]
            print(x, y)
            tmp -= y

Measured memory_bytes: 14332
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef pair<ll, ll> P;

const int mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11

int main()
{
    ll x,k,d; cin >> x >> k >> d;
    ll ans = 0;
    if(abs(x)/d <= k){
        ll num = abs(x)/d;
        ll res = k - num;
        if(res % 2 == 0){
            ans = abs(abs(x) - num*d);
        }else{
            ans = abs(abs(abs(x) - num*d) - d);
        }
    }else{
        ans = abs(abs(x) - k*d);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
from collections import deque

H, W = map(int, input().split())
M = []
for i in range(H):
    M.append(list(input().strip()))

ans = 0

def bfs(sx, sy):
    global ans
    dist = [[-1 for _ in range(W)] for _ in range(H)]
    q = deque()
    q.append((sx, sy))
    dist[sy][sx] = 0

    while q:
        v = q.popleft()
        x, y = v[0], v[1]
        for dx, dy in [(-1, 0), (1, 0), (0, 1), (0, -1)]:
            newx, newy = x+dx, y+dy
            if not (0 <= newx < W):
                continue
            if not (0 <= newy < H):
                continue
            if M[newy][newx] == '#':
                continue
            if dist[newy][newx] != -1:
                continue
            q.append((newx, newy))
            d = dist[y][x] + 1
            dist[newy][newx] = dist[y][x] + 1
            ans = max(ans, d)

for y in range(H):
    for x in range(W):
        if M[y][x] == '#':
            continue
        bfs(x, y)

print(ans)



Measured memory_bytes: 3316
#include <cstdio>

char str[200005];
int C;
long long Ans;

int main() {
	scanf("%s", str);
	for (int i = 0; str[i]; ++i) {
		if (str[i] == 'B')
			++C;
		else
			Ans += C;
	}
	printf("%lld\n", Ans);
	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------
void solve(){
    long long a, b;
    long long c;
    long long ma, mb;
    long long ans;
    cin >> a >> b;
    ma = a;
    mb = b;
    a = max(ma,mb);
    b = min(ma,mb);
    c = a % b;
    dbg = true;
    while(c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    ans = ma / b * mb;
    cout << ans << endl;

    
    

}

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



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

using namespace std;

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

	string s;
	cin>>s;
	bool p=0; 
	if(s.size() & 1){ 
		cout<<"No";
		return 0;
	}
	for(char c:s){ 
		if(!p){ 
			if(c!='h'){ 
				cout<<"No";
				return 0;
			} 
		}else{ 
			if(c!='i'){ 
				cout<<"No";
				return 0;
			}
		} 
		p=!p;
	} 
	cout<<"Yes"; 

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 200005;
const int MAXT = 530000;

struct seg{
	int lim, tree[MAXT];
	void init(int n){
		memset(tree, 0x3f, sizeof(tree));
		for(lim = 1; lim <= n; lim <<= 1);
	}
	void update(int x, int v){
		x += lim;
		tree[x] = min(tree[x], v);
		while(x > 1){
			x >>= 1;
			tree[x] = min(tree[2*x], tree[2*x+1]);
		}
	}
	int query(int s, int e){
		 s+=lim;
		 e+=lim;
		 int ret=1e9;
		 while(s < e){
		 	 if(s%2 == 1) ret = min(ret, tree[s++]);
		 	 if(e%2 == 0) ret = min(ret, tree[e--]);
		 	 s >>= 1;
		 	 e >>= 1;
		 }
		 if(s == e) ret= min(ret, tree[s]);
		 return ret;
	}
}seg;

int n, q;
vector<int> in[MAXN];
vector<int> out[MAXN];
pi intv[MAXN];
int d1[MAXN], d2[MAXN];
int s[MAXN], b[MAXN];

int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++){
		scanf("%d",&b[i]);
		s[i] = s[i-1] + (1 - b[i]);
	}
	scanf("%d",&q);
	for(int i=0; i<q; i++){
		scanf("%d %d",&intv[i].first,&intv[i].second);
	}
	sort(intv, intv + q, [&](const pi &a, const pi &b){
		return a.second < b.second;
	});
	for(int i=0; i<q; i++){
		in[intv[i].first].push_back(i);
		out[intv[i].second + 1].push_back(i);
	}
	seg.init(n + 5);
	for(int i=n+1; i; i--){
		if(i < n + 1){
			d1[i] = d1[i + 1] + b[i];
			for(auto &j : in[i]) d1[i] = min(d1[i], d2[j] + s[intv[j].second] - s[intv[j].first - 1]);
		}
		for(auto &j : out[i]){
			d2[j] = min(seg.query(intv[j].first + 1, intv[j].second) - s[intv[j].second], d1[i]);
		}
		for(auto &j : out[i]){
			seg.update(intv[j].first, d2[j] + s[intv[j].second]);
		}
	}
	cout << d1[1] << endl;
}



Measured memory_bytes: 24320
N, M = map(int, input().split())
D = [None] * M
for i in range(M):
  a, b = map(int, input().split())
  D[i] = (a, b)
D.reverse()

P = list(range(N))
C = [1] * N
R = [1] * N
def root(x):
  if P[x] == x:
    return x
  else:
    rx = root(P[x])
    P[x] = rx
    return rx

def find(x, y):
  return root(x) == root(y)

def union(x, y):
  rx = root(x)
  ry = root(y)
  if rx != ry:
    if R[ry] > R[rx]:
      rx, ry = ry, rx
    P[ry] = rx
    C[rx] += C[ry]
    R[rx] = max(R[rx], R[ry] + 1)

def size(x):
  return C[root(x)]

f = N * (N - 1) // 2
F = []
for a, b in D:
  a -= 1
  b -= 1
  F.append(f)
  if not find(a, b):
    f = max(0, f - size(a) * size(b))
    union(a, b)

F.reverse()
for f in F:
  print(f)

Measured memory_bytes: 100824
s = input()
# print(s)

ans = 0
count = 0
for c in s:
    # print(c)
    
    if c in ['A', 'C', 'G', 'T']:
        count += 1
    else:
        count = 0
        
    # print(ans)
    ans = max(ans, count)
    
print(ans)

Measured memory_bytes: 8948
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val (s,t) = readLine()!!.split(" ")

    val sb = StringBuilder(2*n)
    val sit = s.iterator()
    val tit = t.iterator()

    while(sit.hasNext() && tit.hasNext()){
        sb.append(sit.nextChar())
        sb.append(tit.nextChar())
    }

    println(sb.toString())

}



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

int main(void){

    int N; cin>>N;
    int sum=0, mx=0;

    for (int i = 0; i < N; ++i) {
        int tmp; cin>>tmp;
        sum+=tmp;
        if(mx < tmp) mx = tmp;
    }
    sum -= mx;

    if(mx < sum) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;
ll powmod(__int128_t a, ll k, ll m){
	__int128_t ap=a, ans=1;
	while(k){
		if(k&1){
			ans*=ap;
			ans%=m;
		}
		k>>=1;
		ap=ap*ap%m;
	}
	return ans;
}
bool is_prime(ll n){
    if(n<=1 || !(n&1)) return (n==2);
	ll d=n-1;
	int k=0;
	while(!(d&1)){
		d>>=1;
		k++;
	}
	vector<ll> va{2, 325, 9375, 28178, 450775, 9780504, 1795265022};
	for(auto aa:va){
		ll a=aa%n;
		if(a==0) continue;
		bool comp=1;
		ll ap=powmod(a, d, n);
		if(ap==1 || ap==n-1) continue;
		for(int r=1; r<k; r++){
			ap=(__int128_t)ap*ap%n;
			if(ap==n-1){
				comp=0;
				break;
			}
		}
		if(comp) return false;
	}
	return true;
}
ll gcd(ll a, ll b){
	if(a==0) return b;
	if(b==0) return a;
	if(a<0) a=-a;
	if(b<0) b=-b;
	const int s=__builtin_ctzll(a|b);
	a>>=__builtin_ctzll(a);
	while(b){
		b>>=__builtin_ctzll(b);
		if(a>b) swap(a, b);
		b-=a;
	}
	return a<<s;
}
ll rho(ll n, ll& c){
	if(!(n&1)) return 2;
	while(1){
		ll x=2, y=2, d=1;
		while(d==1){
			x=((__int128_t)x*x+c)%n;
			y=((__int128_t)y*y%n+c)%n;
			y=((__int128_t)y*y%n+c)%n;
			d=gcd(abs(x-y), n);
		}
		if(d==n){
			c++;
			continue;
		}
		return d;
	}
}
vector<pair<ll, int>> factorize(ll n){
	if(n<=1){
		vector<pair<ll, int>> ret;
		return ret;
	}
	map<ll, int> mp;
	vector<ll> v(1, n);
	ll c=1;
	while(!v.empty()){
		ll x=v.back();
		v.pop_back();
		if(is_prime(x)){
			mp[x]++;
			continue;
		}
		ll p=rho(x, c);
		v.push_back(p);
		v.push_back(x/p);
	}
	vector<pair<ll, int>> ret;
	for(auto p:mp) ret.push_back(p);
	return ret;
}
int main()
{
	int n;
	cin>>n;
	map<ll, int> mp;
	const ll INF=1e11;
	vector<pair<ll, ll>> v(n);
	for(int i=0; i<n; i++){
		ll s;
		cin>>s;
		vector<P> fac=factorize(s);
		ll x=1, y=1;
		for(auto p:fac){
			if(p.second%3==1){
				x*=p.first;
				if(y>INF/p.first) y=INF;
				else y*=p.first;
				if(y>INF/p.first) y=INF;
				else y*=p.first;
			}else if(p.second%3==2){
				x*=(p.first*p.first);
				if(y>INF/p.first) y=INF;
				else y*=p.first;
			}
		}
		mp[x]++;
		if(x>y) swap(x, y);
		v[i]=make_pair(x, y);
	}
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	int ans=0;
	for(auto p:v){
		if(p.first==1) ans++;
		else ans+=max(mp[p.first], mp[p.second]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 12160
N = int(input())
D = {}
for _ in range(N):
    S = "".join(sorted(input()))
    if S in D:
        D[S] += 1
    else:
        D[S] = 1
 
out = 0
for i in D.values():
    out += i * (i-1) //2
print(out)

Measured memory_bytes: 17852
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
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;
}
int main() {
    int n;cin>>n;
    vector<long double> d(n);
    rep(i,n){
        cin>>d.at(i);
    }
    
    sort(ALL(d));
    
    long double ans=d[0];
    rep(i,n-1){
        ans=(d[i+1]+ans)/2;
    }
    
    cout << fixed << setprecision(15);
    cout<<ans<<endl;
    
    return 0;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

int main ()
{
    int A [3] ;
    int t ;

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

    }
    sort (A + 0 , A + 3) ;

    t = abs((A[2] - A[1]) + (A[1] - A[0])) ;
    cout << t ;



    return 0;
}


Measured memory_bytes: 256
while True:
	n, k, m = map(int, raw_input().split())
	if n == k == m == 0: break
	stones = range(1, n + 1)
	m -= 1
	k -= 1
	while len(stones) != 1:
		stones.pop(m)
		m = (m + k) % len(stones)
	print stones[0]

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


int main()
{
	int p[25]={},cnt=0,n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",p+i);
	for(int i=2;i<n;++i) if((p[i]>p[i+1]&&p[i]<p[i-1])||(p[i]<p[i+1]&&p[i]>p[i-1])) cnt++;
	cout<<cnt;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <regex>
using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)

typedef long long ll;



int main()
{
    int N;
    int T,A;
    int H[10001];
    cin>>N>>T>>A;
    FOR(i,1,N+1)cin>>H[i];

    int ans = -1;
    int min = 999999999;
    FOR(i,1,N+1){
        if(abs(A*1000-(T*1000-H[i]*6))<min){
            min = abs(A*1000-(T*1000-H[i]*6));
            ans = i;
        }
    }
    

    cout<<ans<<endl;
}



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

int main(){
    string n;
    cin >> n;
    if(n.size() == 1){
        cout << n << endl;
        return 0;
    }
    ll ans = 0;
    ans += 9*(n.size()-1);
    string s;
    s += n[0];
    rep(i,n.size()-1) s+= '9';
    if(s != n){
        int num = n[0] - '1';
        cout << ans + num << endl;
        return 0;
    }
    if(s == n){
        int num = n[0] - '0';
        cout << ans+num << endl;
        return 0;
    } 
} 

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

int main(){
	int n;
	cin>>n;
  string s;
  cin>>s;
  vector<char>arr;
  for(int i=0; s[i]; i++) arr.push_back(s[i]);
  arr.erase(unique(arr.begin(),arr.end()),arr.end());
  cout<<arr.size();
}

Measured memory_bytes: 3744
from bisect import bisect_left, bisect_right

N = int(input())
L = list(map(int, input().split()))

L.sort()
result = 0
for i in range(N - 2):
  a = L[i]
  for j in range(i + 1, N - 1):
    b = L[j]
    result += bisect_left(L, a + b) - j - 1
print(result)


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

int main() {
  int n,k,x,y;
  cin>>n>>k>>x>>y;
  if (n<=k) {
    cout<<n*x<<endl;
  }
  else {
    cout<<k*x+(n-k)*y<<endl;
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int h, w, d; cin >> h >> w >> d;
    vector<vector<int>> mat(h, vector<int>(w));
    map<int, P> mp;
    rep(i, h) rep(j, w) {
        int x; cin >> x;
        mat[i][j] = x;
        mp[x] = {i, j};
    }
    vector<int> s(h*w+2, 0);
    rep(i, h*w+1) {
        if (i<=d) s[i] = 0;
        else {
            s[i] = s[i-d] + abs(mp[i].fi-mp[i-d].fi) + abs(mp[i].se-mp[i-d].se);
        }
    }
    debug(s);
    int q; cin >> q;
    rep(i, q) {
        int x, y; cin >> x >> y;
        cout << s[y] - s[x] << endl;
    }
}

Measured memory_bytes: 7424
n_a_b = list(map(int,input().split()))

ans = 0
plus = 0

for i in range(0,n_a_b[0]+1,1):
    num = i

    for j in range(5):
        plus = plus + num % 10
        num = int(num /10) 

    if  n_a_b[1] <= plus and plus <= n_a_b[2]:
        ans = ans + i

    plus = 0

print(ans)

Measured memory_bytes: 3064
#include <iostream>
int main(){
int a,b;
std::cin>>a>>b;
if(a>b){
std::cout<<"a > b"<<std::endl;
}
if(a<b){
std::cout<<"a < b"<<std::endl;
}
if(a==b){
std::cout<<"a == b"<<std::endl;
}
}

Measured memory_bytes: 1156
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		char[] letters = scanner.next().toCharArray();
		char[] ans = new char[letters.length];
		int p = 0; 
		
		for (int i = 0; i < letters.length; i++) {
			if (letters[i] == 'B') {
				if (p>0) {
					p--;
				}
			}else {
				ans[p] = letters[i];
				p++;
			}
		}
		String s = new String(ans);
		s = s.substring(0, p);
		System.out.println(s);
		scanner.close();
	}
}


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

using Int = int;
using namespace std;

#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; };
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; };
template<class T> T th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

int main(){
	int n, m;
	cin >> n >> m;
	bool solved[112345] = {};
	int wa[112345] = {};
	unsigned ac = 0, was = 0;
	RC(i, m){
		int p;
		string s;
		cin >> p >> s;
		--p;
		if(!solved[p]){
			if(s == "AC"){
				++ac;
				solved[p] = true;
			}else{
				++wa[p];
			}
		}
	}
	RC(i, n){
		if(solved[i]) was += wa[i];
	}
	cout << ac << " " << was << endl;
}


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

int main(){
  int N,W;
  cin >> N >> W;
  vector<int> weights(N);
  vector<int> values(N);
  int V = 0;
  for(int i = 0; i < N; i++){
    cin >> weights[i] >> values[i];
    V = max(V,values[i]);
  }
  vector<vector<int>> dp(N+1,vector<int>(N*V+1,1000000001));
  dp[0][0] = 0;
  for(int i = 0; i < N; i++){
    for(int v = 0; v <= N*V; v++){
      if(v >= values[i]) dp[i+1][v] = dp[i][v-values[i]]+weights[i];
      dp[i+1][v] = min(dp[i+1][v],dp[i][v]);
    }
  }
  for(int v = N*V; v >= 0; v--){
    if(dp[N][v] <= W){
      cout <<  v << endl;
      break;
    }
  }
}

Measured memory_bytes: 43324
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws Exception
	{
		int a=nextInt();
		int v=nextInt();
		int b=nextInt();
		int w=nextInt();
		int t=nextInt();
		if(v<=w)
		{
			if(a==b)
				out.println("YES");
			else
				out.println("NO");
			return;
		}
		int time=(Math.abs(b-a)+v-w-1)/(v-w);
		if(time<=t)
			out.println("YES");
		else
			out.println("NO");
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws Exception
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws Exception{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws Exception{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws Exception{
		return br.readLine();
	}
	int nextInt()throws Exception{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws Exception{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws Exception{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 32916
N = int(input())
lisS = list(map(int,input().split()))
Q = int(input())
lisT = list(map(int,input().split()))


def check(mid,key):
    return lisS[mid] > key

def binary_search(key):
    OK = N #絶対Trueになるやつ
    NG = -1 #絶対Falseになるやつ
    while abs(OK-NG)>1:
        mid = (OK+NG)//2
        if check(mid,i):
            OK = mid
        else:
            NG = mid
    return lisS[NG] == key

ans = 0
for i in lisT:
    ans += binary_search(i)

print(ans)



Measured memory_bytes: 16708
N = int(input())

count = 0
flag = False
for i in range(N):
    D1,D2 = map(int,input().split())
    if D1 == D2:
        count += 1
        if count >= 3:
            flag = True
    else:
        count = 0

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9164