akhauriyash/Code-Regression huggingface dataset:
/// However long the night,
///     The dawn will break
/// ICPC next year

#include<bits/stdc++.h>
using namespace std ;
const int N = 1e5+5 ;

string str ;
int ans[N] ;
int main(){
    cin >> str ;
    int s=0 ,e = str.size()-1 ;
    while(s<str.size() && str[s]=='L'){
        ++ans[0] ;
        ++s ;
    }
    while(e>=0 && str[e]=='R'){
        ++ans[str.size()-1] ;
        --e ;
    }
    while(s<=e){
        int cntR=0 ,cntL=0 ;
        int to = s ,a=-1 ,b=-1 ;
        while(to<=e && str[to]=='R') ++cntR ,a = to++ ;
        b = a+1 ;
        while(to<=e && str[to]=='L') ++cntL ,to++ ;

        if(cntR>=cntL) ans[a] = (cntR+cntL+1)/2 ,ans[b] = cntR + cntL - ans[a] ;
        else ans[a] = (cntR+cntL)/2 ,ans[b] = cntR + cntL - ans[a] ;

        int stps = max(cntR ,cntL)-1 ;
        if(stps%2) swap(ans[a],ans[b]);

        s = to ;
    }
    for(int i=0;i<str.size();++i)printf("%d ",ans[i]);
    return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const LL mod = 1e9 + 7;
int N;
char S1[55],S2[55];
LL ans;

int main(){
	scanf("%d" , &N);
	scanf(" %s" , S1);
	scanf(" %s" , S2);
	int d = 0;
	ans = 1;
	repp(i,0,N){
		if(S1[i] == S2[i]){
			if(d == 0){
				(ans *= 3) %= mod;
			} else if(d == 1){
				(ans *= 2) %= mod;
			}
			d = 1;
		} else {
			if(d == 0){
				(ans *= 6) %= mod;
			} else if(d == 1){
				(ans *= 2) %= mod;
			} else {
				(ans *= 3) %= mod;
			}
			d = 2;
			++i;
		}
	}
	printf("%lld\n" , ans);
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
vector<int> v[100010];
vector<int> ans;
bool used[100010];
int c=0;
void dfs(){
    int now=ans.back();
    //cout<<now<<" "<<c<<endl;
    rep(i,0,v[now].size()){
        int ne=v[now][i];
        if(used[ne])continue;
        used[ne]=true;
        ans.push_back(ne);
        dfs();
        break;
    }
    if(c==0){
        reverse(ans.begin(),ans.end());
        c=1;
        now=ans.back();
        rep(i,0,v[now].size()){
            int ne=v[now][i];
            if(used[ne])continue;
            used[ne]=true;
            ans.push_back(ne);
            dfs();
            break;
        }
    }
}
int main(){
    int n,m;cin>>n>>m;
    
    rep(i,0,m){
        int a,b;cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
        
    }
    ans.push_back(1);
    
    fill(used,used+n+1,false);
    used[1]=true;
    dfs();
    cout<<ans.size()<<endl;
    rep(i,0,ans.size()-1)cout<<ans[i]<<" ";
    cout<<ans.back()<<endl;
}


Measured memory_bytes: 9976
#include <bits/stdc++.h>
#define INF 100000000
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)


int main(){
    int a, b, i = 0;
    cin >> a >> b;
    if ((b - 1) % (a - 1)){
        i += 1;
    }
    cout << (b - 1) / (a - 1) + i << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n;
    cin >> n;
    int ans = 111;
    while (ans < n) {
        ans += 111;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
   
    new Main().run();
  }

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      String[] lines = in.readLine().split(" ");
      int n = Integer.parseInt(lines[0]);
      int k = Integer.parseInt(lines[1]);

      String line = in.readLine();
      int offset=0,next=0;
      char regx = ' ';
      int[] ax = new int[n];
      for(int i=0; i<n; i++) {
        if((next = line.indexOf(regx,offset)) == -1)
          next = line.length();
        ax[i] = Integer.parseInt(line.substring(offset, next));
        offset = next + 1;
      }

      int min = Integer.MAX_VALUE;
      for(int i=0; i<n-k+1; i++) {
        int sumF = Math.abs(ax[i]) + Math.abs(ax[i+k-1] - ax[i]);
        int sumB = Math.abs(ax[i+k-1] + Math.abs(ax[i+k-1]) - ax[i]);
        int sum = Math.min(sumF, sumB);
        if(i == 0 || sum < min) min = sum;
      }

      System.out.println(min);
    }
    catch(IOException e) {
      System.out.println(e);
    }
  }
}

Measured memory_bytes: 34588
# coding: utf-8
# Your code here!

