akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    int d;
    cin >> d;
    if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

int main()
{
  int n,k;
  cin >> n >> k;
  
  ld p[n+1];
  rep1(i,n)
  {
    int score = i;
    if(score >= k)
    {
      while(i <= n)
      {
        p[i] = (long double)(1.0/(long double)n);
        i++;
      }
      break;
    }
    
    p[i] = (long double)(1.0/(long double)n); 
    while(score < k)
    {
      score *= 2;
      p[i] *= (long double)(1.0/2.0);
    }
  }
  
  ld ans = 0.0;
  rep1(i,n)
  {
    ans += (long double)p[i];
  }
  
  cout << fixed;
  cout << setprecision(20);
  cout << (long double)ans << endl;
  
}


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

int main()
{
    const ll MOD = 1e9+7;
    int n,m;
    cin >> n >> m;
    vector<int> s(n), t(m);
    for(auto& si:s) cin >> si;
    for(auto& ti:t) cin >> ti;

    vector<vector<ll>> dp(n+1,vector<ll>(m+1, 0));
    rep(i,n+1) dp[i][0] = 1;
    rep(j,m+1) dp[0][j] = 1;

    rep(i,n) {
        rep(j,m) {
            dp[i+1][j+1] = (dp[i+1][j] + dp[i][j+1] - dp[i][j] + 3*MOD) % MOD;
            if(t[j] == s[i]) 
                dp[i+1][j+1] = (dp[i+1][j+1] + dp[i][j]) % MOD;
        }
    }

    cout << dp[n][m] << endl;
    return 0;
}

Measured memory_bytes: 31616
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>

using namespace std;

int main()
{
    int N, K;
    if (scanf("%d%d", &N, &K) < 2) return 0;

    int d = 0;
    for (int i = 0; i < N; i++)
    {
        int tmp;
        if (scanf("%d", &tmp) < 1) return 0;

        if (abs(tmp - K) <= tmp) d += abs(tmp - K) * 2;
        else d += tmp * 2;
    }

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


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main() {
	int n;
	int a[2][120];
	int b[2][120];
	cin >> n;
	for (int i = 0; i < n; i++) { cin >> a[0][i]; }
	for (int i = 0; i < n; i++) { cin >> a[1][i]; }
	b[0][0] = a[0][0];
	for (int i = 1; i < n; i++) {
		b[0][i] = b[0][i - 1] + a[0][i];
	}
	b[1][0] = a[0][0] + a[1][0];
	for (int i = 1; i < n; i++) {
		if (b[0][i] > b[1][i - 1]) { b[1][i] = b[0][i] + a[1][i]; }
		else { b[1][i] = b[1][i - 1] + a[1][i]; }
	}
	cout << b[1][n-1] << endl;
}

Measured memory_bytes: 256
//Let's join Kaede Takagaki Fan Club !!
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 1000000007;//998244353
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}

int cnt[20][20], n;

