akhauriyash/Code-Regression huggingface dataset:
# joisinoお姉ちゃんは、
# あるプログラミングコンテストの決勝を控えています。
# このコンテストでは、N 問の問題が用意されており、
# それらには 1～N の番号がついています。
# joisinoお姉ちゃんは、
# 問題 i(1≦i≦N) を解くのにかかる時間が Ti 秒であることを知っています。
# また、このコンテストでは、M 種類のドリンクが提供されており、
# 1～M の番号がついています。
# そして、ドリンク i(1≦i≦M) を飲むと、脳が刺激され、問
# 題 Pi を解くのにかかる時間が Xi 秒になります。
# 他の問題を解くのにかかる時間に変化はありません。
# コンテスタントは、
# コンテスト開始前にいずれかのドリンクを 1 本だけ飲むことができます。
# joisinoお姉ちゃんは、それぞれのドリンクについて、
# それを飲んだ際に、全ての問題を解くのに何秒必要なのかを知りたくなりました。
# 全ての問題を解くのに必要な時間とは、
# それぞれの問題を解くのにかかる時間の合計です。
# あなたの仕事は、
# joisinoお姉ちゃんの代わりにこれを求めるプログラムを作成することです。

# 必要な情報を取得
n = gets.chomp.to_i

t_line = gets.chomp.split

t = Array.new

n.times do |i|
  t << t_line[i].to_i
end

m = gets.chomp.to_i

p = Array.new
x = Array.new

m.times do
  p_x_line = gets.chomp.split
  p << p_x_line[0].to_i
  x << p_x_line[1].to_i
end

# それぞれの場合において、結果を出力
m.times do |i|
  sum = 0
  
  n.times do |j|
    if j == p[i] - 1
      sum += x[i]
    else
      sum += t[j]
    end
  end
  
  puts sum
end

Measured memory_bytes: 3836
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <sstream> //C++
#include <queue> //C++
#include <string> //C++
#include <iostream> //C++
#include <vector> //C++
#include <algorithm> //C++
using namespace std; //C++
#define rep(i, a, n) for (i = (a); i < (n); i++)

//scanf("%d",&x);
//printf("%d",x);
//for(i=0;i<N;i++){  }
//if( == ){  }else{  }
//while( ){  }

/*
int N, i;
int H[100];
scanf("%d", &N);
for (i = 0; i < N; i++) scanf("%s", &H[i]);
*/




int main()
{
	int n, m;
	int i,x;
	cin >> n >> m;

	vector<int> a ;
	double sum = 0;

	rep(i, 0, n) {
		cin >> x;
		a.push_back(x);
		sum += x;
	}

	sort(a.begin(), a.end());

	for (i = 1; i <= m; i++) {
		if (a[n - i] < (double)(sum / (4 * m))) {
			cout << "No";
			return 0;
		}
	}

	cout << "Yes";

	
	
}




Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define ll long long int


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

Measured memory_bytes: 3644
#include <bits/stdc++.h>  
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << " -- "
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll                 long long  
#define p(x)               cout << x << "\n" ; 
#define MOD                100000007
#define pi                 pair<int,int>
#define vi                 vector <int>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"
#define mi                 map <int,int> 
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             x.begin(),x.end() 
using namespace std ; 
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set ; 
const int M = 1e9+7;    
const int N = 5e5;  // limit for array size
int tests() {
  // vector <vector <int>> v(n,vector <int> (m,25));
  int n ; cin >> n ;
  n ++ ; 
  cout << n/2 << '\n' ;
  return 0; 
}
int main(){
    I__O ;  
    int cases = 1 ;
    // cin >> cases ; 
    while(cases--)
      tests(); 
  return 0 ; 
}

Measured memory_bytes: 256
readline = open(0).readline
writelines = open(1, 'w').writelines

N = int(readline())
*A, = map(int, readline().split())

Q = int(readline())
ans = []
for q in range(Q):
    b, e, k = map(int, readline().split())
    ans.append("%d\n" % A[b:e].count(k))
writelines(ans)


Measured memory_bytes: 5828
#include<stdio.h>

#define N 1000000

int A[N], n;

int binSearch(int key) {
  int first = 0, last = n, middle;

  while (first < last) {
    middle = (first + last) / 2;
    if (key == A[middle]) return 1;
    if (key > A[middle]) first = middle+1;
    else if (key < A[middle]) last=middle;
  }

  return 0;
}