while True:
    S = input()
    if S == "#":
        break
    
    status = "A"
    
    for i in range(len(S)):
        if status == "A":
            if S[i] == "0":
                status = "X"
            else:
                status = "Y"
        elif status == "B":
            if S[i] == "0":
                status = "Y"
            else:
                status = "X"
        elif status == "X":
            if S[i] == "0":
                status = "NA"
            else:
                status = "Z"
        elif status == "Y":
            if S[i] == "0":
                status = "X"
            else:
                status = "NA"
        elif status == "Z":
            if S[i] == "0":
                status = "W"
            else:
                status = "B"
        elif status == "W":
            if S[i] == "0":
                status = "B"
            else:
                status = "Y"
        else:
            status = "NA"
    
    if status == "B":
        print("Yes")
    else:
        print("No")
    



Measured memory_bytes: 5564
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define int long long
using namespace std;

int n, m;
vector<int> yaku;

signed main() {
	int i;
	
	cin >> n >> m;
	for (i = 1; i * i <= m; i++) {
		if (m % i == 0) {
			yaku.push_back(i);
			if (m / i != i) yaku.push_back(m / i);
		}
	}
	
	int ans = 1;
	for (i = 0; i < yaku.size(); i++) {
		if (m >= n * yaku[i]) {
			ans = max(ans, yaku[i]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
 
void solve(){
    int n;
    cin >> n;
    
    string s, t;
    cin >> s >> t;
    string ans = "";
    int is = 0, it = 0;
    for(int i = 0; i <2 * n; ++i) {
        if(i % 2 == 0){
            ans += s[is ++];
        }
        else{
            ans += t[it ++];
        }
    }
    cout << ans;
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s; 
int main(){
	cin>>s;
	if(s.find('F')==std::string::npos){printf("No");return 0;}
	if(s.find('C')<s.rfind('F')) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var n = int.Parse(inputs[0]);
            var l = int.Parse(inputs[1]);
            var result = 0;

            var min = l;
            for (var i = 0; i < n; i++)
            {
                result += i + l;
                min = Math.Abs(min) < Math.Abs(i + l) ? min : i + l;
            }

            Console.WriteLine(result - min);
        }
    }
}


Measured memory_bytes: 27528
#include <iostream>
#include <cstdio>
#include <map>

using namespace std;

int main() {
    int n, m;
    map<int, int> mp;

    bool ok;

    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        mp[a]++;
    }
    cin >> m;
    ok = true;
    for (int i = 0; i < m; i++) {
        int b;
        cin >> b;
        if (mp.count(b) && mp[b] > 0) {
            mp[b]--;
        } else {
            ok = false;
        }
    }

    if (ok) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 9600
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


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;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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


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

	ll res = n * (n - 1) / 2;
	
	cout << res << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
int main()
{
    ll n, ans = 0;
    cin >> n;
    map<ll, ll> mp;
    for(ll i=1;i<=n;i++)
    {
        ll x;
        cin >> x;
 
        ans += mp[i-x];
 
        mp[i+x]++;
    }
 
    cout << ans;
 
    return 0;
}


Measured memory_bytes: 26136
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back()
#define INF 1000000000

using namespace std;

const int mod = 1e9+7;

int main(){
	
	int x, y;
	
	cin>>x>>y;
	
	for(int i = 0; i <= x; i++){
		if(i*2+4*(x-i) == y){
			cout<<"Yes\n";
			return 0;
		}
	}
	cout<<"No\n";
}


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

typedef unsigned short     ushort;
typedef unsigned int       uint;

inline ushort myGCD( ushort m, ushort n )
{
    while ( n > 0 )
    {
        ushort tmp = m % n;
        m = n;
        n = tmp;
    }
    return m;
}

typedef std::vector<uint> GcdElem;

GcdElem CalcGcdElem( const GcdElem & elem1, const GcdElem & elem2 )
{
    GcdElem result( elem1.size(),0 );
    
    for ( int i = 1; i <= elem1.size(); ++i )
    {
        //result[ myGCD(i,i) -1 ] += elem1[i-1] * elem2[i-1];
        for ( int j = 1; j <= elem2.size(); ++j )
        {
            result[ myGCD(i,j) -1 ] += elem1[i-1] * elem2[j-1];
        }
    }
    
    return result;
}

 
int main( void )
{
    ushort N;
    std::cin >> N;
    
    GcdElem a(N,1), b(N,1), c(N,1);
    GcdElem resultElem = CalcGcdElem( a, CalcGcdElem(b,c) );
    //GcdElem resultElem = CalcGcdElem( b,c );
    
    uint result = 0;
    for ( ushort i = 0; i < resultElem.size(); ++i )
    {
        result += resultElem[i] * ( i+1 );
    }
    std::cout << result << std::endl;
    //std::cout << resultElem[0] << std::endl;
    return 0;
}

Measured memory_bytes: 3588
import java.util.*;

public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		for(;;){
			String input = scan.next();
			if(input.equals("-")){
				break;
			}
			int m = scan.nextInt();
			int len = input.length();
			String output = input;
			List<Character> listC = new LinkedList<Character>();
			for(int i = 0; i < len; i++){
				char c = output.charAt(i);
				listC.add(c);
			}
			for(int i = 0; i < m; i++){
				int h = scan.nextInt();
				for(int j = 0; j < h; j++){
					char c = listC.get(0);
					listC.remove(0);
					listC.add(c);
				}
			}
			for(char c : listC){
				System.out.print(c);
			}
			System.out.println("");
		}
	}
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    vi a(n);
    int m = sqrt(n);
    vi b((n+m-1)/m);

    auto add = [&](int s, int t, int x) {
        if(s/m == t/m) {
            for(int i = s; i != t; i++) {
                a[i] += x;
            }
        } else {
            for(; s%m; a[s++] += x);
            for(; t%m; a[--t] += x);
            for(s /= m, t /= m; s != t; b[s++] += x);
        }
    };
    auto get = [&](int i) {
        int res = 0;
        res += a[i];
        res += b[i/m];
        return res;
    };

    while(q--) {
        int t;
        cin >> t;
        if(t) {
            int i;
            cin >> i;
            cout << get(i-1) << '\n';
        } else {
            int s, t, x;
            cin >> s >> t >> x;
            add(s-1, t, x);
        }
    }
}


Measured memory_bytes: 3344
n = int(input())
s = input()

ans = 0
for i in range(1, n):
    cnt = 0
    for j in range(n-i):
        if s[i+j] == s[j]:
            cnt += 1
        else:
            ans = max(ans, min(cnt, i))
            cnt = 0
    ans = max(ans, min(cnt, i))

print(ans)


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

const int mod = 1000000007;

int main() {
    string a;
    cin >> a;
    int n = a.length();
    
    int cnt[26];
    for (int i = 0; i < 26; i++) cnt[i] = 0;
    for (int i = 0; i < n; i++) {
        int c = a[i] - 'a';
        cnt[c]++;
    }

    ll ans = 0;
    for (int i = 0; i < 26; i++) {
        ans += (ll)cnt[i] * (n - cnt[i]);
    }

    ans /= 2;
    ans++;

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

Measured memory_bytes: 640
def gcd(x,y):
    while y:
        x,y = y , x % y 
    return x

def gcd2(array):
    t = array[0]
    for i in array:
        t = gcd(t,i)
    return t

n=input()
a=list(map(int,input().split()))
print(gcd2(a))

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vecll = vector<long long>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(n) (n).begin(), (n).end()

int main()
{
    ll n, k, mask=0, b;
    cin >> n >> k;
    rep(i, k)
    {
        cin >> b;
        mask |= (1LL << b);
    }

    for (ll bit=0; bit < (1LL<<n); bit++)
    {
        vector<ll> S;
        bool flag = false;
        for (ll i=0; i < n; i++)
        {
            if (bit & (1LL << i))
            {
                S.push_back(i);
            }
        }

        if ((bit & mask)==mask) flag=true;

        if (flag)
        {
            cout << bit << ":";
            for (ll i=0;i<(ll)(S.size());i++)
            {
                cout << " " << S[i];
            }
            cout << endl;
        }
    }

}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i, n)  for(ll i = 0; i < (n); ++i)
#define rep1(i,n)  for(ll i = 1;i <= (n); ++i)
#define pb push_back
#define M 1000000007
unordered_map<ll,ll>mp;

int main()
{
    fastIO
	ll n;
  cin>>n;
  vector<ll>v;
  rep(i,n)
  {
    ll e;cin>>e;
    v.pb(e);
  }
  ll m=v[0];
  ll res=0;
  for(ll i=1;i<n;i++)
  {
    	if(v[i]<m)
          res+=m-v[i];
    	m=max(m,v[i]);
  }
  cout<<res;
	return 0;
}


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

int main(){
  int A, B;
  cin >>A>>B;
  int c, d, e, f;
  if (100*A%8==0){
      c=100*A/8;
  }
  else{
      c=100*A/8+1;
  }
  if (100*(A+1)%8==0){
      d=100*(A+1)/8-1;
  }
  else{
      d=100*(A+1)/8;
  }
  if (10*B%1==0){
      e=10*B/1;
  }
  else{
      e=10*B/1+1;
  }
  if (10*(B+1)%1==0){
      f=10*(B+1)/1-1;
  }
  else{
      f=10*(B+1)/1;
  }
  if(d<e||f<c){
      cout<<-1<<endl;
  }
  else{
      if(e<=c&&c<=f){
          cout<<c<<endl;
      }
      else{
          cout<<e<<endl;
      }
  }

}

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

int main(){
  ll n;
  cin >> n;
  if(n%2 == 1){
    cout << 0 << endl;
    return 0;
  }
  ll ans = 0;
  n /= 10;
  ans += n;
  while(n > 0){
    n /= 5;
    ans += n;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  while(cin >> n >> m, n | m) {
    vector<int> sum = {0};
    for(int i = 0; i < n; ++i) {
      int K;
      cin >> K;
      sum.push_back((sum.back() + (K % m)) % m);
    }
    int answer = 0;
    set<int> used = {m};
    for(auto j: sum) {
      answer = max(answer, (j - *used.lower_bound(j) + m + m) % m);
      used.insert(j);
      used.insert(j + m);
    }
    cout << answer << endl;
  }
}

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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;

// Data structures.
struct Point {
    double x, y;
    Point(double x = 0, double y = 0) : x(x), y(y) {}
    Point(const Point& p) : x(p.x), y(p.y) {}

    Point operator+(const Point& p) const { return Point(x + p.x, y + p.y); }
    Point operator-(const Point& p) const { return Point(x - p.x, y - p.y); }
    Point operator*(double k) const { return Point(k * x, k * y); }
    Point operator/(double k) const { return Point(x / k, y / k); }

    bool operator<(const Point& p) const { return x != p.x ? x < p.x : y < p.y; }
    bool operator==(const Point& p) const { return fabs(x - p.x) < 1e-10 && fabs(y - p.y) < 1e-10; }

    static double norm(const Point& p) { return sqrt(p.x * p.x + p.y * p.y); }
    static double dot(const Point& p1, const Point& p2) { return p1.x * p2.x + p1.y * p2.y; }
    static double cross(const Point& p1, const Point& p2) { return p1.x * p2.y - p1.y * p2.x; }
};

struct Segment {
    Point s, t;
};
typedef Segment Line;

class Circle {
public:
    Point c;
    double r;
    Circle(double cx = 0.0, double cy = 0.0, double r = 0.0) : c(cx, cy), r(r) {}
    Circle(Point c = Point(), double r = 0.0) : c(c), r(r) {}
};

double distance(const Line& l, const Point& p) {
    return abs(Point::cross(l.t - l.s, p - l.s)) / Point::norm(l.t - l.s);
}

Point norm_vector(const Point& v) {
    double norm = Point::norm(v);
    return Point(v.y / norm, -v.x / norm);
}

Point project(const Point& p1, const Point& p2, const Point& p) {
    double dot = Point::dot(p2 - p1, p - p1);
    double norm = Point::norm(p2 - p1);
    return Point(p2 - p1) * dot / (norm * norm) + p1;
}

vector<Point> cross_point(const Circle& c, const Line& l) {
    vector<Point> ans;

    double d = distance(l, c.c);
    Point vec = Point(l.t - l.s) / Point::norm(l.t - l.s);
    Point mid = project(l.s, l.t, c.c);
    double norm = sqrt(c.r * c.r - d * d);

    ans.push_back(mid + vec * norm);
    ans.push_back(mid - vec * norm);

    return ans;
}

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

    double cx, cy, r;
    cin >> cx >> cy >> r;
    Circle c(cx, cy, r);

    int q;
    cin >> q;

    rep(i, 0, q) {
        Line l;
        cin >> l.s.x >> l.s.y >> l.t.x >> l.t.y;
        vector<Point> ps = cross_point(c, l);
        sort(ps.begin(), ps.end());
        printf("%.10f %.10f %.10f %.10f\n", ps[0].x, ps[0].y, ps[1].x, ps[1].y);
    }

    return 0;
}


Measured memory_bytes: 3184
/*----------------by syr----------------*/
/*
  -----  -----  -----
  |   |  |---|    _/
  |   |  | \_    /
  -----  |   \  -----

  |---\  \   /  |\  /|
  |   |   \_/   | \/ |
  |   |   / \   |    |
  |---/  /   \  |    |
*/
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cstring>
#include<cstdlib>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<limits>
#include<list>
#include<map>
#include<math.h>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<sstream>
#include<string>
#include<time.h>
#include<utility>
#include<vector>

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i,x,y) for(int i=(x);i<(y);++i)
#define REP(i,x,y) for(int i=(x);i<=(y);++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ldb;
typedef pair<int,int> pii;

