akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mmp make_pair
#define st first
#define nd second
#define rd third
#define ll long long
#define pii pair <int, int>
#define tri pair <pii, int>
#define itr pair <int, pii>
#define PQ priority_queue
#define all(v) (v).begin(), (v).end()
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, n) for (int (i) = (a); (i) < (int)(n); i++)
#define FORN(i, a, n) for (int (i) = (a); (i) > (int)(n); i--)
#define Rep(i, n) for (int (i) = 0; (i) <= (int)(n); i++)
#define For(i, a, n) for (int (i) = (a); (i) <= (int)(n); i++)
#define Forn(i, a, n) for (int (i) = (a); (i) >= (int)(n); i--)
#define FORD(i, n) for (int (i) = (int)(n) - 1; i>= 0; i--)
#define rep(i, n) for (int (i) = 1; (i) <= (int)(n); i++)
#define EACH(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define DEBUG(x) cout << #x << " = " << (x) << endl;
#define PR(a, n) {cout << #a << " = "; FOR(_, 1, n) cout << a[_] << ' '; puts(""); }
#define PRO(a, n) { cout << #a << " = "; REP(_, n) cout << a[_] << ' '; puts(""); }
#define pi 3.1415926535897932384626433832795028841971
//#define LOCAL

const int INF = 1 << 30;
const int N = 1005;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};

inline ll read()
{
	ll x = 0; int f = 1, c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
	return x * f;
}

int n; 
map <string, int> mp; 

int main()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	
	n = read(); 
	int mx = 0; 
	REP(i, n)
	{
		string s; cin >> s; 
		mp[s]++; 
		mx = max(mx, mp[s]); 
	}
	
	vector <string> ans; 
	for (map<string, int> :: iterator it = mp.begin(); it != mp.end(); it++)
	{
		if (it -> nd == mx) ans.pb(it -> st); 
	}
	
	sort(all(ans)); 
	REP(i, ans.size()) puts(ans[i].c_str()); 
	
	return 0;
}


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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

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

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

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}

void No(){
	cout<<"No"<<endl;
	exit(0);
}

template<class T>
void chmax(T& a,T b){
	a=max(a,b);
}

template<class T>
void chmin(T& a,T b){
	a=min(a,b);
}

template<class T>
void ResetVector(vector<T>& v,int n,const T& t){
	v.clear();
	v.resize(n,t);
}

