akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (a) ;i < (b) ;i++)
#define repr(i, a, b) for (int i = (b) - 1 ;i >= a ;i--) 
int main(){
	long ww = 1000000007 ;
	long ans = 1 ;

	int N ;
	vector <int> T, A ;
	int tmp ;
	cin>>N ;
	for (int i = 0 ;i < N ;i++){
		cin>>tmp ;
		T.push_back(tmp) ;
	}
	for (int i = 0 ;i < N ;i++){
		cin>>tmp ;
		A.push_back(tmp) ;
	}
	vector <int> tt = T ;
	vector <int> aa = A ;

	if(T[N - 1] != A[0])
		ans = 0 ;

	for (int i = N - 1 ;i > 0 ;i--)
		if(T[i] != T[i - 1]){
			tt[i] = 1 ;
			if (T[i] > A[i])ans = 0 ;
		}
	
	for (int i = 0 ;i < N - 1 ;i++)
		if(A[i] != A[i + 1]){
			aa[i] = 1 ;
			if (A[i] > T[i])ans = 0 ;
		}
	tt[0] = 1 ;aa[N - 1] = 1 ;

	for (int i = 0 ;i < N ;i++)
		ans = (long(ans) * long(min(aa[i], tt[i]))) % ww ;


//	for (int i = 0 ;i < N ;i++)cout<<T[i]<<' ' ;cout<<endl ;
//	for (int i = 0 ;i < N ;i++)cout<<A[i]<<' ' ;cout<<endl ;

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


Measured memory_bytes: 1912
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define ins insert
#define sz(x) (long long)x.size()
typedef long long ll;
typedef long double ld;
const int N = 1e5 + 5;
const ld pi = 3.141592653;
const ll MOD = 1e9 + 7;
const ll mod = 998244353;
const ll INF = __LONG_LONG_MAX__;

using namespace std;

int dx[9]={1, -1, 0, 0, 1, 1, -1, -1, 0};
int dy[9]={0, 0, 1, -1, 1, -1, 1, -1, 0};

int main()
{
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int T = 1;
        //cin>>T;
        while(T--)
        {
                int n, k, t;
                cin>>n>>k>>t;
                if(n%k==0) cout<< (n/k) * t;
                else cout<< (n/k + 1)*t;
        }
        return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<int, int> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };


int main() {

	int w, a, b;
	cin >> w >> a >> b;

	if (b > a) {

		int ans = b - (w + a);
		if (ans > 0) {
			cout << ans << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
	else {
		int ans = a - (w + b);
		if (ans > 0) {
			cout << ans << endl;
		}
		else {
			cout << 0 << endl;
		}
	}

	
	return 0;
}

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

constexpr int MOD = 1'000'000'007; //'
constexpr int MAX = 1100;
constexpr int dh[8] = {0, 1, 0, -1, -1, 1, 1, -1};
constexpr int dw[8] = {1, 0, -1, 0, 1, 1, -1, -1};

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; i++) {
        cin >> s[i];
    }
    
    int dp[MAX][MAX] = {};
    dp[0][0] = 1;
    vector<vector<bool>> seen(h, vector<bool>(w, false));
    
    queue<pair<int, int>> que;
    que.emplace(0, 0);
    
    while (not que.empty()) {
        int i, j;
        tie(i, j) = que.front();
        que.pop();
        if (seen[i][j]) continue;
        seen[i][j] = true;
        for (int k = 0; k < 2; k++) {
            int di = i + dh[k], dj = j + dw[k];
            if (h <= di or w <= dj) continue;
            if (s[di][dj] == '#') continue;
            dp[di][dj] += dp[i][j];
            dp[di][dj] %= MOD;
            que.emplace(di, dj);
        }
    }
    
    
    cout << dp[h-1][w-1] << '\n';
    return 0;
}

Measured memory_bytes: 6272
#include <iostream>
#include <vector>

using namespace std;

struct UnionFind {
    vector< int > data;

    UnionFind(int sz) {
        data.assign(sz, -1);
    }

    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return (false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    int find(int k) {
        if(data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }

    int size(int k) {
        return (-data[find(k)]);
    }
};

int main(void) {
    int N, M;
    cin >> N >> M;
    UnionFind uf(N);

    int ans = N - M;
    while(M--) {
        int X, Y, Z;
        cin >> X >> Y >> Z;
        --X; --Y;
        if(!uf.unite(X, Y)) ++ans;
    }

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


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <stdio.h>

using namespace std;

#define MAX 100005
#define NIL -1

typedef struct Node{int p, r, l, degree, depth, height;}Node;

Node T[MAX];
int n;

int cir_sibling(int u){
    if(T[u].p == NIL)return -1;
    if(T[T[u].p].l == u)return T[T[u].p].r;
    else return T[T[u].p].l;
}

void print(int u){
    cout << "node ";
    cout << u;
    cout << ": parent = ";
    cout << T[u].p;
    cout << ", sibling = ";
    cout << cir_sibling(u);
    cout << ", degree = ";
    cout << T[u].degree;
    cout << ", depth = ";
    cout << T[u].depth;
    cout << ", height = ";
    cout << T[u].height;
    cout << ", ";
    if(T[u].p == NIL)cout << "root";
    else if(T[u].l == NIL && T[u].r == NIL)cout << "leaf";
    else cout << "internal node";
    cout << endl;
}

void cir_degree(int u){
    int cnt = 0;
    if(T[u].r != NIL)cnt++;
    if(T[u].l != NIL)cnt++;
    T[u].degree = cnt;
}

void cir_depth(int u, int p){
    // first of u defines root
    T[u].depth = p;
    if(T[u].l != NIL)cir_depth(T[u].l, p+1);
    if(T[u].r != NIL)cir_depth(T[u].r, p+1);
}

void cir_height(int u, int p){
    if(T[u].height<p)
        T[u].height = p;
    if(T[u].p != NIL)cir_height(T[u].p, p+1);
}

int main(int argc, const char * argv[]) {
    // insert code here...
    
    
    /////////
    //write//
    /////////
    
    // for input
    int tnode, tright, tleft;
    cin >> n;
    int root_val = 0;
    
    for(int i=0; i<n; i++)T[i].p = T[i].l = T[i].r = T[i].degree = T[i].depth = T[i].height = NIL;
    
    for(int i=0; i<n; i++){
        cin >> tnode >> tleft >> tright;
        T[tnode].l = tleft;
        T[tnode].r = tright;
        T[tleft].p = tnode;
        T[tright].p = tnode;
    }
    
    for(int i=0; i<n; i++){
        if(T[i].p == NIL)root_val = i;
        cir_degree(i);
        cir_height(i, 0);
    }
    
    cir_depth(root_val, 0);
    
    for(int i=0; i<n; i++){
        print(i);
    }
    
    return 0;
}



Measured memory_bytes: 3088
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<vector<int> > s(n, vector<int>(3));
        for(int i=0; i<n; ++i){
            for(int j=0; j<3; ++j){
                cin >> s[i][j];
            }
            sort(s[i].begin(), s[i].end());
        }

        multimap<int, int> mm;
        for(int i=0; i<n; ++i){
            do{
                for(int j=0; j<60; ++j){
                    int hour = (s[i][0] + j) % 60;
                    int min = (s[i][1] + j) % 60;
                    int sec = (s[i][2] + j) % 60;
                    if(hour % 5 != min / 12)
                        continue;
                    int k = (hour / 5 * 60 + min) * 60 + sec;
                    mm.insert(make_pair(k, i));
                }
            }while(next_permutation(s[i].begin(), s[i].end()));
        }

        vector<int> m(n, 0);
        int numZero = n;
        multimap<int, int>::iterator it1, it2;
        it1 = it2 = mm.begin();
        int ret = -1;
        int len = INT_MAX;
        int curr;
        while(it2 != mm.end()){
            while(it2 != mm.end() && numZero != 0){
                curr = it2->first;
                if(m[it2->second] == 0)
                    -- numZero;
                ++ m[it2->second];
                ++ it2;
            }

            while(numZero == 0){
                if(curr - it1->first < len){
                    len = curr - it1->first;
                    ret = it1->first;
                }
                if(it2 == mm.end())
                    break;
                if(m[it1->second] == 1)
                    ++ numZero;
                -- m[it1->second];
                ++ it1;
            }
        }

        for(int i=0; i<2; ++i){
            int sec = (ret + i*len) % 60;
            int min = (ret + i*len) / 60 % 60;
            int hour = (ret + i*len) / (60 * 12);
            ostringstream oss;
            oss << setfill('0');
            oss << setw(2) << (hour/5) << ':' << setw(2) << min << ':' << setw(2) << sec;
            cout << oss.str();
            if(i == 0)
                cout << ' ';
        }
        cout << endl;
    }
}

Measured memory_bytes: 0
#include <stdio.h>

int search(int A[], int n, int key){
    int i =0;
    A[n] = key;
    while (A[i] != key) i++;
    return i != n;
}

int main(){
    int i, n,A[10000+1],q,key, sum =0;
    
    scanf("%d",&n);
    for (i =0; i<n ; i++) scanf("%d", &A[i]);
    
    scanf("%d",&q);
    for(i=0; i<q; i++) {
        scanf("%d",&key);
        if(search(A, n, key)) sum++ ;
    }
    printf("%d\n",sum);

    return 0;
}


Measured memory_bytes: 2136
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;

struct Edge{int to,from,cost;};

#ifdef DEBUGLOCAL
#define debug cout
#else
stringstream __ss__;
#define debug __ss__
#endif

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) debug << *i << " "; debug << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;i--)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repnd(i,m,n) for(int i=(n)-1;i>=(m);i--)
#define rep0(i,n) for(i=0;i<(n);++i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define SS stringstream
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