const int INF=1e9+7;
const int maxn=2e5+5;

int n,cnt;
char s[maxn];
ll ans;

int main(){
	scanf("%s",s);
	n=strlen(s);
	FOR(i,0,n) if(s[i]=='W') ans+=cnt; else ++cnt;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((a) >> (b)) & 1
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

map<int, int> res; // map[i]:=ｎを素因数分解したときiは何乗か。

//Ｏ(√n)
//素因数分解
void prime_factor(int n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      while (n % i == 0) {
        res[i]++;
        n /= i;
      }
    }
  }
  if (n != 1) {
    res[n]++;
  }
}

signed main() {
  int N;
  cin >> N;

  //Ｎ！の各要素を素因数分解し、足し合わせる。
  for (int i = 2; i <= N; i++) {
    prime_factor(i);
  }

  int ans = 0;

  for (int i = 2; i <= N; i++) {
    for (int j = i + 1; j <= N; j++) {
      for (int k = 2; k <= N; k++) {
        if (i == j || j == k || k == i) continue;
        if (res[i] >= 4 && res[j] >= 4 && res[k] >= 2) ans++;
      }
    }
  }

  for (int i = 2; i <= N; i++) {
    for (int j = 2; j <= N; j++) {
      if (i == j) continue;
      if (res[i] >= 14 && res[j] >= 4) ans++;
      if (res[i] >= 24 && res[j] >= 2) ans++;
    }
  }

  for (int i = 2; i <= N; i++) {
    if (res[i] >= 74) ans++;
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

struct Process {
    string name;
    int time;
};

class Queue {
  public:
    Queue(int size = 100005);
    void enqueue(Process);
    Process dequeue();
    bool is_empty();

  private:
    Queue(const Queue &src);
    Process *process;
    int size_;
    int head_;
    int tail_;
};

Queue::Queue(int size) : size_{size} {
    process = new Process[size_];
    head_ = tail_ = 0;
}

void Queue::enqueue(Process p) {
    process[tail_] = p;
    tail_ = (tail_ + 1) % size_;
}

Process Queue::dequeue() {
    Process p = process[head_];
    head_ = (head_ + 1) % size_;
    return p;
}

bool Queue::is_empty() {
    return head_ == tail_;
}

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

    int n;
    int time;
    cin >> n >> time;

    // preprocess
    Queue CPU;
    while (n--) {
        string name;
        int time;
        cin >> name >> time;
        Process p;
        p.name = name;
        p.time = time;
        CPU.enqueue(p);
    }

    // process
    int total_time = 0;
    while (!CPU.is_empty()) {
        Process temp = CPU.dequeue();
        if (temp.time - time > 0) {
            temp.time -= time;
            total_time += time;
            CPU.enqueue(temp);
        } else {
            total_time += temp.time;
            cout << temp.name << " " << total_time << endl;
        }
    }
}



Measured memory_bytes: 7048
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
#include <ctime>
#include <numeric>
using namespace std;
static const double EPS = 1e-8;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const double pi=acos(-1);
int dx[]={0,1,0,-1,1,1,-1,-1},dy[]={1,0,-1,0,1,-1,1,-1};


int n,m;
int in[10000];
vector<pair<PI,int > > ti;
void solve(){
  rep(i,n)cin>>in[i];
  ti.clear();
  ti.pb(mp(mp(m/in[0]*in[0],in[0]),1));

  PI mit=ti[0].F;
  PI mat=ti[0].F;
  
  for(int i=1;i<n;++i){
    bool ok=false;
    for(int k=0;k<=m;k+=in[i]){
      if(k<mit.F)continue;
      if(k>mit.F){
        ok=true;
        ti.pb(mp(mp(k,in[i]),i+1));
        break;
      }
      if(k==mit.F && in[i]>mit.S){
        ok=true;
        ti.pb(mp(mp(k,in[i]),i+1));
        break;
      }

      if(k==mit.F && in[i]==mit.S && i!=n-1){
        ok=true;
        ti.pb(mp(mp(k,in[i]),i+1));
        break;        
      }
    }
    
    if(ok){
      mit=min(mit,ti.back().F);
      continue;
    }
    ti.pb(mp(mp(m/in[i]*in[i],in[i]),i+1));
    mit=min(mit,ti.back().F);    
  }
  sort(ALL(ti));

  if(SZ(ti)>1 && ti[0].F==ti[1].F)cout<<n<<endl;
  else if(SZ(ti))cout<<ti[0].S<<endl;
  else for(;;);
}

main(){
  while(cin>>n>>m,n)solve();
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <deque>

struct BFS
{
  size_t N;
  size_t M;
  std::vector<std::vector<size_t>> Graph;
  std::vector<size_t> dist;
  std::vector<std::vector<size_t>> distMap;
  std::deque<size_t> que;
  std::vector<size_t> arrow;

  BFS()
  {
    std::cin>>N;
    std::cin>>M;

    Graph.assign(N,std::vector<size_t>());
    for(size_t i=0;i!=M;i++)
    {
      size_t j1,j2;
      std::cin>>j1>>j2;
      j1--;
      j2--;
      Graph[j1].push_back(j2);
      Graph[j2].push_back(j1);
    }

    dist.assign(N,-1);
    distMap.assign(N,std::vector<size_t>());
    arrow.assign(N,-1);
  }

  void find(size_t pos)
  {
    dist[pos]=0;
    distMap[dist[pos]].push_back(pos);
    que.push_back(pos);

    while(que.empty()==false)
    {
      pos=que.front();
      que.pop_front();

      for(size_t i=0;i!=Graph[pos].size();i++)
      {
        size_t nextPos=Graph[pos][i];

        if(dist[nextPos]!=-1)
          continue;

        dist[nextPos]=dist[pos]+1;
        distMap[dist[nextPos]].push_back(nextPos);
        que.push_back(nextPos);
        arrow[nextPos]=pos;
      }
    }
  }
};

int main()
{  
  BFS f;
  f.find(0);

  for(size_t i=1;i!=f.arrow.size();i++)
  {
    if(f.arrow[i]==-1)
    {
      std::cout<<"No"<<std::endl;
      return 0;
    }
  }

  std::cout<<"Yes"<<std::endl;
  for(size_t i=1;i!=f.arrow.size();i++)
  {
    std::cout<<f.arrow[i]+1<<std::endl;
  }

  return 0;
}

Measured memory_bytes: 17064
N = int(input())

S = str()
a = True
count = 1
memo = 0
while a:
    amari = N%(2 ** count)
#    print ('amari', amari)
    if (amari- memo) == 2 ** (count-1):
        s = 1
    else:
        s = 0
    memo = memo + s * (-2) **(count-1)
#    print ('momo', memo)
    S = str(s) + S
    count += 1
    if memo == N:
        print (S)
        a = not a

Measured memory_bytes: 3064
#include <valarray>
#include <cstdio>
using namespace std;
typedef valarray<int>V;
int n,m,a,b,c,t;
V M(const V &x,const V &y){
	V z(n*n);
	int i=0,j;
	for(;i<n;i++)for(j=0;j<n;j++)z[i*n+j]=(x[slice(i*n,n,1)]*y[slice(j,n,n)]).sum()%m;
	return z;
}
V E(const V &x,const int n){
	if(n==1)return x;
	if(n&1)return M(E(x,n-1),x);
	V y=E(x,n>>1);
	return M(y,y);
}
V s,x;
void O(const V &r){
	int i=0;
	for(;i<n;i++)printf(i<n-1?"%d ":"%d\n",(r[slice(i*n,n,1)]*s).sum()%m);
}
main(){
	int i;
	for(;scanf("%d%d%d%d%d%d",&n,&m,&a,&b,&c,&t),n;){
		s.resize(n);
		for(i=0;i<n;i++)scanf("%d",&s[i]);
		x.resize(1);
		x.resize(n*n);
		if(t){
			x[0]=b;
			x[1]=c;
			for(i=1;i<n-1;i++){
				x[i*n+i-1]=a;
				x[i*n+i]=b;
				x[i*n+i+1]=c;
			}
			x[i*n+i-1]=a;
			x[i*n+i]=b;
			O(E(x,t));
		}else{
			for(i=0;i<n;i++)x[i*n+i]=1;
			O(x);
		}
	}
}

Measured memory_bytes: 1088
from heapq import *

n, m = map(int, input().split())
abab = [list(map(int, input().split())) for _ in range(n)]
bites = [[] for _ in range(m)]
for a, b in abab :
    if a <= m : bites[a-1].append(-b)
    
ans = 0
board = []
for bite in bites:
    for b in bite : heappush(board, b)
    if board : ans -= heappop(board)
print(ans)

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

int main() {
  int N, A, B, x;
  cin >> N >> A >> B;
  
  int PlanA = N * A;
  int PlanB = B;
  
  if( PlanA > PlanB ){
  	x = PlanB;
  } else if ( PlanA < PlanB ) {
    x = PlanA;
  } else {
    x = PlanA;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    while(1){
        int t; cin >> t;
        string s; cin >> s;
        if(t==0&&s=="0")break;
        int p=0;
        for(char c:s){
            p+=c-'0';
        }
        if(p>t){
            printf("error\n");
            continue;
        }
        p=-1;
        int cnt=1;
        int n=s.size();
        vector<int> res;
        vector<int> v;
        for(int i=0;i<(1<<n-1);i++){
            v.clear();
            int sum=0;
            int now=s[0]-'0';
            for(int j=0;j<n-1;j++){
                if((i>>j)&1){
                    v.push_back(now);
                    sum+=now;
                    now=s[j+1]-'0';
                }
                else{
                    now=now*10+s[j+1]-'0';
                }
            }
            sum+=now;
            v.push_back(now);
            if(sum<=t){
                if(p==sum){
                    cnt++;
                }
                else if(sum>p){
                    p=sum;
                    cnt=1;
                    res=v;
                }
            }
        }
        if(cnt>=2){
            printf("rejected\n");
        }
        else{
            printf("%d",p);
            for(int vv:res){
                printf(" %d",vv);
            }
            printf("\n");
        }
    }
}


Measured memory_bytes: 3276
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        int[] arr = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int h1 = arr[0];
        int m1 = arr[1];
        int h2 = arr[2];
        int m2 = arr[3];
        int k = arr[4];
        int ans = 60 * h2 + m2 - (60 * h1 + m1) - k;
        Console.WriteLine(ans);


    }
  

}

Measured memory_bytes: 18860
package main

import "fmt"

func main() {
	var n, div, ans int
	fmt.Scan(&n)

	for i := 1; i <= n; i += 2 {
		div = 0
		for j := 1; j <= i; j++ {
			if i%j == 0 {
				div++
			}
		}
		if div == 8 {
			ans++
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
X, K, D = map(int, input().split())
count1 = abs(X) // D
count2 = (abs(X) // D)+1
if count1 < K:
    if (K - count1) %2 ==0:
        print(abs(abs(X)-abs(D*count1)))
        
    else:
        print(abs(abs(X)-abs(D*count2)))
else:
    print(abs(abs(X)-abs(D*K)))

Measured memory_bytes: 9176
program tree_restoring
  implicit none
  integer :: n, a(100), d(100), l, u, i
  a = 0
  d = 0
  read(*,*) n
  read(*,*) a(1:n)
  l = minval(a(1:n))
  u = maxval(a(1:n))
  do i = 1, n
    d(a(i)) = d(a(i))+1
  end do
  do i = l+1, u
    if (d(i).lt.2) then
      write(*,'(a)') "Impossible"
      stop
    end if
  end do
  if (d(l).ne.1+mod(u,2)) then
    write(*,'(a)') "Impossible"
    stop
  end if
  write(*,'(a)') "Possible"
  stop
end program tree_restoring

Measured memory_bytes: 256
import * as fs from 'fs';

namespace AtCoder.abc103 {
    class ProgramA {
        args: string[];

        constructor(inp: string[]) {
            this.args = inp;
        }

        main(): void {
            const a: number[] = this.args[0].split(' ').map(Number).sort((a, b) => a - b);

            let ans: number = 0;
            a.reduce((prev: number, curr: number, idx: number) => {
                if (idx === 0) return curr;
                ans += Math.abs(curr - prev);
                return curr;
            }, 0)
            console.log(ans);
        }
    }

    const args: string[] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');
    const func = new ProgramA(args);
    func.main();
}

Measured memory_bytes: 7500
#include <functional>
#include <iostream>
#include <queue>
using namespace std;
typedef long long ll;

template <typename S>   //semi group
struct UnionFind
{
    using F = function<S(S, S)>;
    
    const F f;
    
    vector<int> par, rank;
    vector<S> dat;
    
    UnionFind(int n, const F f = [](S a, S b){return a + b;}) : f(f){
        par.resize(n);
        rank.resize(n);
        dat.assign(n, 1);
        for(int i = 0; i < n; i++){
            par[i] = i;
            rank[i] = 0;
        }
    }
    
    int find(int i){
        if(i == par[i]) return i;
        return par[i] = find(par[i]);
    }
    
    bool same(int i, int j){
        return find(i) == find(j);
    }
    
    void unite(int i, int j){
        if(same(i, j)) return;
        i = find(i), j = find(j);
        if(rank[i] < rank[j]){
            par[i] = j;
            dat[j] = f(dat[i], dat[j]);
        }
        else{
            par[j] = i;
            dat[i] = f(dat[i], dat[j]);
            if(rank[i] == rank[j]) rank[i]++;
        }
    }
    
    S query(int i){
        return dat[find(i)];
    }
};

int main()
{
    int n;
    cin >> n;
    int x[100005], y[100005];
    vector<int> vx[100005], vy[100005];
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i];
        x[i]--; y[i]--;
        vx[x[i]].push_back(i);
        vy[y[i]].push_back(i);
    }
    bool b[100005]{0};
    queue<int> que;
    UnionFind<ll> ufs(n), ufx(100005), ufy(100005);
    ll ans = 0;
    for(int i = 0; i < n; i++){
        if(b[i]) continue;
        b[i] = true;
        que.push(i);
        while(que.size()){
            int u = que.front();
            que.pop();
            for(int v : vx[x[u]]){
                if(b[v]) continue;
                b[v] = true;
                ufs.unite(u, v);
                ufy.unite(y[u], y[v]);
                que.push(v);
            }
            for(int v : vy[y[u]]){
                if(b[v]) continue;
                b[v] = true;
                ufs.unite(u, v);
                ufx.unite(x[u], x[v]);
                que.push(v);
            }
        }
        ans += ufx.query(x[i]) * ufy.query(y[i]) - ufs.query(i);
    }
    cout << ans << endl;
}


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

#define F first
#define S second
#define P push
#define pb push_back
#define MEM(dp,i) memset(dp,i,sizeof(dp))
#define W while
#define R return
#define C continue
#define SI size()
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define SF(x) scanf("%Id",&x)
#define SF2(x,y) scanf("%Id%Id",&x,&y)
#define SF3(x,y,z) scanf("%I64d%I64d%I64d",&x,&y,&z)
#define SF4(x,y,z,o) scanf("%I64d%I64d%I64d%I64d",&x,&y,&z,&o)
#define all(v) v.begin(),v.end()

using namespace std;
const long long INF = 1e9+1;
const long long MOD = 1e9+7;
const int MX=100015;

int main(){
    string s;
    cin>>s;
    int n=s.size();
    ll res=0;
    bool f=0;
    for(int i=0;i<n;i++){
        if(f)res+=9;
        else{
            if(s[i]=='9')res+=9;
            else{
                if(i==0){
                    res+=s[i]-'0';
                }
                else{
                    res--;
                    f=1;
                    res+=9;
                }
            }
        }
    }
    cout<<res;
}




Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace ConsoleApp1
{
    using static Util;

    internal class Program
    {


        static void Main(string[] args)
        {
            var input = ReadLongs();
            var ab = input[0];
            var bc = input[1];
            var ca = input[2];

            var s = (ab*bc)/2;
            Console.WriteLine(s);
#if DEBUG
            Console.Read();
#endif
        }


    }

    public static class Util
    {
        public static long[] ReadLongs() 
        {
            return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        }
        public static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pl;
typedef vector<pl> vpl;
int main() {
	ios::sync_with_stdio(0);
	ll k,x,y;
	cin >> k >> x >> y;
	bool rx = false,ry = false,sw = false;
	if(x < 0) {x *= -1;rx = true;}
	if(y < 0) {y *= -1;ry = true;}
	if(x < y) {swap(x,y);sw = true;}
	ll d = x+y;
	if(!(k%2)) {
		if(d%2) {
			cout << "-1\n";
			return 0;
		}
	}
	vpl res;
	if((d%2) && (d<k)) {
		res.push_back({x,x-k});
		res.push_back({x+(k+x-y)/2,x-(k+x-y)/2});
		res.push_back({x,y});
	} else {
		ll bs;
		if((d < k) && (!(d%2))) {
			bs = 2;
		} else {
			ll bt = (k-(d%k))%k;
			if(!(bt%2)) {
				bs = (d+k-1)/k;
			} else {
				bs = (d+k-1)/k+1;
			}
		}
		ll a = 0,b = 0;
		ll dec = (d-bs*k)/2;
		while(b-k >= dec) {
			b -= k;
			res.push_back({a,b});
		}
		if(b > dec) {
			a += k-(b-dec);
			b = dec;
			res.push_back({a,b});
		}
		while(a+k <= x) {
			a += k;
			res.push_back({a,b});
		}
		if(a < x) {
			b += k-(x-a);
			a = x;
			res.push_back({a,b});
		}
		while(b+k <= y) {
			b += k;
			res.push_back({a,b});
		}
	}
	cout << res.size() << '\n';
	for(int i=0;i<res.size();i++) {
		if(sw) {swap(res[i].first,res[i].second);}
		if(rx) {res[i].first *= -1;}
		if(ry) {res[i].second *= -1;}
		cout << res[i].first << " " << res[i].second << '\n';
	}
}


Measured memory_bytes: 5484
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>

typedef long long ll;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
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;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/
const ll MOD=1000000007;

void solve(){
	string s;
	cin>>s;
	
	ll a=atoi(s.substr(0,2).c_str());
	ll b=atoi(s.substr(2,2).c_str());

	if((a>12 || a==0)&& (b>12||b==0)){
		cout<<"NA"<<endl;		
	}
	else if(a>12||a==0){
		cout<<"YYMM"<<endl;
	}
	else if(b>12||b==0){
		cout<<"MMYY"<<endl;
	}
	else{
		cout<<"AMBIGUOUS"<<endl;
	}
	
}


int main(){
	
	solve();
	
    return 0;
}


Measured memory_bytes: 256
import collections
n=int(input())
s=input()
max=0
for i in range(1,n):
    cnt=0
    x = set(s[:i])
    y = set(s[i:])
    for item in x:
        if item in y:
            cnt += 1
    if cnt > max:
        max = cnt
print(max)

Measured memory_bytes: 3316
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

using ll = long long;

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

#define mp make_pair
#define mt make_tuple

/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)

/* ---------- container ---------- */

#define gsort(b, e) sort(b, e, greater<decltype(*b)>())

/* ----------- debug ---------- */

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

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

/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
const int INF = 1 << 30;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
inline T sq(T a) { return a * a; }

template <typename T>
T gcd(T a, T b) {
    if (a > b) return gcd(b, a);
    return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

ll pcnt(ll b) {
    return __builtin_popcountll(b);
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

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

    int h[N];
    for (int i = 0; i < N; ++i) {
        cin >> h[i];
    }
    sort(h, h + N);

    int ans = INF;
    for (int i = 0; i + K <= N; ++i) {
        ans = min(ans, h[i + K - 1] - h[i]);
    }

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


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

int main() {
	char b;
	cin >> b;

	if (b == 'A') cout << 'T' << endl;
	else if (b == 'C') cout << 'G' << endl;
	else if (b == 'G') cout << 'C' << endl;
	else cout << 'A' << endl;

}

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

int main(){
	string s;
	unsigned long long int k;

	unsigned long long int tp= s.size()-1;
//	long long int digit[9];

	cin>>s;
	cin>>k;

	for(int i=0; i< s.size(); i++){
		if(s.at(i) != '1'){
			tp= i;
			break;
		}
	}

	if(k> tp)
		cout<< s.at(tp)<<endl;
	else 
		cout<<1<<endl;


/*	digit[0]= 1;

	for(int i=1; i< 9; i++){
		digit[i]= log10(i+1) * 5000000000000000;
		cout << digit[i]<<endl;
	} 
*/


	return 0;
}

Measured memory_bytes: 256