namespace MaxFlow{
	using CapType=int;
	const CapType inf=1145141919;
	struct Edge{
		int to,rev;
		CapType cap;
	};
	vector<vector<Edge>> g;
	vi itr,level;
	void Init(int n){
		ResetVector(g,n,vector<Edge>());
		ResetVector(itr,n,0);
		ResetVector(level,n,0);
	}
	void AddEdge(int from,int to,CapType cap){
		g[from].PB({to,(int)g[to].size(),cap});
		g[to].PB({from,(int)g[from].size()-1,0});
	}
	void bfs(int s){
		fill(level.begin(),level.end(),-1);
		level[s]=0;
		queue<int> q;
		q.push(s);
		while(!q.empty()){
			int v=q.front();q.pop();
			for(auto e:g[v])if(e.cap>0&&level[e.to]==-1){
				level[e.to]=level[v]+1;
				q.push(e.to);
			}
		}
	}
	CapType dfs(int v,int t,CapType f){
		if(v==t)
			return f;
		for(int&i=itr[v];i<(int)g[v].size();i++){
			Edge& e=g[v][i];
			if(e.cap>0&&level[e.to]==level[v]+1){
				CapType d=dfs(e.to,t,min(f,e.cap));
				if(d>0){
					e.cap-=d;
					g[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}
	CapType Calc(int s,int t){
		CapType flow=0;
		while(1){
			bfs(s);
			if(level[t]==-1)
				return flow;
			fill(itr.begin(),itr.end(),0);
			CapType f;
			while((f=dfs(s,t,inf))>0)
				flow+=f;
		}
	}
}

int main(){
	int h=read(),w=read();
	vector<string> board(h);
	REP(i,h)
		cin>>board[i];
	MaxFlow::Init(h*w*2+2);
	int s=h*w*2,t=s+1;
	REP(i,h)REP(j,w){
		int p=i*w+j,q=p+h*w;
		if(board[i][j]=='X'){
			if(i==0||i==h-1||j==0||j==w-1){
				cout<<-1<<endl;
				return 0;
			}
			MaxFlow::AddEdge(s,p,MaxFlow::inf);
			MaxFlow::AddEdge(p,q,MaxFlow::inf);
		}else
			MaxFlow::AddEdge(p,q,1);
		if(i==0||i==h-1||j==0||j==w-1)
			MaxFlow::AddEdge(q,t,MaxFlow::inf);
		int dxy[]={0,-1,0,1,0};
		REP(k,4){
			int y=i+dxy[k+1],x=j+dxy[k];
			if(0<=y&&y<h&&0<=x&&x<w)
				MaxFlow::AddEdge(q,y*w+x,MaxFlow::inf);
		}
	}
	cout<<MaxFlow::Calc(s,t)<<endl;
}


Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>

using namespace std;

int main(int argc, char* argv[])
{

	int n,m;

	cin >> n >> m;

	cout << (n-1)*(m-1) << endl;

	return 0;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int n, m, q;
int a[50], b[50], c[50], d[50];

llong solve(int idx, vector<int> v){
  
  llong res = 0;
  //スコア計算
  if(idx == n){
    
    REP(i,q){
      if(v[b[i]] - v[a[i]] == c[i]) res += d[i];
    }
    return res;
  }

  if(idx == 0){
    for(int i = 1; i <= m; ++i){
      v[0] = i;
      res = max(res, solve(idx+1, v));
    }
  }else{
    for(int i = v[idx-1]; i <= m; ++i){
      v[idx] = i;
      res = max(res, solve(idx+1, v));
    }
  }

  return res;
}

int main(){

  cin >> n >> m >> q;
  vector<int> v(n);
  REP(i,n){
    v[i] = 0;
  }
  REP(i,q){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--; b[i]--;
  }

  cout << solve(0, v) << endl;

  return 0;

}





Measured memory_bytes: 3160
#include <iostream>
using namespace std;
 
int main() {
     
    while(true){
        int n,m,a;
        cin >> n >> m >> a;
        if(n==0&&m==0&&a==0){
                break;
        }
         
        int amida[101][1001]={{0}};
         
        for(int i=0;i<m;i++){
            int h,p,q;
            cin >> h >> p >> q;
            amida[p][h]=1;
        }
         
        for(int j=1000;j>0;j--){
            if(amida[a][j]==1) a++; //????????????
            else if(amida[a-1][j]==1) a--; //???
        }
         
        cout << a << endl;
    }
     
    return 0;
}

Measured memory_bytes: 1560
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,m=0;long long int ans=0;
  cin>>n;
  for(int  i=0;i<n;++i){
        int x;
    cin>>x;
    m=max(x,m);
    ans+=m-x;
  //cout << ans << " ";
  }
  cout << ans ;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    ll a, b, k;
    cin >> a >> b >> k;
    if(k >= a+b){
        cout << 0 << ' ' << 0 << endl;
        return 0;
    }
    else if(k>=a && k-a<b){
        cout << 0 << ' ' << b-k+a << endl;
        return 0;
    }
    else{
        cout << a-k << ' ' << b << endl;
        return 0;
    }
}

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

int main() {
    char c;
    cin >> c;
    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
l = []
for i in range(n):
    l.append([int(i) for i in input().split()])
l.sort()
ans = 0
for i in range(n):
    if m <= l[i][1]:
        ans += l[i][0] * m
        break
    else:
        ans += l[i][0] * l[i][1]
        m -= l[i][1]
print(ans)

Measured memory_bytes: 21616
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define ff first
#define ss second
#define prec(y,x) fixed<<setprecision(y)<<x
#define inf 1e18
#define pi 3.1415926535

int main()
{
	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

	int x, n;
	cin >> x >> n;
	if (n == 0)
	{
		cout << x; return 0;
	}
	set<int> s;
	int a[n];
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		s.insert(a[i]);
	}
	auto itr = s.find(x);
	if (itr == s.end())
	{cout << x ; return 0;}
	for (int i = 1; i <= 200; i++)
	{
		auto it = s.find(x - i);
		if (it == s.end())
		{cout << x - i; return 0;}
		it = s.find(x + i);
		if (it == s.end())
		{cout << x + i; return 0;}
	}

	return 0;
}


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

int main() {
  string s;
  cin >> s;
  int fa = -1, lz = 0;
  for (int i=0; i<s.size(); i++) {
    if (s[i] == 'A' && fa == -1)
      fa = i;
    if (s[i] == 'Z')
      lz = i;
  }
  cout << lz-fa+1 << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */

void solve(istream &cin) {
    ll N, M, C;
    cin >> N >> M >> C;
    if(!cin) return;
    vector<ll> B;
    ll ans = 0;
    for (int j = 0; j < M; ++j) {
        ll tmp;
        cin >> tmp;
        B.push_back(tmp);
    } // end j
    for (int i = 0; i < N; ++i) {
        ll sum = C;
        for (int j = 0; j < M; ++j) {
            int a;
            cin >> a;
            sum += a * B[j];
        } // end j
        if(sum > 0) ans++;
    } // end i
    cout << ans << endl;
    
    
}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    cerr << "DEBUG MODE" << endl;
    string test_cases = "test.txt";
    auto fs = fstream(test_cases, fstream::in);
    while(fs) {
        solve(fs);
    }
#else
    solve(cin);
#endif
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <bitset>
#define rep(i,a) for(int i=0;i<(a);++i)

const int MAX_N = 2000, MAX_A = 2000;

int N;
int A[MAX_N];
int S = 0;
std::bitset<MAX_N*MAX_A> dp;

int main()
{
  scanf( "%d", &N );

  dp[0] = 1;

  rep( i, N )
  {
    scanf( "%d", A+i );
    S += A[i];
    dp |= dp<<A[i];
  }

  for( int i = (S+1)/2; i <= S; ++i ) if( dp[i] )
  { printf( "%d\n", i ); break; }

  return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <cmath>
#include <iomanip>
#include <utility>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

long long gcd(int x, int y){
    if ( x == 0 ) return y;

    return gcd(y%x, x);
}

long long lcm(int x, int y){
    if ( y == 0 ){
        return x;
    }

    return x*y/gcd(x, y);
}

int min(int a, int b){
    return a > b ? b : a;
}

int max(int a, int b){
    return a > b ? a : b;
}

int main()
{
    cin.sync_with_stdio( false );
    int a,b;
    cin>>a>>b;

    string br = "";
    for (int i=0;i<a;i++){
        br+=b + '0';
    }

    string br1 = "";
    for (int i=0;i<b;i++){
        br1+=a + '0';
    }

    vector <string> aa;
    aa.push_back(br);
    aa.push_back(br1);
    sort(aa.begin(), aa.end());
    cout<<aa[0]<<endl;
}


Measured memory_bytes: 3644
N = int(input())
pas = [0]*5
for i in range(5):
  pas[i] = int(input())
min_pas = min(pas)
if N==min_pas:
  times = 0
elif min_pas == 1:
  times = N-1
else:
  times = N//min_pas
times += 5
print(times)

Measured memory_bytes: 3064
from collections import Counter


n = int(input())
lst_v = list(map(int, input().split()))


lst_o = lst_v[::2]
lst_e = lst_v[1::2]
cnt_o = Counter(lst_o).most_common() + [(0, 0)]
cnt_e = Counter(lst_e).most_common() + [(0, 0)]


if cnt_o[0][0] == cnt_e[0][0]:
    rem_number = max(cnt_o[0][1] + cnt_e[1][1], cnt_o[1][1] + cnt_e[0][1])
else:
    rem_number = cnt_o[0][1] + cnt_e[0][1]
ans = n - rem_number


print(ans)


Measured memory_bytes: 21212
p = [[0 for a in range(10)] for b in range(10)]
def smallink(x,y):
    return [(x+i,y+j) for i in range(-1,2,1) for j in range(-1,2,1)\
            if abs(i)+abs(j)<=1 and x+i>=0 and x+i<=9 and y+j>=0\
            and y+j<=9]
def ink(x,y):
    return [(x+i,y+j) for i in range(-1,2,1) for j in range(-1,2,1)\
            if x+i>=0 and y+j>=0 and x+i<=9 and y+j<=9]
def bigink(x,y):
    return [(x+i,y+j) for i in range(-2,3,1) for j in range(-2,3,1)\
            if abs(i)+abs(j)<=2 and x+i>=0 and y+j>=0 and x+i<=9\
            and y+j<=9]

while True:
    try:
        x,y,size=map(int,raw_input().split(","))
        if size==1:
            L=smallink(x,y)
        elif size==2:
            L=ink(x,y)
        else:
            L=bigink(x,y)
        while len(L)!=0:
            point=L.pop(0)
            p[point[0]][point[1]]+=1
    except:
        break

count=0
max=0
for i in range(10):
    for j in range(10):
        if(p[i][j]>max):
            max=p[i][j]
        if(p[i][j]==0):
            count+=1
print count
print max

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

void out(string s, int h);

int main() {
	string str;
	int m, h;
	int h_total = 0;
	while (cin >> str) {
		if (str == "-") break;
		cin >> m;
		for (int i = 0; i < m; i++) {
			cin >> h;
			h_total += h;
		}
		out(str, h_total);
		h_total = 0;
	}
	return 0;
}

void out(string s, int h) {
	int num = h % s.length();
	string t = s.substr(num);
	for (int i = 0; i < num; i++) {
		t += s[i];
	}
	cout << t << endl;
}

Measured memory_bytes: 1212
//#pragma GCC         optimize("O3")
#include            <bits/stdc++.h>
#include            <ext/pb_ds/assoc_container.hpp>
#include            <ext/pb_ds/tree_policy.hpp>
#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define mp          make_pair
#define mem(x,i)    memset(x,i,sizeof(x))
#define ff          first
#define ss          second
#define popcount(x) __builtin_popcount(x)
#define all(x)      x.begin(),x.end()
#define Case(t)     for(int ks=1;ks<=t;ks++)
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define D(x)        cerr<< __LINE__ <<": "<< #x << " = "<<(x) <<'\n';
#define endl        '\n'

using namespace std;
using namespace __gnu_pbds;

using ll  = long long;
using ld  = long double;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;

const int INF    = 0x3f3f3f3f;
const ll LL_INF  = 0x3f3f3f3f3f3f3f3f;
const double PI  = acos(-1);
const double eps = 1e-4;
const int mod    = 998244353;
const int mx     = 100005;
template <typename T>  using orderedSet =
    tree<T, null_type, less_equal<T>,
    rb_tree_tag, tree_order_statistics_node_update>;//find_by_order,order_of_key*/

/*------------------------------Graph Moves----------------------------*/
//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

//ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(; b; b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
/*----------------------BitMask-----------------------------------------*/
//inline int setBit(int N,int pos){return N=N | (1<<pos);}
//inline int resetBit(int N,int pos){return N= N & ~(1<<pos);}
//inline bool checkBit(int N,int pos){return (bool) (N& (1<<pos));}

int main()
{
    int n;
    cin>>n;
    ll vil[n+1];
    ll her[n];
    for(int i=0;i<=n;i++)cin>>vil[i];
    for(int i=0;i<n;i++) cin>>her[i];
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        ll c=her[i];
        if(c>vil[i])
        {
            ans+=vil[i];
            c-=vil[i];
            if(c>vil[i+1]) ans+=vil[i+1];
            else ans+=c;
            vil[i+1]=max(0LL,vil[i+1]-c);
        }
        else ans+=c;
    }
    cout<<ans<<endl;
}


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


#define endl "\n"
#define pi                 3.1415926535897932384626433832795
#define ll                 long long
#define pb                 push_back
#define pii                pair < int , int >
#define vecsort(v)         sort(v.begin(),v.end())
#define lcm(x,y)           (x/__gcd(x,y))*y
#define vecsum(v)          accumulate(v.begin(), v.end(), 0)
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)

long long a[200005];
int main(){

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

    int n ;
    cin >> n ;
    set < long long > s;
    for( int i = 0 ; i < n ; i++){
       cin >> a[i];
       s.insert(a[i]);
    }
    if( s.size() == n ){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }


	return 0;

}

Measured memory_bytes: 14544
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <stack>

using namespace std;

int main(){
	int n,q,label,com,x,y,to_change1,to_change2;

	scanf("%d %d",&n,&q);
	int table[n];

	for(int i = 0; i < n; i++)table[i] = i;
	label = n;

	for(int i = 0; i < q; i++){
		scanf("%d %d %d",&com,&x,&y);

		if(com == 1){
			if(table[x] == table[y])printf("1\n");
			else{
				printf("0\n");
			}
		}else{
			to_change1 = table[x];
			to_change2 = table[y];

			for(int i = 0; i < n; i++){
				if(table[i] == to_change1 || table[i] == to_change2){
					table[i] = label;
				}
			}
			label++;
		}
	}

    return 0;
}

Measured memory_bytes: 2732
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <map>
#include <cmath>
#include <vector>

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

typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main() {
    int n, d;
    cin >> n >> d;
    int ans = (n+d*2) / (d*2+1);
    cout << ans << endl;
}

Measured memory_bytes: 256
s = list(input())
a = int("".join(s[:2]))
b = int("".join(s[2:]))
c = 0
d = 0
if a and a <= 12:
    c = 1
if b and b <= 12:
    d = 1
if c and d:
    print("AMBIGUOUS")
elif c:
    print("MMYY")
elif d:
    print("YYMM")
else:
    print("NA")

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N)
  cin >> A[i];
  ll dp[100010][2] = {};
  dp[2][0] = A[0] + A[1];
  dp[2][1] = -dp[2][0];
  REP(i, N)
  {
    if (i < 2)
      continue;
    dp[i + 1][0] = max(dp[i][0] + A[i], dp[i][1] + A[i]);
    dp[i + 1][1] = max(dp[i][0] - 2 * A[i - 1] - A[i], dp[i][1] + 2 * A[i - 1] - A[i]);
  }
  cout << max(dp[N][0], dp[N][1]) << endl;
  return 0;
}

Measured memory_bytes: 2176
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <iostream>
#include <algorithm>
#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());

//グラフ理論用変数
//vector<vector<llong> > graph(N);

int main(){
    llong N,M;
    llong a,b;

    cin >> N >> M;

    vector<vector<llong> > graph(N);
    for(int i=0; i<M; i++){
        cin >> a >> b;
        graph[a-1].push_back(b-1);
        graph[b-1].push_back(a-1);
    }
    for(int i=0; i<graph.size(); i++){
        cout << graph[i].size() << endl;
    }
    return 0;
}

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

using namespace std;

int main(){
    long long a,b,cnt=0,d;
    scanf("%lld%lld",&a,&b);
    while(1){
        if(a>b) break;
        cnt++;
        a*=2;
    }
    printf("%lld\n",cnt);

    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);
    int N;
    string S,T;
    cin >> N >> S >> T;
    string ans="";
    rep(i,N){
        ans+=S[i];
        ans+=T[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
mod = 10 ** 9 + 7

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N = 2 * 2 * 10 ** 5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


mx = min(k, n - 1)
ans = 0
for i in range(mx + 1):
    ans += cmb(n, i, mod) * cmb(n - 1, n - i - 1, mod)
    ans %= mod

print(ans)


Measured memory_bytes: 50832
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	vector<int> a(n);
	bool one = false;
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		
		if( a[i] == 1 ) one = true;
	}
	
	int ans = 0;
	int target = a[n - 1] - 1;
	int pre_index = n - 1;
	
	for(int i = n - 2; i >= 0; --i) {
		
		if( a[i] == target && target > 0 ) {
			target--;
			ans += (pre_index - i - 1);
			pre_index = i;
		}				
		
		if( target <= 0 ) { 
			if( pre_index > 0 ) ans += pre_index;
			break;
		}
	}
	
	if( target == 0 ) cout << ans << endl;
	else if( target != 0 && one ) cout << n - 1 << endl;
	else cout << -1 << endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,t;
  cin>>n>>t;
  int a[n];
  int i;
  for(i=0;i<n;i++)
  cin>>a[i];
  long long int ans=t,d=t;
  for(i=1;i<n;i++)
  {
    if(d>=a[i])
    {
      ans+=a[i]-a[i-1];
      d=a[i]+t;
    }
    else
    {
      ans+=d-a[i-1];
      d=a[i]+t;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4336
#include <iostream>

using namespace std;

long long int MOD = 1000000007;

long long int dp[2020][2020];

int N, M, S[2020], T[2020];

long long int s[2020][2020];

int main(void) {

	cin >> N >> M;

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

	for (int i = 1; i <= M; i++) {
		cin >> T[i];
	}

	for (int i = 0; i <= N; i++) { dp[i][0] = 1; }

	for (int j = 0; j <= M + 1; j++) { dp[0][j] = 1; }


	
		for (int n = 1; n <= N; n++) {
			for (int m = 1; m <= M; m++) {
				if (S[n] == T[m]) { s[n][m] = s[n - 1][m] + dp[n - 1][m - 1]; }
				else { s[n][m] = s[n - 1][m]; }
			dp[n][m] = dp[n][m - 1]+s[n][m];
			dp[n][m] %= MOD;
			/*dp[n][m] = dp[n][m - 1];
			for (int k = 1; k <= n; k++) {
				if (T[m] == S[k]) {
					dp[n][m] += dp[k - 1][m - 1];
					dp[n][m] %= MOD;
				}
			}*/
		}
	}

	cout << dp[N][M] << endl;

	return 0;
}

Measured memory_bytes: 63744
#include <stdio.h>

int main(int argc, char** argv)
{
  int n,m,l,r;
  scanf("%d %d", &n, &m);
  
  l=1,r=n;
  for(int i=0;i<m;++i){
    int ll,rr;
    scanf("%d %d", &ll, &rr);
    if(ll>l) l=ll;
    if(rr<r) r=rr;
  }
  printf("%d\n", r<l?0:r-l+1);
  return 0;
}



Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<vector>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*

 */
int n,i;

int main(){
  cin>>n>>i;
  cout<<n-i+1<<endl;

  return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline

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

    d = []
    for i in range(N-1):
        d.append(A[i+1] - A[i])
    d.append(K-A[-1]+A[0])
    print(K - max(d))


if __name__ == '__main__':
    main()


Measured memory_bytes: 80892
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
    long N;
    scanf("%ld",&N);
    long a[N-1],sum[N-1],usum[N-2];
    int i,j,k,l;
    for(i=0;i<N;i++)
    {
        scanf("%ld",&a[i]);
    }
    sum[0]=a[0];
    for(k=1;k<N;k++)
    {
        sum[k] =sum[k-1]+a[k];
    }
    for(l=0;l<N-1;l++)
    {
        usum[l]=sum[N-1]-(sum[l]*2);
        usum[l]=labs(usum[l]);
    }
    long min=usum[0];
    for(j=1;j<N-1;j++)
    {
        if(usum[j]<min)
        {
            min=usum[j];
        }
    }
    printf("%ld",min);
}


Measured memory_bytes: 4864
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 1e5 + 5;
int main() {
    abdelrahman010
    multiset<int> st;
    int n;
    cin >> n;
    while(n--) {
        int x;
        cin >> x;
        if(st.empty())
            st.insert(x);
        else {
            auto it = st.lower_bound(x);
            if(it != st.begin())
                st.erase(--it);
            st.insert(x);
        }
    }
    cout << st.size();
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
    string s;
    cin >> s;
    reverse(s.begin(), s.end());

    string day[] = {"dream", "dreamer", "erase", "eraser"};
    for(int i=0; i<4; i++) reverse(day[i].begin(), day[i].end());

    bool can_all = true;
    for(int i=0; i<s.size();){
        bool can_small = false;
        for(int j=0; j<4; j++){
            string d = day[j];
            if(s.substr(i, d.size())==d){
                can_small = true;
                i += d.size();
            }
        }
        if(!can_small){
            can_all = false;
            break;
        }
    }

    string ans="NO";
    if(can_all) ans = "YES";
    cout << ans << "\n";
    return 0;
}


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

int main() {

    int N;
    cin >> N;

    int ec = 0, fc = 0;
    rep(i, N) {
        int a;
        cin >> a;

        if (a % 2 == 0) {
            ec++;
            if (a % 3 == 0 || a % 5 == 0)
                fc++;
        }
    }

    if (ec == fc)
        cout << "APPROVED";
    else
        cout << "DENIED";
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
a, b, c = sorted([int(x) for x in input().split()])

xb = (c - b) // 2
b += xb * 2
xa = (c - a) // 2
a += xa * 2

x = xa + xb
if a == b and b == c:
    print(x)
elif a < c and b < c:
    print(x + 1)
else:
    print(x + 2)


Measured memory_bytes: 3060
import Data.List
import Text.Printf

mktbl :: Float -> Int -> [Float] -> [Int]
mktbl _ n [] = [n]
mktbl r n (v:vs) =
  if v < r
  then mktbl r (n+1) vs
  else
    if v < (r+5)
    then (n:(mktbl (r+5) 1 vs))
    else (n:(mktbl (r+5) 0 (v:vs)))

plot' :: [Int] -> [Int] -> [String]
plot' [] [] = []
plot' (i:is) [] =
  ( ((show i) ++ ":"):(plot' is [] ) )
plot' (i:is) (t:ts) =
  ( ( (show i) ++ ":" ++ (take t $ repeat '*') ):(plot' is ts) )

plot t = 
  let i = [1..6]
  in
    plot' i t 

ans i = 
  let s = sort i
      t = mktbl 165 0 s
  in
    plot t

main = do
  _ <- getLine -- n
  c <- getContents
  let i = map read $ lines c :: [Float]
      o = ans i
  mapM_ putStrLn o

Measured memory_bytes: 4116
def solve(): # 071C - Make a Rectangle
    n = int(input())
    sides = list(map(int, input().split(" ")))
    check_dual = {}
    possible_sides = []

    for i in sides:
        if i in check_dual:
            check_dual[i] += 1
        else:
            check_dual[i] = 1

    tmp_square = 0
    for k, v in check_dual.items():
        if v >= 4 and k > tmp_square:
            tmp_square = k
            possible_sides.append(k)
        elif v == 2 or v == 3:
            possible_sides.append(k)
        else:
            pass

    possible_sides.sort(reverse=True)
    if tmp_square == 0 and len(possible_sides) < 2:
        print(0)
    elif tmp_square != 0 and len(possible_sides) == 0:
        print(tmp_square ** 2)
    elif tmp_square != 0 and len(possible_sides) == 1:
        print(max(tmp_square ** 2, tmp_square * possible_sides[0]))
    else:
        print(max(tmp_square ** 2, possible_sides[0] * possible_sides[1]))

solve()

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

int main(){
  int N,L;
  string all;
  cin>>N>>L;
  vector<string> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  for(string x:vec){
    all+=x;
  }
  cout<<all<<endl;
    
  
}

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

int main(){
  int a, b;
  int d, r;
  double f;
  cin >> a >> b;
  d = a / b;
  r = a % b;
  f = (1.0*a)/(1.0*b);
  cout << d << " " << r << " ";
  printf("%.8lf\n",f);
  return 0;
}



Measured memory_bytes: 3192
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	n = int(input())
	#b , c = tin()
	#s = input()
	al = lin()
	bl = lin()
	cl = lin()
	al.sort()
	bl.sort()
	cl.sort()
	cl_num=bl[:]
	cl_pos=0
	for i, vb in enumerate(bl):
		while cl_pos <n and cl[cl_pos] <= vb:
			cl_pos += 1
		cl_num[i] = n-cl_pos
		
	cl_nokori=[0]*n
	cl_nokori[-1] = cl_num[-1]
	for i, v in enumerate(cl_num[::-1]):
		if i == 0:
			continue
		cl_nokori[n-i-1] = cl_nokori[n-i]+v
	
	ret = 0
	bl_pos=0
	for va in al:
		while bl_pos < n and va >= bl[bl_pos]:
			bl_pos += 1
		if bl_pos == n:
			break
		ret += cl_nokori[bl_pos]
	print(ret)
		
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)


Measured memory_bytes: 99308
import java.io.BufferedReader
import java.util.*
import kotlin.math.min

fun main() = abc175c()

@OptIn(ExperimentalStdlibApi::class)
fun abc175c() = SimpleFastIOWithToken_abc175c().exec {
    val (x, count, moveDist) = List(3) { readLong() }

    var remainDist = if (x >= 0) x else x * -1
    var remainCount = count

    if (remainDist > moveDist) {
        val moveCount = min(remainDist / moveDist, count)
        remainDist -= moveCount * moveDist
        remainCount -= moveCount
    }

    val answer = if (remainCount % 2 == 0L) remainDist else moveDist - remainDist

    println(answer)
}

// region kokokara template dayo (^o^)
@Suppress("unused", "HasPlatformType", "MemberVisibilityCanBePrivate", "ClassName")
private class SimpleFastIOWithToken_abc175c(private val separator: String = System.lineSeparator()) {
    private val br: BufferedReader = System.`in`.bufferedReader()
    private var st: StringTokenizer = StringTokenizer("")
    private val sb: StringBuilder = StringBuilder()
    private fun prepareNext() = run { if (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) }

    fun readString(): String = run { prepareNext() }.run { st.nextToken() }
    fun readInt(): Int = Integer.valueOf(readString())
    fun readLong(): Long = java.lang.Long.valueOf(readString())

    fun println(): Unit = run { sb.append(separator) }
    fun print(any: Any): Unit = run { sb.append(any) }
    fun println(any: Any): Unit = run { sb.append(any.toString() + separator) }

    fun exec(action: SimpleFastIOWithToken_abc175c.() -> Unit) {
        var t: Throwable? = null
        Thread(null, { action() }, "solve", 128 * 1024 * 1024)
            .apply { setUncaughtExceptionHandler { _, t1 -> t = t1 } }
            .apply { start() }.join()
        t?.let { throw it }
        kotlin.io.print(sb)
    }

    fun readLine(): Nothing = error("readLine is disabled.")
}
// endregion kokomade template dayo (^o^)


Measured memory_bytes: 34576
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[200010];
int dp[200010];
vector<int> V[200010];

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
	}
	REP(i,N){
		V[A[i]].push_back(i);
	}
	dp[0]=1;
	for(int i=1;i<=N;i++){
		dp[i]+=dp[i-1];
		dp[i]%=MOD;
		int c=A[i-1];
		int p=distance(V[c].begin(),lower_bound(V[c].begin(),V[c].end(),i-1));
		if(0<p){
			int k=V[c][p-1];
			if(i-1-k>1){
				dp[i]+=dp[k+1];
				dp[i]%=MOD;
			}
		}
	}
	cout<<dp[N]<<endl;
	return 0;
}


Measured memory_bytes: 14336
import java.util.Scanner;

//Saizo
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t--!=0){
			int n = sc.nextInt();
			int h = sc.nextInt();
			int down = 0;
			int up = 0;
			for(int i=1;i<n;i++){
				int x = sc.nextInt();
				if(h>x){
					down = Math.max(down, h-x);
				}
				else{
					up = Math.max(up, x-h);
				}
				h = x;
			}
			System.out.println(up+" "+down);
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main(void)
{
    int n, m;
    char c[256], a;
    string s;
    while(1) {
        cin >> n;
        if(n == 0) break;
        s = "";
        for(int i=0; i<128; i++) c[i] = i;
        for(int i=0; i<n; i++) {
            cin >> a;
            cin >> c[a];
        }
        cin >> m;
        for(int i=0; i<m; i++) {
            cin >> a;
            s += c[a];
        }
        cout << s << endl;
    }
    return 0;
}

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

#define I inline void 

using namespace std ; 

using ll = long long ; 
using ld = long double ; 
	
const int N = 100 + 7 ; 

// How interesting!

int n; 

int fat[N] , sz[N] ; 

I init(){
	for(int i = 0 ;i < N ;i++)
		fat[i] = i ,sz[i] = 1 ;
}

int fin(int x){
	if(fat[x] != x)
		return fat[x] = fin(fat[x]) ;
	return x ; 
}

I link(int u , int v){
	u = fin(u) ; 
	v = fin(v) ; 
	fat[u] = v ; 
	sz[v] +=sz[u] ; 
	sz[u] = 0 ; 
}

vector<pair<int,int> >arr ; 
map<pair<int,int>,int> mp ;


int main(){
	ios_base::sync_with_stdio(0) ; 
	cin.tie(0) ; 
	//freopen("in.in", "r" , stdin) ;
	cin >> n; 
	for(int i = 0 ;i < n; i++){
		int x , y;
		cin >> x >> y ; 
		arr.push_back({x , y}) ; 
		mp[{x,y}] = i + 1;
	}
	int ans = n ; 
	for(int i = 0 ;i < n; i++){
		for(int j = 0; j< n ;j ++){
			if(i == j) continue ; 
			init() ; 

			int dx = arr[j].first - arr[i].first ; 
			int dy = arr[j].second - arr[i].second ; 
			link(i + 1 , j + 1) ; 

			for(int k = 0 ; k < n ; k ++){
				if(k == i || k == j)
					continue ; 
				int ft = mp[{arr[k].first - dx , arr[k].second - dy}] ; 

				if(ft){
					link(k + 1, ft ); 
				}
			}
			int ret = 0 ; 
			for(int k = 1; k <=n ; k++){
				if(fin(k) == k){
					ret++ ;
				}
			}
			ans = min(ans , ret ) ; 

		}
	}	
	cout<< ans ; 
	return 0 ; 
}

Measured memory_bytes: 7184
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	sc.Split(bufio.ScanWords)
	N, Y := getInt(), getInt()

	for i := 0; i <= N; i++ {
		for j := 0; j <= N; j++ {
			k := N - i - j
			if k < 0 {
				continue
			}
			total := i*10000 + j*5000 + k*1000
			//out(i, j, k, total)
			if total == Y {
				out(i, j, k)
				return
			}
		}
	}
	out(-1, -1, -1)
}


Measured memory_bytes: 640
use whiteread::parse_line;

fn main() {
    let x: usize = parse_line().unwrap();
    let xs = x.to_string();
    let left: usize = xs[0..1].parse().unwrap();
    let ans = left + 9 * (xs.len() - 1);
    let mut maxv: Vec<usize> = vec![left];
    for _ in 0..xs.len() - 1 {
        maxv.push(9);
    }
    let max: usize = maxv.iter().fold(0, |x, y| x * 10 + y);

    if max <= x {
        println!("{}", ans);
    } else {
        println!("{}", ans - 1);
    }
}


Measured memory_bytes: 2164
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    string n;
    cin >> n;
    int sum = 0;
    int cnt = 0;
    int in = n.size();
    if(n < "10"){
        cout << n << '\n';
        return 0;
    }   
    rep(i,in){
        if(n[i] == '9') cnt++;
        sum += 9;
    }   
    sum -= 9;
    if(cnt == in) cout << 9 * in << '\n';
    else if(cnt == in - 1 && n[0] != '9') cout << sum + ((int)(n[0] - '0')) << '\n';
    else cout << sum + ((int)(n[0] - '0') - 1) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n;
    cin >> n;

    unordered_map<int, int> pf;

    for (int i = 2; i <= n; i++) {
        int t = i;
        int j = 2;
        while (j * j <= t) {
            if (t % j == 0) {
                pf[j]++;
                t /= j;
            }
            else {
                j++;
            }
        }
        if (t > 1) pf[t]++;
    }

    int res = 0;

    int c2 = 0, c5 = 0, c14 = 0, c24 = 0, c74 = 0;

    for (auto&& p : pf) {
        if (p.second >= 74) c74++;
        if (p.second >= 24) c24++;
        if (p.second >= 14) c14++;
        if (p.second >= 4) c5++;
        if (p.second >= 2) c2++;
    }

    res += c74;

    res += c24 * (c2 - 1);

    res += c14 * (c5 - 1);

    res += c5 * (c5 - 1) * (c2 - 2) / 2;

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  vector<int> v(3);
  rep(snip_i, 3) cin >> v.at(snip_i);
  sort(v.begin(), v.end());
  if(v.at(2) == v.at(1) + v.at(0)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <map>
using namespace std;
int N; long long x;
char c[10]; map<char, long long> m;
char I[5] = {'M', 'A', 'R', 'C', 'H'};
int main() {
  scanf("%d", &N);
  for(int i = 0; i < N; i++) {
    scanf("%s", c); m[c[0]]++;
  }
  for(int i = 0; i < 3; i++) {
    if(!m[I[i]]) continue;
    for(int j = i+1; j < 4; j++) {
      if(!m[I[j]]) continue;
      for(int k = j+1; k < 5; k++) {
        if(!m[I[k]]) continue;
        x += m[I[i]]*m[I[j]]*m[I[k]];
      }
    }
  }
  printf("%ld", x);
}

Measured memory_bytes: 256
// 11:50
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <tuple>
using namespace std;
typedef long long ll;
#define for1(i,n) for (ll i=0;i<(n);(i)++)
#define for2(i,m,n) for (ll (i)=(m);(i)<(n);(i)++)
#define for3(i,m,n,d) for (ll (i)=(m);(i)<(n);(i)+=(d))
#define INF (1LL << 60)
#define STRING(str) #str
#define DEBUG 1
#if DEBUG
    #define dump(var) dump2(STRING(var), var)
#else
    #define dump(var)
#endif

template <typename T>
void dump2(const string& name, const T& value)
{
    cerr << name << ": " << value << endl;
}
void dump2(const string& name, const tuple<ll,ll,ll>& value)
{
    ll a,b,c;
    tie(a,b,c) = value;
    cerr << name << ": (" << a << ", " << b << ", " << c << ")" << endl;
}

string A[10];
ll H,W;

bool dfs(ll h, ll w)
{
    bool ret = false;
    if (A[h][w] != '#') {
        return false;
    }
    if (h == H-1 && w == W-1) {
        return true;
    }
    if (h < H-1) {
        ret = ret || dfs(h+1, w);
    }
    if (w < W-1) {
        ret = ret || dfs(h, w+1);
    }
    return ret;
}

void solve()
{
    cin >> H >> W;
    ll cnt = 0;
    for1(h,H) {
        string s;
        cin >> s;
        A[h] = s;
        for (char a : s) {
            if (a == '#') {
                ++cnt;
            }
        }
    }
    dump(cnt);
    if (cnt != H + W - 1) {
        cout << "Impossible" << endl;
        return;
    }
    bool result = dfs(0,0);
    if (result) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }
}

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


Measured memory_bytes: 256
#!/usr/bin/perl

sub main() {
  my($A,$B)=split(/ /,<>);
  chomp($B);
  my $ans = prob($A,$B);
  print $ans;
}

sub prob() {
  my($A,$B) = @_;
  if($B==1){return 0}
  if($B-$A <= 0){ return 1}
  for my $i(2..40){
    if($A*$i-($i-1) >= $B){
      return $i;
    }
  }
}

&main();

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

int main() {
    ll N,A,B;
    cin >> N >> A >> B;
    vector<ll> X(N);
    for(int i=0;i<N;i++) cin >> X[i];
    ll tmp=X[0];
    ll ans=0;
    for(int i=1;i<N;i++){
        if(A*(X[i]-tmp)>=B)ans+=B;
        else ans+=A*(X[i]-tmp);
        tmp=X[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
from collections import defaultdict

def prime(k):
    res=[]
    while k>1:
        count=2
        flag=False
        while count*count <= k:
            if k%count==0:
                res.append(count)
                k//=count
                flag=True
                break
            count+=1
        if not(flag):
            res.append(k)
            k=1
    return res

n,p=map(int,input().split())
d=defaultdict(int)
for z in prime(p):
    d[z]+=1

ans=1

for c,x in d.items():
    ans*=c**(x//n)
if n==1:
    print(p)
else:
    print(ans)


Measured memory_bytes: 3316