int main(){
	scanf("%d", &n);
	rep(i, n){
		long double val; scanf("%Lf", &val);
		val *= 1000000000.;
		ll num = (ll)floor(val + 0.5L);
		//cout << num << endl;
		int t = 0, f = 0;
		while(num%2 == 0){
			t++; num /= 2;
		}
		while(num%5 == 0){
			f++; num /= 5;
		}
		cnt[min(t, 18)][min(f, 18)]++;
	}
	ll ans = 0;
	rep(i, 19) rep(j, 19) rep(a, 19) rep(b, 19){
		if(mp(i, j) > mp(a, b)) continue;
		
		if(mp(i, j) == mp(a, b) && i >= 9 && j >= 9){
			ans += 1LL * cnt[i][j] * (cnt[i][j]-1) / 2;
		}
		else if(i+a >= 18 && j+b >= 18) ans += 1LL * cnt[i][j] * cnt[a][b];
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
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 dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int a,b;
    cin >> a >> b;
    for(int i=0;i<=a;i++){
        if(i*2 + (a-i)*4 == b){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i,a,b) for(int i=a,almo5t=b;i<almo5t;++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    
const int N = 0;
    
typedef long long int ll;
    
using namespace std;
    
int main(){
    int n;cin>>n;
    int grades[n];
    int sums1 = 0;
    fore(i,0,n){
        cin>>grades[i];
        sums1 += grades[i];
    }
    std::sort(grades,grades+n);
    int sums2 = sums1;
    fore(i,0,n){
        if(sums2%10 == 0){
            if(grades[i]%10 != 0){
                sums2 -= grades[i];
                break;
            }
        }else{
            break;
        }
    }
    if(sums2 %10 == 0){
        cout<<0;
    }else{
        cout<<sums2;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<utility>
#include<math.h>
#include<set>
#include<map>
#include<string.h>
#include<stack>
#define n 200000
#define loop(a, b) for(int i = a; i<=b; i++)
using namespace std;
typedef pair<int, int> P;
typedef long long lli;
typedef double llf;
struct edge{
	int from, to, weight;
	bool operator < (const edge& thing) const
	{
		return thing.weight < weight;
	}
};
vector<edge> V[n + 50];
bool visit[n + 50];
int arr[n + 50], a, b, c, d, e;
string str1, str2;
void addedge(int a, int b, int c)
{
	edge temp;
	temp.from = a;
	temp.to = b;
	temp.weight = c;
	V[a].push_back(temp);
}


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


void solve()
{
	cin >> a >> b;
	if(b < a) a --;
	cout << a; 
}
int main()
{
	int times = 1;
//	cin << times;
	loop(1, times)
	{
		solve();
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 4992
# AOJ 0166: Area of Polygon
# Python3 2018.6.18 bal4u

import math
M = 0.00872664625997164788461845384244
EPS = 1e-8

a = [0]*2
s = [0.0]*2
while True:
	eof = False
	for i in range(2):
		s[i] = a[i] = 0;
		n = int(input())
		if n == 0:
			eof = True
			break
		for j in range(1, n):
			v = int(input())
			a[i] += v
			s[i] += math.sin(M*v)*math.cos(M*v)
		v = 360-a[i]
		s[i] += math.sin(M*v)*math.cos(M*v)
	if eof: break
	if abs(s[1]-s[0]) <= EPS: print(0)
	elif s[1] >= s[0]: print(2)
	else: print(1);


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

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

    ll n, tx, ans = 0;
    cin >> n >> tx;
    vector<ll> t(n);
    rep(i, 0, n) cin >> t[i];
    t.push_back(1e12);
    rep(i, 0, n) {
        ans += min(t[i + 1] - t[i], tx);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
int X1[1010],X2[1010],Y[1010];
int X[1010],Y1[1010],Y2[1010];

int HNG[4040][4040];
int VNG[4040][4040];

template<int um> class UF {
	public:
	vector<int> par,rank,cnt;
	UF() {par=rank=vector<int>(um,0); cnt=vector<int>(um,1); for(int i=0;i<um;i++) par[i]=i;}
	void reinit() {int i; FOR(i,um) rank[i]=0,cnt[i]=1,par[i]=i;}
	int operator[](int x) {return (par[x]==x)?(x):(par[x] = operator[](par[x]));}
	int count(int x) { return cnt[operator[](x)];}
	int operator()(int x,int y) {
		if((x=operator[](x))==(y=operator[](y))) return x;
		cnt[y]=cnt[x]=cnt[x]+cnt[y];
		if(rank[x]>rank[y]) return par[x]=y;
		rank[x]+=rank[x]==rank[y]; return par[y]=x;
	}
};
UF<4000*4000> uf;


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	vector<int> Xs,Ys;
	Xs.push_back(-1<<30);
	Xs.push_back(0);
	Xs.push_back(1<<30);
	Ys.push_back(-1<<30);
	Ys.push_back(0);
	Ys.push_back(1<<30);
	FOR(i,N) {
		cin>>Y1[i]>>Y2[i]>>X[i];
		Xs.push_back(X[i]);
		Ys.push_back(Y1[i]);
		Ys.push_back(Y2[i]);
	}
	FOR(i,M) {
		cin>>Y[i]>>X1[i]>>X2[i];
		Xs.push_back(X1[i]);
		Xs.push_back(X2[i]);
		Ys.push_back(Y[i]);
	}
	sort(ALL(Xs));
	sort(ALL(Ys));
	Xs.erase(unique(ALL(Xs)),Xs.end());
	Ys.erase(unique(ALL(Ys)),Ys.end());
	FOR(i,N) {
		X[i]=lower_bound(ALL(Xs),X[i])-Xs.begin();
		Y1[i]=lower_bound(ALL(Ys),Y1[i])-Ys.begin();
		Y2[i]=lower_bound(ALL(Ys),Y2[i])-Ys.begin();
		VNG[Y1[i]][X[i]]++;
		VNG[Y2[i]][X[i]]--;
	}
	FOR(i,M) {
		X1[i]=lower_bound(ALL(Xs),X1[i])-Xs.begin();
		X2[i]=lower_bound(ALL(Xs),X2[i])-Xs.begin();
		Y[i]=lower_bound(ALL(Ys),Y[i])-Ys.begin();
		HNG[Y[i]][X1[i]]++;
		HNG[Y[i]][X2[i]]--;
	}
	
	
	FOR(x,Xs.size()) FOR(y,Ys.size()) {
		if(x) HNG[y][x]+=HNG[y][x-1];
		if(y) VNG[y][x]+=VNG[y-1][x];
		if(x&&VNG[y][x]==0) uf(y*4000+x,y*4000+x-1);
		if(y&&HNG[y][x]==0) uf(y*4000+x,(y-1)*4000+x);
	}
	
	
	int rx,ry;
	rx=lower_bound(ALL(Xs),0)-Xs.begin();
	ry=lower_bound(ALL(Ys),0)-Ys.begin();
	if(uf[ry*4000+rx]==uf[0]) return _P("INF\n");
	
	ll ret=0;
	FOR(x,Xs.size()-1) FOR(y,Ys.size()-1) if(uf[ry*4000+rx]==uf[y*4000+x]) {
		ret+=1LL*(Ys[y+1]-Ys[y])*(Xs[x+1]-Xs[x]);
	}
	cout<<ret<<endl;
	
	
		
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 308792
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	string s;
	cin>>s;
	int l=s.length();
	map<char,int> mp;
	FOR(i,0,l){
		mp[s[i]]++;
	}
	int ans=mod;
	for(auto x:mp){
		string t(s);
		char ch=x.ST;
		int lt=l,cn=x.ND,c=0;
		while(lt!=cn){
			c++;
			FOR(i,0,lt-1){
				if(t[i]!=ch&&(t[i+1]==ch)){t[i]=ch;cn++;}
			}
			if(t[lt-1]==ch)cn--;
			lt--;
		}
		if(c<ans)ans=c;
	}

	cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;

#define pll pair<ll,ll>
#define ff first
#define snd second
#define pb push_back
#define vll vector<ll>
#define vpll vector<pll>
#define endl "\n"
#define MOD 1000000007
using namespace std;

ll const N = 1e5+1;


void solve()
{
   ll a,b;
   cin>>a>>b;
   cout<<(a*b);
}
 
int main() {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
	    int t=1;
	    //cin>>t;
	    while(t--)
	    {
	            solve();
	    }
	    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for (ll i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--)
#define IREP(i, n) IFOR(i, n, 0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(), greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v)                                                              \
  cout << #v << "=(" << v[0];                                                  \
  FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; }                     \
  cout << ")" << endl;
#define mdebug(m)                                                              \
  cout << #m << "=" << endl;                                                   \
  REP(i_debug, m.size()) {                                                     \
    REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; }    \
    cout << endl;                                                              \
  }
#define Lower_bound(v, x)                                                      \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;

template <typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) {
  REP(i, a.size()) {
    cin >> a[i];
    a[i]--;
  }
}

ll mod = 1000000007;

int main() {
  ll N;
  cin >> N;
  vec a(N, -1);
  vec appeared(8, 0);
  ll num_crown = 0;
  REP(i, N) {
    cin >> a[i];
    if (a[i] >= 3200)
      num_crown++;
    else
      appeared[a[i] / 400] = 1;
  }

  ll ans = 0;
  REP(i, 8) { ans += appeared[i]; }

  if (num_crown > 0) {
    // ans += 1;
    if (num_crown == N) {
      cout << 1 << " " << num_crown << endl;
      return 0;
    }
    cout << ans << " " << ans + num_crown << endl;
  } else
    cout << ans << " " << ans << endl;

  return 0;
}

Measured memory_bytes: 256
n, y = map(int, input().split())
y //= 1000
a = 0; b = 0; c = 0
f = False
for i in range(n+1):
    for j in range(n+1):
        if 9*i + 4*j == y - n and i + j <= n:
            a = i
            b = j
            f = True
            break
if f: print(a, b, y-10*a-5*b)
else: print(-1, -1, -1)

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

int main() {
  int a = 0, b = 0;
  cin >> a >> b;
  int ans = ( a + b ) / 2;
  if( ( a + b ) % 2 != 0 ){
    ans += 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3564
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
using namespace std;

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define FOREACH(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)

int pages[50];

int main()
{
  int n;
  while (scanf("%d", &n), n) {
    REP(j, n) {
      scanf("%d", &pages[j]);
    }
    pages[n] = 10000000;
    int a = pages[0], c = 1;
    bool first = true;
    FOR(j, 1, n+1) {
      if (pages[j] != pages[j-1] + 1) {
        if (first)
          first = false;
        else
          printf(" ");
        if (c == 1)
          printf("%d", a);
        else
          printf("%d-%d", a, pages[j-1]);
        a = pages[j];
        c = 1;
      } else {
        ++c;
      }
    }
    puts("");
  }
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n; cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
        a[i]--;
    }

    ll tmp=0,cnt=0;
    while(true){
        if(tmp==1){
            cout<<cnt<<endl;
            break;
        }else if(cnt>=n){
            cout<<-1<<endl;
            break;
        }
        cnt++;
        tmp=a[tmp];
    }
    return 0;
}

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

namespace ABC118_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strs = Console.ReadLine().Split(' ');
            int n = int.Parse(strs[0]);
            int m = int.Parse(strs[1]);

            int[] count = new int[m+1];
            int ans = 0;

            for (int i = 0; i < n; ++i)
            {
                string[] strs2 = Console.ReadLine().Split(' ');
                int k = int.Parse(strs2[0]);

                bool lastPersonFlag = (i == n - 1);

                for (int j = 0; j < k; ++j)
                {
                    int index = int.Parse(strs2[j + 1]);
                    ++count[index];

                    if (lastPersonFlag)
                    {
                        if (count[index] == n)
                        {
                            ++ans;
                        }
                    }
                }
            }

            Console.WriteLine("{0}", ans);
        }
    }
}


Measured memory_bytes: 13140
s = input()
k = int(input())

def f(n):
    s_ = s * n
    r = 0
    i = 0
    while i < len(s_) - 1:
        if s_[i] == s_[i + 1]:
            r += 1
            i += 2
        else:
            i += 1

    return r

x1=f(1)
x2=f(2)
x3 = f(3)





if s.count(s[0]) == len(s):
    ans = k // 2 * x2 + (x1 if k % 2 == 1 else 0)
else:
    ans = x1 + (x2 - x1) * (k - 1)

print(ans)

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

using namespace std;

#define long long long
#define INF (long) 1e18
#define MOD 1'000'000'007
#define mll map<long, long>
#define pll pair<long, long>
#define umap unordered_map
#define umll umap<long, long>
#define uset unordered_set
#define pb push_back
#define FOR(i, a, b) \
  for (long i = (a); i < (long) (b); i++)
#define PRINTV(v) \
  FOR (_i, 0, v.size()) \
    cout << v[_i] << " "; \
  cout << "\n";

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

  long n, m;
  cin >> n >> m;

  long resp;
  if (n == 1 and m == 1) resp = 1;
  else if (n == 1) resp = m - 2;
  else if (m == 1) resp = n - 2;
  else resp = (n - 2) * (m - 2);
  printf("%lld\n", resp);
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
    
    static int n;
    static List<String> list;

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        n = Integer.parseInt(sc.next());
        String p = "";
        String q = "";
        for(int i = 0; i < n; i++){
            p += sc.next();
        }
        for(int i = 0; i < n; i++){
            q += sc.next();
        }
        
        LinkedList<Integer> listA = new LinkedList<>();
        LinkedList<Integer> listB = new LinkedList<>();
        for(int i = 1; i <= n; i++){
            listA.add(i);
        }
        
        list = new ArrayList<>();
        permutation(listA, listB);
        Collections.sort(list);
        int a = 0;
        int b = 0;
        for(int i = 0; i < list.size(); i++){
           if(list.get(i).equals(p)){
               a = i;
           }
           if(list.get(i).equals(q)){
               b = i;
           }
        }
        
        System.out.println(Math.abs(a-b));
    }
    
    static void permutation(LinkedList<Integer> a, LinkedList<Integer> b){
        
        if(a.isEmpty()){
            String s = "";
            for(int i = 0; i < n; i++){
                s += b.get(i);
            }
            list.add(s);
            return;
        }
        
        for(int i = 0; i < a.size(); i++){
            b.addLast(a.removeFirst());
            permutation(a, b);
            a.addLast(b.removeLast());
        }
    }
}

Measured memory_bytes: 59408
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<cstdio>
#include<queue>
#include<map>
#include<set>
#define MN 300000
#define ll long long
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,L,x[MN+5],t[MN+5],pre[MN+5],suf[MN+5];
priority_queue<int> q;
bool Solve(int s)
{
    while(q.size()) q.pop();
    memset(pre,0,sizeof(pre));memset(suf,0,sizeof(suf));
    int P=0,S=0;
    for(int i=1;i<=n;++i)
    {
        int a=(t[i]-1)/(2*L),b=(t[i]-1)%(2*L)+1;s-=a;
        int end1=2*(L-x[i])>=b?2:1;
        int end2=2*x[i]>=b?1:2;
        if(end1==end2)
        {
            if(end1==1) ++P,--pre[i];
            else ++suf[i];
        }
        else
        {
            if(end1==1) ++P,--pre[i],++suf[i];
            else ++P,--pre[i],q.push(i);
        }
    }
    for(int i=0;i<=n;++i)
    {
        P+=pre[i];S+=suf[i];
        while((P&&P+S>s-1)||S>s)
        {
            if(q.empty()||q.top()<=i) return false;
            int x=q.top();q.pop();//cout<<"Get"<<x<<endl;
            --P;++pre[x];++suf[x];
        }
    }
    return true;
}
int main()
{
    n=read();L=read();
    for(int i=1;i<=n;++i) x[i]=read();
    for(int i=1;i<=n;++i) t[i]=read();
    int l=1,r=1e9,mid,res;
    while(l<=r)
    {
        mid=l+r>>1;
        if(Solve(mid)) res=mid,r=mid-1;
        else l=mid+1;
    }
    printf("%lld\n",1LL*res*L*2);
    return 0;
}

Measured memory_bytes: 7156
#include <bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define repf(i, n) for(int i=1; i<(int)(n+1); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli n;
    string s, t;
    cin >> n >> s >> t;
    rep(i, n) cout << s.at(i) << t.at(i);
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
// 簡潔なスタイル
int N; // 少しだけ多めに取る
int min111(vector<long long>A) {
    long long ans = A.at(0);
    for(int i=0;i<A.size();i++) {
        if (ans > A.at(i)){
            ans = A.at(i);
        }
    }
return ans;
}
long long max111(vector<long long> A) {
    long long ans = A.at(0);
    for(int i=0;i<A.size();i++) {
        if (ans < A.at(i)){
            ans = A.at(i);
        }
    }
return ans;
}
long long sum111(vector<long long> A) {
    long long sum=0;
    for(int i=0;i<A.size();i++) {
        sum += A.at(i);
    }
return sum;
}
int main() {
int N;    
cin >> N;
vector<long long> A(N);
for (int i=0; i<N; ++i){
cin >> A.at(i);
}
cout <<min111(A)<<' '<<max111(A)<<' '<<sum111(A)<<endl;

}


Measured memory_bytes: 3320
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	s := getNextLine(scanner)
	for op1 := -1; op1 <= 1; op1 += 2 {
		for op2 := -1; op2 <= 1; op2 += 2 {
			for op3 := -1; op3 <= 1; op3 += 2 {
				sum := int(s[0] - '0')
				sum += op1 * int(s[1]-'0')
				sum += op2 * int(s[2]-'0')
				sum += op3 * int(s[3]-'0')
				if sum == 7 {
					op := [3]rune{'+', '+', '+'}
					if op1 == -1 {
						op[0] = '-'
					}
					if op2 == -1 {
						op[1] = '-'
					}
					if op3 == -1 {
						op[2] = '-'
					}
					fmt.Printf("%c%c%c%c%c%c%c=7", s[0], op[0], s[1], op[1], s[2], op[2], s[3])
					return
				}
			}
		}
	}
}


Measured memory_bytes: 640
#include<iostream>
//#include<CastingInterop.h>
#include<string>
#include<array>
using namespace std;

int main()
{
	int a, b, c , x=0 ;
	cin >> a >> b >> c;
	x = (a * 100) + (b * 10) + c;
	
	if (x % 4 == 0)
		cout << "YES";
	else
		cout << "NO";}

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


#define MAXN 1919810
int n,m;
char a[MAXN];

bool fuck(int l,int r) 
{
	while(l < r) {
		if(a[l] != a[r]) return 0;
		l ++;
		r --;
	}
	return 1;
}

signed main()
{
	scanf("%s",a+1);
	n = strlen(a+1);
	if(fuck(1,n) && fuck(1,(n>>1)) && fuck(((n+3)>>1),n)) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    if(S[2] == S[3] and S[4] == S[5]){
        cout << YES << endl;
    }else{
        cout << NO << endl;
    }

}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[allow(unused_macros)]
macro_rules! chmin {
    ( $ x : expr , $ y : expr ) => {
        if $x > $y {
            $x = $y;
            true
        } else {
            false
        }
    };
}

fn main() {
    input! {
        n: usize, m: usize,
        ab: [(i64, i64);n],
        cd: [(i64, i64);m]
    }
    for i in 0..n {
        let (a, b) = ab[i];
        let mut ret = 0;
        let mut dist = 1i64 << 60;
        for j in 0..m {
            let (c, d) = cd[j];
            if chmin!(dist, (a-c).abs() + (b-d).abs()) {
                ret = j;
            }
        }
        println!("{}", ret+1);
    }
}

Measured memory_bytes: 4352
def main():
    n=int(input())
    s=list(input())
    dict1={}
    for i in range(len(s)):
        if s[i] not in dict1:
            dict1[s[i]]=1
        else:
            dict1[s[i]]+=1
    if n==1:
        s.sort()
        print(''.join(s))
        return
    for _ in range(n-1):
        dict2={}
        t=list(input())
        for i in range(len(t)):
            if t[i] in dict1 and dict1[t[i]]>0:
                if t[i] not in dict2:
                    dict2[t[i]]=1
                    dict1[t[i]]-=1
                else:
                    dict2[t[i]]+=1
                    dict1[t[i]]-=1
        dict1=dict2
    ans=[]
    for i in dict2:
        for _ in range(dict2[i]):
            ans.append(i)
    ans.sort()
    print(''.join(ans))
if __name__ == "__main__":
    main()

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

#define ll long long

using namespace std;

int main()
{
	ll n, l; cin>>n>>l;
	vector<pair<ll, ll> > p(n);
	set<ll> s;
	for(int i=0; i<n; i++){
		ll l, r; cin>>l>>r;
		s.insert(l); s.insert(r);
		p[i] = make_pair(l, r);
	}
	sort(p.begin(), p.end());
	ll cur=0, x=0;
	for(int i=0; i<n; i++){
		ll maxi=0;
		while(p[i].first<=cur){
			maxi = max(maxi, p[i].second);
			i++;
		}
		cur = maxi;
		x++; i--;
		if (cur==l) break;
	}
	ll mini, y;
	map<ll, ll> m;
	ll idx=0;
	for(auto it=s.begin(); it!=s.end(); it++){
		m[*it] = idx;
		idx++;
	}
	vector<ll> imos(s.size()+1);
	for(int i=0; i<n; i++){
		ll left = m[p[i].first];
		ll right = m[p[i].second];
		imos[left]++;
		imos[right+1]--;
	}
	mini = imos[0];
	for(int i=1; i<imos.size()-1; i++){
		imos[i]+=imos[i-1];
		mini = min(mini, imos[i]);
	}
	y = n-(mini-1);
	cout << x << " " << y << endl;

	return 0;
}


Measured memory_bytes: 51056
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define gap ' '
#define L(i) ((i) - (&i))
 
const int MAXN = 1e5;
const int MAX = 1e4;
const int MOD = 1e9+7;
const int INF = 1e9 + 5;
int n;

int main(){		
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; ++i)
		cin >> a[i];
	vector<int> dp(n,INF);
	dp[0] = 0;
	for(int i = 0; i < n; ++i){
		for(int j : {i+1, i+2}){
			if(j < n){
				dp[j] = min(dp[j], dp[i] +abs(a[i] - a[j]));
			}
		}
	}
	cout << dp[n-1] << endl;

 	return 0;
}	


Measured memory_bytes: 3960
#include<stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
int INFTY = (1<<21);
int M[100][100];
int pr(int);
int main(){
  int i,j,n,m;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&m);
      M[i][j]=(m==-1)?INFTY:m;
    }
  }
  printf("%d\n",pr(n));
  return 0;
}
int pr(int n){
  int i,u,mi,d[100],p[100],color[100],sum=0;
  for(i=0;i<n;i++){
    d[i]=INFTY;
    p[i]=-1;
    color[i]=WHITE;
  }
  d[0]=0;
  while(1){
    mi = INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(mi>d[i]&&color[i]!=BLACK){
	u=i;
	mi=d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
    for(i=0;i<n;i++){
      if(color[i]!=BLACK&&M[u][i]!=INFTY){
	if(d[i]>M[u][i]){
	  d[i]=M[u][i];
	  p[i]=u;
	  color[i]=GRAY;
	}
      }
    }
  }
  for(i=0;i<n;i++){
    if(p[i]!=-1)sum+=M[i][p[i]];
  }
  return sum;
}



Measured memory_bytes: 2112
(a, b) = map(int, input().split())

def f(d):
    if 1 == d % 2:
        n1 = int(d / 2) + 1
        return 1 if 1 == n1 % 2 else 0
    else:
        n1 = d / 2
        return d + 1 if 1 == n1 % 2 else d

ans = f(a-1) ^ f(b) if 0 != a else f(b)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
const int INF = 1000000000;

int main() {
    int n, m; cin >> n >> m;
    int c[m];
    for (int i = 0; i < m; i++) cin >> c[i];
    int dp[50100];
    for (int i = 0; i < 50100; i++) dp[i] = INF;
    dp[0] = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < m; j++) {
            if (i >= c[j]) {
                dp[i] = min(dp[i], dp[i - c[j]] + 1);
            }
        }
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 3304
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define INF (1<<28)
#define DEKAI 1000000007
#define FDST int hogehogehoge;cin>>hogehogehoge;
#define int long long

signed main(){
	int done[4];
	lp(i,4) done[i]=0;
	lp(i,3){
		int a,b;
		cin>>a>>b;
		done[a-1]++;
		done[b-1]++;
	}
	string ans="YES";
	lp(i,4){
		if(done[i]>2) ans="NO";
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S, check = "";
  int a = 0;
  cin >> S;
  for (int i = 0; i < 5; i++) {
    check += "hi";
    if (S == check) {
      cout << "Yes" << endl;
      a++;
      break;
    }
  }
  if (a == 0) {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(ll i=0;i<n;++i)
typedef long long ll;
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(){
   vector<ll> g;
   int a,b,c,k;
   cin >> a >> b >> c >>k;
   ll sum=0;
   if(k>a){
      sum +=a;
      k-=a;
      if(k>b){
         k-=b;
         if(k!=0) sum += (-1)*k;
      }
   }else{
      sum=k;
   }
   
   cout << sum << endl;
   return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <cstdlib>
#include <cctype>
#include <cstdio>

using namespace std;

int main()
{
    string s;
    stack<double> St;
    double a, b;
    while (getline(cin, s)) {
        stringstream ss(s);

        while (ss >> s) {
            if (s == "+") {
                b = St.top(); St.pop();
                a = St.top(); St.pop();
                St.push(a+b);
            }
            else if (s == "-") {
                b = St.top(); St.pop();
                a = St.top(); St.pop();
                St.push(a-b);
            }
            else if (s == "*") {
                b = St.top(); St.pop();
                a = St.top(); St.pop();
                St.push(a*b);
            }
            else if (s == "/") {
                b = St.top(); St.pop();
                a = St.top(); St.pop();
                St.push(a/b);
            }
            else {
                St.push(atoi(s.c_str()));
            }
        }
        printf("%.6f\n", St.top());
        St.pop();
    }
    return 0;
}

Measured memory_bytes: 3200
h, w = map(int, input().split())
l = [input() for i in range(h)]
ans = []
for row in l:
    ans.append(list(row))

for i in range(h):
    for j in range(w):
        if l[i][j] == '#': continue
        c = 0
        if i > 0:
            if j > 0 and l[i-1][j-1] == '#': c += 1
            if l[i-1][j] == '#': c += 1
            if j < w-1 and l[i-1][j+1] == '#': c += 1
        if j > 0 and l[i][j-1] == '#': c += 1
        if j < w-1 and l[i][j+1] == '#': c += 1
        if i < h-1:
            if j > 0 and l[i+1][j-1] == '#': c += 1
            if l[i+1][j] == '#': c += 1
            if j < w-1 and l[i+1][j+1] == '#': c += 1
        ans[i][j] = c
        
for row in ans:
    print(''.join(list(map(str, row))))

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <ctime>
#include <climits>
#include <cfloat>
#include <cstdint>
#include <cstddef>
#include <cinttypes>
#include <memory>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <array>
#include <valarray>
#include <string>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <bitset>
#include <queue>
#include <complex>
#include <tuple>
#include <utility>
#include <functional>
#include <algorithm>
#include <numeric>

using namespace std;

const double EPS = 1e-10;
const int64_t INF = 1e9;

const int MAX_N = 500;

int N;
int x[MAX_N];

void solve()
{
	vector<tuple<int,int,int>> v;
	for (int i = 0; i < N; ++i) {
		v.push_back(make_tuple(x[i], i, i));
	}
	sort(v.begin(), v.end());

	int pos = 1;
	int index = 0;
	stack<int> f;
	vector<int> ans(N * N);
	int ans_i = 0;
	for (int i = 0; i < N; ++i) {
		int t = get<0>(v[i]) - pos;
		while (t > 0 && index < N) {
			int s = min(t, get<1>(v[index]));
			t -= s;
			get<1>(v[index]) -= s;
			for (int j = 0; j < s; ++j) {
				ans[ans_i++] = get<2>(v[index]);
			}
			if (t > 0) ++index;
		}
		if (t > 0) {
			int s = min(t, (int)(f.size()));
			t -= s;
			for (int i = 0; i < s; ++i) {
				int a = f.top(); f.pop();
				ans[ans_i++] = a;
			}
		}
		if (t > 0) {
			printf("No\n");
			return;
		}

		if (get<1>(v[i]) > 0) {
			printf("No\n");
			return;
		}
		pos = get<0>(v[i]) + 1;
		ans[ans_i++] = get<2>(v[i]);
		for (int j = 0; j < N - 1 - get<2>(v[i]); ++j) {
			f.push(get<2>(v[i]));
		}
	}

	printf("Yes\n");
	while (!f.empty()) {
		int a = f.top(); f.pop();
		ans[ans_i++] = a;
	}

	for (int i = 0; i < N * N; ++i) {
		printf("%d%c", ans[i] + 1, i == N * N - 1 ? '\n' : ' ');
	}


}

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) {
		scanf("%d", &x[i]);
	}
	solve();

	return 0;
}



Measured memory_bytes: 2688
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int s;
    cin >> s;
    int a = s / 100, b = s % 100;
    bool f1 = false, f2 = false;
    if(a > 0 && a <= 12) f1 = true;
    if(b > 0 && b <= 12) f2 = true;
    if(f1 && f2){
        cout << "AMBIGUOUS" << endl;
    }else if(f1 && !f2){
        cout << "MMYY" << endl;
    }else if(!f1 && f2){
        cout << "YYMM" << endl;
    }else{
        cout << "NA" << endl;
    }
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

// ############################################################################################

#define FOREACH(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define FOR(i, a, n) for (register int i = (a); i < (int)(n); ++i)
#define FORE(i, a, n) for (i = (a); i < (int)(n); ++i)
#define Size(n) ((int)(n).size())
#define all(n) (n).begin(), (n).end()

#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair

#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<double, double>

#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>

#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)

#define mod 1000000007
#define inf 1e18

#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

// ############################################################################################

ll mpow(ll base, ll exp) {
    ll res = 1;
    while (exp > 0) {
        if (exp % 2) res = (res * base) % mod;
        base = (base * base) % mod;
        exp /= 2;
    }
    return res % mod;
}

void a_k_s() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
}

ll n, w, wt, val;
vector<pll> v;
ll ans = -1;

void solve(ll i, ll weight, ll value) {
    // Base Case
    if (weight == 0 || i == n) {
        ans = max(ans, value);
        return;
    }

    // Recursive Case
    if (v[i].ff <= weight) {
        solve(i + 1, weight - v[i].ff, value + v[i].ss);
    }
    solve(i + 1, weight, value);
}

int main() {
    a_k_s();

    cin >> n >> w;
    v.pb({0, 0});
    FOR(i, 0, n) {
        cin >> wt >> val;
        v.pb({wt, val});
    }

    sort(all(v));

    vector<vector<ll>> dp(n + 1, vector<ll>(w + 1, 0));
    // cout << "Reached Here\n";

    FOR(i, 1, n + 1) {
        FOR(wt, 1, w + 1) {
            // cout << i << ' ' << wt << endl;
            dp[i][wt] = dp[i - 1][wt];
            if (v[i].ff <= wt) {
                dp[i][wt] = max(dp[i][wt], dp[i - 1][wt - v[i].ff] + v[i].ss);
            }
        }
    }

    // solve(0, w, 0);

    // cout << ans << endl;

    cout << dp[n][w] << endl;

    return 0;
}

Measured memory_bytes: 83144
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b-1);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,r;cin>>n>>r;
  if(n>=10){
    cout<<r<<endl;
    return 0;
  }
  else {
    cout<<r+100*(10-n)<<endl;
  }
  return 0;

}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

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

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

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