int main() {
    int i, q, num, cnt=0;

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

    scanf("%d", &q);

    for (i = 0; i < q; i++) {
      scanf("%d", &num);
      if (binSearch(num)) cnt++;
    }

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



Measured memory_bytes: 2960
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
int n,m;
ll p[1010],a[1010],b[1010],c[1010];

ll f(){
    lol(i,n)p[i]=a[i]+b[i]+c[i];
    sort(p,p+n);
    ll ans=0;
    for(int i=0;i<m;i++){
	ans+=p[n-1-i];
    }
    return ans;
}
void sa(){
    lol(i,n)a[i]=-a[i];
}
void sb(){
    lol(i,n)b[i]=-b[i];
}
void sc(){
    lol(i,n)c[i]=-c[i];
}

int main(){
    cin>>n>>m;
    lol(i,n){
	cin>>a[i]>>b[i]>>c[i];
    }
    ll ans=f();
    sa();
    ans=max(ans,f());
    sa();sb();
    ans=max(ans,f());
    sb();sc();
    ans=max(ans,f());
    sc();
    sa();sb();
    ans=max(ans,f());
    sa();sb();
    sb();sc();
    ans=max(ans,f());
    sb();sc();
    sa();sc();
    ans=max(ans,f());
    sb();
    ans=max(ans,f());
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
N, C, K = map(int, input().split())
T = []
for _ in range(N):
    T.append(int(input()))
T = sorted(T)
first = 0
C_now = C
count = 1
for t in T:
    if C_now == C:
        first = t
        C_now -= 1
    else:
        if t - first <= K:
            C_now -= 1
        else:
            count += 1
            first = t
            C_now = C-1
    if C_now == 0:
        count += 1
        C_now = C
if C_now == C:
    count -= 1
print(count)


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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << (a) << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

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

const int N = 2020;

using mask = bitset<N*N>;

mask dp;

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

    dp.set(0);
    int n, sum = 0; cin >> n;
    forn(_,n) {
        int x; cin >> x;
        sum += x;
        dp |= dp<<x;
    }
    int ans = (sum+1)/2;
    while (!dp[ans]) ++ans;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main
{
    public static void main(String[] df)
    {
        Scanner s=new Scanner(System.in);
        String a=s.next();
        String b=s.next();
        int count=0;
        for(int i=0;i<a.length();i++)
            if(a.charAt(i)!=b.charAt(i))
                count++;
        System.out.println(count);
    }
}

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

typedef long double ld;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef pair<ll,ld> pd;
typedef pair<ld,ll> pdi;

typedef vector <pd> vpi;
typedef pair<pi,ll> pii;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 1010
#define int ll

pi st,e;
int N;

pii points[maxn];

ld cirtocir(pii c1,pii c2){
	int dist = (c1.f.f - c2.f.f)*(c1.f.f - c2.f.f) + (c1.f.s - c2.f.s) * (c1.f.s - c2.f.s);
	
	ld d = sqrt(dist);
	
	return max((ld)0,d - c1.s - c2.s);
}

ld ptop(pi p1,pi p2){
	int dist = (p1.f - p2.f)*(p1.f - p2.f) + (p1.s - p2.s) * (p1.s - p2.s);
	
	return sqrt(dist);
}

ld ptocir(pi p1,pii c2){
	int dist = (p1.f - c2.f.f)*(p1.f - c2.f.f) + (p1.s - c2.f.s) * (p1.s - c2.f.s);
	
	return max((ld)0,(ld)sqrt(dist) - c2.s);
}
	
	
vpi adj[maxn];
ld dist[maxn];

int32_t main(){
	fast;
	
  	cout<<setprecision(10);
	cin>>st.f>>st.s>>e.f>>e.s;
	cin>>N;
	
	FOR(i,1,N){
		cin>>points[i].f.f>>points[i].f.s>>points[i].s;
	}
	
	FOR(i,0,N+1){
		FOR(j,i+1,N+1){
			ld dist;
			if (i == 0 && j == N+1) dist = ptop(st,e);
			else if (i == 0) dist = ptocir(st,points[j]);
			else if (j == N+1) dist = ptocir(e,points[i]);
			else dist = cirtocir(points[i],points[j]);
			
			//cout<<i<<' '<<j<<' '<<dist<<'\n';
			adj[i].pb(pd(j,dist));
			adj[j].pb(pd(i,dist));
		}
	}
	
	priority_queue <pdi,vector <pdi>, greater <pdi> > pq;
	
	pq.push(pdi(0,0));
	
	FOR(i,0,N+1) dist[i] = -1;
	dist[0] = 0;
	
	while (!pq.empty()){
		pdi cur = pq.top(); pq.pop();
		//cout<<cur.f<<' ';
		
		if (dist[cur.s] != cur.f) continue;
		
		aFOR(i,adj[cur.s]){
			if (dist[i.f] == -1 || dist[i.f] > cur.f + i.s){
				dist[i.f] = cur.f + i.s;
				pq.push(pdi(dist[i.f],i.f));
			}
		}
	}
	
	cout<<dist[N+1];
	
	
}



Measured memory_bytes: 42640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
#define int long long
int a[54];
int pasc[54][54];
void cal() {
	pasc[0][0] = 1;
	for (int i = 0; i <= 50; i++) {
		for (int j = 0; j <= i; j++) {
			pasc[i + 1][j] += pasc[i][j];
			pasc[i + 1][j + 1] += pasc[i][j];
		}
	}
	return;
}

signed main() {
	int n,p;
	cin >> n>>p;
	for (int i = 0; i < n; i++)cin >> a[i];
	int e = 0, o = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] & 1)e++;
		else o++;
	}
	cal();
	int ans = 0;
	for (int i = p; i <= e; i += 2) {
		for (int j = 0; j <= o; j += 1) {
			ans += pasc[e][i]*pasc[o][j];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 1000000000
#define INF 3223372036854775807
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
//#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
#define lg length()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invp(a,p)pom(a,p-2,p)
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<Pll,ll> a,pair<Pll,ll> b){
        return a.fi.se>b.fi.se;
}
ll cmp2(pair<ll,ll> a,pair<ll,ll> b){
    if(a.fi!=b.fi)
        return  a.se<b.se;
    else
        return a.se>b.se;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(int argc, char * argv[]){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("big.txt", "r", stdin);
    //freopen("out3.txt", "w", stdout);
    //------------------------------
    string s;cin>>s;
    if(s[s.lg-1]=='s')s+="es";
    else{
        s+='s';
    }
    cout<<s<<endl;
    //------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //------------------------------- 
    return 0;
}
//----------------------------------------------------------------------









































Measured memory_bytes: 3664
#include<iostream>
#include<map>
#include<vector>
using namespace std;
int t[1000000];
int u[1000000],us;
int v[1000000];
int n,a,size;
int main(){
  while(cin>>n&&n){
    size=(n-1)/2;
    for(int i=0;i<1000000;i++)t[i]=u[i]=v[i]=0;
    us=0;

    for(int i=1;i<n;i++){
      a=i*i%n;
      t[a]++;
      if(t[a]==1)u[us++]=a;
    }

    for(int i=0;i<us;i++){
      for(int j=0;j<us;j++){
	if(i==j)continue;
	a=u[i]-u[j];
	if(a<0)a+=n;
	if(a>size)a=n-a;
	v[a]++;
      }
    }
    for(int i=1;i<=size;i++){
      cout<<v[i]<<endl;
    }
  }
  return 0;
}

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

int main() {
    int N;
    string S;
    cin >> N;
    map<string, ll> mp;
    rep(i,N) {
        cin >> S;
        sort(S.begin(), S.end());
        ++mp[S];
    }
    ll ans = 0;
    for (auto x : mp) {
        if (x.second >= 2) {
            ans += x.second * (x.second - 1) / 2;
        }
    }
    cout << ans << endl;
}


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

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;
typedef pair<ll, ll> pll;

const int INF = 100000000;
const ll LINF = 1e18+5;

int main() {
    ll a,b;
    cin >> a >> b;
    if(a<=b){
        rep(i,b) cout << a;
        cout << endl;
    } else {
        rep(i,a) cout << b;
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N=int(input())
a=[0]
a=a+list(map(int,input().split()))
c=[0]*(N+1)

for i in range(N,0,-1):
  kari=a[i]
  for j in range(2,N+1):
    if i*j <= N:
      kari=kari+c[i*j]
    else:
      break
  c[i]=kari%2
M=sum(c)
b = [i for i in range(1,N+1) if c[i] ==1]
b2 = ' '.join(map(str,b))
print(M)
if M>0:
  print(b2)


Measured memory_bytes: 19884
m=[]
for i in 0..9
  m[i]=gets.chomp.to_i
end

for i in 0..(m.length-1)
  j=m.length-1
  while j>=i
    if m[j-1]<=m[j]
      t=m[j]
      m[j]=m[j-1]
      m[j-1]=t
    end
    j-=1
  end
end

for i in 0..2
  print m[i],"\n"
end




Measured memory_bytes: 6872
#include <bits/stdc++.h>
using namespace std;
const int DP_SIZE = 1010;

int dp[DP_SIZE][DP_SIZE];

int main(){
	int N;
	cin >> N;
	
	for(int n=0; n<N; n++){
		for(int i=0; i<DP_SIZE; i++) for(int j=0; j<DP_SIZE; j++) dp[i][j] = 0;
		string S, T;
		cin >> S >> T;
		for(int i=0; i<(int)S.size(); i++){
			for(int j=0; j<(int)T.size(); j++){
				if(S[i] == T[j]) dp[i+1][j+1] = dp[i][j] + 1;
				else dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
			}
		}
		cout << dp[S.size()][T.size()] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 7156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX=100010;
int n,k,a[MAX],idx;
int main(){
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    printf("%d\n",(n-2)/(k-1)+1);
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<iomanip>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int a, b;
    cin >> a >> b;
    ll ans=b;
    for(int i=1; i<a; i++){
        ans *= (b-1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n=gets.to_i
a=gets.split.map(&:to_i).sort
power2=[2]
30.times{power2 << power2.last*2}
power2.reverse!
h=Hash.new(0)
a.each{|v|h[v]+=1}
ans=0
a.reverse.each{|v|
  next if h[v]==0
  power2.each{|k|
    break if k<v
    if h[k-v]>0
      if k-v==v
        if h[k-v]>1
          h[v]-=2
        else
          next
        end
      else
        h[v]-=1
        h[k-v]-=1
      end
      ans+=1
      break
    end
  }
}

puts ans

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

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=a;i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

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

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

using ld=long double;
using cm=complex<ld>;
#define x real()
#define y imag()
const ld eps=1e-8;
const ld PI=acos(ld(-1));
int sgn(ld a){return a<-eps?-1:(a>eps?1:0);}
ld dot(cm a,cm b){return a.x*b.x+a.y*b.y;}
ld crs(cm a,cm b){return a.x*b.y-a.y*b.x;}
ld crs(cm a,cm b,cm c){return crs(b-a,c-a);}
int ccw(cm a,cm b){return sgn(crs(a,b));}
int ccw(cm a,cm b,cm c){return ccw(b-a,c-a);}
auto cmcmp=[](cm a,cm b){
	int s=sgn(a.x-b.x);
	if(s)return s<0;
	else return sgn(a.y-b.y)<0;
};
bool cmeq(cm a,cm b){
	return sgn(a.x-b.x)==0&&sgn(a.y-b.y)==0;
};
//(-pi,0](0,pi]
int argtype(cm a){
	if(sgn(a.y)==0)return a.x<0?1:0;
	return a.y<0?0:1;
}
int argcmp(cm a,cm b){
	int at=argtype(a),bt=argtype(b);
	if(at!=bt)return at<bt?-1:1;
	return -ccw(a,b);
};

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	while(1){
		int n;cin>>n;
		if(n==0)break;
		vc<cm> vs;
		rep(i,n){
			ld a,b;
			char c;
			cin>>a>>c>>b;
			vs.eb(a,b);
		}
		const ld p2=2*PI;
		int ans=1;
		rep(r,n){
			using pl=pair<ld,ld>;
			vc<pl> qs;
			const auto add=[&](ld a,ld b){
				while(sgn(b-a-p2)>0)b-=p2;
				while(sgn(b-a)<0)b+=p2;
				while(sgn(a)<0){
					a+=p2;
					b+=p2;
				}
				if(b>p2){
					qs.eb(a,p2);
					qs.eb(0,b-p2);
				}else{
					qs.eb(a,b);
				}
			};
			rep(i,n)if(i!=r){
				cm a=vs[i]-vs[r];
				dmp(vs[i]);
				dmp(vs[r]);
				dmp(a);
				a/=norm(a);
				a*=2;
				ld len=abs(a);
				if(sgn(len-1)<0)continue;
				chmax(len,1);
				ld c=arg(a),d=acos(1/len);
				dmp(len);
				dmp(c);
				dmp(d);
				add(c-d,c+d);
			}
			vc<ld> pos{0,p2};
			for(auto q:qs){
				pos.pb(q.a);
				pos.pb(q.b);
			}
			sort(all(pos));
			dmp(pos);
			pos.erase(unique(all(pos),cmeq),pos.ed);
			dmp(pos);
			int s=pos.size();
			vi sum(s);
			for(auto q:qs){
				int a=lower_bound(all(pos),q.a-eps)-pos.bg;
				int b=lower_bound(all(pos),q.b-eps)-pos.bg;
				dmp(a);
				dmp(b);
				rng(i,a,b+1)
					sum[i]++;
			}
			rep(i,s)
				chmax(ans,sum[i]+1);
		}
		cout<<ans<<endl;
	}
}



Measured memory_bytes: 3244
import sys

if sys.subversion[0] == "PyPy":
    import io, atexit

    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()
RS = raw_input
RA = lambda x=int: map(x, RS().split())
RN = lambda x=int: x(RS())


def solve():
    curr = 1
    left = k
    vis = {}
    while left > 0:
        curr = a[curr-1]
        left -= 1
        if not curr in vis:
            vis[curr] = k - left
        else:
            loopsize = k - left - vis[curr]
            left %= loopsize
            break
    while left > 0:
        curr = a[curr-1]
        left -= 1
    print(curr)


    return





n, k = RA()
a = RA()
solve()



Measured memory_bytes: 112552
#include <iostream>
#include <algorithm>

using namespace std;

struct Card
{
	int num;
	char design;
	int suffix;
};

int partition(Card A[], int p, int r) {
	int x = A[r].num;
	int i = p;

	for (int j = p; j < r; j++) {
		if (A[j].num <= x) {
			swap(A[i++], A[j]);
		}
	}
	swap(A[i], A[r]);

	return i;
}

void quicksort(Card A[], int p, int r) {
	if (p < r) {
		int q = partition(A, p, r);
		quicksort(A, p, q - 1);
		quicksort(A, q + 1, r);
	}
}

bool stable(Card A[], int n) {
	for (int i = 0; i < n - 1; i++) {
		if (A[i].num == A[i + 1].num && A[i].suffix > A[i + 1].suffix) {
			return false;
		}
	}

	return true;
}

int main() {
	int n;
	cin >> n;
	Card A[n];

	for (int i = 0; i < n; i++) {
		cin >> A[i].design >> A[i].num;
		A[i].suffix = i;
	}

	quicksort(A, 0, n - 1);

	if (stable(A, n)) {
		cout << "Stable";
	}
	else {
		cout << "Not stable";
	}
	cout << endl;

	for (int i = 0; i < n; i++) {
		cout << A[i].design << " " << A[i].num << endl;
	}

	return 0;
}

Measured memory_bytes: 2340
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
    for(int i = 0; i < N; i++) {
      int a = sc.nextInt();
      if(map.containsKey(a)) {
        map.put(a, map.get(a) + 1);
      } else {
        map.put(a, 1);
      }
    }
    boolean flg = true;
    for(int i = 1; i <= N; i++) {
      if(i % 2 == 1) {
        if(map.containsKey(N - i)) {
          if(i == N) {
            if(map.get(N - i) != 1) {
              flg = false;
              break;
            }
          } else {
            if(map.get(N - i) != 2) {
              flg = false;
              break;
            }
          }
        } else {
          flg = false;
          break;
        }
      }
    }
    long ans = 0;
    if(flg) {
      ans = 1;
      int power = N / 2;
      for(int i = 0; i < power; i++) {
        ans = (ans * 2) % 1000000007;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 64116
import numpy as np

n, k = np.array(input().split(" ")).astype(int)
a = np.array(input().split(" ")).astype(int)

num_less = 0
num_more = 0
for i in range(n):
    for j in range(i,n):
        if i==j:
            continue
        if a[i] > a[j]:
            num_less += 1
        elif a[i] < a[j]:
            num_more += 1

num_all = (num_less%(10**9 + 7)) * ((k*(k+1)//2)%(10**9+7))
num_all += (num_more%(10**9 + 7)) * ((k*(k-1)//2)%(10**9+7))
print(num_all%(10**9 + 7))

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

int main(){
    string s; cin >> s;
    sort(s.begin(), s.end());
    if(s[0]==s[1] && s[2]==s[3] && s[2]!=s[1]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=1000000007;
int fact[1111111];
int inv[1111111];

int mpow(int n,int m){
	int ret=1;
	while(m){
		if(m&1)ret=ret*n%mod;
		n=n*n%mod;
		m>>=1;
	}
	return ret;
}

int binom(int n,int k){
	return fact[n]*inv[k]%mod*inv[n-k]%mod;
}

inline void add(int &a,int b){
	a+=b;
	if(a>=mod)a-=mod;
}

int N,M;
string S;

int dp[222222];
int sum[222222];

signed main(){
	fact[0]=1;
	for(int i=1;i<1111111;i++)fact[i]=fact[i-1]*i%mod;
	inv[1111111-1]=mpow(fact[1111111],mod-2);
	for(int i=1111111-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;


	cin>>N>>M;
	cin>>S;

	if(S[0]=='B'){
		rep(i,M){
			if(S[i]=='R')S[i]='B';
			else S[i]='R';
		}
	}

	while(S.size()&&S.back()=='R')S.pop_back();

	if(S.size()==0){
		int ans=0;
		int a=1,b=0;
		rep(i,N){
			int aa=(a+b)%mod;
			int bb=a;
			a=aa;b=bb;
		}
		add(ans,a);

		a=0;b=1;
		rep(i,N){
			int aa=(a+b)%mod;
			int bb=a;
			a=aa;b=bb;
		}
		add(ans,b);
		cout<<ans<<endl;
		return 0;
	}

	if(N%2){
		cout<<0<<endl;
		return 0;
	}

	int ma=1001001001;
	int cur=0;
	while(cur<S.size()){
		int nex=cur;
		while(nex<S.size()&&S[cur]==S[nex])nex++;
		if(S[cur]=='R'){
			int l=nex-cur;
			if(cur==0){
				if(l%2)chmin(ma,l);
				else chmin(ma,l+1);
			}
			else{
				if(l%2)chmin(ma,l);
			}
		}
		cur=nex;
	}

    ma=(ma+1)/2;
    N/=2;

    dp[0]=sum[0]=1;

    int ans=0;
    for(int i=1;i<=N;i++){
        dp[i]=sum[i-1];
        if(i>ma)dp[i]=(dp[i]-sum[i-ma-1]+mod)%mod;
        sum[i]=(sum[i-1]+dp[i])%mod;
    }

    for(int i=1;i<=ma;i++){
        add(ans,dp[N-i]*i%mod*2%mod);
    }
    cout<<ans<<endl;
	return 0;
}


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

int main(){
  long long int p, N;
  long long int count = 0;
  
  scanf("%lld", &N);
  for(long long int i = 1; i <= N; i++){
    scanf("%lld", &p);
    if(p != i) count++;
  }
  
  std::cerr << "Answer:" << std::endl;
  if(count == 0 || count == 2){
    std::cout << "YES" << std::endl;
  }
  else{
    std::cout << "NO" << std::endl;
  }
  
  return 0;
}


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

int main(){
    int s1,count=0;
    cin >> s1;
    if (s1>=100){
        count++;
        s1-=100;
    }
    if (s1>=10){
        count++;
        s1-=10;
    }
    if (s1>=1){
        count++;
    }
    cout << count;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define pb push_back
#define MOD 1000000007
#define INF 1000000000000
#define EPS 0.00000000001
typedef long long ll;

ll power(ll x, ll y) // x^y
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
        {
            res = res * x % MOD;
        }
        x = x * x % MOD;
        y >>= 1;
    }
    return res;
}

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

    ll x;
    cin>>x;
    ll ans=0;
    for(int i=1;i<=40;i++){
        for(int j=2;j<=10;j++){
            if(power(i,j)>x){
                continue;
            }
            ans=max(ans,power(i,j));
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
const int INF = 1e8;

int H, W, A, B;
vector<vector<int>> ans(1010, vector<int>(1010, 9));

int main(){
    cin >> H >> W >> A >> B;

    rep(y,H){
        rep(x,W){
            if((x<A && y<B) || (x>=A && y>=B)) ans[y][x] = 1;
            else ans[y][x] = 0;
        }
    }

    rep(y,H){
        rep(x,W){
            cout << ans[y][x];
        }
        cout << endl;
    }
}


Measured memory_bytes: 5248
package main

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

func main()  {
  sc := bufio.NewScanner(os.Stdin)
  sc.Buffer(make([]byte, 64*1024*1024), 64*1024*1024)
  sc.Scan()
  A := sc.Text()
  sc.Scan()
  B := sc.Text()
  if len(A) > len(B) {
    fmt.Println("GREATER")
    return
  } else if len(A) < len(B) {
    fmt.Println("LESS")
    return
  } else {
    for i := 0; i < len(A) ; i++ {
      if A[i] > B[i] {
        fmt.Println("GREATER")
        return
      } else if A[i] < B[i] {
        fmt.Println("LESS")
        return
      }
    }
    fmt.Println("EQUAL")
    return
  }
}


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

using namespace std;

int c[550],s[550],f[550],e[550];
int main()
{
    int n;
    while(scanf("%d",&n)==1)
    {
        memset(c,0,sizeof(c));
        memset(s,0,sizeof(s));
        memset(f,0,sizeof(f));
        memset(e,0,sizeof(e));
        for(int i=1; i<n; i++)
        {
            scanf("%d%d%d",&c[i],&s[i],&f[i]);
        }
        for(int j=1; j<n; j++)
        {
            int cnt=0;
            for(int i=j; i<n; i++)
            {
                if(cnt>s[i])
                {
                    int sum=s[i];
                    while(1)
                    {
                        sum+=f[i];
                        if(sum>=cnt)
                        {
                            cnt=sum;
                            break;
                        }
                    }
                    cnt+=c[i];
                }
                else
                    cnt=s[i]+c[i];
            }
            e[j]=cnt;
        }
        for(int i=1; i<=n; i++)
            printf("%d\n",e[i]);
    }
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"log"
	"math"
	"sort"
)

func main() {
	log.SetFlags(log.Lshortfile)
	var n int
	fmt.Scan(&n)
	l := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&l[i])
	}
	var cnt int
	sort.Ints(l)
	for i := 0; i < n-2; i++ {
		for j := i + 1; j < n-1; j++ {
			a := l[i]
			b := l[j]
			k := lower_bound(l, a+b)
			cnt += k - j - 1
		}
	}
	fmt.Println(cnt)
}

func lower_bound(a []int, x int) int {
	var ok, ng, mid int
	ng = -1
	ok = len(a)
	for ok-ng > 1 {
		mid = (ok + ng) / 2
		if a[mid] >= x {
			ok = mid
		} else {
			ng = mid
		}
	}
	return ok
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var inf = int(1e9)

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-

N = int(input())

S = []
for i in range(N):
    S.append(input())

count_map = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}

for s in S:
    count_map[s] += 1

for count_key, count in count_map.items():
    print(count_key + " x " + str(count))


Measured memory_bytes: 16252
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
import java.util.function.*;

final class Point{
	int x, y;

	public Point(int x, int y) {
		this.x = x;
		this.y = y;
	}
}

final class Solver {
	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		var points = new Point[N];
		var che = new Point[N];
		for (int i = 0; i < points.length; i++) {
			int x = Integer.parseInt(sc.get());
			int y = Integer.parseInt(sc.get());
			points[i] = new Point(x, y);
			che[i] = new Point(x + y, x - y);
		}

		var sortedByX = Arrays.copyOf(che, N);
		var sortedByY = Arrays.copyOf(che, N);
		Arrays.sort(sortedByX, Comparator.comparingInt(p -> p.x));
		Arrays.sort(sortedByY, Comparator.comparingInt(p -> p.y));
		System.out.println(Math.max(sortedByX[N - 1].x - sortedByX[0].x, sortedByY[N - 1].y - sortedByY[0].y));
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		new Solver().solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

Measured memory_bytes: 69192
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

N, K = map(int, input().split())
S = list(input())
S[K - 1] = S[K - 1].lower()
print(''.join(S))




Measured memory_bytes: 38256
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo 1e18
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vs vector<string>

using namespace std;

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

const long double Pi=acos(-1),e=2.718;
const int N=3e3+10,mod=998244353;
Matrix dp;
vll a;
ll n,k;
ll solve(int i,int sum){
    if(i==n)return (k==sum);
    if(sum > k)return 0;
    ll &ret = dp[i][sum];
    if(ret+1)return ret;
    ret = solve(i+1,sum+a[i]) + 2*solve(i+1,sum);
    ret %= mod;
    return ret;
}
int main ()
{
    FASTIO;
    cin >> n >> k;
    a.resize(n);
    dp.assign(N,vll(N,-1));
    for(auto &x:a)cin >> x;
    cout << solve(0,0) << endl;
    return 0;
}
/**


*/


Measured memory_bytes: 74188
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int shift(int n){
    if(n>0) return (n+2)/4;
    if(n<0) return (n-1)/4;
    return 0;
}

void base_2(int n){
    string base_2="";
    if(n == 0) base_2 = "0";
    while(n != 0){
        if(n%4==0 && shift(n) != 0) base_2 = "00" + base_2;
        if((n%4==1||n%4==-3) && shift(n) != 0) base_2 = "01" + base_2;
        if((n%4==1||n%4==-3) && shift(n) == 0) base_2 = "1" + base_2;
        if(n%4==2||n%4==-2) base_2 = "10" + base_2;
        if(n%4==3||n%4==-1) base_2 = "11" + base_2;
        n = shift(n);
    }
    cout << base_2 << endl;
}

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

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline
import time


_, = map(int,readline().split())
D = 365
*c, = map(int,readline().split())
s = tuple(tuple(map(int,readline().split())) for _ in range(D))

def output(ans):
    for i in ans: print(i+1)

def score(ans,s,c): # ans: 0-indexed としたときのスコアの計算
    last = [-1]*26
    score = 0
    for i, ai in enumerate(ans):
        score += s[i][ai]
        last[ai] = i
        for ci,li in zip(c,last):
            score -= ci*(i-li)
        #print(score) # i日目のスコア
    return score


#ans = [max(range(26),key=lambda x: si[x]) for si in s]
#ans = (list(range(26))*20)[:365]

def first_solution(s,c):
    minus = c[:]
    ans = [0]*365
    for i, si in enumerate(s):
        ans[i] = idx = max(range(26), key=lambda x:si[x]+minus[x])
        for i in range(26):
            minus[i] += c[i]
        minus[idx] = 0
    return ans        


"""
solution = 初期解(ランダム生成や、貪欲法など他の手法で求めたものを利用)
while 時間のある限り:
    solution を(ランダムに)少し変形
    if 変形前より解が悪化:
        solution を変形前の状態に戻す
"""

def main(ans,s,c):
    start = time.time()
    while time.time() - start < 0.5:
        pass
    return ans

#print(score(ans,s,c))
output(main(first_solution(s,c),s,c))







Measured memory_bytes: 9396
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    ll a[n+2];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    ll sum=accumulate(a,a+k,0,[&](ll k,ll x){return k=k+x;});
    cout<<sum<<endl;
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

ll sum(vector<ll> v){
  ll count = 0;
  for(auto a : v){
    count += abs(a);
  }
  return count;
}


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

  ll n;
  cin >> n;
  vector<ll> v(n);
  ll count = 0;
  bool zero = false;
  for (ll i = 0; i < n; i++) {
    cin >> v[i];
    if(v[i] == 0) zero = true;
    if(v[i] < 0){
      count++;
    }
  }
  if(count % 2 == 1 && zero) count++;
  if(count % 2 == 0){
    cout << sum(v) << endl;
    return 0;
  }

  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    a[i] = abs(v[i]);
  }
  ll res = sum(v);
  ll minv = *min_element(ALL(a));

  res -= minv * 2;
  cout << res << endl;


}


Measured memory_bytes: 2560
#include <stdio.h>

int main(void){
    int cuisine[5];
    int cuisine_10[5];
    int min=10;
    int min_index=0;
    int ans=0;
 	for(int i=0; i<5; i++){
      	scanf("%d", &cuisine[i]);
        cuisine_10[i] = ((cuisine[i]-1)/10+1)*10;
        if(min>cuisine[i]%10&&cuisine[i]%10!=0){
            min=cuisine[i]%10;
            min_index=i;
        }
    }
    for(int i=0;i<5;i++){
        if(i!=min_index){
            ans+=cuisine_10[i];
        }
    }
    ans+=cuisine[min_index];
    printf("%d",ans);
}



Measured memory_bytes: 128
package main

import (
	"fmt"
	"io"
	"os"
	"regexp"
)

func solve(w io.Writer, r io.Reader) {
	var S string
	fmt.Scan(&S)
	amb := regexp.MustCompile("^(0[1-9]|1[0-2])(0[1-9]|1[0-2])$")
	mmyy := regexp.MustCompile("^(0[1-9]|1[0-2])")
	yymm := regexp.MustCompile("(0[1-9]|1[0-2])$")

	var ans string
	if amb.MatchString(S) {
		ans = "AMBIGUOUS"
	} else if mmyy.MatchString(S) {
		ans = "MMYY"
	} else if yymm.MatchString(S) {
		ans = "YYMM"
	} else {
		ans = "NA"
	}
	
	fmt.Fprintln(w, ans)
}

func main() {
	solve(os.Stdout, os.Stdin)
}

Measured memory_bytes: 768
#ifdef INPUT
#include <sstream>
stringstream input(R"(
2
80 70
)");
#define cin input
#endif

#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <numeric>

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

vector<int> s;

int rt(int a)
{
	return s[a] == a ? a : s[a] = rt(s[a]);
};

void un(int a, int b)
{
	a = rt(a);
	b = rt(b);
	if (a != b)
	{
		if (a > b)
			swap(a, b);
		s[b] = a;
	}
};

struct Counter {
    int* out;
	int dum;

    explicit Counter(int* where) : out(where) {
        // Handled in initializer list
    }

    /* Either make this a template, or make the class itself a template. */
    void operator++() {
        ++ *out;
    }

    int& operator*() {
        return dum;
    }
};

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

	vector<int> p(n);
	for (auto& x : p)
	{
		cin >> x;
		--x;
	}
	
	s.assign(n, 0);
	iota(s.begin(), s.end(), 0);

	REP (i, m)
	{
		int a, b;
		cin >> a >> b;
		un(--a, --b);
	}

	map<int, pair<set<int>, set<int>>> r;

	REP (i, n)
	{
		int d = rt(i);
		r[d].first.insert(i);
		r[d].second.insert(p[i]);
	}

	int c = 0;
	for (const auto& e : r)
		set_intersection(e.second.first.begin(), e.second.first.end(), e.second.second.begin(), e.second.second.end(), Counter(&c));

	cout << c << endl;

	return 0;
}


Measured memory_bytes: 24448
# PDFで解法が4つも書いてある

x,y,z,k =  list(map(int, input().split() ))

aa = list(map(int, input().split() ))
bb = list(map(int, input().split() ))
cc = list(map(int, input().split() ))

aa.sort(reverse = True)
bb.sort(reverse = True)
cc.sort(reverse = True)
# 降順＝大きい方から順

ab = [i + j for i in aa for j in bb]
# appendを使うと遅いので、二重の内包記法を使う 
# 外側でaaの要素、内側でbbの要素が動いていく。今回はどっちでも良いけど。
ab.sort(reverse = True)

max_len = min(k, len(ab))
abc = [i + j for i in ab[:max_len] for j in cc]
abc.sort(reverse = True)

for i in range(k):
	print(abc[i])


Measured memory_bytes: 207728
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
//using Debug;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        //Solve();
        WriteLine(Solve());
    }
    static string Solve()
    {
        var k = Input.num;
        var ar = Input.arL.Reverse().ToArray();
        if (ar[0] != 2) return "-1";
        var min = 2L;
        var max = 2L;
        for(var i = 0; i < k; i++)
        {
            var le = (min + ar[i] - 1) / ar[i]*ar[i];
            var ri = max / ar[i] * ar[i];
            if (le<min||max<le||ri<min||max<ri) return "-1";
            min = le;
            max = ri + ar[i] - 1;
        }
        return $"{min} {max}";
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


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

typedef long long LL;
typedef pair<int, int> II;

const int MAXN = (int) 2e5 + 10;
int n, k, a[MAXN];

int main() {
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);

    priority_queue<int> pq;
    sort(a + 1, a + 1 + n);
    for (int i = 1; i <= n; ++i) {
        int j = i;
        while (j < n && a[j + 1] == a[i]) j++;
        pq.push(-(j - i + 1));
        i = j;
    }

    int ans = 0;
    while ((int) pq.size() > k) {
        ans -= pq.top();
        pq.pop();
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 2168
#include<stdio.h>
int main() {
	long long int h,w,k,memo,result;
	long long int two[10] = { 1,2,3,5,8,13,21,34,55,256,512 };
	scanf("%lld%lld%lld", &h, &w, &k);
	long long int s[105][10] = {};
	s[h + 1][k] = 1;
	for (int i = h; i >= 1; i--) {
		for (int j = 1; j <= w; j++) {
			memo = 0;
			if (j == 1 || j == w) {
				memo += two[w - 2] * s[i + 1][j];
			}
			else {
				memo += (two[j-2]*two[w-j-1]) * s[i + 1][j];
			}

			if (j == 1||j==w-1) {
				memo += two[w - 3] * s[i + 1][j+1];
			}
			else if (j == w) {

			}
			else
			{
				memo += (two[j-2]*two[w - j-2]) * s[i + 1][j+1];
			}

			if (j == 1) {
				
			}
			else if (j == w||j==2) {
				memo += two[w - 3] * s[i + 1][j - 1];
			}
			else
			{
				memo += (two[j - 3] * two[w - j - 1]) * s[i + 1][j-1];
			}
			memo %= 1000000007;
			s[i][j] = memo;
		}
	}
	printf("%lld", s[1][1]);

}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{
    int N,K,X,Y;
    cin >> N >> K >> X >> Y;

    if(N>K)
    {
        int yDay = N-K;
        cout << K*X + yDay*Y << endl;
    }
    else
    {
        cout << N*X << endl;
    }
    
    return 0;
}

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

vector<ll> lun;

void dfs(ll x) {
	string t = to_string(x);
	if(t.size() > 10)
		return;

	lun.push_back(x);

	for(ll i=t.at(t.size()-1)-'0'-1; i<=t.at(t.size()-1)-'0'+1; ++i)
		if(i>=0 && i<=9)
			dfs(x*10+i);
}


int main() {
	ll K,c=0;
	cin >> K;

	for(ll i=1; i<=9; ++i)
		dfs(i);
	sort(lun.begin(), lun.end());

	cout << lun.at(K-1) << endl;
}

Measured memory_bytes: 2420
#include<iostream>
using namespace std;
int main()
{
	int w,n,a,b,c;
	char null;
	cin>>w>>n;
	int l[w];
	for(int k=0;k<w;k++)
	{
		l[k]=k+1;
	}
	for(int i=0;i<n;i++)
	{
	cin>>a>>null>>b;
	c=l[a-1];
	l[a-1]=l[b-1];
	l[b-1]=c;
    }
    for(int j=0;j<w;j++)
    {
    cout<<l[j]<<endl;
	}
return 0;
}

Measured memory_bytes: 2960
// #include C {
#include<cstring>
#include<cassert>
#include<cstdio>
#include<cctype>
#include<cmath>
// }

// #include C++ {
#include<functional>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<map>
#include<set>
// }

using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef DEBUG_MODE

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 100005
#define MAX_M 100005
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

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

/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
//  WF("output.txt");
	DF("err.txt");
	
	int N;
	scanf("%d", &N);
	int maxxA = 0, minnB = 0;
	for (int i = 0; i < N; i++) {
		int A, B;
		scanf("%d %d", &A, &B);
		if (A > maxxA) {
			maxxA = A;
			minnB = B;
		}
	}
	printf("%d\n", maxxA + minnB);
}

Measured memory_bytes: 256