akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)

int main() {
  ll a, b; cin >> a >> b;
  if (a%2) {
    bitset <50> tmp(a);
    rep(i, (b-a)%4) {
      bitset <50> s(b-i);
      tmp = tmp ^ s;
    }
    ll res = 0;
    rep(i, 50) {
      if (tmp.test(i)) res += (ll)pow(2, i);
    }
    cout << res << endl;
  } else {
    bitset <50> tmp(0);
    rep(i, (b-a+1)%4) {
      bitset <50> s(b-i);
      tmp = tmp ^ s;
    }
    ll res = 0;
    rep(i, 50) {
      if (tmp.test(i)) res += (ll)pow(2, i);
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 4096
from collections import Counter

def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    ans = sum(a)
    q = int(input())
    #d = dict((x,a.count(x)) for x in set(a))
    d = Counter(a)
    for _ in range(q):
        b, c = map(int, input().split())
        # cの値がない場合の対処
        d.setdefault(c, 0)
        # bの値がない場合の対処
        d[c] = d.get(c) + d.get(b, 0)
        # 差分はbの個数 * (c-b) 
        diff = d.get(b, 0) * (c-b)
        d[b] = 0
        ans += diff
        print(ans)
        
if __name__ == '__main__':
    main()

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

using namespace std;

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

	int aidx = 0;
	int maxcnt = 0;
	bool isA = false;
	for (int i = 0; i < s.size(); i++)
	{
		if (s.at(i) == 'A' && !isA)
		{
			aidx = i;
			isA = true;
		}
		if (s.at(i) == 'Z')
		{
			if (isA)
			{
				maxcnt = max(maxcnt, i - aidx + 1);
			}
		}
	}
	cout << maxcnt << endl;
}


Measured memory_bytes: 640
using System;

namespace AtCoderSucks
{
    internal static class Program
    {
        private static void Main(string[] args)
        {
            int[] A1 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int[] A2 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int[] A3 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

            int N = int.Parse(Console.ReadLine());

            bool[,] P = new bool[,]
            {
                {
                    false, false, false
                },
                {
                    false, false, false
                },
                {
                    false, false, false
                },
            };

            for (int i = 0; i < N; i++)
            {
                int B = int.Parse(Console.ReadLine());

                for (int j = 0; j < 3; j++)
                {
                    if (B == A1[j])
                        P[0, j] = true;
                }
                for (int j = 0; j < 3; j++)
                {
                    if (B == A2[j])
                        P[1, j] = true;
                }
                for (int j = 0; j < 3; j++)
                {
                    if (B == A3[j])
                        P[2, j] = true;
                }
            }

            bool bingo = false;

            for (int i = 0; i < 3; i++)
            {
                if (P[i, 0] && P[i, 1] && P[i, 2])
                {
                    bingo = true;
                }
            }
            for (int i = 0; i < 3; i++)
            {
                if (P[0, i] && P[1, i] && P[2, i])
                {
                    bingo = true;
                }
            }
            if (P[0, 0] && P[1, 1] && P[2, 2])
                bingo = true;
            if (P[0, 2] && P[1, 1] && P[2, 0])
                bingo = true;

            if (bingo)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


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

string s;
int d;
const ll mod = 1e9 + 7;
const ll N = 1e4 + 7;

ll dp[N][107][2];

ll solve(int idx, int sum, bool less) {
	if (idx == s.size()) {
		return (sum%d == 0);
	}

	ll& ans = dp[idx][sum][less];
	if (~ans) {
		return ans;
	}
	ans = 0;
	if (less) {
		for (int i = 0; i < 10; i++) {
			ans += solve(idx + 1, (sum + i) % d, less);
			ans %= mod;
		}
	}
	else {
		for (int i = 0; (i + '0') < s[idx]; i++) {
			ans += solve(idx + 1, (sum + i) % d, 1);
			ans %= mod;
		}
		ans += solve(idx + 1, (sum + s[idx] - '0') % d, 0);
		ans %= mod;
	}
	return ans;
}





int main() {
	cin >> s >> d;
	memset(dp, -1, sizeof dp);
	cout << (solve(0, 0, 0) - 1 + mod) % mod;


}

Measured memory_bytes: 17792
'use strict';
  (function(stdin) { 
      var inputs = stdin.toString();
      var params = inputs.split('\n')[0].split(' ').map(Number);
      (function(a,b) {
        console.log(a * b,(a + b)*2);

    }(params[0],params[1])); 
  }(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7376
import sys
input = sys.stdin.readline
from collections import Counter

INF = float('inf')

""" Input
S = input()
N = int(input())
N, A, B = map(int, input().split())
A = list(map(int, input().split()))
D = [int(input()) for _ in range(N)]
"""

def main():
    N, Y = map(int, input().split())

    ans_10000 = -1
    ans_5000 = -1
    ans_1000 = -1

    for a in range(N+1):
        for b in range(N-a+1):
            c = N - a - b
            total = 10000 * a + 5000 * b + 1000 * c
            if total == Y:
                ans_10000 = a
                ans_5000 = b
                ans_1000 = c

    print(ans_10000, ans_5000, ans_1000)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38768
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef unsigned long long ull;
const ull MOD = 1000000007;
const int MAX_N = 100000;
ull fact[MAX_N + 1];
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ull ans;
	fact[0] = 0;
	fact[1] = 1;
	for (int i = 2; i < MAX_N + 1; i++){
		fact[i] = (fact[i - 1] * i) % MOD;
	}
	while (1){
		int N, R;
		cin >> N;
		if (N == 0) break;
		vector<int> word(N);
		for (int i = 0; i < N; i++) word[i] = i;
		word.push_back(0);
		ans = 0;
		cin >> R;
		vector<int> s(2*R+2, 0);
		s[2 * R + 1] = N;
		for (int i = 0; i < R; i++){
			cin >> s[i] >> s[i+R];
			s[i]--; s[i+R]--;
			s.push_back(s[i] + 1);
			s.push_back(s[i+R] + 1);
			word[s[i]] ^= word[s[i+R]];
			word[s[i+R]] ^= word[s[i]];
			word[s[i]] ^= word[s[i+R]];
		}
		sort(s.begin(), s.end());
		s.erase(unique(s.begin(), s.end()), s.end());
		for (int i = 0, R = s.size() - 1; i < R; i++){
			ull tmp = 0;
			int si = s[i], sip = s[i+1];
			for (int j = si; j < sip; j++){
				tmp = (tmp + fact[N - j - 1]) % MOD;
			}
			tmp = (tmp * word[si]) % MOD;
			ans =(ans + tmp) % MOD;
			int dif = sip - si;
			for (int j = i + 1; j < R; j++){
				word[s[j]] -= (word[s[j]] > word[si] ? dif : 0);
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2788
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
    char suit;
    int value;
};

struct Card L[MAX /2 +2], R[MAX /2 + 2];

void merge(struct Card A[], int n, int left ,int mid, int right){
    int i,j,k;
    int n1 = mid - left;
    int n2 = right - mid;
    for(i=0;i<n1;i++)L[i] = A[left + i];
    for(i=0;i<n2;i++)R[i] = A[mid + i];
    L[n1].value = R[n2].value = SENTINEL;
    i = j = 0;
    for(k=left;k<right;k++){
        if(L[i].value <= R[j].value){
            A[k] = L[i++];
        }else{
            A[k] = R[j++];
        }
    }
}

void mergeSort(struct Card A[],int n, int left, int right){
    int mid;
    if(left + 1 < right){
        mid =(left + right) /2;
        mergeSort(A,n,left,mid);
        mergeSort(A,n,mid,right);
        merge(A,n,left,mid,right);
    }
}

int partition(struct Card A[], int n, int p, int r){
    int i,j;
    struct Card t,x;
    x= A[r];
    i = p - 1;
    for(j=p; j<r; j++){
        if(A[j].value <= x.value){
            i++;
            t=A[i];A[i] = A[j]; A[j] = t;
        }
    }
    t=A[i+1]; A[i+1]= A[r]; A[r] = t;
    return i+1;
}

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

int main(){
    int n,i,v;
    struct Card A[MAX],B[MAX];
    char S[10];
    int stable = 1;

    scanf("%d",&n);

    for(i=0;i<n;i++){
        scanf("%s %d",S,&v);
        A[i].suit = B[i].suit = S[0];
        A[i].value = B[i].value = v;
    }

    mergeSort(A,n,0,n);
    quickSort(B,n,0,n-1);

    for(i=0;i<n;i++){
            //マージソートとクイックソートの結果を比べる
        if(A[i].suit != B[i].suit) stable = 0;
    }
    if(stable == 1) printf("Stable\n");
    else printf("Not stable\n");
    for(i=0;i<n;i++){
        printf("%c %d\n",B[i].suit,B[i].value);
    }
    return 0;
}


Measured memory_bytes: 4056
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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; }

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}
int lcm(int a, int b){return a*b / gcd(a, b);}

int main(){
    int n;
    cin >> n;
    vector<bool> color(8, false);
    int m = 0, highest = 0;
    for(int i = 0; i < n; i++){
        int rate;
        cin >> rate;
        if(rate <= 399) color[0] = true;
        else if(rate <= 799) color[1] = true;
        else if(rate <= 1199) color[2] = true;
        else if(rate <= 1599) color[3] = true;
        else if(rate <= 1999) color[4] = true;
        else if(rate <= 2399) color[5] = true;
        else if(rate <= 2799) color[6] = true;
        else if(rate <= 3199) color[7] = true;
        else highest++;
    }

    for(int i = 0; i < 8; i++){
        if(color[i] == true){
            m++;
        }
    }
    cout << max(1, m) << " " << m+highest << endl;
    return 0;
}


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

#define pb push_back
#define mp make_pair

#define fi first
#define se second

typedef long long ll;

using namespace std;
ll n, a[100500], b[100500];

int main(){

cin >> n; ll sum = 0;
for(int i=1;i<=n;i++){
    cin >> a[i];
    sum += a[i];
}
ll k = n * (n + 1) / 2;
if(sum % k != 0){
    cout << "NO";
    return 0;
}
k = sum / k;
a[n + 1] = a[1];
sum = 0;
for(int i=2;i<=n + 1;i++){
    int x = a[i] - a[i - 1] - k;
    x = -x;
    if(x < 0 || x % n != 0){
        cout << "NO";
        return 0;
    }
    b[i] = x / n;
    sum += b[i];
}
if(sum == k){
    cout << "YES";
}
else cout << "NO";
return 0;
}


Measured memory_bytes: 1792
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define trav(x,a) for (const auto& x: a)
#define sz(x) (int)(x).size()
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int _i = 0; _i < (n); _i++) ni(a[_i])
#define nal(a, n) for (int _i = 0; _i < (n); _i++) nl(a[_i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
const int N = 1e6 + 5;
const double eps = 1e-9;
vi adj[N];
int dp[N], vis[N], bip = 1;
int cnt[2];

void dfs(int u, int d, int p) {
  dp[u] = d%2;
  cnt[dp[u]]++;
  vis[u] = 1;
  trav(v, adj[u]) {
    if (vis[v] == 1) {
      if (v == p)
        continue;
      if (dp[v] == dp[u])
        bip = 0;
      continue;
    }
    dfs(v, d+1, u);
  }
}

int main() {
  ll n, m; scanf("%lld %lld", &n, &m);
  for (int i =1 ; i <= m; i++) {
    int u, v; scanf("%d %d", &u, &v);
    adj[u].pb(v);
    adj[v].pb(u);
  }
  dfs(1, 0, -1);
  if (bip)
    printf("%lld\n", cnt[0] * 1ll * cnt[1] - m);
  else
    printf("%lld\n", (n*(n-1))/2 - m);
  return 0;
}


Measured memory_bytes: 34176
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

// Returns n divisors ORDER BY ASC.
vector<i64> getDivisors(i64 n) // {{{
{
    vector<i64> ret;
    i64 i = 1;
    for (i = 1; i * i < n; ++i) {
        if (n % i == 0) {
            ret.emplace_back(i);
            ret.emplace_back(n / i);
        }
    }
    if (i * i == n) ret.emplace_back(i);
    sort(begin(ret), end(ret));
    return ret;
} // }}}

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    i64 N, M;
    cin >> N >> M;

    const auto gs = getDivisors(M);

    i64 ans = 0;
    for (i64 const g : gs) {
        i64 const p = M / g;
        if (p >= N) chmax(ans, g);
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int result;
  result = 0;
  int resultnow;
  resultnow = 100;
  int a;
  for (int i = 0; i < n; i++)
  {
      cin >> a;
      result = 0;
      while (a%2==0)
      {
          a=a/2;
          result=result+1;
      }
      

      resultnow = min(result,resultnow);
       

          
  
      
  }
  cout << resultnow << endl;
  
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
#define mod ((ll)1e9+7)
#define inf ((ll)1e18+5)
#define maxx ((ll)1e6+5)
#define pb push_back
#define endl "\n"
#define time(i) cout<<"\nTime Elapsed "<<i<<" : " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll expm(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
/*
bool sv[maxx]={0};    // returns 0 if a num is prime
int sp[maxx]={0};     // gives smallest prime factor of the number
void Sieve() {for(int i= 2; i< maxx; i+= 2) sv[i]=1,sp[i] = 2;sv[2]=0;for(ll i = 3; i < maxx; i += 2){if (!sv[i]){sp[i] = i;for (ll j = i; (j*i) < maxx; j += 2){if (!sv[j*i])sv[j*i] = true, sp[j*i] = i;}}}}
ll fact[maxx]={0}; // returns factorial of that number
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<maxx;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncrm(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expm(fact[r],mod-2)))%mod; res=(res*(expm(fact[n-r],mod-2)))%mod; return res;}
ll inv[maxx];   // returns the modular inverse of number
void inversify( ll m){inv[1]=1;for(int i=2;i<maxx;i++){inv[i]= m- m/i*inv[m%i]%m;}}
ll ncr(ll n,ll r,ll m){int ans=1;for (int i = 0; i < r; i++){ans=ans*(n-i)%m*inv[i+1]%m;}return ans;}
*/
signed main(){
  fast;
  //usefile;
  //test
  {
    int n,x,y;
    cin>>n>>x>>y;
    vector<int> ans(n);
    int dis=0;
    for(int i=1;i<n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            dis=min(j-i,abs(i-x)+1+abs(j-y));
            ans[dis]++;
        }
    }
    for(int i=1;i<n;i++)
    {
        cout<<ans[i]<<" ";
    }
  }
  //time("");
  return 0;
}

Measured memory_bytes: 256
N=int(input())
T,A=map(int,input().split())
H=list(map(int,input().split()))
min = 1e8
ans = None

for i in range(N):
    temp = T - H[i]*0.006
    diff = abs(A-temp)
    if diff < min:
        min = diff
        ans = i

print(ans + 1)

Measured memory_bytes: 62472
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = 1234567;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	ll l,r;
	cin>>l>>r;
	if(r-l >= 2018){
		cout<<0<<endl;
		return 0;
	}
	ll ans = LINF;
	int mod = 2019;
	for(int i=l; i<=r-1; i++){
		for(int j=i+1; j<=r; j++){
			ans = min(ans, (ll)i*j%mod);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
typedef long long i64;
int main(){
  int A,B;
  cin >> A >> B;
  cout << ((A<=8 && B<=8) ? "Yay!":":(") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(void)
{
	int a,b,c,d,i,p,x,y,sa;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&p);
	x=a*p;
	if(c>=p){
		y=b;
	}
	else{
		sa=p-c;
		y=d*sa+b;
	}
	if(x>y) printf("%d\n",y);
	else{ printf("%d\n",x);}
	return 0;
}
	

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

 
int main(){
  int n, t;
  cin >> n >> t;
  int ans = 10000;
  for(int i=0; i<n; i++){
    int ci, ti;
    cin >> ci >> ti;
    if(ti<=t) ans = min(ans, ci);
  }
  if(ans == 10000){
    cout << "TLE" << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;
use std::collections::HashMap;

fn input<T:FromStr>() -> T {
  let mut line: String = String::new();
  io::stdin().read_line(&mut line);
  line.trim().parse().ok().unwrap()
}



fn main() {
  let nums_str: String = input();
  let nums_vec_char: Vec<char> = nums_str.chars().collect();
  let mut nums: Vec<i32> = Vec::new();
  for n in nums_vec_char {
    nums.push(n as i32 - 48);
  }

  for bit in 0..1<<3 {
    let mut sum = nums[0];
    let mut opes = vec![""; 3];
    for i in 0..3 {
      if bit & (1<<i) != 0 {
        opes[i as usize] = "+";
        sum += nums[(i+1) as usize];
      } else {
        opes[i as usize] = "-";
        sum -= nums[(i+1) as usize];
      }
    }
    if sum == 7 {
      println!("{}{}{}{}{}{}{}=7", nums[0], opes[0], nums[1], opes[1], nums[2], opes[2], nums[3]);
      return
    }
  }
}


Measured memory_bytes: 4352
n = int(input())
s, t = [0] * n, [0] * n
for i in range(n):
    a, b = input().split()
    s[i] = a
    t[i] = int(b)
x = input()

ans = 0
for i in range(n)[::-1]:
    if s[i] == x: break
    ans += t[i]

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
 
const int maxn = 5e3 + 20;

ll dp[maxn] , a[maxn];

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

	int n;
	ll x , y;
	cin >> n >> x >> y;

	for(int i = 1; i <= n; i++)
		cin >> a[i];

	a[n + 1] = n + 1;
	memset(dp , 63 , sizeof dp);
	dp[0] = 0;
	for(int i = 1; i <= n + 1; i++)
	{
		int mx = -1 , t = 0;
		for(int j = i - 1; j >= 0; j--)
		{
			if(a[j] > a[i])
				t++;
			else if(a[j] > mx)
			{
				mx = a[j];
				dp[i] = min(dp[i] , dp[j] + t * x + (i - j - 1 - t) * y);
			}
		}
	}

	cout << dp[n + 1] << endl;
}


















Measured memory_bytes: 384
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

ans = 0
for ss in s:
    tmp = 0
    for tt in t:
        if ss == tt:
            tmp -= 1
    for sss in s:
        if ss == sss:
            tmp += 1
    ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 38896
#include<stdio.h>
#include<algorithm>
#include<queue>
using namespace std;
char str[20];
int ijk[1<<16][16];
int v[1<<16][16];
int ABS(int a){return max(a,-a);}
int main(){
	int a;
	while(scanf("%d",&a),a){
		scanf("%s",str);
		int A=0;
		for(int i=0;i<a;i++){
			if(str[i]=='B')A+=(1<<i);
		}
		scanf("%s",str);
		int B=0;
		for(int i=0;i<a;i++){
			if(str[i]=='B')B+=(1<<i);
		}
		for(int i=0;i<(1<<a);i++)for(int j=0;j<a;j++){
			ijk[i][j]=999999999;
			v[i][j]=0;
		}
		priority_queue<pair<int,pair<int,int> > >Q;
		for(int i=0;i<a;i++){
			Q.push(make_pair(0,make_pair(A,i)));
			ijk[A][i]=0;
		}
		while(Q.size()){
			int cost=-Q.top().first;
			int bit=Q.top().second.first;
			int at=Q.top().second.second;
			Q.pop();
			if(v[bit][at])continue;
			v[bit][at]=1;
			for(int i=0;i<a;i++){
				for(int j=0;j<a;j++){
					if((bit&(1<<i))&&!(bit&(1<<j))){
						int to=bit-(1<<i)+(1<<j);
						if(!v[to][j]&&ijk[to][j]>cost+ABS(at-i)+ABS(i-j)){
							ijk[to][j]=cost+ABS(at-i)+ABS(i-j);
							Q.push(make_pair(-ijk[to][j],make_pair(to,j)));
						}
					}else if(!(bit&(1<<i))&&(bit&(1<<j))){
						int to=bit-(1<<j)+(1<<i);
						if(!v[to][j]&&ijk[to][j]>cost+ABS(at-i)+ABS(i-j)){
							ijk[to][j]=cost+ABS(at-i)+ABS(i-j);
							Q.push(make_pair(-ijk[to][j],make_pair(to,j)));
						}
					}
				}
			}
		}
		int ret=9999999;
		for(int i=0;i<a;i++)ret=min(ret,ijk[B][i]);
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 20296
r, l = map(int, (input().split()))

ans = 2018
max_l = min(l, (r//2019+1)*2019)

for i in range(r, max_l):
    for j in range(i+1, max_l+1):
        ans = min((i * j) % 2019, ans)
    
        if ans == 0:
            break
    
print(ans)

Measured memory_bytes: 39024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int A[N];
  for(int i=0;i<N;i++) cin>>A[i];
  int ans=0;
  sort(A,A+N);
  for(int i=0;i<N;i++){
    if(i%2) ans-=A[N-1-i];
    else ans+=A[N-1-i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
 
    int mis = 0;
    int N; cin >> N;
    F0R(i, N) {
        int cur; cin >> cur;
        if (cur != i+1) mis++;
    }
    string ans = (mis <= 2) ? "YES" : "NO";
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 3584
n, m = map(int, input().split())
h = list(map(int, input().split()))
a = [x*0 for x in range(m)]
b = [x*0 for x in range(m)]
for i in range(m):
    a[i], b[i] = map(int, input().split())
count = 0

c = [x*0 for x in range(n)]
p = [1 for x in range(n)]

#print(p)

for i in range(m):
    c[a[i]-1] += 1
    c[b[i]-1] += 1
for i in range(n):
    if c[i]==0:
        h[i] = 0
        p[i] = 0
        count += 1

#print(p)

for i in range(m):
    if h[a[i]-1] <= h[b[i]-1]:
        p[a[i]-1] = 0
    if h[a[i]-1] >= h[b[i]-1]:
        p[b[i]-1] = 0

#print(p)

for i in range(n):
    if p[i]==1:
        count += 1

print(count)

Measured memory_bytes: 22648
def main():
    n=int(input())
    domino=[list(input()) for i in range(2)]
    mod=10**9+7

    if domino[0][0]==domino[1][0]:
        dp=[3]
        i=1
        before=True
    else:
        dp=[6]
        i=2
        before=False

    while i<n:
        if domino[0][i]==domino[1][i]:
            if before:
                nex=dp[-1]*2%mod
                dp.append(nex)
            else:
                nex=dp[-1]%mod
                dp.append(nex)
            before=True
            i+=1
        else:
            if before:
                nex=dp[-1]*2%mod
                dp.append(nex)
            else:
                nex=dp[-1]*3%mod
                dp.append(nex)
            before=False
            i+=2
    print(dp[-1])
if __name__=='__main__':
    main()

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

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

  vector<tuple<int, int, int>> city;
  vector<pair<int, int>> ans(M);
  rep(i, M) {
    int p, y;
    cin >> p >> y;
    city.push_back(make_tuple(p, y, i));
  }

  sort(all(city));

  int pref_prev = get<0>(city[0]);
  //int pref_prev = city[0].first;
  int cnt_city = 0;
  rep(i, M) {
    int pref_now = get<0>(city[i]);
    //int pref_now = city[i].first;
    if (pref_now == pref_prev) {
      cnt_city++;
    } else {
      cnt_city = 1;
      pref_prev = pref_now;
    }

    //printf("%06d%06d\n", pref_now, cnt_city);
    int idx = get<2>(city[i]);
    ans[idx] = make_pair(pref_now, cnt_city);

  }

  rep(i, M) {
    printf("%06d%06d\n", ans[i].first, ans[i].second);
  }

  return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

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

int main() {
  int N, K;
  cin >> N >> K;
  int result = 1, tmp = K;
  while (N >= tmp) {
    tmp *= K;
    result++;
  }
  cout << result << endl;
  return 0;
}


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

#define PI 3.14159265358979323846264338327950L

int main() {

  int A,B,H,M;
  cin >> A >> B >> H >> M;

  long double rad = 2*PI*((long double)H/12.0+(long double)M/720.0-(long double)M/60.0);

  long double result = (long double)(A*A+B*B)-(long double)(2.0*A*B)*cosl(rad);
  printf("%20.20Lf\n", sqrtl(result));

}


Measured memory_bytes: 4152
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::input;
//use proconio::marker::Chars;
//use proconio::marker::Usize1;
//use std::collections::HashSet;
//use std::collections::HashMap;
//use std::collections::BTreeMap;
use std::cmp::*;
// use std::num;

fn main() {
    input! {
        X:usize,Y:usize,A:usize,B:usize,C:usize,
       mut p:[i64;A],
       mut q:[i64;B],
       mut r:[i64;C]
    }
    p.sort_by_key(|&num| Reverse(num));
    q.sort_by_key(|&num| Reverse(num));
    r.sort_by_key(|&num| Reverse(num));
    // 各林檎を食べる数をa,b,cとすると、無色をc個食べる時の総和sumを求めると？
    //let mut ans = vec![0i64; C];
    //  println!("p {:?}", p);    println!("q {:?}", q);    println!("r {:?}", r);
    let mut a = X;
    let mut b = Y;
    let mut c = 0;
    let mut sum = 0;
    for i in 0..a {
        sum += p[i]
    }
    for i in 0..b {
        sum += q[i]
    }

    //  println!("a {}, b {}, sum {}", a, b, sum);
    //ans[0] = sum;
    // ここから計算
    for c in 0..C {
        if b == 0 || (a > 0 && p[a - 1] <= q[b - 1]) {
            if p[a - 1] < r[c] {
                sum = sum - p[a - 1] + r[c];
                a -= 1;
            }
        } else {
            if b > 0 && q[b - 1] < r[c] {
                sum = sum - q[b - 1] + r[c];
                b -= 1;
            }
        }
        if a == 0 && b == 0 {
            break;
        }
    }
    println!("{}", sum);
}


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


int main(){
    
    string s;
    cin>>s;
    
    vector<int> v(s.size());
    
    bool bb=false;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'){
            v[i]=1;
        }else{
            v[i]=0;
        }
    }
    
    int sm=0;
    int sum=0;
    for(int i=0; i<s.size(); i++){
        sum+=v[i];
        sum*=v[i];
        
        sm=max(sum, sm);
    }
    
    cout<<sm<<endl;
}


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

int main() {
  int N;
  cin >> N;
  
  for(int i = 0; i < N; i++){
    string S;
    cin >> S;
    
    if(S == "Y"){
      cout << "Four" << endl;
    return 0;
    }
  }
  cout << "Three" << endl;   
}

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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  long long int a[n] = {0};
  a[0] = 2;
  a[1] = 1;
  for (int i = 2; i <= n; i++) {
    a[i] = a[i - 1] + a[i - 2];
  }
  cout << a[n] << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60
#define MOD 1000000007

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j
#define fix(i) fixed << setprecision(i)
#define so(a) sort(begin(a), end(a))
#define soR(a) sort(begin(a), end(a), greater<ll>())
#define sum(a) accumulate(begin(a), end(a), 0)


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() {
    char N[3];

    rep(i, 0, 3) {
        cin >> N[i];
    }
    rep(i, 0, 3) {
        if (N[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main() {
    int k,s;
    cin >> k >> s;
    int ans=0;
    for (int i = 0; i <= k; i++) {
        for (int j = 0; j <= k; j++) {
                if(s-i-j<=k&&s-i-j>=0) ans++;
    }
    }
    cout << ans << endl;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    vector<int> ans(3);
    ans.at(a-1) = 1;
    ans.at(b-1) = 1;

    for (int i=0; i<3; i++) {
        if (ans.at(i) == 0) {
            cout << i+1 << endl;
        }
    }
}

Measured memory_bytes: 256
import math
import collections
def calc_combi2(n):
    if n<=1:
        return 0
    return math.factorial(n)/(math.factorial(n-2)*math.factorial(2))
n=int(input())
data=list(map(int,input().split()))
data_cnt=collections.Counter(data)
count=0
for i in data_cnt.values():
    count+=calc_combi2(i)
for i in data:
    ans=count-data_cnt[i]+1
    print(int(ans))

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

using namespace std;

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

const int N = 1010;

int a[N], len;
char s[N];

int main()
{

    scanf("%d%s", &len, s + 1);

    for(int i = 1; i <= len; i++)
        if(s[i] == 'I') a[i] = a[i - 1] + 1;
        else a[i] = a[i - 1] - 1;

    int res = a[0];
    for(int i = 1; i <= len; i++) res = max(res, a[i]);

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


Measured memory_bytes: 256
while True:
    n, x = map(int,input().split())
    if n == 0 and x == 0:
        break

    counter = 0

    for first in range(n, 2, -1):
        # print("first:", first)

        for second in range(first-1, 1, -1):
            # print("second:", second)
            third = x - (first + second)

            if third > 0 and third < second:
                # print(first, second, third)
                counter = counter + 1 

    print(counter)


Measured memory_bytes: 5592
#include <stdio.h>
int main()
{
    int a,b,c,d;
    scanf("%d %d %d",&a,&b,&c);
    if(a>b)
    printf("0");
    else
    {
    d=b/a;
    if(d>c)
    printf("%d",c);
    else
    printf("%d",d);
    }
    return 0;
}

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

bool used[100];

int main() {
    string s;

    cin >> s;

    for(char c : s) {
        used[c - 'a'] = true;
    }

    for(int i = 0; i < 26; i++) {
        if(!used[i]) {
            s.push_back('a' + i);
            cout << s << endl;
            return 0;
        }
    }

    string z = s;

    if(next_permutation(s.begin(), s.end())) {
        for(int i = 0; i < z.size(); i++) {
            if(s[i] != z[i]) {
                while(s.size() > i + 1) {
                    s.pop_back();
                }

                cout << s << endl;
                return 0;
            }
        }
    } else {
        cout << "-1" << endl;
    }

    return 0;
}


Measured memory_bytes: 768
import math

def is_prime(n):
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

def main():
    x = int(input())
    
    ans = 0

    max = 10 ** 5

    for i in range(x,max+x):
        if is_prime(i):
            ans = i
            break

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include<ctime>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#define file(x)freopen(x".in","r",stdin);freopen(x".out","w",stdout)
#define rt register int
#define l putchar('\n')
#define ll long long
#define r read()
using namespace std;
inline ll read(){
    ll x=0;char zf=1;char ch=getchar();
    while(ch!='-'&&!isdigit(ch))ch=getchar();
    if(ch=='-')zf=-1,ch=getchar();
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();return x*zf;
}
void write(ll y){if(y<0)putchar('-'),y=-y;if(y>9)write(y/10);putchar(y%10+48);}
void writeln(const ll y){write(y);putchar('\n');}
int k,m,n,x,y,z,cnt,ans;
char c1[200010],c2[200010];
int main(){
	n=r;m=r;scanf("%s",c1),scanf("%s",c2);
	int gd=__gcd(n,m);
	ll ans=(ll)n*m/gd;
	for(rt i=0,j=0;i<=n;i+=n/gd,j+=m/gd)
	if(c1[i]!=c2[j]){
		puts("-1");
		return 0;
	}cout<<ans;
	
	return 0;
}


Measured memory_bytes: 384
n = int(input())
s = input()
t = s.count("R")*s.count("G")*s.count("B")
for i in range(n):
    for j in range(i+1, n):
        k = 2*j - i
        if k < n and s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            t -= 1

print(t)


Measured memory_bytes: 68096
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			final long K = sc.nextLong();
			
			long[] arr = new long[N];
			for(int i = 0; i < N; i++) {
				arr[i] = sc.nextLong();
			}
			
			int answer = 0;
			for(int i = 0; i < N; i++) {
				if(arr[i] >= K) { answer++; }
			}
			
			
			System.out.println(answer);
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 29372
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   long long n;
   array<long long, 5> x;
   cin >> n;
   for(int i = 0; i < x.size(); i++){
      cin >> x[i];
   }
   long long min_x = *min_element(x.begin(), x.end());
   cout << (n + min_x - 1)/min_x + 4  << endl;
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cstring>
#include <climits>
using namespace std;
#define ll long long
#define FOR(i,n) for(int i=0;i<n;i++)
#define sz(x) (int)(x.size())
#define all(x) (x).begin(),(x).end()
template<typename tp> void read(tp &x) {cin >> x;}
template<typename tp, typename... Args> void read(tp& x, Args&... args) {read(x);read(args...);}
const int mxN = (int)1e5,INF = (int)1e9,MOD = (int)1e9+7;

void solve()
{
	char a[3],b[3];
	FOR(i,2)read(a[i]);
	FOR(i,2)read(b[i]);
	a[2] = b[2] = 0;
	int x = atoi(a),y = atoi(b);
	if((x>12 && y>12) ||(x==0&&y==0))cout << "NA\n";
	else if(x==0) cout << (y<=12?"YYMM":"NA");
	else if(y==0) cout << (x<=12?"MMYY":"NA");
	else if(x<=12 && y<=12)cout << "AMBIGUOUS";
	else if(x<=12)cout << "MMYY";
	else cout << "YYMM";
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int test = 1;
	//read(test);
	while(test--)
		solve();
	return 0;
}



Measured memory_bytes: 3640
import sys

paths = [list(map(int, input().split())) for i in range(3)]
for a, b in paths[:]:
    paths.append([b, a])

for start in range(1, 5):
    visited_paths = [start]
    cnt = 0
    while len(visited_paths) < 4:
        for path in paths[:]:
            if path[0] == visited_paths[-1]:
                visited_paths.append(path[1])
                paths.remove(path)
                paths.remove([path[1], path[0]])
                break
        cnt += 1
        if cnt > 10:
            break
    if cnt > 10:
        continue
    print('YES')
    sys.exit()
print('NO')
sys.exit()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<ctime>
#include<set>
#include<iomanip>
#define sqr(x) (x)*(x)
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
//#define long long long long
using namespace std;
long long n,i,j,rt,cnt,sz[200005],rnd[200005];
long long l[200005],r[200005];
long long ans,m,a[200005],val[200005];
long long nwnd(long long x)
{
	cnt++;
	l[cnt]=r[cnt]=0;
	sz[cnt]=1;val[cnt]=x;rnd[cnt]=rand()*32768+rand();
	return cnt;
}
void pushup(long long x)
{
	sz[x]=1+sz[l[x]]+sz[r[x]];
}
void split(int x,long long y,long long &sl,long long &sr)
{
	if (!x)
	{
		sl=sr=0;
		return;
	}
	if (val[x]<=y)
	{
		split(r[x],y,r[x],sr);
		sl=x;
		pushup(x);
		return;
	}
	else
	{
		split(l[x],y,sl,l[x]);
		sr=x;
		pushup(x);
		return;
	}
}
long long merge(long long x,long long y)
{
	if (!x||!y) return x+y;
	if (rnd[x]>rnd[y])
	{
		r[x]=merge(r[x],y);
		pushup(x);
		return x;
	}
	else
	{
		l[y]=merge(x,l[y]);
		pushup(y);
		return y;
	}
}
int main()
{
	cin>>n>>m;
	fz1(i,n)
	{
		cin>>a[i];
		a[i]-=m;
		a[i]+=a[i-1];
	}
	rt=nwnd(0);
	fz1(i,n)
	{
		long long t1,t2;
		split(rt,a[i],t1,t2);
		ans+=sz[t1];
		rt=merge(merge(t1,nwnd(a[i])),t2);
	}
	cout<<ans<<endl;
	return 0;
}

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

template <typename T>
bool contains(const vector<T>& vec, const T& item) {
  return std::find(vec.begin(), vec.end(), item) != vec.end();
}

int main() {
  int H, W;
  cin >> H >> W;

  char area[H][W];

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> area[i][j];
    }
  }

  for (int i = 0; i < W + 2; i++) cout << '#';
  cout << endl;

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (j == 0) cout << '#';
      cout << area[i][j];
      if (j == W - 1) cout << '#';
    }
    cout << endl;
  }

  for (int i = 0; i < W + 2; i++) cout << '#';
  cout << endl;
}


Measured memory_bytes: 3644
#include <cstdio>
#include<cstdlib>
#include<cstring>

struct Node {
  int key;
  Node *next, *prev;
};

Node *nil;

Node* listSearch(int key){
  Node *cur = nil->next;
  while (cur !=nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = (Node *) malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  Node *cur = nil-> next;
  int isf =0;
  while(1){
    if (cur == nil) break;
    if (isf++ >0) printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf ("\n");
}

void deleteNode(Node *t){
  if( t==nil) return ;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deleteKey(int key){
  
  deleteNode(listSearch(key));
}

void insert(int key){
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  
  x->next = nil->next;
  nil->next->prev =x;
  nil ->next =x;
  x->prev =nil;
}

int main(){
  int key,n,i;
  int size=0;
  char com[20];
  int np=0,nd=0;
  scanf("%d", &n);
  init();
  for (i=0;i<n;i++){
    scanf("%s%d",com, &key);
    if(com[0]=='i'){
      insert(key);
      np++;
      size++;}
    else if (com[0]=='d'){
      if (strlen(com)>6){
        if(com[6]=='F') deleteFirst();
      else if (com[6]=='L')deleteLast();
    }else {
        deleteKey(key); nd++;
      }
      size--;
    }
  }
  printList();
  return 0;
}

  


  


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

#define ll long long
#define ld long double

using namespace std; 
void solve(); 
int main() 
{ 
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
  
    int t = 1; 
    // cin >> t; 
    while (t--) { 
        solve(); 
    } 
  
    cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
    return 0; 
} 

void solve() 
{ 
	int n;
    cin >> n;

    int x = n/1.08;
    int y = ceil(n/1.08);

    if (floor(x * 1.08) == n) {
        cout << x << "\n";
        return;
    } else if (floor(y * 1.08) == n) {
        cout << y << "\n";
        return;
    }

    cout << ":(" << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi = 3.141592654;
void solve()
{
    ll a,b;
    cin>>a>>b;
    if(a==b)
    {
        for(int i=0;i<a;i++)
            cout<<a;
        cout<<endl;
    }
    else if(a>b){
            for(int i=0;i<a;i++)
            cout<<b;
        cout<<endl;

    }
    else{
        for(int i=0;i<b;i++)
            cout<<a;
        cout<<endl;
    }


}

int main()
{
    ios_base :: sync_with_stdio(false);
    ll t;
   // cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(N: int):
    ret = (1000 - (N % 1000)) % 1000
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61740