akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    REP(i, S.length()) {
        int diff = S[i] - 'A';
        diff += N;
        diff %= 26;
        S[i] = (char)diff + 'A';
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
int a[100001];
int main(){
    int N;
    cin >> N;
    REP1(i,N) cin >> a[i];
    int now = 1;
    REP1(i,N-1){
        now = a[now];
        if(now == 2){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


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

#define PI 3.14159265359
#define eps 1e-8
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
typedef long long int ll;
const int INF = 1<<29;
typedef long long ll;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

double tick() { 
	static clock_t oldticks;
	clock_t newticks = clock();
	double diff = 1.0 * (newticks - oldticks) / CLOCKS_PER_SEC; 
	oldticks = newticks;
	return diff;
}

bool prime[10000010];
inline void sieve(){
	prime[0]=prime[1]=0;
	for(int i=2;i<10000010;i++)
		prime[i]=1;
	for(int i=2;i<sqrt(10000010);i++){
		if(prime[i]==1){
			for(int j=i*i;j<10000010;j+=i)
				prime[j]=0;
		}
	}
}

inline bool isPrime(ll n){
    if (n <= 1)
        return false; 
    for (int i = 2; i < n; i++)
        if (n % i == 0)
            return false;
    return true;
}

inline int toInt(string s){
	//return atoi(s.c_str());
	int x=(int)s[0]-48;
	return x;
}

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

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

inline bool isLeap(int yy){
	return ((yy%4 == 0 && yy%100 != 0) || yy%400 == 0);
}

string s;

int main(){
	ios_base::sync_with_stdio(false); //Fast I/O
	cin.tie(NULL);
	//freopen("in.txt","r",stdin);
	//freopen("output.txt","w",stdout);	
	
    cin >> s;

    for(char c: s){
        if(c==',')
            cout << " ";
        else
            cout << c;
    }

    //cerr << tick();

	return 0;
}

Measured memory_bytes: 256
from collections import deque
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
moves = ((1, 0), (-1, 0), (0, 1), (0, -1))
cnt = [[float('inf') for _ in range(w)] for _ in range(h)]
cnt[0][0] = 0

def bfs():
    q = deque([(0, 0)])
    while q:
        y, x = q.popleft()
        for dy, dx in moves:
            if 0 <= y+dy < h and 0 <= x+dx < w and s[y+dy][x+dx] != '#' and cnt[y+dy][x+dx] == float('inf'):
                q.append([y+dy, x+dx])
                cnt[y+dy][x+dx] = cnt[y][x] + 1
    
bfs()
if cnt[h-1][w-1] != float('inf'):
    short_path = cnt[h-1][w-1]
    ans = 0
    ans += short_path + 1
    for i in range(h):
        for j in range(w):
            if s[i][j] == '#':
                ans += 1

    ans = h*w - ans 
    print(ans)
else:
    print(-1)


Measured memory_bytes: 3436
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <string>
#include <map>
#include <queue>
#include <list>

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define vint vector<int>
#define INF 1e9

using namespace std;
typedef long long  ll;

int main(){

    string s, t;
    cin >> s >> t;

    ll ans = 0;
    REP(i, 0, s.size()){
        if(s[i] != t[i]){
            ++ans;
        }
    }

    p(ans);

    return 0;
}


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

int main(){
   int N, M;
   cin >> N >> M;
   int Nnum, Mnum;
   Nnum = (N * (N-1))/2;
   Mnum = (M * (M-1))/2;
   cout << Nnum + Mnum << endl;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
)

func main() {
	N := readi()
	A := readi()
	B := readi()
	C := readi()
	D := readi()
	E := readi()

	t := []int{A, B, C, D, E}
	sort.Ints(t)

	tmp := int(math.Ceil(float64(N) / float64(t[0])))

	fmt.Println(4 + tmp)
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func chmin(x *int, y int) bool {
	if *x > y {
		*x = y
		return true
	}
	return false
}

func chmax(x *int, y int) bool {
	if *x < y {
		*x = y
		return true
	}
	return false
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func permutations(arr []int) [][]int {
	var helper func([]int, int)
	res := [][]int{}

	helper = func(arr []int, n int) {
		if n == 1 {
			tmp := make([]int, len(arr))
			copy(tmp, arr)
			res = append(res, tmp)
		} else {
			for i := 0; i < n; i++ {
				helper(arr, n-1)
				if n%2 == 1 {
					tmp := arr[i]
					arr[i] = arr[n-1]
					arr[n-1] = tmp
				} else {
					tmp := arr[0]
					arr[0] = arr[n-1]
					arr[n-1] = tmp
				}
			}
		}
	}
	helper(arr, len(arr))
	return res
}

func isPrime(n int) bool {
	if n == 1 {
		return false
	}
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

func divisor(n int) (res []int) {
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			res = append(res, i)
			if i*i != n {
				res = append(res, n/i)
			}
		}
	}
	sort.Ints(res)
	return
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7
)

var (
	readString func() string
)

func init() {
	readString = newReadString(os.Stdin)
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}


Measured memory_bytes: 640
// Problem : C. Chocolate Bunny
// Contest : Codeforces - Codeforces Round #669 (Div. 2)
// URL : https://codeforces.com/contest/1407/problem/C
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define vvi vector<vector<int> >
#define vb vector<bool>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define pii pair<int,int>
#define mii map<int,int>
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mkp make_pair
#define all(v) v.begin(),v.end()
#define input(a,b,n) for(i=b;i<n;i++){cin>>a[i];}
#define print(a) for(i=0;i<a.size();i++){cout<<a[i]<<" ";}cout<<endl;
#define trace1(a); cout<<"a="<<a<<endl;
#define trace2(a,b); cout<<"a="<<a<<" b="<<b<<endl;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int inf=0x3f3f3f3f3f3f3f3f;
int power(int a, int b){
    int res = 1;
    while(b!=0){
        if(b&1){
            res *= a; 
        }
        a = (a * a);
        b = (b / 2);
    }
    return res;
}
vector<vector<int> > dp(100001,vector<int>(101,-1));
int knapSack(int W, int wt[], int val[], int n) 
{ 
   // Your code here
   if(dp[W][n]!=-1)
   {
       return dp[W][n];
   }
   if(W==0)
   {
       dp[W][n]=0;
       return 0;
   }
   if(n==0)
   {
       dp[W][n]=0;
       return 0;
   }
   int x=-1,y=-1;
   if(wt[n-1]<=W)
   {
       x=val[n-1]+knapSack(W-wt[n-1],wt,val,n-1);
   }
   y=knapSack(W,wt,val,n-1);
   if(x!=-1&&y!=-1)
   {
       dp[W][n]=max(x,y);
       return max(x,y);
   }
   else if(x!=-1)
   {
       dp[W][n]=x;
       return x;
   }
   else
   {
       dp[W][n]=y;
       return y;
   }
}
int32_t main()
{
	//fast;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
    	int w,n;
    	cin>>n>>w;
    	int wt[n];
    	int val[n];
    	int i;
    	for(i=0;i<n;i++)
    	{
    		cin>>wt[i]>>val[i];
    	}
    	cout<<knapSack(w,wt,val,n)<<endl;
	}
    return 0;
}


Measured memory_bytes: 85176
#include <iostream>

using namespace std;

int N, K, S;

int dfs(int sum, int cnt, int max_)
{
	int total = 0;

	if (sum == S && cnt == K) { return 1; }

	if (cnt != K)
	{
		for (int i = max_ + 1; i <= N; i++)
		{
			total += dfs(sum + i, cnt + 1, i);
		}
	}

	return total;
}

int main()
{
	while (true)
	{
		cin >> N >> K >> S;

		if (N == 0 && K == 0 && S == 0) { break; }

		cout << dfs(0, 0, 0) << endl;
	}

	return 0;
}

Measured memory_bytes: 3068
#include <cstdio>
#include <iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  int A[N];
  int B[N];
  int maxA=0;int max=0;
  for(int i=0; i<N; i++){
    cin >> A[i] >> B[i];
    if(A[i]>maxA){
      max = A[i] + B[i];
      maxA =A[i];
    }
  }
  cout << max << endl;
  return 0;
}


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

#ifdef DEBUG
#define NDEBUG
#include "cout11.h"
#endif
#undef NDEBUG
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

ll solve(ll X, ll Y) {
    if (Y == 1) return -1;
    if (X % Y == 0) return -1;
    return X;
}

int main() {
    ll X, Y; cin >> X >> Y;
    cout << solve(X, Y) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
int N,i;
double m,a[99];
    for(cin>>N;i<N;++i)cin>>a[i];
    sort(a,a+N);
    for(i=0;i<N;++i){m=(m+a[i])/(i?2:1);}
    printf("%f",m);
}


Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    div_i = 0
    for i in range(N):
        if i <= K - 1:
            pass
        else:
            if A[i] > A[div_i]:
                print("Yes")
            else:
                print("No")
            div_i += 1


if __name__ == '__main__':
    main()


Measured memory_bytes: 94268
n, m = map(int, input().split())
a = list(map(int, input().split()))
std = 1 / (4 * m)
cnt = 0
for i in range(n):
    if a[i] >= std * sum(a):
        cnt += 1
if cnt >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  int N, K; cin >> N >> K;
  vector<ll> A(N); rep(i,N) cin >> A[i];
  rep(i,N-K){
    if(A[i]<A[i+K]) cout << "Yes" << '\n';
    else cout << "No" << '\n';
  }
  return 0;
}


Measured memory_bytes: 4840
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/05/02 22:33:52 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

using namespace std;

#define	int	long long
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

typedef long long 			ll;
typedef vector<int>			VI;
typedef vector<vector<int>>	VVI;
typedef pair<int, int>		PII;

// TOP
void	Main()
{
	int	a, b, n;
	cin >> a >> b >> n;
	// rep(i, 20)
	// 	cout << floor(a * i / b) - a * floor(i / b) << endl;
	int x;
	x = floor(a * min(b - 1, n) / b);
	int y;
	y = a * floor((min(b - 1, n)) / b);
	cout << x - y << endl;
}
// END

int32_t	main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string Input;
            int N, M;
            int ac = 0;
            int wa = 0;

            Input = Console.ReadLine();
            N = int.Parse(Input.Split(' ')[0]);
            M = int.Parse(Input.Split(' ')[1]);

            int[] ac_flag = new int[105000];
            int[] wa_count = new int[105000];

            for (int i = 0; i < M; i++)
            {
                int No;
                string S;
                Input = Console.ReadLine();
                No = int.Parse(Input.Split(' ')[0]);
                S = Input.Split(' ')[1];

                if(S == "AC")
                {
                    if(ac_flag[No - 1] == 0)
                    {
                        ac_flag[No - 1] = 1;
                        ac++;
                        wa += wa_count[No - 1];
                    }
                }

                if(S == "WA")
                {
                    if(ac_flag[No - 1] == 0)
                    {
                        wa_count[No - 1]++;
                    }
                }
            }
            Console.WriteLine("{0} {1}", ac, wa);
        }
    }
}


