akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main()
{
  int x, y;

  while (1)
  {
    cin >> x;
    cin >> y;
    if (x == 0 && y == 0)
    {
      break;
    }
    else
    {
      for (int i = 0; i < x; i++)
      {
        for (int j = 0; j < y; j++)
        {
          cout << "#";
        }
        cout << endl;
      }
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3104
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	long long int a[100005];
	for (i = 0; i <= n; i++)
		scanf("%lld", &a[i]);
	long long int max[100005], min[100005];
	max[n] = min[n] = a[n];
	for (i = n - 1; i >= 0; i--)
	{
		max[i] = max[i + 1] + a[i];
		min[i] = (min[i + 1] + 1) / 2 + a[i];
	}
	if (min[0] > 1)
	{
		printf("-1\n");
		return 0;
	}
	long long int ans = 0;
	long long int p = 1;
	for (i = 0; i <= n; i++)
	{
		ans += p;
		p = (p - a[i]) * 2;
		if (p > max[i + 1])
			p = max[i + 1];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4032
/*
Author: Babin Dutta
*/

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define endl "\n"

ll dp[1000][1000];
char c[1000][1000];

void solve(){
	int n,m; cin>>n>>m;
	//char c;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>c[i][j];
		}
	}
	f(i,m){
		if(c[0][i] == '.') dp[0][i]=1;
		else break;
	}
	f(i,n){
		if(c[i][0] == '.') dp[i][0]=1;
		else break;
	}
	ff(i,1,n-1){
		ff(j,1,m-1){
			if(c[i][j] == '#') continue;
			dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
		}
	}
	cout<<dp[n-1][m-1]<<endl;
}

int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}

Measured memory_bytes: 9088
#include<stdio.h>

int main(){
    int i,j,n,r[200000]={0},max,min;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&r[i]);
    }   
    max=r[1]-r[0];
    min=r[0];
    for(i=1;i<n;i++){
        if(max<r[i]-min){
            max=r[i]-min;
        }   
        if(min>r[i])min=r[i];
    }   
    printf("%d\n",max);
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        b[i] = a[i];
    }

    sort(b.begin(), b.end());
    b.erase(unique(b.begin(), b.end()), b.end());

    auto f = [&](int k) {
        vector<int> s(2 * n + 1, 0);
        int sum = n; s[sum] = 1;
        long long ans = 0, add = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] >= k) add -= s[--sum];
            else add += s[sum++];
            ans += add;
            s[sum]++;
        }
        return ans;
    };

    int ok = 0, ng = int(b.size());
    const long long x = ((1LL * n * (n + 1)) / 2);
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (f(b[mid]) * 2LL <= x) ok = mid;
        else ng = mid;
    }

    cout << b[ok] << '\n';

    return 0;
}

Measured memory_bytes: 1804
#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...) 
#define hash _hash
#define next _next
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)
 
#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 50010
 
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}
 
//FILE* outFile;
inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}


int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}

string a="",b="",g[2]={".","#"};
int out(string &s,string &t){
	cout<<s<<"\n"<<t<<"\n";fflush(stdout);
	string x;
	cin>>x;
	if(x[0]=='e')exit(0);
	return x[0]=='T';
}
int main(){
    int T,i,j,k,ca=0,m,n,K;
    //cout<<setprecision(10)<<fixed;
    cin>>n;
    int x,v[4]={0};
    rep(i,0,4){
    	a=g[i&1],b=g[i>>1&1];
    	k=out(a,b);
    	if(k)v[i]=1,x=i;
    }
    int len=0;
    a=g[x&1],b=g[x>>1&1];
    rep(i,1,n){
    	int flag=0;
    	rep(j,0,4)if(v[j]){
    		string aa=a+g[j&1],bb=b+g[j>>1&1];
    		k=out(aa,bb);
    		if(k){a=aa,b=bb;flag=1;break;}
    	}
    	if(!flag){
    		len=i;break;
    	}
    }
	rep(i,0,n-len){
		rep(j,0,4)if(v[j]){
    		string aa=g[j&1]+a,bb=g[j>>1&1]+b;
    		k=out(aa,bb);
    		if(k){a=aa,b=bb;break;}
    	}
	}
    return 0;
}



Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, A[110][2]; 
	cin >> N; 
	for(int i = 1; i <= N; i++) cin >> A[i][0]; 
	for(int i = 1; i <= N; i++) cin >> A[i][1]; 
	int S[110] = {}; int T[110] = {}; 
	for(int i = 1; i <= N; i++) S[i] = S[i-1] + A[i][0]; 
	for(int i = N; i >= 1; i--) T[i] = T[i+1] + A[i][1]; 
	int mx = 0; 
	for(int i = 1; i <= N; i++) mx = max(mx, S[i] + T[i]); 
	cout << mx << endl; 
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
ll gcd(ll a, ll b)
{
	for (;;)
	{
		if (a < b)swap(a, b);
		a %= b;
		if (a == 0)return b;
	}
}
ll a[202020];
int main()
{
	int num;
	scanf("%d", &num);
	deque<int>deq;
	for (int i = 0; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		if (i % 2 == 0)deq.push_back(z);
		else deq.push_front(z);
	}
	if (num % 2)reverse(deq.begin(), deq.end());
	for (int i = 0; i < num; i++)printf("%d ", deq[i]); printf("\n");
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
const double PI = acos(-1);
int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; ll k;
	cin >>n >>k;
	VI a(n), f(n);
	rep(i, n) cin >>a[i];
	rep(i, n) cin >>f[i];
	
	sort(all(a));
	sort(f.rbegin(), f.rend());
	VL sm(n);
	rep(i, n) sm[i] = (ll)a[i] * f[i];
	
	auto ckd=[&](ll s){
		ll rtn = 0;
		rep(i, n) rtn += max(0LL, (sm[i] - s + f[i]-1)/f[i]);
		return rtn <= k;
	};
	
	ll hi=1LL<<55, lw=-1;
	while(hi - lw >1){
		ll md = (hi+lw)/2;
		(ckd(md)? hi: lw) = md;
	}
	cout << hi <<"\n";
	return 0;
}


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