const int dx[]={1,-1,0,0,1,-1,1,-1,0};
const int dy[]={0,0,1,-1,1,-1,-1,1,0};

double point[50][3];

double eq(double a,double b){
	return fabs(a-b)<=fabs(a)*0.0005;
}

double dis(int a,int b){
	return sqrt((point[a][0]-point[b][0])*(point[a][0]-point[b][0])+(point[a][1]-point[b][1])*(point[a][1]-point[b][1])+(point[a][2]-point[b][2])*(point[a][2]-point[b][2]));
}

int main() {
	int n=in();
	while(n--){
		double p,q,r;
		int m;
		cin>>p>>q>>r>>m;
		rep(i,m){
			cin>>point[i][0]>>point[i][1]>>point[i][2];
		}
		rep(i,m)rep(j,m)if(i!=j)rep(k,m)if(i!=k)if(j!=k){
			if(eq(dis(i,j)/p,dis(j,k)/q)&&eq(dis(i,j)/p,dis(k,i)/r))cout<<k+1<<" "<<i+1<<" "<<j+1<<endl;
		}
	}
	return 0;
}

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

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

    int n;
    cin >> n;
    vector<int> a(n);
    int mx = -1;
    rep(i, n){
        cin >> a[i];
        mx = max(mx, a[i]);
    }

    vector<int> b(mx+10, 0);
    rep(i, n){
        int d = a[i];
        for(int j = d; j < mx+10; j += d) ++b[j];
    }

    int res = 0;
    rep(i, n){
        if(b[a[i]] == 1) ++res;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 7956
# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
# define int long long
  
using namespace std;
  
const int N = 1e5 + 7;
const int INF = 1e18;
const int mod = 1e9 + 7; 

int R[N], G[N], B[N], n;

string s;

int check( int k, char c ) {

	if ( k >= n ) {
		return 0;
	}
	return ( s[k] == c );
}
  
int32_t main() {
    speed;
	cin >> n;
	cin >> s;

	for ( int i = n - 1; i >= 0; i-- ) {

		R[i] += R[i + 1];
		G[i] += G[i + 1];
		B[i] += B[i + 1];
		
		if ( s[i] == 'R' ) {
			R[i]++;
		}
		if ( s[i] == 'G' ) {
			G[i]++;
		}
		if ( s[i] == 'B' ) {
			B[i]++;
		}
	}
	int ans = 0;

	for ( int i = 0; i < n; i++ ) {
		for ( int j = i + 1; j < n; j++ ) {

			
			if ( s[i] == s[j] ) {
				continue;
			}
			int d = j - i;
			int k = j + d;

			if ( j + 1 >= n ) {
				continue;
			}
			if ( s[i] == 'R' && s[j] == 'G' ) {
				ans += B[j + 1];

				ans -= check( k, 'B' );
			}
			if ( s[i] == 'R' && s[j] == 'B' ) {
				ans += G[j + 1];

				ans -=  check( k, 'G' );
			}
			if ( s[i] == 'G' && s[j] == 'R' ) {
				ans += B[j + 1];

				ans -= check( k, 'B' );
			}
			if ( s[i] == 'G' && s[j] == 'B' ) {
				ans += R[j + 1];

				ans -= check( k, 'R' );
			}
			if ( s[i] == 'B' && s[j] == 'R' ) {
				ans += G[j + 1];

				ans -= check( k, 'G' );
			}
			if ( s[i] == 'B' && s[j] == 'G' ) {
				ans += R[j + 1];

				ans -= check( k, 'R' );
			}
			// for ( int k = j + 1; k < n; k++ ) {

			// 	if ( j - i == k - j || s[i] == s[j] || s[i] == s[k] || s[j] == s[k] ) {
			// 		continue;
			// 	}
			// 	ans++;
			// }
		}
	}
	cout << ans;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll, ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define pdd pair<double, double>
#define f first
#define s second
#define MOD 1000000007
#define mkp make_pair
#define M_PI 3.14159265358979323846
#define FOR(i,l,r) for (int i=l;i<=r;i++)
#define LOR(i,l,r) for (ll i=l;i<=r;i++)
#define FORD(i,r,l) for (int i=r;i>=l;i--)
#define LORD(i,r,l) for (ll i=r;i>=l;i--)
#define INF 1000000000
#define CL(x) memset(x,0,sizeof(x))
#define DEB(x) cout << #x << " : " << x << '\n'
#define ALL(x) x.begin(), x.end()
#define SZ(x) x.size()
#define UI(x) (int)(x-'A')
#define LI(x) (int)(x-'a')
typedef long long ll;

#define MXN 100005
int N,A[MXN];
int ans;
multiset<int> S;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>N;
    FOR(i,1,N)cin>>A[i];
    FOR(i,1,N)
    {
        if( S.empty() || S.lower_bound(A[i])==S.begin() )
        {
            ans++;
            S.insert(A[i]);
        }
        else
        {
            S.erase( --S.lower_bound(A[i]) );
            S.insert(A[i]);
        }
    }
    cout<<ans<<'\n';

    return 0;
}

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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec g(nmax);





void solve4ts()
{
    
    string s;
    cin>>s;
    if(s=="ABC") cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
    
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

Measured memory_bytes: 7820
#include <bits/stdc++.h>
#define pct puts("zyw ---> dsb");
#define rep(a, b, c) for(int a = (b); a <= (c); ++ a)
#define per(a, b, c) for(int a = (b); a >= (c); -- a)
using namespace std;
template <class T> void rd(T &x){
  x = 0; int f = 1; char ch = getchar();
  while(ch < '0' || ch > '9'){ if(ch == '-') f = -1; ch = getchar(); }
  while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  x *= f;
}

#define eps 1e-8

typedef long long ll;
const int maxn = 3e5 + 5;
int n, m;
ll f[maxn], g[maxn], h[maxn];
ll t[maxn];
ll sum[maxn];
int st[maxn], top;

int sgn(double x){ return x < -eps ? -1 : x > eps; }

namespace part1{
  ll cal[maxn];

  double slope(int x, int y){ return (double) (cal[y] - cal[x]) / (y - x); }

  void sol(ll *f){
	rep(i, 1, n) sum[i] = sum[i - 1] + t[i];
	f[0] = 0;
	st[top = 1] = 0;
	rep(i, 1, n){
	  int l = 1, r = top;
	  while(l < r){
		int mid = l + r >> 1;
		if(sgn(i - slope(st[mid], st[mid + 1])) >= 0) r = mid;
		else l = mid + 1;
	  }
	  f[i] = max(f[i - 1], cal[st[l]] - (ll) i * st[l] - sum[i] + ((ll) i * i + i) / 2);
	  cal[i] = f[i] + ((ll) i * i - i) / 2 + sum[i];
	  while(top > 1 && sgn(slope(st[top - 1], st[top]) - slope(st[top], i)) <= 0) top --;
	  st[++ top] = i;
	}
  }

  void sol(){
	sol(f);
	reverse(t + 1, t + n + 1);
	sol(g);
	reverse(t + 1, t + n + 1);
	reverse(g + 1, g + n + 1);
  }
}

namespace part2{
  ll cal[maxn], tmp[maxn];

  double slope(int x, int y){ return (double) (cal[y] - cal[x]) / (y - x); }

  void divide(int l, int r){
	if(l == r) return ;
	int mid = l + r >> 1;
	divide(l, mid), divide(mid + 1, r);
	rep(i, l, mid) cal[i] = f[i - 1] + sum[i - 1] + ((ll) (i - 1) * (i - 1) - i + 1) / 2;
	rep(i, mid + 1, r) cal[i] = g[i + 1] - sum[i] + ((ll) i * i + i) / 2;
	top = 0;
	rep(i, l, mid){
	  while(top > 1 && sgn(slope(st[top - 1], st[top]) - slope(st[top - 1], i)) <= 0) top --;
	  st[++ top] = i;
	}
	rep(i, mid + 1, r){
	  while(top > 1 && sgn(i - slope(st[top - 1], st[top])) >= 0) top --;
	  tmp[i] = cal[st[top]] - (ll) (st[top] - 1) * i + cal[i];
	}
	per(i, r - 1, mid + 1) tmp[i] = max(tmp[i], tmp[i + 1]);
	rep(i, mid + 1, r) h[i] = max(h[i], tmp[i]);
	top = 0;
	rep(i, mid + 1, r){
	  while(top > 1 && sgn(slope(st[top - 1], st[top]) - slope(st[top - 1], i)) <= 0) top --;
	  st[++ top] = i;
	}
	rep(i, l, mid){
	  while(top > 1 && sgn(i - slope(st[top - 1], st[top])) >= 0) top --;
	  tmp[i] = cal[st[top]] - (ll) st[top] * (i - 1) + cal[i];
	}
	rep(i, l + 1, mid) tmp[i] = max(tmp[i], tmp[i - 1]);
	rep(i, l, mid) h[i] = max(h[i], tmp[i]);
  }
  
  void sol(){
	rep(i, 1, n) sum[i] = sum[i - 1] + t[i];
	divide(1, n);
  }
}

int main(){
  memset(h, -0x3f, sizeof(h));
  rd(n);
  rep(i, 1, n) rd(t[i]);
  part1 :: sol();
  part2 :: sol();
  rd(m);
  while(m --){
	int i, v; rd(i), rd(v);
	printf("%lld\n", max(f[i - 1] + g[i + 1], h[i] + t[i] - v));
  }
  return 0;
}
/*
5
1 1 4 1 1
2
3 2
3 10
*/


Measured memory_bytes: 22528
n = int(input())

l = []
while True:
    if n%26 == 0:
        l.append(26)
        n = n//26 - 1
    else:
        l.append(n % 26)
        n //= 26
    if n == 0:
        break
    
ans = []
for v in l:
    ans.append(chr(v + 96))

print("".join(ans[::-1]))

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


int main(){
	int n;
	cin >> n;
	std::vector<int> v(n);
	for(int i=0;i<n;i++){
		cin >> v[i];
	}
	int sum = accumulate(v.begin() , v.end() , 0);
	int ans = 0;
	for(int i=0;i<n;i++){
		ans += v[i]*(sum-v[i]);
	}
	cout << ans/2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>


int main(){

    char a[5];

    scanf("%s", &a);

    int ans = 0;

    if( a[0] == '1' ) ans++;
    if( a[1] == '1' ) ans++;
    if( a[2] == '1' ) ans++;
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;

// N, E, S, W
const int dx[4] = {-1, 0,  1,  0};
const int dy[4] = { 0, 1,  0, -1};

map<char, int> mpdir = {
    {'U', 0}, {'R', 1}, {'D', 2}, {'L', 3}
};

int W, H, N;
int e[501][501][2]; // e[x][y][d] (d = 0: down, d = 1: right)

inline bool inside(int x, int y, int R, int C) {
    return 0 <= x && x < R && 0 <= y && y < C;
}

void add(int x, int y, int k) {
    if (k == 1 || k == 2) {
        x += dx[k], y += dy[k];
    }
    ++e[x][y][(k % 2) ^ 1];
}

void move(int& x, int& y, int k) {
    // people can move in 0 <= x < H, 0 <= y < W
    if (inside(x + dx[k], y + dy[k], H, W)) {
        add(x, y, k);
        x += dx[k], y += dy[k];
    }
}

void update() {
    int x, y;
    cin >> y >> x;
    int T;
    cin >> T;
    string s;
    cin >> s;
    rep(t, T) {
        rep(i, s.size()) {
            move(x, y, mpdir[s[i]]);
        }
    }
}

int getCost(int x, int y, int k) {
    if (k == 0 || k == 3) {
        x += dx[k], y += dy[k];
    }
    return e[x][y][k % 2];
}

int dijkstra(int sx, int sy, int gx, int gy) {
    priority_queue<TUPLE, vector<TUPLE>, greater<TUPLE>> pq;   // cost, x, y
    VV d(H + 1, V(W + 1, inf));
    d[sx][sy] = 0;
    pq.push(TUPLE(0, sx, sy));

    while (!pq.empty()) {
        int c, x, y;
        tie(c, x, y) = pq.top(); pq.pop();
        if (x == gx && y == gy) break;
        if (d[x][y] < c) continue;

        rep(k, 4) {
            int nx = x + dx[k], ny = y + dy[k];
            // !!! cable can move in 0 <= x < H + 1, 0 <= y < W + 1 !!!
            if (!inside(nx, ny, H + 1, W + 1)) continue;
            int nc = c + getCost(x, y, k);
            if (d[nx][ny] > nc) {
                d[nx][ny] = nc;
                pq.push(TUPLE(nc, nx, ny));
            }
        }
    }
    return d[gx][gy];
}

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

    cin >> W >> H >> N;
    int cable_sx, cable_sy, cable_gx, cable_gy;
    cin >> cable_sy >> cable_sx >> cable_gy >> cable_gx;
    rep(i, N) {
        update();
    }

    cout << dijkstra(cable_sx, cable_sy, cable_gx, cable_gy) << endl;

}

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

template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
typedef long long ll;
typedef unsigned int ui;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)

int a[3][105],dp[3][105];

int main()
{
	//freopen("1.in","r",stdin);
	int	n; 
	cin>>n;
	rep(j,1,2)
	rep(i,1,n)cin>>a[j][i];
	rep(j,1,2)
	rep(i,1,n)dp[j][i]=max(dp[j][i-1],dp[j-1][i])+a[j][i];
	cout<<dp[2][n];
}


Measured memory_bytes: 3672
h, w = map(int, input().split())
T = [[] for i in range(h)]
for i in range(h):
    a = list(input())
    T[i] = a

# for i in range(h):
#     print("".join(map(str, T[i])))

flag = True
for i in range(h):
    for j in range(w):
        if T[i][j] == "#":
            flag2 = False
            for dx, dy in [(0, 1), (1, 0), (-1, 0), (0, -1)]:
                nx, ny = i + dx, j + dy

                if 0 <= nx < h and 0 <= ny < w and T[nx][ny] == "#":
                    flag2 = True

            if not flag2:
                flag = False

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



Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

ll high(vector<int> table) {
    sort(table.begin(), table.end(), greater<int>());
    ll ret = 0;
    ll multi = 10000000;
    for(int r = 0; r < table.size(); r++) {
        ret += table[r] * multi; multi /= 10;
    }
    return(ret);
}

ll low(vector<int> table) {
    sort(table.begin(), table.end());
    ll ret = 0;
    ll multi = 10000000;
    for(int r = 0; r < table.size(); r++) {
        ret += table[r] * multi; multi /= 10;
    }
    return(ret);
}

int main(void) {
    int num; cin >> num;
    string input;
    for(int r = 0; r < num; r++) {
        cin >> input;
        vector<int> table;
        for(int c = 0; c < input.length(); c++) table.push_back(input[c] - '0');
        
        cout << (high(table) - low(table)) << endl;
    }
    return(0);
}

Measured memory_bytes: 1220
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
namespace AtCoder_Beginner_Contest_127
{
    class Program
    {
        static public int[] SIn() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static void Main(string[] args)
        {
            var AB = SIn();
            var A = AB[0];
            var B = AB[1];
            if (13 <= A) WriteLine(B);
            else if (6 <= A) WriteLine(B / 2);
            else WriteLine(0);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}


ll dp[105][100009];

void test_case() {

    int n;
  ll w;
  cin >> n >> w;
  vector<ll> wight(n);
  vector<ll> val(n);
  rep(i,n){
    cin >> wight[i] >> val[i];
  }
  rep(i,n+1) rep(j,100001) dp[i][j] = INF;
  dp[0][0] = 0;
 
  for (int i = 0;i < n;i++){
    for (int j = 0;j <= 100000;j++){
      if (j-val[i] >= 0) dp[i+1][j] = min(dp[i][j],dp[i][j-val[i]] + wight[i]); 
      else dp[i+1][j] = dp[i][j]; 
    }
  }
  ll ans = 0;
  for (ll g = 0; g <= 100000;g++){
    if (dp[n][g] <= w) ans = max(g,ans);
  }
  cout << ans << endl;


}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


    int t = 1;
    //cin >> t;
    while(t--)
    {   
        test_case();
    }
}


Measured memory_bytes: 82540
n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))
a.append(0)
x=[]
t=a[0]
c=1
for i in range(1,n+1):
  if a[i]!=t:
    x.append(c)
    c=1
    t=a[i]
  else:
    c+=1
x.sort()
z=0
for i in range(len(x)-k):
  z+=x[i]
print(z)

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

int main(){
  vector<vector<int>> cmp(3,vector<int>(3));
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      cin >> cmp.at(i).at(j);
  if(cmp.at(0).at(0)+cmp.at(1).at(1)==cmp.at(0).at(1)+cmp.at(1).at(0)
  && cmp.at(0).at(0)+cmp.at(2).at(2)==cmp.at(0).at(2)+cmp.at(2).at(0)
  && cmp.at(1).at(1)+cmp.at(2).at(2)==cmp.at(1).at(2)+cmp.at(2).at(1))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int INF = 0x3f3f3f3f;;
vector<int> h(1e5 + 10);
vector<int> dp(1e5 + 10, INF);


int dfs(int j) {
    if (j <= 0) return 0;
    if (j == 1) {
      return abs(h[1] - h[0]);  
    }
    if (j == 2) {
      return abs(h[2] - h[0]);  
    }
    if (dp[j] != INF) return dp[j];
    
    dp[j] = min(abs(h[j] - h[j-1]) + dfs(j-1), abs(h[j] - h[j-2]) + dfs(j-2));
    return dp[j];
}
int main() {
    int n;
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    
    
    cout << dfs(n-1) << '\n';
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> A(N);
    priority_queue<int> q;
    REP(i,N) cin >> A[i].first >> A[i].second;
    sort(A.begin(), A.end());

    ll ans = 0;
    int idx = 0;
    for(int i=M-1;i>=0;i--){
        while(idx < N){
            if(i + A[idx].first <= M){
                q.push(A[idx].second);
                idx++;
            }
            else break;
        }
        if(!q.empty()){
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            HashSet<int> types = new HashSet<int>();
            for (int i = 0; i < n; i++)
            {
                var d = int.Parse(Console.ReadLine());
                types.Add(d);
            }

            Console.WriteLine(types.Count());
        }
    }
}


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

#define SWAP(T,X,Y) {const T gensym1 = X; X = Y; Y = gensym1;}

int main(void) {
  unsigned long long int n, x;
  unsigned long long int res;

  scanf("%llu%llu", &n, &x);

  res = n;
  n = n - x;
  for (;;) {
    if (n % x == 0) {
      res += 2 * n - x;
      break ;
    } else {
      res += x * 2 * (n / x);
      n %= x;
      SWAP(unsigned long long int, n, x);
    }
  }
  printf("%llu\n", res);
  
  return (0);
}


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

int main() {
	// your code goes here
	int a, b ,c , cnt = 0;
	
	cin >> a >> b >> c;
	
	for(int x = a; x <= b; x++ ){
		if (c % x ==0){
			cnt = cnt + 1;
		}
	}
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 3096
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[] A = new int[N];
        for (int i = 0; i < N; ++i) {
            A[i] = sc.nextInt();
        }
        sc.close();

        Arrays.sort(A);
        int ans = 0;
        for (int i = 0; i < N; ++i) {
            if(X >= A[i]){
                ++ans;
                X -= A[i];
            }
        }
        if (ans == N && X > 0) {
            --ans;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 21972
#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>;
static const long long INF = 100000000;

ll pow(int n){
    if (n == 0){
        return 1;
    }
    else {
        ll k = 1;
        rep(i,n){
            k = 2*k + 1;
        }
        return k;
    }
}
int main(){
    ll c = 0;
    ll h;
    cin >> h;
    while (h != 1){
        h = h/2;
        c++;
    }
    cout << pow(c) << endl;
}


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

int main(){
    int n;
    cin >> n;
    int a[n], x[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        x[i] = a[i];
    }
    sort(x, x + n);
    int m1 = x[n / 2], m2 = x[(n - 1) / 2];
    for(int i = 0; i < n; i++){
        if(m1 <= a[i]) cout << m2 << endl;
        else cout << m1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
string s,t;
vector<vector<int > >memo(3000,vector<int >(3000,-1));
vector<vector<int > >x(3000,vector<int >(3000,-1));
vector<vector<int > >y(3000,vector<int >(3000,-1));

int calc(int i,int j){
    if(i==s.size() || j==t.size())return 0;
    if(memo[i][j]!=-1)return memo[i][j];
    else{
        int maxi=0;
        
        if(s[i]==t[j]){maxi=max(maxi,1+calc(i+1,j+1));x[i][j]=i+1;y[i][j]=j+1;}
        else{
            int max1,max2;
            max1 = calc(i+1,j);
            max2 = calc(i,j+1);
            if(max1>max2){x[i][j]=i+1;y[i][j]=j;}
            else {x[i][j] = i;y[i][j]=j+1;}
            maxi = max(max1,max2);
        }
        memo[i][j] = maxi;
        return maxi;
        
        
        
    }
}
int main(){
    cin>>s>>t;
    int len = calc(0,0);
   int startx=0,starty=0,newx,newy;
    while(startx!=s.size() && starty!=t.size()){
        //cout<<startx<<' '<<starty<<'\n';
        //pointed to by the 
        if(startx==-1 || starty==-1){cout<<"-1 found\n";break;}
        newx = x[startx][starty];
        newy = y[startx][starty];
        if(newx==startx+1 && newy == starty+1){
            cout<<s[startx];
        }
        startx = newx;
        starty = newy;
    }
    
}


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

int main(){
  long long int a,b;
  cin >> a >> b;
  vector<long long int> primes;
  for(long long int i=2;i*i<=a;i++){
    if(a%i==0){
      primes.push_back(i);
      while(a%i==0){
        a=a/i;
      }
    }
  }
  if(a!=1){
    primes.push_back(a);
  }
  long long int cntr=0;
  for(auto i : primes){
    if(b%i==0){
      cntr++;
    }
  }
  cout << cntr+1 << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(void){
    int n,a,b;
    cin>>n>>a>>b;
    int d=b-a;
    if(d%2==0)cout<<"Alice"<<endl;
    else cout<<"Borys"<<endl;
    return 0;
}


Measured memory_bytes: 256
imput = gets.chomp.split(" ").map!{|item| item.to_i}
a = imput[0].to_f
b = imput[1].to_f
h = imput[2].to_f
m = imput[3].to_f

hang = Math::PI*(30*h + m/2)/180
mang = Math::PI*m*6/180

hy = Math.sin(hang)*a
hx = Math.cos(hang)*a
my = Math.sin(mang)*b
mx = Math.cos(mang)*b
puts Math.sqrt((hy-my)**2 + (hx-mx)**2)


Measured memory_bytes: 14720
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        
        if(N>=18){
            System.out.println("Yes");
        }else{
            if(N==17||N==13||N==10||N==9||N==6||N==5||N<=3){
                System.out.println("No");
            }else{
                System.out.println("Yes");
            }
        }
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define R cin>>
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return (x<0||x>=n||y<0||y>=m)?false:true;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
typedef pair<int,int> P;

int main() {
  int n;
  while(R n && n) {
    vector<int> a[5];
    int d[n][5];
    rep(i,n) {
      rep(j,5) R d[i][j];
    }
    rep(i,5) {
      rrep(j,n) a[i].pb(d[j][i]);
    }
    int ans=0;
    while(1) {
      bool ck=true;
      rep(i,n) {
	if(a[2][i]==0) continue;
	int cnt=1;
	for(int j=1; j>=0; j--) {
	  if(a[j][i]!=a[2][i]) break;
	  else cnt++;
	}
	for(int j=3; j<=4; j++) {
	  if(a[j][i]!=a[2][i]) break;
	  else cnt++;
	}
	if(cnt<3) continue;
	for(int j=1; j>=0; j--) {
	  if(a[j][i]!=a[2][i]) break;
	  else a[j][i]=0;
	}
	for(int j=3; j<=4; j++) {
	  if(a[j][i]!=a[2][i]) break;
	  else a[j][i]=0;
	}
	ans+=a[2][i]*cnt;
	a[2][i]=0;
	ck=false;
      }
      rep(i,5) {
	fill(remove(a[i].begin(),a[i].end(),0),a[i].end(),0);
      }
      if(ck) break;
    }
    pr(ans);
  }
  return 0;
}


Measured memory_bytes: 1216
import sys
input = sys.stdin.readline

def binary_search_int(ok, ng, test):
    """
    :param ok: solve(x) = True を必ず満たす点
    :param ng: solve(x) = False を必ず満たす点
    """
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if test(mid):
            ok = mid
        else:
            ng = mid
    return ok

def test(x):
    temp = 0
    for a in A:
        temp += (a-1)//x
    return temp <= K

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



print(binary_search_int(10**9+100,0,test))


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


#define MOD 1000000007


int main() {
    long long n; cin >> n;
    long long a[n];
    for (int i = 0; i < n; i++) cin >> a[i];

    long long ans = 0;
    for (int i = 0; i < 64; i++) {
        long long cnt1 = 0, cnt2 = 0;
        for (int j = 0; j < n; j++)
            if (a[j] & (1LL<<i)) cnt1++;
            else cnt2++;
        ans = (ans%MOD + (((cnt1*cnt2)%MOD)*((1LL<<i)%MOD)))%MOD;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 2560
//#pragma GCC optimize ("O2")
#include<bits/stdc++.h>
#include<unistd.h>
using namespace std;
//#define int long long
#define double long double
#define vec vector
#define vi vector<int>
#define FZ(n) memset((n),0,sizeof(n))
#define FMO(n) memset((n),-1,sizeof(n))
#define unset unordered_set
#define ii pair<int, int>
#define vii vector<ii>
#define F first
#define S second
#define PB push_back
#define ALL(x) begin(x),end(x)
#define SZ(x) ((int)(x).size())
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define bitcount(n) __builtin_popcountll(n)
template <typename T,typename U>
std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {
  return {l.first+r.first, l.second+r.second};
} 
typedef void (*callback_function)(void); // type for conciseness
const long long ZERO = 0LL;
const long long INF64 = 1e18;
const int INF32 = 1e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0L);
const double EPS = static_cast<double>(1e-9);
typedef long long ll;

void FILEIO() {  freopen("in.txt", "r", stdin);  freopen("out.txt", "w", stdout); }
// Init variables here
void input() {
	
}

bool goodMonth(int aa) { 
	return (aa>0 and aa <=12); 
}


void solve() {
	char c[4];
	FOR(i, 0, 4) cin >> c[i];
	int mm = ((int)(c[0]-'0'))*10 + (int)(c[1]-'0');
	int yy = ((int)(c[2]-'0'))*10 + (int)(c[3]-'0');
	
	if(!goodMonth(mm) and !goodMonth(yy)) {cout << "NA" << endl; return;}
	
	if(goodMonth(mm) and goodMonth(yy)) {cout << "AMBIGUOUS" << endl; return;}
	
	if(goodMonth(mm) and !goodMonth(yy)) {cout << "MMYY" << endl; return;}
	if(!goodMonth(mm) and goodMonth(yy)) {cout << "YYMM" << endl; return;}
	
}

//#undef int
int main() {
//#define int long long
  ios_base::sync_with_stdio(false); cin.tie();
//  FILEIO();
//auto beginProgram = chrono::steady_clock::now();

  //int t; cin >> t;
  //while (t--) 
  {
    input();
    solve();
  }

  //auto endProgram = chrono::steady_clock::now();

  return 0;
}


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

using namespace std;
typedef long long LL;

const int N=1e5+10;

bool vis[N];
int n,m,cnt,pos[N],a[N],node[N],to[N];
LL ans[N];
LL k;

void Init()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",&pos[i]);
	scanf("%d%lld",&m,&k);
	for (int i=1;i<=m;++i) scanf("%d",&a[i]);
}

void Dfs(int x)
{
	if (vis[x]) return ;
	vis[x]=1;
	node[cnt++]=x;
	Dfs(to[x]);
	
}

void Solve()
{
	for (int i=n;i>=2;--i) pos[i]-=pos[i-1];
	for (int i=1;i<=n;++i) to[i]=i;
	for (int i=1;i<=m;++i) swap(to[a[i]],to[a[i]+1]);
	
	for (int i=1;i<=n;++i)
		if (!vis[i])
		{
			cnt=0;
			Dfs(i);
			for (int j=0;j<cnt;++j)
				ans[node[j]]=pos[node[(j+k)%cnt]];
		}
	
	for (int i=2;i<=n;++i) ans[i]+=ans[i-1];
	
	for (int i=1;i<=n;++i) printf("%lld.0\n",ans[i]);
}

int main()
{
	Init();
	Solve();
	return 0;
}


Measured memory_bytes: 3840
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

using CostType = int;
struct Edge {
  int src, dst; CostType cost;
  Edge(int src, int dst, CostType cost = 0) : src(src), dst(dst), cost(cost) {}
  inline bool operator<(const Edge &x) const {
    return cost != x.cost ? cost < x.cost : dst != x.dst ? dst < x.dst : src < x.src;
  }
  inline bool operator<=(const Edge &x) const { return !(x < *this); }
  inline bool operator>(const Edge &x) const { return x < *this; }
  inline bool operator>=(const Edge &x) const { return !(*this < x); }
};

int main() {
  const int N = 20;
  int l; cin >> l;
  vector<Edge> graph;
  int now = 1;
  REP(i, N - 1) {
    graph.emplace_back(i, i + 1, 0);
    if ((1 << (i + 1)) < l) {
      graph.emplace_back(i, i + 1, 1 << i);
      now += 1 << i;
    }
  }
  for (int i = N - 2; i >= 0; --i) {
    if (now + (1 << i) - 1 < l) {
      graph.emplace_back(i, N - 1, now);
      now += 1 << i;
    }
  }
  cout << N << ' ' << graph.size() << '\n';
  for (const Edge &e : graph) cout << e.src + 1 << ' ' << e.dst + 1 << ' ' << e.cost << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
const ll mod=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> cnt(4);
    rep(i,6){
        int a; cin >> a;
        ++cnt[--a];
    }
    int c=0;
    rep(i,4) if (cnt[i]==1) ++c;
    if (c==2&&cnt[0]==1) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int n;
	int a[100000];
	int num[100000]={0};
	int num_sum[100000]={0};
	int i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++){
		num[a[i]]++;
	}
	for(i=0;i<99998;i++){
		num_sum[i] = num[i]+num[i+1]+num[i+2];
	}
	int max = 0;
	for(i=0;i<100000;i++){
		if(max < num_sum[i]){
			max = num_sum[i];
		}
	}
	printf("%d",max);
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

int ans[100001];

int main() {
  string str;
  cin >> str;

  // ->
  int num1 = 0;
  int num2 = 0;
  int startIndex = 0;
  for (int i = 0; i < str.size(); i++) {
    if (str[i] == 'R') {
      if ((i - startIndex) % 2 == 0) {
        num1++;
      } else {
        num2++;
      }
    } else {
      if ((i - startIndex) % 2 == 0) {
        ans[i] += num1;
        if (i > 0) {
          ans[i - 1] += num2;
        }
      } else {
        ans[i] += num2;
        if (i > 0) {
          ans[i - 1] += num1;
        }
      }
      num1 = 0;
      num2 = 0;
      startIndex = i + 1;
    }
  }

  // <-
  num1 = 0;
  num2 = 0;
  startIndex = str.size() - 1;
  for (int i = str.size() - 1; i >= 0; i--) {
    if (str[i] == 'L') {
      if ((startIndex - i) % 2 == 0) {
        num1++;
      } else {
        num2++;
      }
    } else {
      if ((startIndex - i) % 2 == 0) {
        ans[i] += num1;
        if (i < str.size() - 1) {
          ans[i + 1] += num2;
        }
      } else {
        ans[i] += num2;
        if (i < str.size() - 1) {
          ans[i + 1] += num1;
        }
      }
      num1 = 0;
      num2 = 0;
      startIndex = i - 1;
    }
  }

  // answer
  cout << ans[0];
  for (int i = 1; i < str.size(); i++) {
    cout << " " << ans[i];
  }

  // cout << str[1] << endl;
}


Measured memory_bytes: 1024
// Problem URL: https://atcoder.jp/contests/abc177/tasks/abc177_c
#include <bits/stdc++.h>
using namespace std;

int main()
{
  int n;
  cin >> n;
  long long product = 0;
  vector<long long> a(n, 0);
  long long sum = 0;
  long long mod = 1000000007;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
    sum %= mod;
  }
  for (long long i = 0; i < n; i++) {
    sum -= a[i];
    if(sum < 0) sum += mod;
    product += a[i] * sum;
    product %= mod;
  }
  cout << product;
  return 0;
}


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		String S = sc.next();
		int judge = 0;

		if(S.charAt(A) != '-') {
			judge += 1;
		}

		for(int i=0; i<A; i++) {
				if(S.charAt(i) == '-') {
					judge += 1;
				}
		}

		for(int j=0; j<B; j++) {
			if(S.charAt(A+1+j) == '-') {
				judge += 1;
			}
		}

		if(judge == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 22996
#include <stdio.h>
main(){

  int S[10000],T[500];
  int n,q,i,j,ans = 0;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){

    scanf("%d",&S[i]);

  }

  scanf("%d",&q);

  for(i = 0 ; i < q ; i++ ){

    scanf("%d",&T[i]);

  }

  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < q ; j++){

      if(S[i] == T[j]) {ans++;
	T[j] = 10000000000;
      }
    }
  }

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

  return 0;

}

Measured memory_bytes: 640