Measured memory_bytes: 17852
// Starting with the name of Allah

#include<stdio.h>
int main()
{
	int K,A,B,i,x,y,z=0;
	scanf("%d",&K);
	scanf("%d %d",&A,&B);

	for(i=A;i<=B;i++){
		if(i%K==0){
			z=2;
			break;
		}
	}
	if(z==2){
		printf("OK\n");
	}
	else{
		printf("NG\n");
	}
}


Measured memory_bytes: 1628
#include <iostream>
#include <sstream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>
#include <list>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))
template<class T> inline bool chmax(T & a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
vector<int> dx = { 1,0,-1,0 }, dy = { 0,1,0,-1 };

int main(void)
{
	int H, W; cin >> H >> W;
	vector<string> A(H); rep(i, 0, H)cin >> A[i];
	vector<vector<int>> dis(H, vector<int>(W, 0));
	queue<int> X, Y;
	rep(i, 0, H) {
		rep(j, 0, W) {
			if (A[i][j] == '#') {
				X.push(i);
				Y.push(j);
			}
		}
	}

	while (!X.empty()) {
		int x = X.front(); X.pop();
		int y = Y.front(); Y.pop();

		rep (i, 0, 4) {
			if (x + dx[i] < 0 || x + dx[i] >= H || y + dy[i] < 0 || y + dy[i] >= W)continue;
			if (A[x + dx[i]][y + dy[i]] == '.') {
				A[x + dx[i]][y + dy[i]] = '#';
				X.push(x + dx[i]);
				Y.push(y + dy[i]);
				dis[x + dx[i]][y + dy[i]] = dis[x][y] + 1;
			}
		}
	}
	int ans = -1;
	rep(i, 0, H)rep(j, 0, W)ans = more(ans, dis[i][j]);
	cout << ans << endl;

	return 0;
}


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

typedef long long ll;

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

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

int main() {
  ll N, M; cin >> N >> M;
  string S, T;
  cin >> S >> T;

  ll L = lcm(N,M);

  map<int,char> str;
  for(ll i=0; i<N; i++){
      str[i*L/N] = S[i];
  }

  for(ll i=0; i<M; i++){
    auto itr = str.find(i*L/M);
    if(itr != str.end()){
      if(itr->second != T[i]){
        cout << -1 << endl;
        return 0;
      }
    }
  }

  cout << L << endl;

}

Measured memory_bytes: 4736
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <map>
#define ll long long

using namespace std;

int main(void){
    ll n, a, b;
    cin >> n >> a >> b;
    ll check = b-a-1;
    if(check%2==0)
        cout << "Borys" << endl;
    else
        cout << "Alice" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
using namespace std;
using ll = long long;
int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> a(200010,0);
    set<ll> st;
    for(ll i=0;i<n;i++){
        ll x;
        cin >> x;
        a[x]++;
        st.insert(x);
    }
    ll cnt = st.size();
    sort(a.begin(),a.end());
    ll ans=0;
    ll i=0;
    while(cnt>k){
        if(a[i]!=0){
            ans+=a[i];
            cnt--;
        }
        i++;
    }
    cout << ans << endl;
}

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

int main()
{  
   string s;
   deque<char>v;
   char add;
   bool beg=true;
   int q,t,c;
   cin>>s;
   cin>>q;
   for(int i=0;i<s.size();i++){ 
       v.push_back(s[i]);
   } 
   while(q--){ 
       cin>>t;
       if(t==1){ 
           if(beg==true)beg=false;
           else beg=true;
       }
       else { 
           cin>>c>>add;
           if(c==1){ 
              if(beg==true)v.push_front(add);
              else v.push_back(add);
           } 
           else { 
               if(beg==true)v.push_back(add);
               else v.push_front(add);
           }
       }
   }
   if(beg==true){ 
       for(int i=0;i<v.size();i++)cout<<v[i];
   }
   else { 
       for(int i=v.size()-1;i>=0;i--)cout<<v[i];
   }   

    
    return 0;
}

Measured memory_bytes: 1024
from collections import defaultdict
import sys
sys.setrecursionlimit(10**6)
n , k = map(int , input().split())
arr = list(map(int , input().split()))
dic = defaultdict(int)
for i in range(1,n+1):
	dic[i] = arr[i-1]
cycle = []
visited = [False]*(10**6)
curr = 1
while True:
	cycle.append(curr)
	visited[curr] = True
	curr = dic[curr]
	#k -= 1
	if visited[curr]:
		break

csize = 0
ind = 0
for i in range(len(cycle)-1,-1,-1):
	if cycle[i] == curr:
		ind = i + 1
		break
	csize += 1
offset = len(cycle) - csize - 1
#print(cycle,csize+1, k , curr,offset)
if k - offset < 0:
	exit(print(cycle[k]))
k -= offset
k %= csize + 1
print(cycle[offset + k])


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

int main() {
  int n, x, t;
  cin >> n >> x >> t;

  if (n % x == 0) cout << (n / x) * t << endl;
  else cout << (n / x + 1) * t << endl;
  return 0;
}


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

using lint = long long;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<vector<T>>;
template <typename T> using VVV = vector<vector<vector<T>>>;
#define rep(i, n) for(int i = 0; i < int(n); i++)
#define repu(i, a, b, s) for(int i = int(a); i < int(b); i += int(s))
#define repd(i, a, b, s) for(int i = int(a); i > int(b); i += int(s))
#define endl "\n"
constexpr lint INF = 2e18;
constexpr lint MOD = 1e9 + 7;

void solve() {
    V<lint> in(3);

    for(auto &&it : in) {
        cin >> it;
    }

    sort(in.begin(), in.end());
    lint ans = in[2] * 10 + in[1] + in[0];
    cout << ans << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <set>
#include <string>

using namespace std;

int main()
{
  string s;
  int N;

  cin >> s >> N;

  set< string > S;

  for(int i = 0; i < s.size() - 1; i++) {
    string tmp = "";
    for(int j = i; j < min(i + N, (int)s.size()); j++) {
      tmp += s[j];
      S.insert(tmp);
    }
  }
  string tmp = string(&(s[s.size() - 1]));
  S.insert(tmp);

  int cnt = 1;
  for(auto v : S) {
    // cout << v << endl;
    if(cnt == N) {cout << v << endl; return 0;}
    cnt++;
  }

  return 0;
}


Measured memory_bytes: 1664
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (int i = 0; i < (n); ++i)	
//setprecision(16)

void outi(int x) { cout << x << endl;}
void soutl(ll x) { cout << x << endl;}
void outs(string x) { cout << x << endl;}
ll max(ll a, ll b) {
	ll max;
	if (a > b) max = a;
	else max = b;
	return max;
}
ll min(ll a, ll b) {
	ll min;
	if (a < b) min = a;
	else min = b;
	return min;
}
//---------------------------------------------------------------

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

	int r = l + n - 1;
	int eat;

	if (r <= 0) eat = r;
	else if (l >= 0) eat = l;
	else eat = 0;

	int ans = (l+l+n-1)*n/2 - eat;

	outi(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);
  int a[3];
  rep(i, 3) cin >> a[i];
  sort(a, a + 3);
  cout << a[0] << " " << a[2] << endl;
  return 0;
}



Measured memory_bytes: 3216
n = int(input())
h = list(map(int, input().split()))

ans = 0
tmp = 0

for i in range(n-1):
    if h[i] >= h[i+1]:
        tmp += 1
    elif h[i] < h[i+1]:
        ans = max(ans, tmp)
        tmp = 0
ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 15020
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;


int main(void) {
	char a, b;
	cin >> a >> b;
	string s = "", t = "";
	rep(i, a - '0') s += b;
	rep(i, b - '0') t += a;
	if (s < t) cout << s << endl;
	else cout << t << endl;
	return 0;
}


Measured memory_bytes: 3548
import java.util.Scanner;
import java.util.Stack;

class Main {

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

    void compute() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        if (A == 5 && B == 5 && C == 7 || A == 5 && B == 7 && C == 5 || A == 7 && B == 5 && C == 5) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 23124
"""
    Author        : Arif Ahmad
    Date          :
    Algo          :
    Difficulty    :
"""
from sys import stdin, stdout
from fractions import gcd


def main():
    n, k = [int(_) for _ in stdin.readline().strip().split()]
    a = [int(_) for _ in stdin.readline().strip().split()]

    g = a[0]
    for x in range(1, n):
        g = gcd(g, a[x])

    if k % g == 0 and k <= max(a):
        stdout.write('POSSIBLE\n')
    else:
        stdout.write('IMPOSSIBLE\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 88172
def point(x):
    return (abs(x), x)

def main():
    X, K, D = map(int, input().split())

    if X < 0:
        k = abs(X) // D
        k = min(k, K)
        ans = X + D*k
        K -= k
        # print(ans, K)
        if K >= 1 and point(ans + D) < point(ans):
            ans += D
            K -= 1
        # print(ans, K)
        if K % 2 == 1:
            ans = ans - D if ans > 0 else ans + D

    else:
        k = X // D
        k = min(k, K)
        ans = X - D*k
        K -= k

        # print(ans, K)
        if K >= 1 and point(ans - D) < point(ans):
            ans -= D
            K -= 1
        # print(ans, K)
        if K % 2 == 1:
            ans = ans - D if ans > 0 else ans + D

    print(abs(ans))

if __name__ == '__main__':
    main()

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

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

#define MOD 1000000007

using namespace std;

int main(){
	int n;
	
	cin >> n;
	
	vector<int> a(n);
	vector<int> ca(n);
	
	for(int i=0; i<n; i++){
		cin >> a[i];
		ca[i]=a[i];
	}
	
	sort(all(ca));
	
	for(int i=0; i<n; i++){
		if(a[i]==ca[n-1])	cout << ca[n-2] << endl;
		else	cout << ca[n-1] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3200
import java.util.*

fun main(args:Array<String>):Unit {
    var isFirst = true
    while(true){
        val account = readLine()!!.toInt()
        if (account == 0) break
        if (!isFirst) println()
        isFirst = false
        val (t, ft, h, fh) = readLine()!!.split(' ').map(String::toInt)
        val bill = Coins(t, ft, h, fh)
        val rest = Coins.payByCoin(bill.account() - account)
        bill.coins().zip(rest.intersection(bill).coins()).map{(b, r) ->
            Pair(b.first, b.second - r.second)
        }.filter{it.second != 0}.forEach {
            println("${it.first} ${it.second}")
        }
    }
}
class Coins(val ten:Int, val fifty:Int, val hundred:Int, val fiveHundred:Int){
    fun intersection(other:Coins):Coins{
        return Coins(minOf(ten, other.ten), minOf(fifty, other.fifty), minOf(hundred, other.hundred), minOf(fiveHundred, other.fiveHundred))
    }
    companion object {
        fun payByCoin(account: Int): Coins {
            return Coins((account % 50) / 10, (account % 100) / 50, (account % 500) / 100, account / 500)
        }
    }
    fun coins():Iterable<Pair<Int, Int>> {
        return listOf(Pair(10, ten), Pair(50, fifty), Pair(100, hundred), Pair(500, fiveHundred))
    }
    fun account():Int = coins().map{(a, b) -> a * b}.sum()
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 5e3 + 5;

int dp[MAXN];

int v[MAXN];

int p[MAXN];

vi g[MAXN];

bitset<MAXN> b1;

void solve(){
	int n;
	scanf("%d", &n);
	REPN(i, 2, n){
		scanf("%d", &p[i]);
		g[p[i]].pb(i);
	}
	REPN(i, 1, n){
		scanf("%d", &v[i]);
	}
	for(int s = n; s >= 1; s--){
		b1.reset();
		b1.set(0);
		int sum_mn = 0, sum_mx = 0;
		REP(i, 0, SZ(g[s])){
			int to = g[s][i];
			int dif = abs(v[to] - dp[to]);
			sum_mn += min(v[to], dp[to]);
			sum_mx += max(v[to], dp[to]);
			b1 |= (b1 << dif);
		}
		if (v[s] < sum_mn){
			printf("IMPOSSIBLE\n");
			return;
		}
		int cur_dif = v[s] - sum_mn;
		for(; cur_dif >= 0; cur_dif--){
			if (b1.test(cur_dif)){
				break;
			}
		}
		dp[s] = sum_mx - cur_dif;
	}
	printf("POSSIBLE\n");
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

using namespace std;

int main(){
    vector<int> A = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << A[--k] << endl;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define be(x) begin(x),end(x)
using namespace std;
typedef long long ll;
int main(){
    int n,amin,amax;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;++i)cin>>a[i];
    amin=*min_element(be(a));
    amax=*max_element(be(a));
    ll asum=accumulate(be(a),0LL);
    printf("%d %d %ld\n",amin,amax,asum);
}


Measured memory_bytes: 3236
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

  int A,B,M;cin>>A>>B>>M;
  vector<ll> a(A), b(B);
  for(int i=0;i<A;i++) cin >> a[i];
  for(int i=0;i<B;i++) cin >> b[i];
  ll ret = 1e15;
  for(int i=0;i<M;i++){
      int x,y;
      ll c;cin>>x>>y>>c;
      x--;y--;
      ret = min(ret, a[x] + b[y] - c);
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  ret = min(ret, a[0] + b[0]);
  cout << ret << endl;
}


Measured memory_bytes: 1792
import sys
input = sys.stdin.buffer.readline
from operator import itemgetter

def main():
    N = int(input())
    a = list(map(int,input().split()))
    active = []
    
    for i in range(N):
        active.append((a[i],i))
        
    active.sort(key=itemgetter(0),reverse=True)
    dp = [[0]*(N+1) for _ in range(N+1)]
    
    for i in range(N):
        for j in range(i+1):
            x,y = j,i-j
            dp[x+1][y] = max(dp[x+1][y],dp[x][y]+active[x+y][0]*(abs(active[x+y][1]-x)))
            dp[x][y+1] = max(dp[x][y+1],dp[x][y]+active[x+y][0]*(abs(active[x+y][1]-(N-y-1))))

    ans = 0
    for i in range(N+1):
        ans = max(ans,dp[i][N-i])
        
    print(ans)
    
if __name__ == "__main__":
    main()


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

int main() {
  int n,y;
  cin >> n >> y;
  int a,b,c;
  
  if(y < 1000*n){
      a = -1;
      b = -1;
      c = -1;
  }
  
  if(y > 10000*n){
      a = -1;
      b = -1;
      c = -1;
  }
  
  int k = y/1000;
  
  int B = (2*((n-k)%9))%9;
  
  
  if(1000*n <= y && y <= 10000*n){  
    for(int i=0; i<=n; i++){
      b = B + 9*i;
      c = n + (n-5*b-k)/9;
      a = n - b - c;
      
      if(10000*a+5000*b+1000*c == y && a+b+c == n && a>=0 && b>=0 && c>=0){
        break;
      }
      
      a = -1;
      b = -1;
      c = -1;
      
    }
  }
  
  cout << a << " " << b << " " << c << endl;
  
	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

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

	var cnt int
	for i := 1; i <= n; i += 2 {
		d := 0
		for j := 1; j <= i; j += 2 {
			if i%j == 0 {
				d++
			}
		}
		if d == 8 {
			cnt++
		}
	}
	fmt.Println(cnt)
}


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

using namespace std;
typedef long long ll;
const int N = 15;
int a[N][N],c[N],res[N];
int n,m,x;

int main(){
	cin>>n>>m>>x;
	for(int i=1;i<=n;i++){
		cin>>c[i];
		for(int j=1;j<=m;j++) cin>>a[i][j];
	}
	ll ans=0x3f3f3f3f;
	for(int i=1;i<(1<<n);i++){
		bool flag=0;
		memset(res,0,sizeof(res));
		for(int j=0;j<n;j++){
			if(i&(1<<j)){
				for(int k=1;k<=m;k++){
					res[k]+=a[j+1][k];
				}
			}
		}
		for(int j=1;j<=m;j++){
			if(res[j]<x){
				flag=1;
				break;
			}
		}
		if(!flag){
			ll tmp=0;
			for(int j=0;j<n;j++){
				if(i&(1<<j)){
					tmp+=c[j+1];
				}
			}
			ans=min(ans,tmp);
		}
	}
	if(ans==0x3f3f3f3f) cout<<-1<<'\n';
	else cout<<ans<<'\n';
	
	return 0;
} 

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

void solve() {
  string S;
  cin >> S;
  string ans = "Yes";
  if (S[0] == S[1] && S[1] == S[2]) {
    ans = "No";
  }
  cout << ans << endl;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main(){
    int N,A,B;
    cin >> N >> A >> B;
    vector<int>h(N);
    for(int i = 0; i < N; i++) {
        cin >> h[i];
    }
    int l = -2,r = INF;
    while(l+1 < r) {
        int mid = (l+r)/2;
        int cnt = 0;
        for(int i = 0; i < N; i++) {
            if(h[i] > mid*B) {
                cnt += (h[i]-mid*B+(A-B)-1)/(A-B);
            }
        }
        if(cnt > mid) {
            l = mid;
        }
        else {
            r = mid;
        }
    }
    cout << r << endl;
}


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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin >> n;
    long long h[n], dp[n];
    for( int i = 0; i < n; i++  ) {
        cin >> h[i];
    }
    dp[0] = 0;
    for( int i = 1; i < n; i++ ) {
        dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
        if( 1 < i ) {
            dp[i] = min( dp[i], dp[i-2] + abs(h[i]-h[i-2]) );
        }
    }
    cout << dp[n-1] << '\n';
    return 0;
}

Measured memory_bytes: 5180
#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()
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;
ll calcNumOfCombination(ll n, ll r){
        ll num = 1;
        for(int i = 1; i <= r; i++){
            num = num * (n - i + 1) / i;
        }
        return num;
    }
int main(){
	int n;
	ll ans=0;
	std::cin >> n;
	std::vector<string> s(n);
	rep(i,n){
		string dum;
		std::cin >> dum;
		sort(all(dum));
		s[i]=dum;
		
	}
	sort(all(s));
	
	int d=0;
	for (ll i = 0; i < n; i++) {
		/* code */

		if(s[i]!=s[d]){
			int del=i-d;
			ans+=calcNumOfCombination(del,2);
			d=i;
			
		}
	}
	int del=n-d;
	ans+=calcNumOfCombination(del,2);
	std::cout << ans << std::endl;
}

Measured memory_bytes: 7808
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

ll n, p;

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> p >> n;
	ll ans = 1;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i != 0)
			continue;
		int cnt = 0;
		while (n % i == 0)
			n /= i, ++cnt;
		while (cnt >= p)
			cnt -= p, ans *= i;
	}
	if (n != 1 && p == 1)
		ans *= n;
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main() {

    int s;
    scanf("%d", &s);

    int num1 = s / 100;
    int num2 = s - num1 * 100;

    //printf("%d %d", num1, num2);

    if ((num1 >= 1 && num1 <= 12) && (num2 >= 1 && num2 <= 12)) {
        printf("AMBIGUOUS");
    } else if (num1 >= 1 && num1 <= 12) {
        printf("MMYY");
    } else if (num2 >= 1 && num2 <= 12) {
        printf("YYMM");
    } else {
        printf("NA");
    }

    return 0;
}


Measured memory_bytes: 1704
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

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

void solve(long long N, long long x) {
  if (N == 1) {
    if (x == 1) {
      print(YES);
      print(1);
    } else {
      print(NO);
    }
  } else if (N == 2) {
    if (x == 2) {
      print(YES);
      print(1);
      print(2);
      print(3);
    } else {
      print(NO);
    }
  } else {
    if (x == 2 && x + 2 <= 2 * N - 1) {
      print(YES);
      map<ll, ll> ans;
      ans[N - 2] = x + 2;
      ans[N - 1] = x - 1;
      ans[N] = x;
      ans[N + 1] = x + 1;

      queue<ll> rest;
      for (ll i = 1; i < 2 * N; i++) {
        if (i < x - 1 || x + 2 < i) {
          rest.push(i);
        }
      }

      for (ll i = 0; i < 2 * N - 1; i++) {
        if (i < N - 2 || N + 1 < i) {
          ll n = rest.front();
          rest.pop();
          print(n);
        } else {
          print(ans[i]);
        }
      }
    } else if (x - 2 >= 1 && x + 1 <= 2 * N - 1) {
      print(YES);
      map<ll, ll> ans;
      ans[N - 2] = x - 2;
      ans[N - 1] = x + 1;
      ans[N] = x;
      ans[N + 1] = x - 1;

      queue<ll> rest;
      for (ll i = 1; i < 2 * N; i++) {
        if (i < x - 2 || x + 1 < i) {
          rest.push(i);
        }
      }

      for (ll i = 0; i < 2 * N - 1; i++) {
        if (i < N - 2 || N + 1 < i) {
          ll n = rest.front();
          rest.pop();
          print(n);
        } else {
          print(ans[i]);
        }
      }
    } else {
      print(NO);
    }
  }
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long x;
  scanf("%lld", &x);
  solve(N, x);
  return 0;
}


Measured memory_bytes: 3200
#include <cstdio>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
//#include <stack>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> II;

int N;
queue<int> order[1001];

inline int next_opponent(int x) {
   return order[x].empty() ? 0 : order[x].front();
}

inline void new_match(set<II>& matches, int x, int y) {
   if (x > y) swap(x, y);
   if (matches.emplace(II(x, y)).second) {
   // fprintf(stderr, "+ match %d %d\n", x, y);
   }
}

int solve() {
   int day = 0;
   int num_matches = N*(N-1)/2;

   set<II> matches;
   FOR(j, 1, N) {
      int i = next_opponent(j);
      if (i > j) continue;
      if (next_opponent(i) == j) {
         new_match(matches, i, j);
      }
   }

   while (num_matches > 0) {
      ++day;

      if (matches.empty())
         return -1;

      for (II match : matches) {
         int i, j;
         tie(i, j) = match;
         order[i].pop();
         order[j].pop();
      // fprintf(stderr, "- match %d %d\n", i, j);
         --num_matches;
      }

      set<II> new_matches;
      for (II match : matches) {
         int i, j;
         tie(i, j) = match;
         int oi = next_opponent(i);
         if (next_opponent(oi) == i) {
            new_match(new_matches, i, oi);
         }

         int oj = next_opponent(j);
         if (next_opponent(oj) == j) {
            new_match(new_matches, j, oj);
         }
      }

      matches = new_matches;
   }
   return day;
}

int main(int argc, char* argv[]) {
   scanf("%d", &N);

   FOR(i, 1, N) {
      REP(t, N-1) {
         int x;
         scanf("%d", &x);
         order[i].push(x);
      }
   }

   int res = solve();
   printf("%d\n", res);

   return 0;
}


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

#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> pi;


int main()
{
    string arr[]={"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};
    string s;
    cin>>s;
    int i=0;
    for(i=0; i<7; i++)
    {
        if(arr[i] == s)
            break;
    }
    i++;
    if(i == 7)
        cout<<7;
    else
        cout<<7-i;
}


Measured memory_bytes: 256
#include <stdio.h>

long is_sqrt(long nb)
{
	long i = 1;
	long count = 0;
	while (i <= nb)
	{
		if (i % 2)
		{
			nb -= i;
			count++;
		}
		i++;
	}
	return (count);
}

long	is_prime(long nb)
{
	if (nb < 2)
		return 0;
	if (nb == 2)
		return 1;

	long i = 2;
	while (i <= is_sqrt(nb))
	{
		if (nb % i == 0)
		{
			return (0);
		}
		i++;
	}
	return (1);
}

int main(void)
{
	long x;
	long i = 1;
	scanf("%ld", &x);
	if (is_prime(x))
	{
		printf("%ld\n", x);
		return 0;
	}
	while (is_prime(x) == 0)
	{
		if (is_prime(x + i))
		{
			printf("%ld\n", x + i);
			return (0);
		}
		i++;
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vi vector<int>
#define sl set<ll>
#define sc set<char>
#define pi pair<int,int>
#define pl pair<ll,ll>
#define mpi map<ll,ll>
#define mpc map<char,ll>
#define forn(i,n) for(ll i=0;i<n;i++)
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define inf        1000000000000

void solve()
{
	ll n;
	cin>>n;
	ll a[n];
	forn(i,n)
	cin>>a[i];
	ll dp[3005][3005]={0};
	for(ll i=n-1;i>=0;i--){
		for(ll j=i;j<n;j++){
			if(i==j){
				dp[i][j]=a[i];
			}
			else{
				dp[i][j]=max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
			}
		}
	}
	cout<<dp[0][n-1];
}

int main()
{
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        cout<<endl;
    }
}


Measured memory_bytes: 70784
N = int(input())
K = int(input())

X = list(map(int, input().split()))

HalfK = K/2.0

Ans = 0

for i in range(N):
    if X[i] > HalfK:
        Ans += 2*(K-X[i])
    else:
        Ans += 2*X[i]
        
print(str(Ans))

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

#define MAXN 1000005
#define int long long

int n,m;
int a[MAXN];
int c[MAXN];

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

signed main()
{
	rd();
	int ans = 0;
	for(int i = 1; i <= n; i ++)
		c[a[i]] ++;
	for(int i = 1; i <= n; i ++)
		ans += ((c[i]*(c[i]-1))>>1);
		
	for(int i = 1; i <= n; i ++) {
		cout<<ans - (c[a[i]]-1)<<"\n";
	}
	return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
  char c;
  cin >> c;
  c++;
  cout << c << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> b(n-1);
    for(int i=0;i<n-1;i++) cin >> b[i];
    // 1番目はb[0], n番目はb[n-1]が最大で確定
    int ans = b[0] + b[n-2];
    // 他はb[i]かb[i-1]のうち小さい方で確定
    for(int i=1;i<n-1;i++){
        ans += min(b[i], b[i-1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256