akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string>
#include <iostream>
using namespace std;
 
int main() {
    string input;
    cin >> input;

    if (input[0]==input[1]&&input[1]==input[2]&&input[2]==input[3]) { cout << "No" << endl; return 0; }
	if(((input[0]==input[1]) && (input[2]==input[3])) ||
       ((input[0]==input[2]) && (input[1]==input[3])) ||
       ((input[0]==input[3]) && (input[1]==input[2]))) {
    	cout << "Yes" << endl;
    } else {
    	cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	
	if(a<b)
	{
		printf("a < b\n");
	}
	else if(a>b)
	{
		printf("a > b\n");
	}
	else
	{
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 1008
#include<bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    int N; cin >> N;
    vi X(N); REP(i, N) cin >> X[i];
    int ans = INF;
    REPS(P, 100)
    {
        int cost = 0;
        REP(i, N) cost += (X[i]-P)*(X[i]-P);
        ans = min(ans, cost);
    }
    cout << ans << endl;
}

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

int main(){
  ll N;cin>>N;
  int F[N][5][2];
  int P[N][11];
  rep(i,N)rep(j,5)rep(k,2) cin>>F[i][j][k];
  rep(i,N)rep(j,11) cin>>P[i][j];
  ll ans=-1e9;
  for(int bit=1;bit<(1<<10);++bit){
    ll tmp_P = 0;    
    rep(i,N){
      ll both_open = 0;
      for(int block=0;block<10;++block){
        //i 0(月朝)~9(金夜)について、営業中の場合
        if(bit & (1<<block)) {        
          int weekday = int(block/2);
          int time = block%2;
          if(F[i][weekday][time]==1) both_open++;
        }
      }
      tmp_P += P[i][both_open];
    }
    ans = max(ans,tmp_P);
  }
  cout << ans << endl;
  }

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <time.h>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
ll n, ans, x;
ll a[111111];
ll vv[111111];

int main(void)
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>n>>x; ll i, j;
	for(i=1 ; i<=n ; i++) cin>>a[i];
	for(i=1 ; i<=n ; i++)
	{
		if(a[i]>x) ans+=(a[i]-x);
		if(a[i]>x) a[i]=x;
	}
	for(i=1 ; i<=n-1 ; i++) vv[i]=a[i]+a[i+1];
	for(i=1 ; i<=n-1 ; i++)
	{
		ll det=0;
		if(vv[i]>x) det=vv[i]-x;
		vv[i]-=det; vv[i+1]-=det;
		ans+=det;
	}
	cout<<ans; return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n){
        cin >> a[i];
    }
    rep(i, n){
        a[i] -= i+1;
    }
    sort(ALL(a));
    ll ans = 0;
    rep(i, n){
        ans += abs(a[i]-a[n/2]);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	
	int n; cin >> n;
	vector<int> v(n);
	for (int &x : v) cin >> x;
	int sum = 0;
	
	for (int i = 0; i < n; i += 2) {
		sum ^= (v[i] ^ v[i+1]);
	}
	
	for (int x : v) {
		cout << (sum ^ x) << " ";
	} cout << "\n";
	
}




Measured memory_bytes: 3940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n;
    cin >> n;
    vector<int> b(n-1);
    rep(i,n-1) cin >> b[i];
    vector<int> a(n);
    a[0] = b[0];
    for(int i=1; i <= n-2; i++){
        a[i] = min(b[i],b[i-1]);
    }
    a[n-1] = b[n-2];
    int ans=0;
    rep(i,n) ans += a[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;


int main(int argc, const char * argv[]) {
  string sa, sb;
  cin >> sa >> sb;


  if(sa == sb){
    cout << "EQUAL" << endl;
  }else if(sa.size() > sb.size() || (sa.size() == sb.size() && sa > sb)){
    cout << "GREATER" << endl;
  }else{
    cout << "LESS" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double angle_h,angle_m;
    angle_m = (m/60)*2*M_PI;
    angle_h = ((h*60+m)/720)*2*M_PI;
    double ax,ay,bx,by;
    //cerr << angle_h << " " <<angle_m << endl;
    ax = a*cos(angle_h);
    ay = a*sin(angle_h);
    bx = b*cos(angle_m);
    by = b*sin(angle_m);
    double diffx = abs(ax-bx);
    double diffy = abs(ay-by);
    printf("%.12f\n",sqrt(diffx*diffx+diffy*diffy));
    return 0;
}

Measured memory_bytes: 4152
#include<stdio.h>
#include<stdlib.h>

struct node{
	struct node *l;
	struct node *r;
	struct node *p;
	int key;
};

typedef struct node * Node;

void inorder(Node);
void preorder(Node);
void insert(int);
char* find(int);

Node root;

int main(void){
	int n,in;
	char input[7];
	int i;

	scanf("%d",&n);

	for(i=0;i<n;i++){
		scanf("%s",input);

		if(input[0]=='i'){
			scanf("%d",&in);
			insert(in);		
		}
		else if(input[0]=='f'){
			scanf("%d",&in);
			printf("%s\n",find(in));
		}
		else{
			if(root!=NULL){
				inorder(root);
				printf("\n");
				preorder(root);
				printf("\n");
			}
		}
	}

	return 0;
}


void insert(int in){
	Node new,work,move;

	new=(Node)malloc(sizeof(struct node));
	new->key=in;
	new->l=NULL;
	new->r=NULL;

	work=NULL;
	move=root;
	while(move!=NULL){
		work=move;
		if(move->key > in){
			move=move->l;
		}
		else{
			move=move->r;
		}
	}

	new->p=work;
	if(work==NULL) root=new;
	else if(work->key > in) work->l=new;
	else work->r=new;

}


void inorder(Node work){
	if(work->l != NULL) inorder(work->l);
	printf(" %d",work->key);
	if(work->r != NULL) inorder(work->r);
}


void preorder(Node work){
	printf(" %d",work->key);
	if(work->l != NULL) preorder(work->l);
	if(work->r != NULL) preorder(work->r);
}


char* find(int in){
	Node work;

	work=root;
	while(work!=NULL){
		if(work->key == in) return "yes";

		else if(work->key > in) work=work->l;
		else work=work->r;
	}

	return "no";
}

Measured memory_bytes: 19364
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int maxn=200005;
ll n,d,k;
ll a[maxn];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        a[i]-=i;
    }
    sort(a+1,a+n+1);
    ll b=0;
    if(n%2==0)
    b=(a[n/2]+a[n/2+1])/2;
    else
    b=a[n/2+1];
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        ans=ans+abs(b-a[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream> // cout, endl, cin
#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
#include <cmath>
#include <limits>
#include <list>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
#define endl "\n"
#define pi 3.14159265358979
using namespace std;
using ll = long long;

int main() {
    int direction = 1; //{1-> left to right: -1 reverse}
    string s; cin >> s;
    list<char> ls;
    for (auto c : s) {
        ls.push_back(c);
    }
    int q; cin >> q;
    for (int i = 0; i < q; i++) {
        int t; cin >> t;
        if (t == 1) {
            direction *= -1;
        }
        else if (t == 2) {
            int f; cin >> f;
            if (f == 1) {
                f = -1;
            }
            else if (f == 2) {
                f = 1;
            }
            int position = f * direction;
            char c; cin >> c;

            if (position < 0) {
                ls.push_front(c);
            }
            else {
                ls.push_back(c);
            }
        }
    }
    if (direction > 0) {
        for (auto l = ls.begin(); l != ls.end(); l++) {
            cout << *l;
        }
        cout << endl;
    }
    else {
        for (auto l = ls.rbegin(); l != ls.rend(); l++) {
            cout << *l;
        }
        cout << endl;
    }
}

Measured memory_bytes: 13088
program main
   implicit none
   integer(8)::n,k,i
   integer(8),allocatable,dimension(:)::h,turn,dummy
   real(8),allocatable,dimension(:)::abss
   real(8)::heikin
   read(*,*)n,k
   allocate(h(n),abss(n),turn(n))
   read(*,*)h
!   heikin=real(sum(h),8)/size(h)
 !  abss=abs(h-heikin)
   call heapsort2(n,h,turn)
   do i=1,n-k
   enddo
   allocate(dummy(n-k+1))
   do i=1,n-k+1
     dummy(i)=abs(h(i)-h(i+k-1))
   enddo
   write(*,*)minval(dummy)
 !  do i=1,k
  !    dummy(i)=h(turn(i))
   !enddo
   !write(*,*)maxval(dummy)-minval(dummy)
   !write(*,*)dummy
contains
subroutine heapsort2(n,array,turn)
  implicit none
  integer(8),intent(in)::n
  integer(8),intent(out)::turn(1:n)
  integer(8),intent(inout)::array(1:n)
  
  integer::i,k,j,l,m
  double precision::t
  
  if(n.le.0)then
     write(6,*)"Error, at heapsort"; stop
  endif
  if(n.eq.1)return

  do i=1,N
     turn(i)=i
  enddo

  l=n/2+1
  k=n
  do while(k.ne.1)
     if(l.gt.1)then
        l=l-1
        t=array(l)
        m=turn(l)
     else
        t=array(k)
        m=turn(k)
        array(k)=array(1)
        turn(k)=turn(1)
        k=k-1
        if(k.eq.1) then
           array(1)=t
           turn(1)=m
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j.le.k)
        if(j.lt.k)then
           if(array(j).lt.array(j+1))j=j+1
        endif
        if (t.lt.array(j))then
           array(i)=array(j)
           turn(i)=turn(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
     turn(i)=m
  enddo

  return
end subroutine heapsort2
end program main


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

using namespace std;

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

const ll mod = 1000000007;
vector<bool> isRed, isBlue;

string ask(vector<int> query) {
  for (int i = 0; i < isRed.size(); i++) cerr << isRed[i] << " ";
  cerr << endl;
  for (int i = 0; i < isBlue.size(); i++) cerr << isBlue[i] << " ";
  cerr << endl;
  cout << "? ";
  for (int i = 0; i < query.size(); i++) {
    cout << query[i]+1;
    if (i < query.size()-1) cout << " ";
    else cout << endl;
  }
  cout << flush;
  string response;
  cin >> response;
  if (response == "-1") exit(0); // fail
  else return response;
}

string answer(vector<char> ans) {
  cout << "! ";
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i];
  }
  cout << endl << flush;
  exit(0); // done
}

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

  int n;
  cin >> n;

  isRed = vector<bool>(2 * n);
  isBlue = vector<bool>(2 * n);
  vector<int> firstQuery;
  for (int i = 0; i < n; i++) firstQuery.push_back(i);
  string firstResponse = ask(firstQuery);
  int left = 0;
  int right = n-1;
  while (left < right - 2) {
    int center = (left + right) / 2;
    vector<int> query;
    for (int j = center; j < center + n; j++) query.push_back(j);
    string response = ask(query);
    if (firstResponse == response) left = center;
    else right = center;
  }
  int p = left+1;
  while (true) {
    vector<int> query;
    for (int j = p; j < p + n; j++) query.push_back(j);
    string response = ask(query);
    if (firstResponse != response) { // 境界
      int exclusion = p-1;
      if (firstResponse == "Red") { // 赤→青の境界
        isRed[exclusion] = true;
        isBlue[exclusion + n] = true;
      }
      else { // 青→赤の境界
        isBlue[exclusion] = true;
        isRed[exclusion + n] = true;
      }
      for (int j = 0; j < 2 * n; j++) {
        if (j < exclusion || exclusion + n < j) {
          vector<int> query;
          for (int k = p; k < p + n - 1; k++) query.push_back(k);
          query.push_back(j);
          string response = ask(query);
          if (response == "Red") isRed[j] = true;
          else isBlue[j] = true;
        }
      }
      int bc = 0;
      int rc = 0;
      vector<int> baseQuery;
      for (int j = 0; j < 2 * n; j++) {
        if (bc < n / 2 && isBlue[j]) {
          baseQuery.push_back(j);
          bc++;
        }
        else if (rc < n / 2 && isRed[j]) {
          baseQuery.push_back(j);
          rc++;
        }
      }
      for (int j = 0; j < 2 * n; j++) {
        if (!isBlue[j] && !isRed[j]) {
          vector<int> query = baseQuery;
          query.push_back(j);
          string response = ask(query);
          if (response == "Red") isRed[j] = true;
          else isBlue[j] = true;
        }
      }
      vector<char> ans;
      for (int j = 0; j < 2 * n; j++) {
        if (isRed[j]) ans.push_back('R');
        else if (isBlue[j]) ans.push_back('B');
      }
      answer(ans);
    }
    p++;
  }

  return 0;
}


Measured memory_bytes: 724
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author indy256
 */

#include <bits/stdc++.h>

using namespace std;

void solve(istream &in, ostream &out) {
    int r;
    in >> r;

    int res = r * r;
    out << res << '\n';
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solve(in, out);
}


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


int main(int argc, const char* argv[]){
    long long  h, w;
    cin >> h >> w;

    if(h == 1 || w == 1){
        cout << 1 << endl;
        return 0;
    }

    long long sum = h * w;
    if(h % 2 == 1 && w % 2 == 1){
        cout << sum / 2 + 1 << endl;
        return 0;
    }

    cout << sum / 2 << endl;
    return 0;
}


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


struct Problem {

	void Solve() {
		UL H, W; cin >> H >> W;
		UL R = max(H, W);
		UL N; cin >> N;
		cout << (N - 1) / R + 1 << endl;
	}

	
	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


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

using namespace std;

int main()
{
    vector<int> a(3);
    for(auto& x : a)
        cin >> x;
    sort(a.begin(), a.end());
    bool f = (a == std::vector<int>{5, 5, 7});
    cout << (f ? "YES" : "NO") << endl;
    return 0;
}


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

int main() {
    vector<int> a(3);
    rep(i,3) cin>>a[i];
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    string A,B,C;
    A=to_string(a[0]);
    B=to_string(a[1]);
    C=A+B;
    int ans=stoi(C)+a[2];
    cout<<ans<<endl;
}   


Measured memory_bytes: 256
import math
N0=int(input())
count=0
temp=9999999
for i5 in range(1,-1,-1):
    N = N0-(9**5) *i5
#    print(N)
    if N<0: continue
    for i4 in range(8,-1,-1):
        N=N0-(9**5) *i5-(9**4)*i4
#        print(N)
        if N<0: continue
        for i3 in range(8,-1,-1):
            N=N0-(9**5) *i5-(9**4)*i4-(9**3)*i3
#            print(N)
            if N<0: continue
            for i2 in range(8,-1,-1):
                N=N0-(9**5) *i5-(9**4)*i4-(9**3)*i3-(9**2)*i2
#                print(N)
                if N<0: continue
                for i1 in range(8,-1,-1):
                    N=N0-(9**5) *i5-(9**4)*i4-(9**3)*i3-(9**2)*i2-9*i1
#                    print(N)
                    if N<0: continue

                    while(N>0):
                        count = count + 1
                        N=N-6**int(math.log(N,6))
                        
                    temp = min([temp,i5+i4+i3+i2+i1+count])
                    count=0
            
print(temp)

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <bitset>

using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)

//ARC061_a
int main() {
	string s;
	cin >> s;
	int n = s.size();
	int64_t ans = 0;
	for (int bit=0; bit<1<<(n-1); bit++) {

		int64_t now = 0;
		for (int i=0; i<n; i++){
			 now *= 10;
			 now += s[i] -'0';

			if (i<n-1&&(bit>>i&1)) {
				ans += now;
				now = 0;
			}
		}
		ans += now;
	}
	cout << ans << endl;
}

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

int main() {
	int x[3000];
	int y[3000];
	int i;
	cin >> x[0] >> y[0];
	while (!(x[i] == 0 && y[i] == 0)) {
		if (x[i] > y[i]) {
			cout << y[i] << " " << x[i] << endl;
		}
		else {
			cout << x[i] << " " << y[i] << endl;
		}
		i++;
		cin >> x[i] >> y[i];
	}
	return 0;
}

Measured memory_bytes: 3016
n = int(input())
s_list = [input() for _ in range(n)]
most_list = []
counter_dict = {}
for s in s_list:
    if s in counter_dict:
        counter_dict[s] += 1
    else:
        counter_dict[s] = 1

sorted_counter = sorted(counter_dict.items(), key=lambda x: x[1], reverse=True)
ans = []
max_num = sorted_counter[0][1]
for c in sorted_counter:
    if max_num == c[1]:
        ans.append(c[0])
    else:
        break

ans.sort()
print('\n'.join(ans))


Measured memory_bytes: 49932
N = gets.chomp.to_i
zoro = 0
N.times{
  d1, d2 = gets.chomp.split.map(&:to_i)
  if d1 == d2
    zoro += 1
  else
    zoro = 0
  end
  if zoro >= 3
    puts "Yes"
    exit
  end
}
puts "No"


Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    string str;
    cin >> str;
    int a = 0, b = 0;
    char c = '0';
    for (int i = 0; i < str.size(); i++) {
        if (str[i] != c)
            a++;
        c ^= '0' ^ '1';
    }
    c = '1';
    for (int i = 0; i < str.size(); i++) {
        if (str[i] != c)
            b++;
        c ^= '0' ^ '1';
    }
    cout << min(a, b) << endl;
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main()
{
	int N, C, ans = INF;
	cin >> N >> C;
	vector<vector<int>> d(C, vector<int>(C));
	vector<vector<int>> c(N, vector<int>(N));
	rep(i, 0, C)rep(i2, 0, C)cin >> d[i][i2];
	rep(i, 0, N)rep(i2, 0, N)cin >> c[i][i2], c[i][i2]--;
	int sum[3][100] = {0};
	rep(color, 0, C) {
		rep(i, 0, N) {
			rep(i2, 0, N) {
				sum[(i + i2) % 3][color] += d[c[i][i2]][color];
			}
		}
	}
	rep(c0, 0, C) {
		rep(c1, 0, C) {
			if (c1 == c0)continue;
			rep(c2, 0, C) {
				if (c2 == c0 || c2 == c1)continue;
				ans = min(ans, sum[0][c0] + sum[1][c1] + sum[2][c2]);
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4716
import bisect

def main():
    n = int(input())
    l = list(map(int, input().split()))

    l.sort()

    ans = 0
    for i in range(n-1):
        for j in range(i+1, n-1):
            ans += bisect.bisect_left(l, l[i] + l[j], j+1) - (j+1)

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
//#include <stack>
#include <climits>
#include <map>
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

int a,b;

int main(){
    cin >> a >> b;
    if(a==0||b==0||(a<0&&b>0)){
        put("Zero");
    }else if(a<0&&(a-b)%2==0){
        put("Negative");
    }else{
        put("Positive");
    }
    return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000;
const double PI = acos(-1);

int main() {
	int d, e;
	while (cin >> d >> e&&d) {
		double ans = 1000;
		for (int i = 0; i <= d; i++){
			double x = sqrt(i*i + (d - i)*(d - i));
			ans = min(ans, fabs(x - (double)e));
		}
		cout << fixed << setprecision(5) << ans << endl;
	}
}

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

int main() {
  int n , a , b;
  cin >> n >> a;
  b = n % 500;

  if (b == 0) {
      cout << "Yes" << endl;
  }
  else if (b <= a) {
      cout << "Yes" << endl;
  }
  else {
      cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> s;
  if("ABC" == s) cout << "ARC" << endl;
  else cout << "ABC" << endl;
}


Measured memory_bytes: 3636
var end = false;

var col_small = new Buffer("#.#.#.#.#.");
var col = new Buffer(300);
for (i = 0; i < 300; i += 10) {
	col_small.copy(col, i, 0);
}
col = col.toString();

require('fs').readFileSync('/dev/stdin', 'ascii').split('\n').forEach(main);

function main(line) {
	if (line === '0 0') {
		end = true;
		return;
	}
	if (end) return;
	var hw = line.split(' ').map(Number);
	var h = hw[0];
	var w = hw[1];
	even = col.slice(0, w);
	odd = col.slice(1, w + 1);
	for (j = 0; j < hw[0]; j++) {
		if (j % 2 === 0) console.log(even);
		else console.log(odd);
	}
	console.log("");
}

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

string s3[3]{
	"aab",
	"c.b",
	"cdd"
};
string s4[4]{
	"aabc",
	"ddbc",
	"efgg",
	"efhh"
};
string s5[5]{
	"ahhii",
	"ag..j",
	"bg..j",
	"b.ffe",
	"ccdde"
};
string s7[7]{
	"a..mmnn",
	"ak..ll.",
	"bkj....",
	"b.j...i",
	"...ggfi",
	".ee..fh",
	"ccdd..h"
};
string ans[1000];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		ans[i].assign(n,'.');
	}
	if(n==2){
		cout<<-1<<endl;
		return 0;
	}
	if(n%3==0){
		for(int i=0;i<n;i+=3){
			for(int j=0;j<3;j++)
				for(int k=0;k<3;k++)
					ans[i+j][i+k]=s3[j][k];
		}
	}
	else if(n%4==0){
		for(int i=0;i<n;i+=4){
			for(int j=0;j<4;j++)
				for(int k=0;k<4;k++)
					ans[i+j][i+k]=s4[j][k];
		}
	}
	else if(n%5==0){
		for(int i=0;i<n;i+=5){
			for(int j=0;j<5;j++)
				for(int k=0;k<5;k++)
					ans[i+j][i+k]=s5[j][k];
		}
	}
	else if(n==7){
		for(int i=0;i<n;i+=7){
			for(int j=0;j<7;j++)
				for(int k=0;k<7;k++)
					ans[i+j][i+k]=s7[j][k];
		}
	}
	else if(n==11){
		for(int j=0;j<7;j++)
			for(int k=0;k<7;k++)
				ans[j][k]=s7[j][k];
		for(int j=0;j<4;j++)
			for(int k=0;k<4;k++)
				ans[7+j][7+k]=s4[j][k];
	}
	else{
		int i;
		for(i=0;(n-i)%4!=0;i+=5){
			for(int j=0;j<5;j++)
				for(int k=0;k<5;k++)
					ans[i+j][i+k]=s5[j][k];
		}
		for(;i<n;i+=4){
			for(int j=0;j<4;j++)
				for(int k=0;k<4;k++)
					ans[i+j][i+k]=s4[j][k];	
		}
	}
	for(int i=0;i<n;i++)
		cout<<ans[i]<<'\n';
}


Measured memory_bytes: 2304
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1e18;

int main() {
  //
  string a = "AKIHABARA";
  int idx[] = {8, 6, 4, 0};
  string s;
  cin >> s;
  for (int x = 0; x < (1 << 4); x++) {
    string tmp = a;
    rep(i, 4) {
      if ((x >> i) & 1) {
        tmp.erase(tmp.begin() + idx[i]);
      }
    }
    if (s == tmp) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
int main()
{
  int num,i,b;
  b=1;
  scanf("%d",&num);
  char a[num];
scanf("%s",a,num);

  for(i=0;i<num-1;++i)
  {
  if(a[i]!=a[i+1]) b++;
  }
  
  printf("%d",b);
  
return 0;
}

Measured memory_bytes: 256
# AtCoder Beginner Contest 155: A (2020/02/16)
A, B, C = map(int, input().split())
if A == B and A != C:
    print('Yes')
elif B == C and B != A:
    print('Yes')
elif C == A and C != B:
    print('Yes')
else:
    print('No')

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int main() {
  string s ;
  cin >> s ;
  int ans = s.length() ;
  if(!(ans&1)) 
    s = s.substr(0,ans-1) ;

  while(s.length()!=0){
    int n = s.length() ;
    if(!(n&1)) {
      int mid = n/2 ;
      string s1 = s.substr(0,mid) ;
      string s2 = s.substr(mid,n) ;
      if(s1 == s2){
        cout << n << endl ;
        return 0 ;
      }
    }
    s = s.substr(0,n-1) ;
  }
	
  return 0 ;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		double a[]=new double[N];
		double max=0;
		double min=200;
		int min2=0;
		double ir=1;
		int z=0;
		while(z<N){
			a[z]=stdIn.nextDouble();
			max+=a[z];
			z++;
		}z=0;
		max/=N;
		while(N-1>=0){
			if(a[N-1]-max<0)
				ir=-1;
			if((a[N-1]-max)*ir<=min){
				min=(a[N-1]-max)*ir;
				min2=N-1;
			}
			N--;
			ir=1;
		}
		System.out.println(min2);
	}

}

Measured memory_bytes: 26580
/**
 *  author: Haunted_Cpp
**/

#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")

template<typename T> ostream &operator << (ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream &operator << (ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream &operator << (ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif

const int MAX_N = 1e6 + 5;

bitset<MAX_N> is_prime;
int fac[MAX_N], cnt[MAX_N];


int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> arr(n);
  int gcd = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    gcd = __gcd(gcd, arr[i]);
  }
  for (int i = 0; i < MAX_N; i++) {
    fac[i] = i;
    is_prime[i] = 1;
  }
  is_prime[0] = is_prime[1] = 0;
  for (int i = 4; i < MAX_N; i += 2) {
    is_prime[i] = 0;
    fac[i] = 2;
  }
  for (int i = 3; i * i < MAX_N; i += 2) {
    if (is_prime[i]) {
      for (int j = i * i; j < MAX_N; j += i) {
        is_prime[j] = 0;
        fac[j] = i;
      }
    }
  }
  auto add_fac = [&](int delta) {
    set<int> add;
    while(delta > 1) {
      add.insert(fac[delta]);
      delta /= fac[delta];
    }
    for (auto to : add) {
      ++cnt[to];
    }
  };
  for (int i = 0; i < n; i++) add_fac(arr[i]);
  int mx = *max_element(cnt, cnt + MAX_N);
  if (mx <= 1) {
    cout << "pairwise coprime" << '\n';
  } else if (gcd == 1) {
    cout << "setwise coprime" << '\n';
  } else {
    cout << "not coprime" << '\n';
  }
  return 0;
}


Measured memory_bytes: 15036
N=int(input())
D,X=map(int,input().split())

A=[]

ans=N

for i in range(N):
    A.append(int(input()))

for i in range(N):
    
    for k in range(1,102):
        if A[i]*k+1<=D:
            ans+=1

ans+=X

print(ans)

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

#define F(i,a,b) for(int i=(a);i<=(b);++i)

const int mod = 924844033;
const int maxn = 2010;
int N,K;
LL d[2][maxn][4],fac[maxn];

inline void add(LL& a,LL b)
{
	a += b;
	if(a >= mod) a -= mod;
}

int main()
{
	scanf("%d %d",&N,&K);
	int p = 0;
	d[p][0][0] = 1;
	F(i,1,K)
   	{
		for(int j=i;j<=N;j+=K)
		{
			p ^= 1;
			memset(d[p],0,sizeof d[0]);
			F(k,0,N) F(l,0,3)
			{
				LL& w = d[p^1][k][l]; 
				if(!w) continue;
				add(d[p][k][(l<<1)&3],w);
				if(!(l&2) && j - K > 0) 
					add(d[p][k+1][(l<<1)&3],w);
				if(j + K <= N) 
					add(d[p][k+1][((l<<1)|1)&3],w);
			}
		}
		p ^= 1;
		memset(d[p],0,sizeof d[0]);
		F(k,0,N) F(l,0,3)
		{
			if(!d[p^1][k][l]) continue;
			add(d[p][k][0],d[p^1][k][l]);
		}
	}
	fac[0] = 1;
	F(i,1,N) fac[i] = fac[i-1]*i%mod;
	LL ans = 0;
	F(i,0,N)
	{
//		printf("%lld ",d[p][i][0]);
		LL m = fac[N-i]*d[p][i][0]%mod;
	   	add(ans,(i&1)?mod - m:m);
	}
	//puts("");
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int D = sc.nextInt();
    if (A + B == C + D) {
      System.out.println("Balanced");
    } else if (A + B < C + D) {
      System.out.println("Right");
    } else {
      System.out.println("Left");
    }
  }
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n;
string s;
void solve(){
	cin >> n >> s;
	
	int ans = 0, ma = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == 'I') ans++;
		if(s[i] == 'D') ans--;
		chmax(ma, ans);
	}
	cout << ma << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


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

int main(){
  int n,r;
  cin>>n>>r;
  
  if(n>=10){cout<<r<<endl;}
  else{cout<<r+(100*(10-n))<<endl;}
  
  return 0;
}

Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int k, a, b;
	cin >> k >> a >> b;
	bool ch = false;
	for(int i = a; i<=b; i++){
		if(i % k == 0) ch = true;
	}
	if (ch) cout << "OK" << endl;
	else cout << "NG" << endl;
	
	//cout << ans << endl;
}

Measured memory_bytes: 3588
#include <algorithm>
#include <cmath>
#include <cstdio>
const int MAXN = 505;
int A[MAXN];
int B[MAXN];
int K, N;
 
bool check(int M) {
  for (int i = 0; i < N; ++i) {
    B[i] = A[i] % M;
  }
  std::sort(B, B+N);
  int lo = 0;
  int hi = N-1;
  int cost = 0;
  while (lo < hi) {
    int sum = B[lo] + B[hi];
    if (sum < M) {
      cost += B[lo];
      B[hi] += B[lo];
      B[lo] = 0;
      ++lo;
    } else {
      // (sum >= M)
      cost += M - B[hi];
      B[hi] = M;
      B[lo] = sum - M;
      if (!B[lo]) ++lo;
      --hi;
    }
  }
  return (B[lo] % M == 0) && (cost <= K);
}
 
int main() {//why this code can ac?
  scanf(" %d%d", &N, &K);
  int S = 0;
  for (int i = 0; i < N; ++i) {
    scanf("%d", &A[i]);
    S += A[i];
  }
  int ret = 1;
  int sqrtS = sqrt(S);
  for (int i = 1; i <= sqrtS; ++i) if ((S % i) == 0) {
    int j = S / i;
    if (check(i)) ret = std::max(i, ret);
    if (check(j)) ret = std::max(j, ret);
  }
  printf("%d\n", ret);
  return 0;
}

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

using namespace std;

int main() {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	int ans = 0;
	if (a <= 0) {
		ans = (-a) * c + d + b * e;
	} else {
		ans = (b - a) * e;
	}
	cout << ans << endl;
}


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

int main(void){
  int n,ans;
  ans=0;
  cin >> n;
  for (int i=1; i<=9; i++){
    for (int j=i; j<=9; j++){
      if (n==i*j) ans=1;
    }
  }
  cout << (ans?"Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main()
{
    long long int a=1,b,n,i,j,sum=0;
    string s,s1;
    cin>>n>>s;
    for(i=0;i<s.size();i++)
    {
        a=s[i]-'A';
        b=(a+n)%26;
        s[i]='A'+b;
        cout<<s[i];
    }

    return 0;
}


Measured memory_bytes: 256
using System;

namespace aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            int count = int.Parse(Console.ReadLine());
            for (int i = 0; i < count; ++i) {
                int runner = 0, outCount = 0, score = 0;
                while(outCount < 3) {
                    var command = Console.ReadLine();
                    if(command == "HIT") {
                        if(runner >= 3) {
                            ++score;
                        }
                        else {
                            ++runner;
                        }
                    }
                    else if(command == "OUT") {
                        ++outCount;
                    }
                    else if(command == "HOMERUN") {
                        score += runner + 1;
                        runner = 0;
                    }
                }
                Console.WriteLine(score);
            }
        }
    }
}

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

signed main(){

  int q;
  cin>>q;
  set<int> s;
  while(q--){
    int c,x;
    cin>>c>>x;
    if(c==0){
      s.insert(x);
      cout<< s.size() <<endl;
    }
    else if(c==1){
      cout<< s.count(x) <<endl;
    }
    else if(c==2){
      s.erase(x);
    }
    else if(c==3){
      int y;
      cin>>y;
      auto itr = s.lower_bound(x);
      auto end = s.upper_bound(y);
      while(itr!=end){
        cout<<*itr<<endl;
        itr++;
      }
    }
  }

}


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

using namespace std;

int main(){
 string s;
  cin >> s;
 
  bool cnt[26]={false},res=true;
  
  for(int i=0;i<s.length();i++) {
    if(cnt[s[i]-'a']) res=false; 
    else cnt[s[i]-'a']=true; 
  }
  
  if(res) cout << "yes" << endl;
  else cout << "no" << endl;


}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cctype>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;

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

template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;

int main() {
	ll n, d;
	cin >> n >> d;
	V<ll> x(n);
	V<ll> y(n);
	rep(i, n) {
		int X, Y;
		cin >> X >> Y;
		x[i] = abs(X);
		y[i] = abs(Y);
	}
	ll d2 = d * d;
	int cnt = 0;
	rep(i, n) {
		ll l2 = x[i] * x[i] + y[i] * y[i];
		if (l2 <= d2) {
			++cnt;
		}
	}
	cout << cnt << endl;
	return 0;
}


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

P f(int x){
    int a = x%10;
    int b = 0;
    while(x){
        b = x;
        x /= 10;
    }
    return P(a,b);
}

/*
youtubeをみて。
なるほど....別に片方固定する必要なんて全然なかった...。
(1,1)とかを全N以下の数でもとめて、それの数を見るだけでいいやんけ...。
*/

int main(){
    int n;
    cin>>n;
    map<P,int> freq;
    //mapは、辞書と同じであった.
    for(int i=1;i<=n;i++){
        P p = f(i);
        freq[p]++;
    }
    //これで集計ですね.
    ll ans = 0;
    for(int i=1;i<=n;i++){
        P p = f(i);
        P q(p.second,p.first);//pの相方
        ans += freq[q];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
def sanbun2(n , al):

    ans = 0

    for i in al:
        while i % 2 == 0:
            ans += 1
            i /= 2

    return ans

def main():
    n = int(input())
    al = list(map(int , input().split()))
    print(sanbun2(n , al))

if __name__ == '__main__':
    main()

Measured memory_bytes: 4148
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    cout << (1000-(N%1000))%1000 << endl;
}

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

int main () {
    int A, B ,C;
    cin >> A >> B >> C;
    if ((A == 7 && B ==5  && C == 5)||(A == 5 && B == 7 && C == 5)||(A == 5 && B == 5 && C == 7)) {
        cout << "YES" << endl;
    }else{
        cout << "NO" <<endl;
    }
}

Measured memory_bytes: 256
#abc087 b-coins
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            y=500*i+100*j+50*k
            if y==x:
                ans+=1
print(ans)

Measured memory_bytes: 3060
import sys


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


A, B, C, X, Y = il()

if A + B < 2 * C:
    print(A * X + B * Y)
    exit()
p = min(X, Y) * 2 * C
n = max(X - Y, Y - X)
if X < Y:
    p += min(2 * C * n, n * B)
else:
    p += min(2 * C * n, n * A)
print(p)


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

int main() {
  string s;
  cin >> s;
  char last = *(s.end() - 1);
  if (last == 's') {
    s += "es";
    cout << s << endl;
  } else {
    s += 's';
    cout << s << endl;
  }
}

Measured memory_bytes: 3624
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
 
#define int long long
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)

int power(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a=a*a;
  n/=2;
}
return res;
}

int32_t main()
{
    fast;
    int x;
    cin>>x;
    int a,b;
    int p,q;
    for(int i=1;i<=800;i++)
    {
        for(int j=-800;j<=800;j++)
        {
            a=power(i,(int)5);
            b=power(j,(int)5);
            if(a-b==x)
            {
              p=i;
              q=j;
             break;
             }
        }
        if(a-b==x)
         break;
    }
    cout<<p<<" "<<q<<"\n";
      return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
int main(void){
    int a,b,c,d;
    scanf("%d %d %d",&a,&b,&c);
    
    if(a>b){
        d=b;
        b=a;
        a=d;
    }
    if(a>c){
        d=c;
        c=a;
        a=d;
    }
    if(b>c){
        d=c;
        c=b;
        b=d;
    }
    printf("%d %d %d\n",a,b,c);

   
   return 0;
}

Measured memory_bytes: 1812
use proconio::{input, marker::Chars};

fn main() {
    input!(s: Chars, t: Chars);

    let m = t.len();
    let eval = |s: &[char]| (0..m).filter(|&i| s[i] != t[i]).count();
    let ans = s.windows(m).map(eval).min().unwrap();

    println!("{}", ans);
}


Measured memory_bytes: 2156