int main() {
  int N; cin >> N;
  vector<int> A(N);
  int maximum =0;
  long long ans =0;
  
  for(int i=0; i<N; i++) cin >> A[i];
  for(int i=0; i<N; i++) {
    maximum =  max(maximum,A[i]);
    int D = maximum;
    ans += D - A[i];
  }
  cout << ans << endl;
}

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

int main(){
	int A, B, C, D;
  	cin >> A >> B >> C >> D;
  	if( A+B > C+D ){
    	cout << "Left" << endl;
    }else if( A+B < C+D ){
    	cout << "Right" << endl;
    }else{
    	cout << "Balanced" << endl;
    }




}

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

using namespace std;
typedef long long ll;

const ll modint = 1000000007;

int main()
{
    int n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;
    ll ans = 1;
    char last;
    for (int i = 0; i < n; i++)
    {
        if (i == 0)
        {
            if (s1[i] == s2[i])
            {
                ans = 3;
                last = 'v';
            }
            else
            {
                ans = 6;
                last = 'h';
                i++;
            }
            continue;
        }
        else
        {
            if (s1[i] == s2[i] & 'v' == last)
            {
                ans *= 2;
                ans %= modint;
                last = 'v';
            }
            else if (s1[i] != s2[i] & 'h' == last)
            {
                ans *= 3;
                ans %= modint;
                last = 'h';
                i++;
            }
            else if (s1[i] != s2[i] & 'v' == last)
            {
                ans *= 2;
                ans %= modint;
                last = 'h';
                i++;
            }
            else
            {
                last = 'v';
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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


//  1 1000
// 50 50
// 
// 1000 10
// 1    1000
//
// 1000 - 1000
// 1 - 10

int main() {
    int n; cin >> n;
    pair<int,int> ab[100000];
    rep(i,n) cin >> ab[i].first >> ab[i].second;
    pair<int,int> cand[100000];
    rep(i,n) {
        cand[i] = make_pair(ab[i].first + ab[i].second, i);
    }
    sort(cand, cand+n, greater<pair<int,int>>());
    lint takahasi = 0;
    lint aoki = 0;
    rep(i,n) {
        if (i % 2 == 0) takahasi += ab[cand[i].second].first;
        else aoki += ab[cand[i].second].second;
    }
    cout << takahasi - aoki << endl;

}

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

int main(){
  int N;
  cin >> N;
  vector<double> A(N);
  for(int i = 0; i < N; i++){
    double x;
    cin >> x;
    A.at(i) = 1 / x;
  }
  double sum = 0;
  for(int i = 0; i < N; i++){
    sum += A.at(i);
  }
  cout << 1 / sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const long long INF = 1LL << 60;

int MOD = 1000000007;



int main(){
    std::ios_base::sync_with_stdio(false);

    int n; cin >> n;
    vector<int> v;
    int prev = -10;
    rep(i,n){
        int a; cin >> a;
        if(a!=prev){
            v.push_back(a);
        }
        prev = a;
    }

    rep(i,v.size()){
        if(i==0){
            if(v.size()>=2 && v[0]<=v[1]+1){
                v[0]--;
            }

            if(v.size()>=2 && v[0]>v[1]+1){
                cout << "No" << endl;
                return 0;
            }

            continue;
        }

	    if(v[i-1] < v[i]){
		    v[i]--;
	    }
    }

    bool good=true;

    rep(i, v.size()-1){
	if(v[i] > v[i+1]){
		good = false;
		break;
	}
    }

    if(good) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n; cin>>n;
  string s; cin>>s;
  int l=0, r=n-1, cnt=0;;
  while(l<r&&r<n){
    while(l<r&&s[l]=='R')
      l++;
    while(r>l&&s[r]=='W')
      r--;
    if(s[l]=='W'&&s[r]=='R')
      swap(s[l],s[r]), cnt++;
  }
  cout<<cnt<<"\n";
  return 0;
}

Measured memory_bytes: 3684
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    ll k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];

    vi next(n), check(200001, -1);
    rep(j, 2) rep(i, n) {
        if(check[a[i]] != -1) {
            next[check[a[i]]%n] = j*n+i-check[a[i]];
        }
        check[a[i]] = j*n+i;
    }
/*
    rep(i, n) cout << next[i] << (i == n-1?'\n':' ');
    cout << endl;*/

    vector<ll> used(n, -1);
    ll roop = 0;
    while(used[roop%n] == -1) {
        used[roop%n] = roop;
        roop += next[roop%n]+1;
    }
    ll X = used[roop%n];
    roop -= X;


    ll aa = k*n-1;
    if(aa > X) {
        aa -= X;
        aa %= roop;
        aa += X;
    }

    vi ans;
    int now = 0;
    while(aa >= 0) {
        if(aa >= next[now]) {
            aa -= next[now]+1;
            now += next[now]+1;
        } else {
            ans.push_back(a[now]);
            aa--;
            now++;
        }
        now %= n;
        //cout << now << ' ' << aa << endl;
    }
    rep(i, ans.size()) cout << ans[i] << (i == ans.size()-1?'\n':' ');
}

Measured memory_bytes: 8108
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <utility>
#include <map>
int needleX[4] = { -1,0,1,0 };
int needleY[4] = { 0,1,0,-1 };

int main(void) {
    int n;

    std::cin >> n;
    std::vector<int> p(100+1);
    for (int i = 1; i <= n; i++) {
        std::cin >> p[i-1] >> p[i];
    }
    int m[100 + 1][100 + 1];
    for (int i = 1; i <= n; i++) {
        m[i][i] = 0;
    }
    for (int l = 2; l <=n; l++) {
        for (int i = 1; i <= n-l+1; i++) {
            int j = i + l - 1;
            m[i][j] = (1<<21);
            for (int k = i ; k <= j - 1;k++) {
                m[i][j] = std::min(m[i][j],  m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
            }
        }
    }
    /*for (int i = 1; i <= n; i++) {
        for (int j = i+1; j <= n; j++) {
            std::cout << m[i][j] << " ";
        }
        std::cout << std::endl;
    }*/
    std::cout << m[1][n] << std::endl;
    return 0;
}


Measured memory_bytes: 3136
program main
  implicit none
  integer(8) :: n, k, i, m, res
  integer(8), allocatable :: fact(:), perm(:, :)
  read *, n, k
  allocate (fact(0:n), perm(n - 1:n, 0:n))
  m = 1000000007
  call calc_fact
  call calc_perm
  res = 0
  do i = 0, min(k, n - 1)
    res = res + modulo(combi(n, i, m) * combi(n - 1, i, m), m)
    res = modulo(res, m)
  end do
  print "(i0)", res
  contains

  function combi(n, k, m)
    implicit none
    integer(8), intent(in) :: n, k, m
    integer(8) :: combi, numera, denomi
    numera = perm(n, k)
    denomi = mod(fact(k), m)
    combi = mod(numera * inv(denomi, m), m)
  end function combi

  subroutine calc_perm()
    integer(8) :: i
    perm(n, 0) = 1
    do i = 1, n
      perm(n, i) = perm(n, i - 1) * (n - i + 1)
      perm(n, i) = modulo(perm(n, i), m)
    end do
    perm(n - 1, 0) = 1
    do i = 1, n - 1
      perm(n - 1, i) = perm(n - 1, i - 1) * (n - i)
      perm(n - 1, i) = modulo(perm(n - 1, i), m)
    end do
  end subroutine calc_perm

  ! O(k)
  ! function perm(n, k, m)
  !   integer(8), intent(in) :: n, k, m
  !   integer(8) :: i, perm
  !   perm = 1
  !   do i = n, n - k + 1, -1
  !     perm = mod(perm * i, m)
  !   end do
  ! end function perm

  subroutine calc_fact()
    integer(8) :: i
    fact(0) = 1
    do i = 1, n
      fact(i) = modulo(fact(i - 1) * i, m)
    end do
  end subroutine calc_fact

  ! O(n)
  ! function fact(n, m)
  !   implicit none
  !   integer(8), intent(in) :: n, m
  !   integer(8) :: i, fact
  !   fact = 1
  !   do i = 1, n
  !     fact = mod(fact * i, m)
  !   end do
  ! end function fact

  ! O(log m)
  function inv(n, m)
    implicit none
    integer(8), intent(in) :: n, m
    integer(8) :: inv
    inv = pow(n, m - 2, m)
  end function inv

  ! O(log p)
  recursive function pow(n, p, m) result(res)
    implicit none
    integer(8), intent(in) :: n, p, m
    integer(8) :: res
    if (p == 0) then
      res = 1
    else if (mod(p, 2_8) == 0) then
      res = mod(pow(n, p / 2, m) ** 2, m)
    else
      res = mod(pow(n, p - 1, m) * n, m)
    end if
  end function pow
end program main


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

/*----------------------------- DEFINES ------------------------------*/

#define eps 1e-9
#define mod 1000000007
#define ump unordered_map // operations take less time compared to map
#define pb push_back
#define pf push_front
#define pof pop_front()
#define pob pop_back()
#define mp make_pair
#define ps(x) push(x) // for stack and queue
#define T top() //  for stack
#define FR front()// for queue
#define BA back()// for queue
#define PP pop()// for queue and stack
#define B begin()
#define E end()
#define F first
#define S second
#define tostr(x) to_string(x)
#define SZ(x) ((int)x.size())
#define ins insert
#define MAE max_element
#define MIE min_element
#define cnt(x) count(x)
#define lb(x) lower_bound(x) // returns an it ptng to the element >=x if no such returns end
#define ub(x) upper_bound(x) // returns an it ptng to the element >x if no such returns end
#define rep(i,x,y) for(int i=x;i<y;i++)
#define per(i,x,y) for(int i=x;i>y;i--)
#define repi(i,x,y) for(int i=x;i<=y;i++)
#define peri(i,x,y) for(int i=x;i>=y;i--)
#define reps(i,x,y,k) for(int i=x;i<y;i+=k)
#define sper(i,x,y,k) for(int i=x;i>y;i-=k) 
#define all(x) ((x.B),(x.E))
#define inf (ll)LLONG_MAX
#define ds1(i,x) for(auto i=x.begin();i!=x.end();i++)
#define ds2(i,x) for(auto i:x) // easy method to iterate through a ds
#define sq(a) (a)*(a)
#define fib(n) ceil(pow((1+sqrt(5),n)-pow((1-sqrt(5),n)/(float)(pow(2,n)*sqrt(5)// compute fib(n) in O(1)
#define FIO {ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);}// fast i/o
#define dig(n) (int)(log10(n)+1) // num of digits
#define ss(x,k) substr(x,k)  // x is the start pos and k is the length of substr.
#define f(x) find(x)
#define set(x,k) memset(x,k,sizeof x)

/*------------------------------ TYPEDEFS-----------------------------*/

typedef long long ll;
typedef long l;
typedef string str;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<pair<int,int> > vpii;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef ump<int,int> umpii;

/*-----------------------------START FROM HERE -----------------------*/

int main(){
	FIO
	
	str s;getline(cin,s);
  	rep(i,0,SZ(s))if(s[i]==',')s[i]=' ';
  	cout<<s;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[300020];
int t[8][2];
int f[300020][8];
int p = 1000000007;
int main() {
	t[0][0] = 2;
	t[0][1] = 1;
	t[1][0] = 3;
	t[1][1] = 5;
	t[2][0] = 4;
	t[2][1] = 7;
	t[3][0] = 6;
	t[3][1] = 1;
	t[4][0] = 2;
	t[4][1] = 2;
	t[5][0] = 5;
	t[5][1] = 5;
	t[6][0] = 3;
	t[6][1] = 3;
	t[7][0] = 2;
	t[7][1] = 1;
	scanf("%s", s);
	int n = strlen(s);
	f[n][1] = 1;
	f[n][5] = 1;
	for (int i = n - 1; i >= 0; i--) {
		for (int j = 0; j < 8; j++) {
			if (s[i] != '1') {
				f[i][j] += f[i + 1][t[j][0]];
			}
			if (s[i] != '0') {
				f[i][j] += f[i + 1][t[j][1]];
			}
			f[i][j] %= p;
		}
	}
	printf("%d\n", f[0][0]);
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

    int n; std::cin >> n;
    int cnt4, cnt_odd, cnt2;
    cnt4 = cnt_odd = cnt2 = 0;
    rep(i, n) {
        int a; std::cin >> a;
        if (a%4 == 0) cnt4++;
        else if (a & 1) cnt_odd++;
        else cnt2++;
    }
    if (cnt_odd-cnt4 <= (cnt2==0)) std::cout << "Yes" << "\n";
    else std::cout << "No" << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n;
    cin >> n;
    vl a(n+1);
    rep(i, n) cin >> a[i+1];
    ll ans = 0LL;
    rep(i, n) a[i+1] += a[i];
    map<ll, ll> mp;
    rep(i, n+1) mp[a[i]]++;
    for(auto& p : mp) {
        if(p.se > 1) ans += p.se * (p.se-1);
    }
    cout << ans / 2<< endl;
    return 0;
}

Measured memory_bytes: 14336
#include <iostream>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>


using namespace std;
typedef long long ll;
const int MX=1e6+7;
const long double eps=-0.00000001;
int a[MX];

vector <int> v[30];
int main()
{
    string s;
    cin>>s;
    int l=s.length();
    for ( int i=0 ; i<l ; i++ )
    {
        if ( i+1<l )
        {
            if ( s[i]==s[i+1] ) { cout<<i+1<<" "<<i+2; return 0; }
        }
        if ( i+2<l )
        {
            if ( s[i]==s[i+2] ) { cout<<i+1<<" "<<i+3; return 0; }
        }
    }

    cout<<"-1 -1";


    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include<map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef unsigned int ui;
typedef unsigned short us;

using namespace std;


int inputValue() {
  int a;
  scanf("%d", &a);
  return a;
};
void inputVector(vector<int>* v) {
  //cin.tie(0);
  //ios::sync_with_stdio(false);
  int a;
  while (cin >> a) {
    if (a == -1)break;
    v->push_back(a);
  }
};

void inputVector(vector<int> * p, int a) {
  p->clear();
  p->shrink_to_fit();
  rep(i, a) {
    int input;
    cin >> input;
    p->push_back(input);
  }
}

void inputVector2(vector<vector<int>>& v, ui r, ui c) {
  int temp;
  for (size_t i = 0; i < r; i++)
  {
    for (size_t j = 0; j < c; j++)
    {
      scanf("%d", &temp);
      v[i][j] = temp;
    }
  }
}
void inputVector3(vector<int>* v0, vector<int>* v1) {
  int a;
  unsigned short count = 0b0;
  while (cin >> a) {
    if (a == -1)break;
    if (count)v0->push_back(a); else v1->push_back(a);
    count = count ^ 1;
  }
};

template <typename T>
void output(T a, int precision) {
  if (precision > 0) {
    cout << setprecision(precision) << a << "\n";
  }
  else {
    cout << a << "\n";
  }
}

int main(int argc, const char * argv[]) {
  int count = 0;
  int tempvalue;
  ui n;
  ui m;
  int c;
  vector<int> b;
  vector<int> a;
  scanf("%d %d %d", &n, &m, &c);
  inputVector(&b, m);
  for (size_t i = 0; i < n; i++)
  {
    inputVector(&a, m);
    tempvalue = c;
    for (size_t j = 0; j < m; j++)
    {
      tempvalue += a[j] * b[j];
    }
    if (tempvalue > 0) {
      ++count;
    }
  }
  printf("%d", count);
  return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main (String args[]) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		String buf;
		int count = 1;

		try {
			while (true) {
				buf = br.readLine();
				if (Integer.parseInt(buf)==0) break;
				System.out.println("Case "+count+": "+Integer.parseInt(buf));
				count++;
			}
		} catch (Exception e) {
			//Exception
		}
	}
}

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

int main(){
    int t,n;
    t = 0;
    cin>>n;
    for(int i = 1;i <= n;i++){
        for(int j = 1;j <= n;j++){
            if(i * j >= n)break;
            t++;
        }
    }
    cout<<t<<"\n";
    //system("PAUSE");
    return 0;

}

Measured memory_bytes: 3640
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
#include <array>
#include <ctype.h> // isdigit
#include <cassert>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ALL(u) begin(u),end(u)
#define PB push_back
#define LE(n,m) ((n) < (m) + EPS * (abs(n) + abs(m)))
#define GE(n,m) ((n) + EPS * (abs(n) + abs(m)) > (m))
#define LT(n,m) ((n) + EPS * (abs(n) + abs(m)) < (m))
#define GT(n,m) ((n) > (m) + EPS * (abs(n) + abs(m)))
#define EQ(n,m) (abs((n)-(m)) < EPS * (abs(n) + abs(m)))

typedef long long int ll;
const int INF = (1<<30) - 1;
const double EPS = 1e-9;
const int MOD = 1000000007;

int N, M, A, B, C;

//length n, a -> b
bool G[110][50][50];
//n?????????????????????????°????
int d[100];


//g++ -std=c++0x -msse4.2 -O3
//#include <bits/stdc++.h>
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.precision(16);
    //cout.setf(ios::fixed);
    
    cin >> N >> M >> A >> B >> C;
    for(int i=0; i<N; i++)
        G[0][i][i] = true;
    
    while(M--){
        int u, v; cin >> u >> v;
        u--; v--;
        G[1][u][v] = true;
    }
    
    for(int l=2; l<=100; l++)
        for(int i=0; i<N; i++)
            for(int j=0; j<N; j++)
                for(int k=0; k<N; k++)
                    G[l][i][j] |= (G[l-1][i][k] & G[1][k][j]);
    
    for(int i=0; i<N; i++)
        d[i] = INF;
    
    d[N-1] = 0;
    vector<int> to{A, B, C};

    bool updated = true;
    while(updated){
        updated = false;
        for(int i=0; i<N; i++){
            int m = 0;
            bool ok = true;
            for(auto c: to){
                bool tans = false;
                int tm = INF;
                for(int j=0; j<N; j++){
                    if(G[c][i][j] && d[j]!=INF){
                        tans = G[c][i][j];
                        tm = min(tm, d[j]+1);
                    }
                }
                ok &= tans;
                m = max(m, tm);
            }
            if(ok){
                if(d[i] > m){
                    d[i] = m;
                    updated = true;
                }
            }
        }
        
    }
    
    if(d[0] == INF)
        cout << "IMPOSSIBLE" << endl;
    else
        cout << d[0] << endl;
    
    return 0;
}

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

int main(){
  int N,buf;
  cin >> N;

  int Nodd= 0;
  for(int i=0; i<N; i++){
    cin >> buf;
    if(buf%2==1){ Nodd++; }
  }

  string ans= (Nodd%2==0) ? "YES" 
                          : "NO";
  cout << ans << endl;
}

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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;

const int N = 2e5 + 5;
const ll INF = 1e18L + 5;

int t[4*N] = {0}, lazy[4*N] = {0};

void push(int node){
    t[2*node] += lazy[node];
    lazy[2*node] += lazy[node];
    t[2*node + 1] += lazy[node];
    lazy[2*node + 1] += lazy[node];
    lazy[node] = 0;
}

void build(vector<ll>& a, int node, int tl, int tr){
    if(tl == tr) return void(t[node] = a[tl]);
    int tm = (tl + tr)>>1;
    build(a, 2*node, tl, tm);
    build(a, 2*node+1, tm+1, tr);
    t[node] = min(t[2*node], t[2*node+1]);
}

void update(int node, int tl, int tr, int l, int r, int add){
    if(l > r) return;
    if(tl == l && tr == r){
        t[node] += add;
        lazy[node] += add;
    } else {
        push(node);
        int tm = (tl + tr)>>1;
        update(2*node, tl, tm, l, min(r, tm), add);
        update(2*node+1, tm+1, tr, max(l, tm+1), r, add);
        t[node] = min(t[2*node], t[2*node+1]);
    }
}

int query(int node, int tl, int tr, int l, int r){
    if(l > r) return INF;
    if(tl == l && tr == r) return t[node];
    push(node);
    int tm = (tl + tr)>>1;
    return min(query(2*node, tl, tm, l, min(r, tm)),
               query(2*node+1, tm+1, tr, max(l, tm+1), r));
}


void solve(){
    ll n, m, l, r, x;
    cin>>n>>m;

    ll tot = 0;
    vector<pll> en[n+1];
    for(int i=0; i<m; i++){
        cin>>l>>r>>x;
        tot += x;
        en[r].push_back({l, x});
    }

    ll best = tot;

    for(int i=1; i <= n+1; i++){
        /// best value till now for putting 1 here
        for(auto p: en[i - 1]){
            l = p.first;
            x = p.second;
            update(1, 0, N - 1, 0, l - 1, x);
        }

        best = query(1, 0, N - 1, 0, i - 1);
        update(1, 0, N - 1, i, i, best);
    }

    cout<<tot - best;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    ll t = 1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}



Measured memory_bytes: 23424
import sys
import heapq

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

X,Y,A,B,C = map(int, readline().split())

P = list(map(int, readline().split()))
Q = list(map(int, readline().split()))
R = list(map(int, readline().split()))

P = sorted(P, reverse=True)[:X]
Q = sorted(Q, reverse=True)[:Y]
R.sort(reverse=True)

heapq.heapify(P)
heapq.heapify(Q)

for r in R:
    p = heapq.heappop(P)
    q = heapq.heappop(Q)

    if p <= q and p < r:
        heapq.heappush(P, r)
        heapq.heappush(Q, q)
    elif q < r:
        heapq.heappush(Q, r)
        heapq.heappush(P, p)
    else:
        heapq.heappush(P, p)
        heapq.heappush(Q, q)

print(sum(P) + sum(Q))

Measured memory_bytes: 21212
#include <bits/stdc++.h>
#define MAX 100005
#define ll long long
#define P 998244353
using namespace std;

int n, m;
ll k, b[MAX];
double a[MAX], tmp[MAX];

void calc(ll k){
	while(k){
		if(k&1){
			for(int i = 1; i <= n; i++) tmp[i] = a[b[i]];
			for(int i = 1; i <= n; i++) a[i] = tmp[i];
		}
		for(int i = 1; i <= n; i++) tmp[i] = b[b[i]];
		for(int i = 1; i <= n; i++) b[i] = tmp[i];
		k >>= 1;
	}
}

int main()
{
	cin >> n;
	for(int i = 1; i <= n; i++){
		scanf("%lf", &a[i]);
		b[i] = i;
	}
	for(int i = n; i >= 1; i--){
		a[i] -= a[i-1];
	}
	cin >> m >> k;
	int x;
	for(int i = 1; i <= m; i++){
		scanf("%d", &x);
		swap(b[x], b[x+1]);
	}
	calc(k);
	double s = 0;
	for(int i = 1; i <= n; i++){
		s += a[i];
		printf("%.1lf\n", s);
	}
	
	return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int N, H[101];
//---------------------------------------------------------------------------------------------------
int ans = 0;
void f(int L, int R) {
    if (L >= R) return;

    int mi = inf;
    rep(i, L, R) chmin(mi, H[i]);

    ans += mi;
    rep(i, L, R) H[i] -= mi;

    vector<int> zero;
    zero.push_back(-1);
    rep(i, L, R) if(H[i] == 0) zero.push_back(i);
    zero.push_back(R);

    int n = zero.size();
    rep(i, 0, n - 1) f(zero[i] + 1, zero[i + 1]);
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> H[i];

    f(0, N);
    cout << ans << endl;
}

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

a_input = [int(i) for i in input().split()]

a = {}

for i in a_input:
  if i in a:
    a[i] += 1
  else:
    a.setdefault(i, 1)
    
need_changes = len(a) - k

a = sorted(a.items(), key=lambda x:x[1])
a_values = [a[i][1] for i in range(len(a))]

count = 0
ans = 0
if need_changes > 0:
  for i in a_values:
    ans += i
    count += 1
    if count == need_changes:
      break
      
print(ans)

Measured memory_bytes: 39044
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int N,A[1000];
  cin>>N;
  for (int i(0);i<N;i++) cin>>A[i];
  for (int i(0);i<N;i++){
    if (A[i]%2 == 0 && (A[i]%3 != 0 && A[i]%5!=0)){
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << 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 pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

int main() {
    int n,m;
    cin >> n >> m;
    vector<vector<int>>a(m);
    rep(i,n) {
        int A,B;
        cin >> A >> B;
        if(A > m) continue;
        // cout << m-A << endl;
        a[m-A].push_back(B);
    }
    priority_queue<int> q;
    ll ans = 0;
    
    for(int i = m-1;i>=0;i--) {
            for(auto x : a[i]) {
                q.push(x);
            }
        if(!q.empty()) {
            ans += q.top();q.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n;
	cin>>n;
	if(n==1)
  {
		cout<<0<<endl;
		return 0;
	}
	ll ans=0;
	for(ll i=1;i<=sqrt(n);i++)
  {
		if(n%i==0&&n%((n-i)/i)!=0&&i<(n-i)/i)
    {
			ans+=(n-i)/i;
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <algorithm>

int main(){
  
  long long int N, K, tmp;
  std::vector<long long int> h;
  
  scanf("%lld%lld", &N, &K);
  for(long long int i = 0; i < N; i++){
    scanf("%lld", &tmp);
    h.push_back(tmp);
  }
  
  // solve problem
  std::vector<long long int> min_cost;
  for(long long int i = 0; i < N; i++){
    min_cost.push_back(2e9);
  }
  min_cost[0] = 0;
  
  for(long long int i = 1; i < N; i++){
    for(int k = 1; k <= K && k <= i; k++){
      min_cost[i] = std::min(min_cost[i], min_cost[i-k] + std::abs(h[i]-h[i-k]));
    }
  }
  
  std::cerr << "Answer:" << std::endl;
  std::cout << min_cost[N-1] << std::endl;
  
  return 0;
}


Measured memory_bytes: 2548
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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
main(void){  
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int n;
  string s;

  cin >> s;

  int val = stoi(s);

  
  
  int s0 = val/1000;
  int s1 = (val%1000)/100;
  
  bool prev = false, suff= false;
  
  if(1 <= s0*10+s1 && s0*10+s1 <= 12){
    prev = true;
  }

  int s2 = (val%100)/10;
  int s3 = (val%10);

  cerr << s0 << " " << s1 << " " << s2 << " " << s3 << endl;
  
  if(1 <= s2*10+s3 && s2*10+s3 <= 12){
    suff = true;
  }  

  if(prev && suff) cout << "AMBIGUOUS" << endl;
  else if(prev && !suff) cout << "MMYY" << endl;
  else if(!prev && suff) cout << "YYMM" << endl;
  else cout << "NA" << endl;
  
  return 0;
}


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

long long n, a, b, ans = 0;
int main() {
	cin >> n;
  	cin >> a;
  	for(int i = 0; i < n - 1; i++) {
    	cin >> b;
      	if(b < a) ans += a - b, b = a;
      	a = b;
    }
  	cout << ans;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, m, a;
    cin>>n;
    if(n%2!=0){
        a=n/2+1;
        cout<<a;
    }
    else
    {
        a=n/2;
        cout<<a;
    }

}


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

int main() {
  int a, b, c, d;
  
  cin >> a >> b >> c >> d;
  
  if (a + b > c + d){
  	cout << "Left" << endl;
  }
  
  else if (a + b == c + d) {
    cout << "Balanced" << endl;
  }
  
  else if (a + b < c + d) {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
n = int(raw_input())

point = [0, 0]
for i in range(n):
    word = map(str, raw_input().split())
    if word[0] == word[1]:
        point[0] += 1
        point[1] += 1
    elif len(word[0]) >= len(word[1]):
        for j in range(len(word[1])):
            if word[0][j] == word[1][j]:
                if j == len(word[1])-1:
                    point[0] += 3
                continue
            elif word[0][j] > word[1][j]:
                point[0] += 3
                break
            else:
                point[1] += 3
                break
    else:
        for j in range(len(word[0])):
            if word[0][j] == word[1][j]:
                if j == len(word[0])-1:
                    point[1] += 3
                continue
            elif word[0][j] > word[1][j]:
                point[0] += 3
                break
            else:
                point[1] += 3
                break
print "%d %d" % (point[0], point[1])

Measured memory_bytes: 6448
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string s;cin>>s;
    string t;cin>>t;
    int t_l=t.size();
    int s_l=s.size();
    int c=-1;
    for(int i=s_l-1;i>t_l-2;i--){
        int idx=t_l-1;
        for(int j=i;j>i-t_l;j--){
            if(t[idx]==s[j] or s[j]=='?') idx--;
            else break;
            if(j==i-t_l+1) c=i-t_l+1;
        }
        if(c!=-1) break;
    }
    int idx=0;
    if(c==-1) cout<<"UNRESTORABLE"<<endl;
    else{
        for(int i=0;i<s_l;i++){
            if(c<=i and i<=c+t_l-1){
                cout<<t[idx];
                idx++;
            }
            else if(s[i]=='?') cout<<'a';
            else cout<<s[i];
        }
        cout<<endl;
    }   
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int MOD = 1e9 + 7;
int main(){
    long long N;
    cin >> N;
    vector<long long> T(N), A(N);
    for(int i = 0; i < N; i++) cin >> T[i];
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 1; i < N; i++){
        if(T[i] > T[i - 1] && T[i] > A[i]){
            cout << 0 << endl;
            return 0;
        }
        if(A[N - i] < A[N - 1 - i] && A[N - 1 - i] > T[N - 1 - i]){
            cout << 0 << endl;
            return 0;
        }
    }
    if(T[N - 1] != A[0]){
        cout << 0 << endl;
        return 0;
    }
    long long ans = 1;
    for(int i = 1; i <= N - 1 - i; i++){
        if(i == N - 1 - i) {
            if(T[i] == T[i - 1] && A[N - 1 - i] == A[N - i]) ans = ans*min(T[i], A[i]) % MOD;
        }
        else{
            if(T[i] == T[i - 1] && A[i] == A[i + 1])ans = ans * min(T[i], A[i]) % MOD;
            if(T[N - 1 - i] == T[N - 2 - i] && A[N - 1 - i] == A[N - i]) ans = ans * min(T[N - 1 - i], A[N - 1 - i]) % MOD;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4824
'use strict'
function main(inp) {
  let maney = inp*1;
  let ans = 0;
  if(maney >= 500){
  	ans += Math.floor(maney / 500)*1000;
    maney = maney%500;
  }
  if(maney >= 5){
    ans += Math.floor(maney / 5)*5;
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
n, k = map(int, input().split())
a = [i-1 for i in map(int, input().split())]

left, right = 0, 10**9
while left < right:
    middle = (left+right)//2
    if middle==0:
        left=1
        break
    count = 0
    for i in a:
        count += i//middle
    
    if count <= k:
        right = middle
    else:
        left = middle + 1

print(left)

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

using namespace std;
typedef long long ll;

// 75 = (2+1) * (4+1) * (4+1)
// 75 = (2+1) * (24+1)
// 75 = (4+1) * (14+1)
// 75 = (74+1)

ll num(vector<ll> table, ll n) {
  ll res = 0;
  for (ll num : table) {
    if (num >= n-1) res += 1;
  }
  return res;
}

int main() {
  ll N;
  cin >> N;
  vector<ll> counts(N+1);
  for (ll i=2; i <= N; ++i) {
    ll cur = i;
    for (ll j=2; j <= i; ++j) {
      while(cur % j == 0) {
        counts[j] += 1;
        cur /= j;
      }
    }
  }
  cout << (
    num(counts, 75) +
    num(counts, 25) * (num(counts, 3)-1) +
    num(counts, 15) * (num(counts, 5)-1) +
    (num(counts, 5) * (num(counts, 5)-1) * (num(counts, 3)-2))/2
    ) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;

    for(int i = 0; i < n; ++i){
        cout << s[i] << t[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N;
  cin>>N;
  string tmp = to_string(N);
  int X = 0;
  for(int i=0;i<tmp.size();++i) {
    X += tmp[i]-'0';
  }
  if(N%X==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)
#define l_ength size

ll sq(ll x){
	return x*x;
}

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

bool isvowel(char c){
	int i;
	string v="aeiou";
	for(i = (v.size()-1); i>=0; --i){
		if(c == v[i]){
			return true;
		}
	}
	return false;
}

ll manhattan(ll x1, ll y1, ll x2, ll y2){
	return ((ll)(abs(x1-x2)+abs(y1-y2)));
}

ll digit(ll x){
	ll ans = 0ll;
	if(!x){
		return 0ll;
	}
	while(x>0){
		ans++;
		x /= 10;
	}
	return ans;
}

ll f(ll a, ll b){
	return max(digit(a),digit(b));
}

char ltou(char c){
	c -= 'a';
	c += 'A';
	return c;
}

int lcm(int a, int b){
	if(a<b){
		return lcm(b,a);
	}
	return ((a%b)?(lcm(b,a%b)):(b));
}

int main(void){
	int n,i;
	ll t,ans,prev,now;
	cin >> n >> t;
	ans = t;
	cin >> prev;
	for(i=1; i<n; ++i){
		cin >> now;
		ans += min(t,now-prev);
		prev = now;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256