akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
#define sort(v) sort(v.begin(), v.end())
#define sortr(v) sort(v.rbegin(), v.rend())
void chmin(int &a, int b) {if(a > b) a = b;}
void chmax(int &a, int b) {if(a < b) a = b;}

const int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,0,n) cin >> a[i];
    rep(i,0,n){
        if(a[i] % 2 == 0){
            if(a[i] % 3 != 0 &&  a[i] % 5 != 0){
                cout <<"DENIED";
                return 0;
            }
        }
    }
    cout << "APPROVED";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,t; cin >> a >> b >> t;
    cout << t/a * b << endl;
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  cout << "{";
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  cout << "}";
  return os;
}

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

int main() {
  string s;
  cin >> s;
  int gx, gy;
  cin >> gx >> gy;

  vector<int> idox, idoy;
  set<int> cangox, cangoy;
  int mode = 0, count = 0;
  bool tokubetu = true;
  for (int i = 0; i <= s.size(); i++) {
    if (s[i] == 'T' || i == s.size()) {
      if (tokubetu) {
        cangox.insert(count);
        tokubetu = false;
      } else if (mode == 0)
        idox.push_back(count);
      else
        idoy.push_back(count);
      mode ^= 1;
      count = 0;
    }
    if (s[i] == 'F') count++;
  }

  if (cangox.size() == 0) cangox.insert(0);
  cangoy.insert(0);

  // ヨコ移動について
  for (int i = 0; i < idox.size(); i++) {
    set<int> res(cangox);
    cangox.clear();
    for (auto x : res) {
      cangox.insert(x + idox[i]);
      cangox.insert(x - idox[i]);
    }
  }

  // タテ移動について
  for (int i = 0; i < idoy.size(); i++) {
    set<int> next(cangoy);
    cangoy.clear();
    for (auto y : next) {
      cangoy.insert(y + idoy[i]);
      cangoy.insert(y - idoy[i]);
    }
  }

  if (cangox.count(gx) && cangoy.count(gy))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define INIVAL 2147483647

#define min(a,b) ((a)<(b)?(a):(b))

int *a, s, t, v, n, w, minval;

void find_min(int k, int l, int r)
{
  if (l>=n || r<=s || t<=l) return;
  if (s<=l && r<=t) {
    if (a[k]<minval)  minval = a[k];
  } else {
    if (a[((k+1)<<1)-1]>=0)  find_min(((k+1)<<1)-1, l, (l+r)>>1);
    if (a[(k+1)<<1]>=0)      find_min((k+1)<<1, (l+r)>>1, r);
    else if (a[k] < minval)  minval = a[k];
  }
}

void update_min(unsigned int k, unsigned int l, unsigned r)
{
  if (k>=w) return;
  update_min(k*2+1, l, (l+r)/2);
  update_min(k*2+2, (l+r)/2, r);
  int lval = k*2+1<n+w ? a[k*2+1] : INIVAL;
  int rval = k*2+2<n+w ? a[k*2+2] : INIVAL;
  a[k] = min(lval, rval);
}

int main()
{
  int i, l;
  char *p, buf[64] = {0};
  fgets(buf, 64, stdin);
  for (n=0,p=buf; *p>' '; n=n*10+*(p++)-'0');
  for (l=0,p++  ; *p>' '; l=l*10+*(p++)-'0');
  w = n>1 ? pow(2,(int)ceil(log2(n)))-1 : 0;
  a = (int*)malloc(sizeof(int)*(w+n));
  for (i=0; i<w+n; i++)  a[i] = INIVAL;
  for (i=w; i<w+n; i++) {
    scanf("%d", &a[i]);
  }
  s = 0; t = n;
  update_min(0, 0, w+1);

  for (s=0; s<=n-l; s++) {
    t = s+l;
    minval = INIVAL;
    find_min(0, 0, w+1);
    if (minval<10) {
      putc_unlocked('0'+minval, stdout);
    } else {
      for (i=63; minval>0; buf[--i]='0'+minval%10,minval/=10);
      fputs(buf+i, stdout);
    }
    if (s<n-l) putc_unlocked(' ', stdout);
  }
  putc_unlocked('\n', stdout);
  return 0;
}



Measured memory_bytes: 9904
#include <stdio.h>

#define INFTY 2000000000

int L[250002],R[250002];

int cnt;

void merge(int *A, int n, int left, int mid, int right){

  int n1=mid-left;
  int n2=right-mid;
  int i,j=0,k;

  for(i=0;i<n1;i++) L[i]=A[left+i];
  for(i=0;i<n2;i++) R[i]=A[mid+i];

  L[n1]=R[n2]=INFTY;

  i=0;

  for(k=left;k<right;k++){

    cnt++;
    if(L[i]<=R[j]){
      A[k]=L[i++];
    }
    else{
      A[k]=R[j++];
    }
  }
}

void mergesort(int *A, int n, int left, int right){

  int mid;

  if(left+1<right){
    mid=(left+right)/2;

    mergesort(A,n,left,mid);
    mergesort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int main(){

  int i,n;

  cnt=0;

  scanf("%d",&n);

  int A[n];

  for(i=0;i<n;i++) scanf("%d",&A[i]);

  mergesort(A,n,0,n);

  for(i=0;i<n-1;i++) printf("%d ",A[i]);

  printf("%d\n", A[i]);

  printf("%d\n",cnt);

  return 0;

}



Measured memory_bytes: 5604
#include<stdio.h>
int main(){
  	char S[10],Y[4],M[2],D[2];
      int i,y,m,d;
  	scanf("%s", S);
  for(i=0;i<=3;i++){
    Y[i]=S[i];
  }
  for(i=0;i<=1;i++){
    M[i]=S[i+5];
  }
    for(i=0;i<=1;i++){
    D[i]=S[i+8];
  }
  y=atoi(Y);
    m=atoi(M);
  
  if(y>2019){
    printf("%s","TBD");
  }else if(y=2019&m>=5){
        printf("%s","TBD");
  }else{
            printf("%s","Heisei");
  }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    int i,b=0;
    cin>>a;
    for(i=0; i<a.size(); i++)
    {
        if(a[i]=='7')
            b=1;
    }
    if(b==1)
    {
        printf("Yes\n");
    }
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
#include <cmath>
#include <cstdio>
#include <complex>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main() {
	ll a,b;
  cin>>a>>b;
  a--;b--;
  cout<<a*b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

	string S;
	cin >> S;
	if(S=="AAA"||S=="BBB"){No
	}
	else{Yes}
	
	return 0;
 

	
}

Measured memory_bytes: 256
#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>;

int main(){
    string s;
    cin >> s;
    if(s == "ARC") cout << "ABC" << endl;
    else cout << "ARC" << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 1000000000
typedef long long ll;

int main(){
    ll N,K;
    cin>>N>>K;
    VL h(N);
    rep(i,0,N){
        cin>>h[i];
    }
    ll ans;
    ll a1=INF,a2=INF;
    ll tmp;
    sort(h.begin(),h.end());
    rep(i,0,N-K+1){
        tmp = abs(h[K-1+i]-h[i]);
        a1=min(tmp,a1);
    }
    reverse(h.begin(),h.end());
    rep(i,0,N-K+1){
        tmp = abs(h[K-1+i]-h[i]);
        a2=min(tmp,a2);
    }
    ans=min(a1,a2);
    cout<<ans<<endl;
    return 0;
}

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

int main() {
    char b;
    cin >> b;

    switch (b) {
        case 'A':
            cout << "T" << endl;
            break;
        case 'T':
            cout << "A" << endl;
            break;
        case 'C':
            cout << "G" << endl;
            break;
        case 'G':
            cout << "C" << endl;
            break;
    }
}


Measured memory_bytes: 256
import math

a, b, C = map(float, input().split())

h = b * math.sin(math.radians(C))
S = a * h / 2

a1 = b * math.cos(math.radians(C))
cc = math.sqrt(h * h + (a - a1) * (a - a1))

print("{a:5f}".format(a=S))
print("{a:5f}".format(a=a + b + cc))
print("{a:5f}".format(a=h))



Measured memory_bytes: 5700
#include<iostream>
#include<cstdio>
#define MAX 2000200
#define INT_MIN -2000000300
using namespace std;
typedef long long ll;
 
class priority_queue{
private:
  int index;
  int Array[MAX];
 
  int heapIncreaseKey(int i,ll key){
    if(key < Array[i])return -1;
    Array[i] = key;
    while(i > 1 && Array[getParent(i)] < Array[i]){
      ll h = Array[i];
      Array[i] = Array[getParent(i)];
      Array[getParent(i)] = h;
      i = getParent(i);
    }
  }
 
  void maxHeapify(int i){
    ll l = getLeft(i);
    ll r = getRight(i);
    ll largest;
    if(l <= index && Array[l] > Array[i])largest=l;
    else largest=i;
    if(r<=index && Array[r] > Array[largest])largest = r;
    if(largest != i){
      ll h;
      h = Array[i];
      Array[i] = Array[largest];
      Array[largest] = h;
      maxHeapify(largest);
    } 
  }
 
public:
 
  priority_queue(){
    index = 0;
  }
 
  void Insert(ll key){ //maxHeapInsert
    ++index;
    Array[index] = INT_MIN;
    heapIncreaseKey(index,key);
  }
 
  ll heapExtractMax(){
    if(index < 1)return -1;
    ll max = Array[1];
    Array[1] = Array[index];
    index--;
    maxHeapify(1);
    return max;
  }
 
 
  int getParent(int i){
    return i/2;
  }
 
  int getLeft(int i){
    return 2*i;
  }
 
  int getRight(int i){
    return 2*i+1;
  }
 
};
 
 
 
int main(){
  string op;
  ll val;
  priority_queue pque = priority_queue();
 
  while(true){
    cin >> op;
    if(op == "insert"){
      scanf("%lld",&val);
      pque.Insert(val);
    }
    else if(op == "extract"){
      printf("%lld\n",pque.heapExtractMax());
    }
    else if(op == "end")break;
  }
 
  return 0;
}

Measured memory_bytes: 7064
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

const int MAX_N = 200050;

int N, Q;
long long S[MAX_N], T[MAX_N], X[MAX_N];
long long D[MAX_N];

std::set<int> st;
std::unordered_map<long long, int> mp;
long long ret[MAX_N];

int main(int argc, char **argv) {
    std::cin >> N >> Q;

    for (int i = 1; i <= N; i++) {
        std::cin >> S[i] >> T[i] >> X[i];
    }

    for (int i = 1; i <= Q; i++) {
        std::cin >> D[i];
    }

    for (int i = 1; i <= Q; i++) {
        st.insert(D[i]);
        mp[D[i]] = i;
        ret[i] = -1;
    }

    std::vector<int> stop;
    for (int i = 1; i <= N; i++) {
        stop.push_back(i);
    }
    std::sort(stop.begin(), stop.end(),
        [&](const int i, const int j) { return X[i] < X[j]; }
    );

    for (int i : stop) {
        long long begin = S[i] - X[i];
        long long end = T[i] - X[i] - 1;
        std::vector<long long> del;
        for (auto itr = st.lower_bound(begin); itr != st.upper_bound(end); ++itr) {
            del.push_back(*itr);
        }

        for (auto d : del) {
            ret[mp[d]] = X[i];
            st.erase(d);
        }
    }

    for (int i = 1; i <= Q; i++) {
        std::cout << ret[i] << std::endl;
    }

    return 0;
}

Measured memory_bytes: 29512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <sstream>
#include <tuple>
#include <vector>

using namespace std;
using namespace chrono;

#ifdef DEBUG
	//~ #define LOCAL_INPUT_FILE
#else
	//#define USE_FILE_IO
#endif

#ifdef USE_FILE_IO
	#define INPUT_FILE "input.txt"
	#define OUTPUT_FILE "output.txt"
	#define cin ____cin
	#define cout ____cout
	ifstream cin(INPUT_FILE);
	ofstream cout(OUTPUT_FILE);
#else
	#ifdef LOCAL_INPUT_FILE
		#define cin ____cin
		ifstream cin("input.txt");
	#endif
#endif

const int infinity = (int)1e9 + 42;
const int64_t llInfinity = (int64_t)1e18 + 256;
const int module = (int)1e9 + 7; 
const long double eps = 1e-8;

mt19937_64 randGen(system_clock().now().time_since_epoch().count());

inline void raiseError(string errorCode) {
	cerr << "Error : " << errorCode << endl;
	exit(42);
}

signed main() {
	#ifndef USE_FILE_IO
		ios_base::sync_with_stdio(false);
	#endif
	int64_t l, r; cin >> l >> r;
	if (r - l > 3000) {
		cout << 0 << endl;
		return 0;
	}
	int64_t rr = 2019;
	for (int i = l; i <= r; ++i) {
		for (int j = l; j < i; ++j) {
			rr = min(rr, int64_t(i) * j % 2019);
		}
	}
	cout << rr << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<list>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back

#define ll __int64
#define P pair<ll,ll>
//#define __int64 long long

string s;
bool t[111111];
int c1,c2;
int a,b,c,d;

int main(){	
	cin>>s;
	int n=s.size();
	rep(i,n){
		if(s[i]=='B')c1++;
		else c2++;
	}

	rep(i,n){
		if(c1>=c2&&s[i]=='B')t[i]=1;
		else if(c2>c1&&s[i]=='W')t[i]=1;//多いほうが1
	}

	bool ca=1,cb=0;

	rep(i,n){
		if(t[i]!=ca)a++,ca=!ca;
		if(t[i]!=cb)b++,cb=!cb;
	}

	bool cc=1,cd=0;

	for(int i=n-1;i>=0;i--){
		if(t[i]!=cc)c++,cc=!cc;
		if(t[i]!=cd)d++,cd=!cd;
	}
	//rep(i,n)cout<<t[i]<<" ";cout<<endl;
	//cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
	cout<<min(min(a,b),min(c,d))<<endl;



	return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;
/*
int N;
string output(int n) {
  string res = "N";
  if(n <= N && to_string(n) <= to_string(N)) res = "Y";
  if(n > N && to_string(n) > to_string(N)) res = "Y";
  cout<<res<<endl;
  return res;
}
*/
int countDigit(int n) {
  int cnt = 0;
  while(n > 0) {
    n /= 10;
    cnt++;
  }
  return cnt;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  //cin >> N;
  //for(N=1;N<100000;N++){
  int dec = 1;
  for(; dec <= 1e11; dec *= 10) {
    cout << "? " << dec << endl;
    string s;
    cin >> s;
    //s = output(dec);
    if(s == "N") break;
  }
  if(dec == 1e12) {
    int x = 9;
    for(; x <= 1e11; x *= 10) {
      cout << "? " << x << endl;
      string s;
      cin >> s;
      //s = output(x);
      if(s == "Y") break;
    }
    assert(x < 1e11);
    cout << "! " << x/9 << endl;
    //continue;
    return 0;
  }
  assert(dec > 1);
  dec /= 10;
  int dig = countDigit(dec);
  //cout << dig <<endl;
  int ans = 0;
  rep(i, dig-1) {
    int lb = ans*10 + (i ? 0 : 1), ub = ans*10 + 10;
    //cout<<lb<<" "<<ub<<endl;
    while(lb+1 < ub) {
      int mb = (lb+ub)/2;
      cout << "? " << mb << endl;
      string t;
      cin >> t;
      //t = output(mb);
      if(t == "Y") lb = mb;
      else ub = mb;
    }
    ans = lb;
  }
  int lb = ans*10 - (dig==1 ? 0 : 1), ub = ans*10 + 9;
  while(lb+1 < ub) {
    int mb = (lb+ub)/2;
    cout << "? " << mb*10 << endl;
    string t;
    cin >> t;
    //t = output(mb*10);
    if(t == "N") lb = mb;
    else ub = mb;
  }
  cout << "! " << ub << endl;
  //assert(ub==N);
  //}
  return 0;
}


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

int main() {
int64_t a,b,n,d,ans;
  cin>>n>>d;
  ans=0;
  for(int64_t i=0;i<n;i++){
  cin>>a>>b;
    if(a*a+b*b<d*d||a*a+b*b==d*d){ans++;}
  }
  cout<<ans<<endl;
}

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

int main(){
  int w,h,x,y,r; cin >> w >> h >> x >> y >> r;
  bool flg = true;
  if(0 > x-r || x+r > w) flg = false;
  if(0 > y-r || y+r > h) flg = false;
  if(flg) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007

void solve()
{
	ll n,x;
	cin>>n>>x;
	ll a[n];
	for(ll i=0;i<n;i++)
		cin>>a[i];
	ll ans=0;
	for(ll i=1;i<n;i++)
	{
		if(a[i]+a[i-1]>x)
		{
			ll c=a[i]+a[i-1]-x;
			ll t=c;
			if(a[i]>=c)
				a[i]-=c;
			else
			{
				c-=a[i];
				a[i]=0;
				a[i-1]-=c;
			}
			ans+=t;
		}
	}	
	cout<<ans;
	return;
}

int main()
{
	fast;
	ll q=1;
	// cin>>q;
	while(q--)
		solve();
	return 0;
}



Measured memory_bytes: 4396
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
 
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }
 
typedef long long LL;
const int N = (int) 105, mod = (int) (1 << 23) * 17 * 7 + 1;
typedef pair<int, bitset<N>> num;
int compute_g(num);
struct cmp {
    bool operator() (num a, num b) const {
        if (a.first != b.first) return a.first < b.first;
        for (int j = 0; j < (int) a.first; ++j)
            if (a.second[j] != b.second[j]) {
                return a.second[j] < b.second[j];
            }
        return 0;
    }
};
map<num, int, cmp> fdp, gdp;
void sadd(int &x, int y) {
    x += y;
    while (x >= mod) x -= mod;
}
int compute_f(num x) {
    if (x.first == 1) return 1 + x.second[0];
    if (fdp.find(x) != fdp.end()) return fdp[x];
    int &res = fdp[x];
    int g = 1;
    int n = x.first;
    for (int j = 0; j < n; ++j) g = g * (1 + x.second[j]) % mod;
    for (int j = 1; j < n; ++j) {
        num xl, xr;
        xl.first = j;
        xr.first = n - j;
        for (int i = 0; i < j; ++i) xl.second[i] = x.second[i];
        for (int i = j; i < n; ++i) xr.second[i - j] = x.second[i];
        sadd(res, compute_f(xr) * (LL) compute_g(xl) % mod);
    }
    sadd(res, compute_g(x));
    return res;
}
int compute_g(num x) {
    if (x.first == 1) return 1 + x.second[0];
    if (gdp.find(x) != gdp.end()) return gdp[x];
    int &res = gdp[x];
    int n = x.first;
    for (int k = 2; k <= n; ++k) if (n % k == 0) {
        num nxt;
        nxt.first = n / k;
        for (int j = 0; j < n / k; ++j) {
            nxt.second[j] = 1;
            for (int i = j; i < n; i += nxt.first)
                nxt.second[j] = nxt.second[j] & x.second[i];
        }	
        sadd(res, compute_f(nxt));
    }
    
    return res;
}  
int main() {
    string s;
    cin >> s;
    num fs;
    fs.first = (int) s.size();
    for (int j = 0; j < (int) s.size(); ++j) 
        fs.second[j] = s[j] - '0';
    cout << compute_f(fs) << '\n';;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 2e5 + 5;

int n;
pair<int, int> a[N];

int32_t main()
{
	IOS;
	cin >> n;
	map<int, int> m;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i].first;
		a[i].second = i;
	}
	//sort(a + 1, a + n + 1);
	int ans = 0;
	for(int i = 1; i <= n; i++)
	{
		ans += m[i - a[i].first];
		m[i + a[i].first]++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 29528
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
  int n, a, b;
  scanf("%d %d %d",&n,&a,&b);
  if((b-a)%2==0) printf("Alice\n");
  else printf("Borys\n");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int K; cin >> K;
    set<string> st;
    int n = S.length();
    rep(i, n) {
        string R;
        for(int j = i; j < min(n, i + 5); j++) {
            R += S[j];
            st.insert(R);
        }
    }
    auto itr = st.begin();
    rep(i, K - 1) itr++;
    cout << *itr << endl;

    return 0;
}


Measured memory_bytes: 4680
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();

        if(A==B){
            System.out.println("Draw");
        }
        else if((A>B && B!=1) || A==1){
            System.out.println("Alice");
        }
        else{
            System.out.println("Bob");
        }

    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int R; cin >> R;
    if (R < 1200) cout << "ABC" << endl;
    else if (R < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void frog1(int arr[],int n)
{
  int dp[n]={0};
  for(int i=1;i<n;i++)
  {
      int option1=abs(arr[i]-arr[i-1])+dp[i-1];
      
      int option2=abs(arr[i]-arr[i-2])+dp[i-2];
      
      dp[i]=min(option1,option2);
      
      
  }
  cout<<dp[n-1];
  
}
int main()
{
     int n;
     cin>>n;
     int arr[n];
     for(int i=0;i<n;i++)
     {
       cin>>arr[i];
     }
     frog1(arr,n);
     return 0;
}

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

int main() {
	long long n;cin>>n;
	long long i=1;
	long long max=sqrt(n);
	long long amin,amax;
	while(i<=max){
		if(n%i==0){
			amax=n/i;
		}
		i++;
	}
	long long ans=1;
	while(amax>=10){
		amax/=10;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}


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

int main(){
  int N,K,i,t=1;

  cin>>N>>K;

  for(i=0;i<N;i++){
    if(t*2 < t+K){
      t = t*2;
    }else{
      t = t+K;
    }
  }
  cout<<t<<endl;

}


Measured memory_bytes: 256
#include <string>
#include <iostream>
using namespace std;
int main()
{
  string S;
  cin >> S;
  bool easy = true;
  for (int i = 0; i < S.length(); i++) {
    if (i%2==0) {
      if (S[i]!='R' && S[i]!='U' && S[i]!='D') easy=false;
    } else {
      if (S[i]!='L' && S[i]!='U' && S[i]!='D') easy=false;
    }
  }
  if (easy) cout << "Yes";
  else cout << "No";
  cout << endl;
}


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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(ll i=0; i<(n); i++)
#define REPj(n) for(ll j=0; j<(n); j++)
#define REPinit(i,a,n) for(ll i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(ll j=(a); j<(n); j++)

//algorithm
#define SORT(c) sort((c).begin(),(c).end())
#define CONTAINER_ALL(a) a.begin(),a.end()

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


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

    vector<int> anntena(5);
    REPinit(i, 0, 5) cin >> anntena[i];

    int k;
    cin >> k;

    if ((anntena[4] - anntena[0]) > k) cout << ":(" << endl;
    else cout << "Yay!" << endl;


    return 0;
}


Measured memory_bytes: 3620
N = int(input())
p = list(map(int,input().split()))
l = [0 for k in range(N+2)]

for k in range(N):
    if p[k] == k+1:
        l[k+1] = 1

t = 0
ans = 0
for e in l:
    if e == 1:
        t += 1
    else:
        ans += (t+1)//2
        t = 0
print(ans)


Measured memory_bytes: 14008
N = int(input())
S = list(input() for _ in range(N))
ac = S.count("AC")
wa = S.count("WA")
tle = S.count("TLE")
re = S.count("RE")
print("AC x",ac)
print("WA x",wa)
print("TLE x",tle)
print("RE x",re)

Measured memory_bytes: 16276
#include <bits/stdc++.h>
using namespace std;
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define contests_de_diya_kar 0
#define PB push_back
#define MP make_pair
#define int long long
#define MOD ((long long) (1000*1000*1000 + 7))
#define inf (int) 2e15
#define exit(a, b) return cout << a, b;
#define eps (double)1e-8
#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define vi vector<int>
#define vb vector<bool>
#define all(v) v.begin(), v.end() 
#define pii pair<int, int>
#define mii map<int, int> 
#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

const int maxn = (int) 1e5;
const int MODULO = MOD;

vi parent, sz, primes;
vector<vi> sieve;

void run_sieve () {
	sieve.resize(maxn + 1);
	for (int i = 2; i <= maxn; i += 1) {
		if (!sieve[i].empty()) continue;
		primes.PB(i);
		for (int j = i; j <= maxn; j += i) sieve[j].PB(i);
	}
}

void make_set (int x) {
	parent[x] = x;
	sz[x] = 1;
}

int find (int a) {
	while (a != parent[a]) a = parent[a];
	return a;
}

void merge (int a, int b) {
	a = find(a), b = find(b);
	if (a == b) return;

	if (sz[a] > sz[b]) {
		parent[b] = a;
		sz[a] += sz[b];
	}
	else {
		parent[a] = b;
		sz[b] += sz[a];
	}
}

int modexp (int a, int b, int mod) {
	if (b == 0) return 1;
	int ans = 1;
	while (b) {
		if (b & 1) ans = (ans * a) % mod;
		a = (a * a) % mod, b /= 2;
	}
	return ans;
}

signed main () {
	start_routine;
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	#endif

	int D, G;
	cin >> D >> G;

	vi p(D + 1), c(D + 1);
	for (int i = 1; i <= D; i += 1) {
		cin >> p[i] >> c[i];
	} 

	int mn = inf;
	for (int i = 0; i < (1 << D); i += 1) {
		vi full, part;
		for (int bit = 0; bit < D; bit += 1) {
			if ((1 << bit) & i) {
				full.push_back(bit + 1);
			}
			else part.push_back(bit + 1);
		}
		int ct = 0;
		int pts = 0;
		for (auto problem: full) {
			pts += (p[problem] * 100 * problem);
			pts += c[problem];
			ct += p[problem];
		}
		if (pts >= G) {
			if (ct < mn) mn = ct;
			continue;
		}
		vi pct = p;
		sort(all(part));
		reverse(all(part));
		for (auto problem: part) {
			while (pct[problem] > 0) {
				pts += (100 * problem);
				ct += 1;
				pct[problem] -= 1;
				if (pct[problem] == 0) {
					pts += c[problem];
				}
				if (pts >= G) {
					if (ct < mn) {
						mn = ct;
						break;
					}
				}
			}
		}
		if (pts >= G) {
			if (ct < mn) {
				mn = ct;
				break;
			}
		}
	}
	print(mn);
	end_routine;	
}


Measured memory_bytes: 256
using System;
using static System.Console;
using System.Linq;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
         int n = int.Parse(ReadLine());
         long ans = 0;
         for(int i = 1; i <= n; i++){
             if(i % 3 != 0 && i % 5 != 0) {
               ans += i;
             }
         }
         WriteLine(ans);
      }
   }
}

Measured memory_bytes: 27532
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
int main()
{
    cin >> N;
    vector<pii> values;
    values.resize(N);
    for (int i = 0; i < N; i++)
    {
        int a, b;
        cin >> a >> b;
        values[i] = mp(a, b);
    }
    sort(values.begin(), values.end());
    pii p = values[0];
    pii q = values[N - 1];
    int res = q.first - p.first + 1;
    res += p.first - 1;
    res += q.second;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1024
#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>;

int main() {
  ll n, k;
  cin >> n >> k;
  if (n % k == 0) {
    cout << 0 << endl;
  } else if (n <= k) {
    cout << min(n, abs(n - k)) << endl;
  } else {
    ll a = n % k;
    cout << min(a, abs(a - k)) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(int n){
    cout << "Yes" << endl;
}

void no (int n){
    cout << "No" << endl;
}

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

ll gcds(ll a, ll b){
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

vector<ll> zen(51);
vector<ll> pat(51);

ll ans (int n, ll k, ll ima){
    if (k == 0LL) return ima;
    if (n == 0) return ima + 1LL;
    if (k == 1LL) return ima;
    if (1LL < k && k < zen[n-1]+2LL) return ans(n-1,k-1LL,ima);
    if (k == zen[n-1]+2LL) return ima + pat[n-1] + 1LL;
    if (zen[n-1]+2LL < k && k < zen[n]) return ans(n-1,k-zen[n-1]-2LL,ima+pat[n-1]+1LL);
    if (k == zen[n]) return ima + pat[n]; 
}

int main() {
    int n; cin >> n;
    ll k; cin >> k;
    zen[0] = 1LL;
    pat[0] = 1LL;
    rep(i,50){
        zen[i+1] = 2LL * zen[i] + 3LL;
        pat[i+1] = 2LL * pat[i] + 1LL;
    }
    cout << ans(n,k,0LL) << endl;
}

Measured memory_bytes: 3644
N = int(input())
red = []
blue = []
for i in range(N):
    a, b = map(int, input().split())
    red.append((a, b))

for i in range(N):
    c, d = map(int, input().split())
    blue.append((c, d))

blue.sort()
red = sorted(red, key=lambda x: x[1])[::-1]
cnt = 0
for i in range(N):
    c, d = blue[i]
    k = -1
    for j in range(len(red)):
        a, b = red[j]
        if a < c and b < d:
            k = j
            break
    if k != -1:
        red.pop(k)
        cnt += 1
print(cnt)


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

using namespace std;

void print_vec(vector<int> vec) {
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i];
		i == vec.size() - 1 ? cout << endl : cout << " ";
	}
}

int main() {
	int n; cin >> n;
	vector<int> vec(n);
	for (int i = 0; i < n; i++)cin >> vec[i];
	print_vec(vec);
	int point = 0;
	for (int i = 1; i < n; i++) {
		int v = vec[i];
		int j = i - 1;
		while (j >= 0 && vec[j] > v) {
			vec[j + 1] = vec[j];
			j--;
			vec[j + 1] = v;
		}
		print_vec(vec);
	}
	return 0;
}

Measured memory_bytes: 1216
#include<iostream>
using namespace std;
int main() {
	int h, w;
	while (1) {
		cin >> h >> w;
		if (h == 0 && w == 0)break;
		for (int i = 0; i < h;i ++) {
			for (int j = 0; j < w; j++) {
				if (i%2 == 0&& j%2 == 0 || i%2 ==  1 && j%2 == 1) {
					cout << "#";
				}
				else {
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


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

int a[10000];

int main()
{
    int n,x,y;
    while(cin>>n>>x>>y)
    {
        memset(a,0,sizeof(a));
        int i,j;
        for(i=1;i<n;i++)
            for(j=i+1;j<=n;j++)
            {
                int ppp;
                if(i<=x)
                {
                    if(j<=x)
                        ppp=j-i;
                    else if(j<=y)
                    {
                        if(j-x<y-j+1)
                            ppp=j-i;
                        else
                            ppp=x-i+y-j+1;
                    }
                    else
                        ppp=x-i+j-y+1;
                }
                else if(i<=y)
                {
                    int ma=max(y,j);
                    int mi=min(y,j);
                    if(j-i<=ma-mi+1+i-x)
                        ppp=j-i;
                    else
                        ppp=i-x+1+ma-mi;
                }
                else
                    ppp=j-i;
                a[ppp]++;
            }
        for(i=1;i<n;i++)
            printf("%d\n",a[i]);
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int L;
    cin >> L;
    vector<tuple<int,int,int>> path;
    int i=1;
    while(L>1){
        if(L%2)path.push_back(make_tuple(i,100,L-1));
        path.push_back(make_tuple(i,i+1,L/2));
        path.push_back(make_tuple(i,i+1,0));
        i++;
        L/=2;
    }
    cout << i << " " << path.size() << endl;
    for(auto t:path){
        cout << get<0>(t) << " " << min(i,get<1>(t)) << " " << get<2>(t) << endl;
    }
}

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

constexpr int64_t INF = 1e18;

struct Input {
	static constexpr int N = 26;
	static constexpr int D = 365;
	vector<int64_t> c;
	vector<vector<int64_t>> s;
	Input() : c(N), s(D, vector<int64_t>(N)) {
		input();
	}
	private: void input() {
		int _D; cin >> _D;
		for(int i = 0; i < N; ++i) {
			cin >> c[i];
		}
		for(int i = 0; i < D; ++i) {
			for(int j = 0; j < N; ++j) {
				cin >> s[i][j];
			}
		}
	}
};

struct Output {
	vector<int> t;
	void print() {
		for(int i = 0; i < Input::D; ++i) {
			cout << t[i] + 1 << '\n';
		}
	}
};

int64_t calc_score(const Input& in, Output& out) {
	int64_t score = 0;
	int last[Input::N] = {};
	for(int d = 0; d < (int)out.t.size(); ++d) {
		last[out.t[d]] = d + 1;
		for(int i = 0; i < Input::N; ++i) {
			score -= (d + 1 - last[i]) * in.c[i];
		}
		score += in.s[d][out.t[d]];
	}
	return score;
}

int64_t evaluate(const Input& in, Output& out, int k) {
	int64_t score = 0;
	int last[Input::N] = {};
	for(int d = 0; d < (int)out.t.size(); ++d) {
		last[out.t[d]] = d + 1;
		for(int i = 0; i < Input::N; ++i) {
			score -= (d + 1 - last[i]) * in.c[i]; 
		}
		score += in.s[d][out.t[d]];
	}
	for(int d = out.t.size(); d < min<int>(out.t.size() + k, Input::D); ++d) {
		for(int i = 0; i < Input::N; ++i) {
			score -= (d + 1 - last[i]) * in.c[i];
		}
	}
	return score;
}

Output solve(const Input& in, int k) {
	Output out;
	for(int d = 0; d < Input::D; ++d) {
		int64_t max_score = -INF;
		int best_i = 0;
		for(int i = 0; i < Input::N; ++i) {
			out.t.push_back(i);
			int64_t score = evaluate(in, out, k);
			if(score > max_score) {
				max_score = score;
				best_i = i;
			}
			out.t.pop_back();
		}
		out.t.push_back(best_i);
	}
	return out;
}

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	Input input;
	Output output;
	int64_t max_score = -INF;
	for(int k = 0; k < Input::N; ++k) {
		Output out = solve(input, k);
		int64_t score = calc_score(input, out);
		if(score > max_score) {
			max_score = score;
			output = out;
		}
	}
	output.print();
	return 0;
}


Measured memory_bytes: 3760
#include <stdio.h>

int main(void) {
  int i, j, n, m;
  while( 1 ) {
    scanf("%d%d", &n, &m);
    if(!n && !m) break;
    int mmax[m];
    for(i = 0; i < m; ++i) mmax[i] = 0;
    for(i = 0; i < n; ++i) {
      int d, v;
      scanf("%d%d", &d, &v);
      d--;
      if(mmax[d] < v) mmax[d] = v;
    }
    int ans = 0;
    for(i = 0; i < m; ++i) ans += mmax[i];
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 2660
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

int dig[3];
bool done[3];

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n,m;
	cin >> n >> m;
	bool zero = 1;
	rep(i,0,m){
		int s,x;
		cin >> s >> x;
		zero &= x == 0;
		--s;
		if(done[s] && dig[s] != x){
			cout << -1 << '\n';
			return 0;
		}
		done[s] = 1;
		dig[s] = x;
	}
	if(n == 1 && zero){
		cout << 0 << '\n';
		return 0;
	}
	bool v = false;
	rep(i,0,1){
		v |= dig[i] != 0;
		if(!v){
			if(done[i]){
				cout << -1 << '\n';
				return 0;
			}
			dig[i] = 1;
		}
	}
	rep(i,0,n)cout << dig[i];
	cout << '\n';
}


Measured memory_bytes: 256
/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

clock_t time_p=clock();
void aryanc403()
{
#ifdef ARYANC403
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/aryan/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    fo(i,3)
    {
        cin>>in;
        a.pb(in);
    }

    sort(all(a));
    a.erase(unique(all(a)),a.end());
    cout<<(sz(a)==2?"Yes":"No")<<endl;

}   aryanc403();
    return 0;
}


Measured memory_bytes: 256
ta,ao,k = map(int,input().split())

if ta < k: #回数が高橋くんのクッキーより多い
    k = k - ta
    ta = 0

else: #回数が高橋くんのクッキーより少ない
    ta = ta - k
    k = 0

if ao < k:
    ao = 0
    k = k - ao

else:
    ao = ao - k
    k = 0

print(ta,ao)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef pair<int, int> pii;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> p(M);
  vector<string> S(M);
  for (int i = 0; i < M; i++) {
    cin >> p[i] >> S[i];
  }
  
  vector<int> passed(N + 1, 0);
  vector<int> wrong(N + 1, 0);
  int wa = 0, ac = 0;
  for (int i = 0; i < M; i++) {
    int pi = p[i];
    string si = S[i];
    if (si == "AC") {
      if (passed[pi] == 0) {
        ac++;
        wa += wrong[pi];
        passed[pi] = 1;
      }
    } else {
      wrong[pi]++;
    }
  }
  cout << ac << " " << wa << endl;
  return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <sstream>
using namespace std;


int main(void){

string input;
int num[2];
int counter = 0;
istringstream stream(input);

while(getline(cin,input)){
        stream.str("");
        stream.clear(stringstream::goodbit);
        stream.str(input);
        stream >> num[0] >> num[1];
        if(num[0] == 0 && num[1] == 0) break;
        else if(num[0] <= num[1]) cout << num[0] << " " << num[1] << "\n";
        else cout << num[1] << " " << num[0] << "\n";
}

}

Measured memory_bytes: 1228
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define sym cout<<"-----------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

#define MAX 100005
int n,m,ans;
P p[MAX];
int t;

signed main(){
  cin>>n>>m;
  
  for(int i=0; i<m; i++){
    cin>>p[i].second>>p[i].first;
  }
  
  sort(p, p+m);
  ans=1;
  t=p[0].first;
  for(int i=1; i<m; i++){
    if(p[i].second>=t){
      ans++;
      t=p[i].first;
    }
  }
  cout<<ans<<en;
  RE;
}

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

int main(){
 int n,a,b;
  cin >> n;
  
 vector<int> d(n);
  rep(i,n) cin >> d.at(i);
  
 sort(d.begin(),d.end());
  
  a=n/2-1;
  b=n/2;
  
  cout << d.at(b)-d.at(a) << endl;
  
}
  
  
  


Measured memory_bytes: 3764
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <memory.h>
#include <cassert>
#include <iomanip>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;



int main() {
	char c;
	set<int> ans;
	for (double n, w, h; cin >> n >> c >> w >> c >> h; ) {
		if (w / h / h >= 25.0) ans.insert(n);
	}
	tr(i, ans) cout << *i << endl;
	
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

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

        for (int i = 0; i < N; i++) {
            int n = sc.nextInt();
            X -= n;
            if (min > n) {
                min = n;
            }
        }
        System.out.println(N + X / min);
    }
}

Measured memory_bytes: 21844
n = int(input())
a, b = map(int, input().split())
c, d = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
ans = 10 ** 3
for w in range(1, n + 1):
  ax, ay = a % w, a // w
  bx, by = b % w, b // w
  cx, cy = c % w, c // w
  dx, dy = d % w, d // w
  ans = min(ans, abs(ax - bx) + abs(ay - by) + abs(cx - dx) + abs(cy - dy))
print(ans)


Measured memory_bytes: 5604