void debug(VS &board){
	int h = board.size();
	rep(i,h){
		cout<<board.at(i)<<endl;
	}
	return;
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

LL lcm(LL a,LL b){
	return a*b/gcd(a,b);
}

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	int s;
	cin>>s;
	int dp[100000];
	dp[0]=1;
	for(int i=0;i<=s;i++){
		dp[i+3]=dp[i+2]+dp[i];
		dp[i+3]%=MOD;
	}
	cout<<dp[s]<<endl;
	return 0;
}


Measured memory_bytes: 3592
/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.

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

int mod = 1000000007;
ll dp[100005];;

ll gcd(long long a,long long b){

  if(b == 0)
    return a;
  else return gcd(b,a%b);
}


int main(){

 ll n,m;
 cin>>n>>m;

  ll a[n],b[m],c[m];
 for(int i=0;i<n;i++)
    cin>>a[i];

 for(int i=0;i<m;i++) cin>>b[i]>>c[i];

 priority_queue< pair<int,int> >Q;

   for(int i=0;i<n;i++)
    Q.push(make_pair(a[i],1));

  for(int j=0;j<m;j++)
    Q.push(make_pair(c[j],b[j]));

  ll ans =0;

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

      pair<int,int> p;
      p = Q.top();
      Q.pop();

      ans += p.first;
     if(p.second > 1){
        p.second--;
        Q.push(p); }
  }

  cout<<ans<<endl;

return 0;
}

Measured memory_bytes: 7628
#include <iostream>
using namespace std;
int main(void){
    int N,L;
    cin >> N >> L;
    if(L<=0&&L+N-1>=0){cout << (2*L+N-1)*N/2 << endl;}
    
    else if(L>0){cout << (2*L+N-1)*N/2-L << endl;}
    
    else{cout << (2*L+N-1)*N/2-L-N+1 << endl;}
    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		int res = 0;
		for (int i = 0; i <= A; i++) {
			for (int j = 0; j <= B; j++) {
				for (int j2 = 0; j2 <= C; j2++) {
					if (X == (500 * i + 100 * j + 50 * j2)) {
						res++;
					}
				}
			}

		}
		System.out.println(res);
	}
}

Measured memory_bytes: 35748
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define inf 1e10
#define mod 1000000007
#define mii map<int,int>
#define pii pair<int,int>
#define setbits(x) __builtin_popcountll(x)
#define lcm(x,y)  (x*y)/__gcd(x,y)


int32_t main()
{
	//c_p_c();

	double a, b, n;
	cin >> a >> b >> n;

	double x = n;
	if (x >= b)
	{
		x = b - 1;
		cout << floor(a * x / b) - (a * floor(x / b));


	}
	else {

		cout << floor(a * x / b) - (a * floor(x / b));

	}



}

Measured memory_bytes: 3808