akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <malloc.h>

#define char_max 200000
#define Nmax 100000

int Pow(int n, int m);
int Max(int N[], int n);
int Min(int N[], int n);
int Sum(int N[], int n);

void Move(int* x, int* y, int d, int n);
void Upper(int* x, int* y, int d);
void Lower(int* x, int* y, int d);
void Right(int* x, int* y, int d);
void Left(int* x, int* y, int d);




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

	if (N == 1) {
		printf("Hello World");
	}
	else {
		int A = 0, B = 0;
		scanf("%d%d", &A, &B);
		printf("%d", A + B);
	}
	





	return 0;
}

void Move(int* x, int* y, int d, int n) {

}

void Upper(int* x, int* y, int d) {
	*y += d;
}
void Lower(int* x, int* y, int d) {
	*y -= d;
}
void Right(int* x, int* y, int d) {
	*x += d;
}
void Left(int* x, int* y, int d) {
	*x -= d;
}

int Pow(int n, int m) {
	int ret = 1;

	for (int i = 0; i < m; i++) {
		ret *= n;
	}

	return ret;
}

int Max(int N[], int n) {
	int max = N[0];

	for (int i = 0; i < n; i++) {
		max = max < N[i] ? N[i]: max;
	}

	return max;
}

int Min(int N[], int n) {
	int min = N[0];

	for (int i = 0; i < n; i++) {
		min = min > N[i] ? N[i] : min;
	}

	return min;
}

int Sum(int N[], int n) {
	int sum = 0;

	for (int i = 0; i < n; i++) {
		sum += N[i];
	}

	return sum;
}

Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;

class Program {

    static void Main (string[] args) {
        int N = int.Parse (Console.ReadLine ());
        long[] A = new long[N];
        long[] B = new long[N];
        for (int i = 0; i < N; i++) {
            string[] strtemp = Console.ReadLine ().Split (' ');
            A[i] = long.Parse (strtemp[0]);
            B[i] = long.Parse (strtemp[1]);
        }

        quickSortB2S (A);
        quickSortB2S (B);

        if (N % 2 == 0) {
            Console.WriteLine (B[N / 2] + B[N / 2 - 1] - A[N / 2] - A[N / 2 - 1] + 1);
        } else {
            Console.WriteLine (B[(N - 1) / 2] - A[(N - 1) / 2] + 1);
        }
    }

    static void quickSortB2S (long[] a) {
        quickSortB2S (a, 0, a.Length - 1);
    }

    static void quickSortB2S (long[] a, int left, int right) {
        if (left < right) {
            int i = left;
            int j = right;
            long tmp;
            long pivot = med3 (a[i], a[i + (j - i) / 2], a[j]);
            while (true) {
                while (a[i] > pivot) i++;
                while (pivot > a[j]) j--;
                if (i >= j) break;
                tmp = a[i];
                a[i] = a[j];
                a[j] = tmp;
                i++;
                j--;
            }
            quickSortB2S (a, left, i - 1);
            quickSortB2S (a, j + 1, right);
        }
    }

    static long med3 (long x, long y, long z) {
        if (x < y) {
            if (y < z) {
                return y;
            } else if (z < x) {
                return x;
            } else {
                return z;
            }
        } else {
            if (z < y) {
                return y;
            } else if (x < z) {
                return x;
            } else {
                return z;
            }
        }

    }

    //1000000007
}

//dotnet run --project test

Measured memory_bytes: 43764
#include<iostream>
using namespace std;
#define ll long long
#define pb push_back
#define mem(x,y) memset(x,y,sizeof(x))

ll A[100005], B[100005];

int main()
{
    ll i,j,k,s,d,r,m,n, mid, cont=1;
    cin>>n;
    for(i=1; i<=n; i++)
    {
        cin>>A[i]>>B[i];
        r = A[i] % B[i];
        if(r) A[i] = B[i] - r; else A[i] = 0;
    }

    for(i=n-1; i>=1; i--) if(A[i] < A[i+1])
    {
        d = A[i+1] - A[i];
        k = d / B[i];
        if(d % B[i]) k++;
        A[i] += k * B[i];
    }

    d = 0; s = 0;
    for(i=n; i>=1; i--)  s += A[i] - d, d = A[i];
    cout<<s<<endl;
    return 0;

}




Measured memory_bytes: 1792
use std::io::*;
use std::str::*;
use std::collections::*;

pub fn read_from<T: FromStr, R: Read>(s: &mut R) -> T {
    let s = s.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    if !s.is_empty() {
        if let Ok(s) = s.parse::<T>() {
            s
        } else {
            panic!("faild to parse {}", s);
        }
    } else {
        if cfg!(local) {
            // eprintln!("reached to EOF");
        }
        std::process::exit(0)
    }
}

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let mut stdin = stdin.lock();
    read_from(&mut stdin)
}

const MOD: u64 = 1000000007;

fn solve(n: usize, k: usize, dp: &mut Vec<Vec<Option<u64>>>) -> u64 {
    if let Some(ans) = dp[n][k] {
        ans
    } else {
        let ans = if n == 0 {
            if k == 0 { 1 } else { 0 }
        } else {
            let mut ans = 0;
            for i in 0..k+1 {
                ans += solve(n-1, k-i, dp);
                ans %= MOD;
            }
            ans
        };
        dp[n][k] = Some(ans);
        ans
    }
}

fn main() {
    loop {
        let n: usize = read();
        let mut m: u64 = read();

        let mut dp = vec![vec![None; 30]; n + 1];

        let mut ans = 1;
        for i in 2..100000 {
            if m % i == 0 {
                let mut exp = 0;
                while m % i == 0 {
                    m /= i;
                    exp += 1;
                }
                // println!("{} {}", i, exp);
                ans *= solve(n, exp, &mut dp);
                ans %= MOD;
            }
        }
        if m != 1 {
            ans *= solve(n, 1, &mut dp);
            ans %= MOD;
        }

        println!("{}", ans);
    }
}


Measured memory_bytes: 67452
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()
	s := make([]string, n)
	for i := range s {
		s[i] = next()
	}

	good := func(a, b int) bool {
		for i := 0; i < n; i++ {
			for j := 0; j < n; j++ {
				if s[(i+a)%n][(j+b)%n] != s[(j+a)%n][(i+b)%n] {
					return false
				}
			}
		}
		return true
	}

	ans := 0
	for a := 0; a < n; a++ {
		if good(a, 0) {
			ans++
		}
	}

	puts(ans * n)
}


Measured memory_bytes: 2016
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

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

using namespace std;
typedef long long int ll;
const ll INF = 10000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

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

    int cnt = 0;
    int ans = 0;
    rep(i, 3) {
        if (s[i] == 'R') cnt++;
        else cnt = 0;
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long int 
#define endl '\n'
#define INF 1000000000
#define MOD 1000000007
#define MAX 100000000 
#define mp make_pair
#define pb push_back
using namespace std;
ll mini(ll a,ll b)
{
	if(a>=b)
	return b;
	else
	return a;
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x,k,d,l;
    cin>>x>>k>>d;
    if(x<0)
    {
    	x=-x;
    }
    l=x/d;
    if(l>=k)
    {
    	x=x-k*d;
    	k=0;
    }
    else
    {
    	x=x-l*d;
    	k=k-l;
    }
    if(k>0)
    {
    	if(k%2!=0)
    	{
    		l=d-x;
    		x=mini(x+d,l);
    	}
    }
    cout<<x<<endl;
}

Measured memory_bytes: 3684
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

static const unsigned long long int MOD = 1000000007LL;

int n, res = 0;
int a[200001], b[200001];

int main()
{
    cin >> n;

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

    for (int i = n; i >= 1; i--)
    {
        int j = 1, ct = 0;
        while (i * j <= n)
        {
            if (b[i * j] == 1)
            {
                ct++;
            }
            j++;
        }

        if (ct % 2 == a[i])
        {
            b[i] = 0;
        }
        else
        {
            b[i] = 1;
            res++;
        }
    }

    cout << res << endl;

    if (res != 0)
    {
        for (int i = 1; i <= n; i++)
        {
            if (b[i] == 1)
            {
                cout << i << " ";
            }
        }
        cout << endl;
    }
    return 0;
}

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

const int N = 100000 + 10;
int bgn[N];
bool vis[N];
int n,m;
int c[N];

namespace solver
{
  void solve()
  {
    scanf("%d%d",&n,&m);
    for(int i=1; i<=n; ++i) c[i] = 1, vis[i] = 0;
	vis[1] = 1;
	int x, y;
	for(int i=1; i<=m; ++i)
	{
	  scanf("%d%d",&x,&y);
      if(vis[x])
	  {
	    vis[y] = 1;
		--c[x]; ++c[y];
		if(!c[x]) vis[x]=0;
	  }
	  else
	  {
	    --c[x]; ++c[y];
	  }
	}
	int ans=0;
	for(int i=1; i<=n; ++i) ans += vis[i];
	printf("%d\n",ans);
	
  }
}

using namespace solver;
int main()
{
  solver :: solve();
}

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

bool v[30];
string a;
bool f(int p, int q) {
	if ((v[p] + v[q]) % 2 == 0) return 1;
	else return 0;
}
int main()
{
	int i;
	cin >>a;
	for (i = 0; i < a.size(); i++) {
		v[a[i] - 'A'] = 1;
	}
	if (f('N' - 'A', 'S' - 'A') && f('E' - 'A', 'W' - 'A')) cout << "Yes";
	else cout << "No";
    return 0;
}


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

const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
 
  // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main(){
    int k;
    string s;
    cin >> k >> s;
    int n = s.size();
    combination c(n+k);
    mint ans;
    for(int i= 0; i<=k; i++){
        mint now = mint(26).pow(k-i);
        now *= mint(25).pow(i);
        now *= c(i+n-1,n-1);
        ans += now;
    }
    cout << ans.x << endl;
    return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    char t[1000001], p[10001];
    int jt[10001];
    cin.getline(t, 1000001);
    int tl=cin.gcount()-1;
    cin.getline(p, 10001);
    int pl=cin.gcount()-1;
    if(pl>tl) return 0;

    jt[0]=-1;
    jt[1]=0;
    int i=2, j=0;
    while(i<=pl){
        if(p[i-1]==p[j]){
            jt[i]=j+1;
            ++i;
            ++j;
        } else if(j>0) j=jt[j];
        else jt[i++]=0;
    }
    i=j=0;
    while(i<tl){
        if(t[i]==p[j]){
            ++i;
            ++j;
            if(j==pl){
                cout<<i-pl<<'\n';
                j=jt[j];
            }
        }else if(j==0) ++i;
        else j=jt[j];
    }
    return 0;
}

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

namespace _0055
{
    public class Program

    {
        public static void Main(string[] args)
        {
            decimal factor = 211 / (decimal)Math.Pow(3, 3);    //211 = 81+54+36+24+16(3^4,3^3*2^1,3^2*2^2,3^1*2^3,2^4)
            while (true)
            {
                string line = Console.ReadLine();
                if (string.IsNullOrEmpty(line)) return;
                Console.WriteLine(decimal.Parse(line) * factor);
            }
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 20048
n,m=map(int,input().split())
A=[[0,0] for i in range(n)]
for i in range(n):
    a,b=map(int,input().split())
    A[i][0]=a
    A[i][1]=b
tmp=0
ans=0
B=sorted(A,key=lambda x:x[0])
for i in range(n):
    if tmp+B[i][1]<m:
        ans+=B[i][1]*B[i][0]
        tmp+=B[i][1]
    elif tmp+B[i][1]>=m:
        s=m-tmp
        ans+=s*B[i][0]
        break
print(ans)

Measured memory_bytes: 22052
using System;

namespace ABC097_A_Colorful_Transceivers
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string[] input = Console.ReadLine().Split(' ');
			int a = int.Parse(input[0]);
			int b = int.Parse(input[1]);
			int c = int.Parse(input[2]);
			int d = int.Parse(input[3]);

			if (Math.Abs(a - b) <= d && Math.Abs(b - c) <= d)
			{
				Console.WriteLine("Yes");
			}
			else if (Math.Abs(a - c) <= d)
			{
				Console.WriteLine("Yes");
			}
			else
			{
				Console.WriteLine("No");
			}
		}
	}
}

Measured memory_bytes: 11092
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef tuple<int, int, int, int> t4;
typedef pair<ll, ll> PL;
typedef long double ldouble;

int s, e;
vector <int> E[100010];

void solve(){
	int n, m; scanf("%d%d", &n, &m);
	rep(i, m){
		int x, y; scanf("%d%d", &x, &y);
		E[x].pb(y);
		E[y].pb(x);
		if(i == 0)s = x, e = y;
	}
	deque <int> D;
	D.push_back(s);
	D.push_back(e);
	int chk[100010] = {};
	chk[s] = chk[e] = 1;
	while(1){
		int changed = 0;
		int ok = -1;
		for(int e : E[s])if(chk[e] == 0){ok = e; break;}
		if(ok != -1){
			D.push_front(ok);
			chk[ok] = 1;
			s = ok;
			changed = 1;
		}
		ok = -1;
		for(int f : E[e])if(chk[f] == 0){ok = f; break;}
		if(ok != -1){
			D.push_back(ok);
			chk[ok] = 1;
			e = ok;
			changed = 1;
		}
		if(changed == 0)break;
	}
	printf("%d\n",sz(D));
	for(int e : D)printf("%d ", e); puts("");
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		//printf("Case #%d: ", tc);
		solve();
	}
	return 0;
}

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

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

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = x * 10 + (c ^ 48), c = nc;
  return x;
  #undef nc
}

typedef long long ll;

void solve() {
  char ch;
  cin>>ch;
  putchar(ch>='a'?'a':'A');
}

int main() {
//  int T = read();
//  while (T--) solve();
  solve();
  return 0;
}


Measured memory_bytes: 3636
N, K = map(int, input().split())

XY = []
for _ in range(N):
    x, y = map(int, input().split())
    XY.append((x, y))
    
dots = XY[:]

import sys
INT_MAX = sys.maxsize

ans = INT_MAX

import itertools
for ((left_x, _), (right_x, _)) in itertools.combinations(dots, 2):
    if left_x > right_x:
        left_x, right_x = right_x, left_x
    for ((_, under_y), (_, top_y)) in itertools.combinations(dots, 2):
        if under_y > top_y:
            under_y, top_y = top_y, under_y
        counter = 0
        for d_x, d_y in dots:
            if  (left_x <= d_x) and (d_x <= right_x) and (under_y <= d_y) and (d_y <= top_y):
                counter += 1
                
        if counter >= K:
            area = (top_y-under_y) * (right_x-left_x)
            if ans > area:
                ans = area
            
print(ans)


Measured memory_bytes: 48748
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

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

    vector <char> S(s.length()), T(t.length());
    
    for (int i = 0; i < s.length(); i++){
        S[i] = s[i];
    }
    sort(S.begin(), S.end());

    for (int i = 0; i < t.length(); i++){
        T[i] = t[i];
    }
    sort(T.begin(), T.end(), greater<char>());

    bool flag = true;

    for (int i = 0; i < S.size() && i < T.size(); i++){
        if (S[i] < T[i]){
            break;
        }else if(S[i] > T[i]){
            flag = false;
            break;
        }
        if (i == min(S.size(), T.size()) - 1){
            if (S.size() >= T.size()){
                flag = false;
            }  
        }
    }

    if (flag == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    


    return 0;
}

Measured memory_bytes: 256
import sys,queue,math,copy,itertools
from fractions import gcd
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

S = input()
ans = len(S)
for i in range(len(S)-1):
    if S[i] != S[i+1]:
        ans = min(ans,max(i+1,len(S)-i-1))

print (ans)



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

int main(){
  int n,k;cin >> n >> k;
  int sum[n+2];
  fill(sum,sum+(n+2),0);
  double ans = 0;
  for(int i=1;i<=n;++i){
    int sumo = i;
    sum[i] = 1;
    while(sumo < k){
      sumo *= 2;
      sum[i] *= 2;
    }
    ans += 1.0/(sum[i]*n);
  }
  printf("%.12lf",ans);
  return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;

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

    std::cin >> N;

    int res = (N - 2) * 180;
    std::cout << res << std::endl;
}


Measured memory_bytes: 256
N = input()
A = list(map(int, input().split()))

if 0 in A:
    print(0)
    exit()

Ans = 1
for i in range(0,len(A)):
    Ans *= A[i]
    if Ans > 10**18:
        print(-1)
        exit()
    else:
        continue
print(Ans)

Measured memory_bytes: 21632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i]; a[i]--;
    }
    
    ll M = 1;
    ll tmp = 2;
    while(tmp < K) {
        M++; tmp = tmp * 2;
    }
    vector<vector<int>> x(M, vector<int> (N));
    for (int i = 0; i < N; i++) {
        x[0][i] = a[i];
    }
    for (int m = 1; m < M; m++) {
        for (int i = 0; i < N; i++) {
            x[m][i] = x[m-1][x[m-1][i]];
        }
    }

    ll ans = 0;
    for (ll m = M-1; m >= 0; m--) {
        if(1 & (K>>m)){
            ans = x[m][ans];
        }
    }
    printf("%lld\n", ans+1);

}

Measured memory_bytes: 52568
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.LinkedList;
import java.util.Collections;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author toshif
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyReader in = new MyReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, MyReader in, PrintWriter out) {
            int n = in.nextInt();
            LinkedList<Integer> b = new LinkedList<>();
            for (int i = 0; i < n; i++) {
                int a = in.nextInt();
                if (i % 2 == 0) {
                    b.addLast(a);
                } else {
                    b.addFirst(a);
                }
            }

            if (n % 2 != 0) {
                Collections.reverse(b);
            }

            StringBuilder sb = new StringBuilder();
            for (Integer v : b) {
                sb.append(v);
                sb.append(" ");
            }
            out.println(sb);
        }

    }

    static class MyReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public MyReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 65028
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int ax[n],ay[n],bx[m],by[m];
    for(int i=0;i<n;i++)cin>>ax[i]>>ay[i];
    for(int i=0;i<m;i++)cin>>bx[i]>>by[i];
    for(int i=0;i<n;i++){
        int ans=0,d=1000000000;
        for(int j=0;j<m;j++){
            if(abs(ax[i]-bx[j])+abs(ay[i]-by[j])<d){
                ans=j,d=abs(ax[i]-bx[j])+abs(ay[i]-by[j]);
            }
        }
        cout<<ans+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 3588
#include<iostream>
using namespace std;
bool has3(int x){
while(x){
if(x%10==3)return true;
x/=10;
}
return false;
}
void call(int n){
for(int x=1;x<=n;x++){
if(x%3==0||has3(x)){
cout<<" "<<x;
}
}
cout<<endl;
}
int main(){
int n;
cin>>n;
call(n);
return 0;
}



Measured memory_bytes: 3092
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int M1, D1, M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;

    if (M1 != M2) {
        write(1);
    }
    else {
        write(0);
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

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

    ll N;
    cin >> N;

    string ans = "";
    while(N > 0) {
        N--;
        ans += 'a' + (N % 26);
        N /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}


Measured memory_bytes: 3660
using System;

namespace aziz
{
    class Program
    {
        static void Main(string[] args)
        {
          String[] HMHMK = Console.ReadLine().Split(' ');
          int H1 = int.Parse(HMHMK[0]);
          int M1 = int.Parse(HMHMK[1]);
          int H2 = int.Parse(HMHMK[2]);
          int M2 = int.Parse(HMHMK[3]);
          int K = int.Parse(HMHMK[4]);
          int result = 0;
          if (H1 >= 0 && H1 <= 23 && H2 >= 0 && H2 <= 23)
          {
              if (M1 >= 0 && M1 <= 59 && M2 >= 0 && M2 <= 59)
              {
                  var H = (H2 - H1 ) * 60;
                  var M = (M2 - M1);
                  result = (H + M) - K;
              }
          }
          Console.WriteLine(result);  
        }
    }
}

Measured memory_bytes: 27540
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(long long)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const long long AMAX = 100000;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);

signed main(){
    long long n,t;
    cin>>n>>t;
    vector<long long> T(n);
    for(long long i=0;i<n;i++)cin>>T[i];
    T.push_back(10000000000);
    long long res = 0;
    for(long long i=0;i<n;i++){
        res+=min(T[i+1]-T[i],t);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 4480
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    a = list(map(int,input().split()))
    
    a.sort(reverse = True)
    ans = 0
    for i in range(N):
        ans += a[2*i + 1]
    
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 31452
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    string s[n];
    rep(i,n)cin >> s[i];
    map<string,int> mp;
    rep(i,n)mp[s[i]]++;
    cout << mp.size() << endl;
}

Measured memory_bytes: 25504
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>

using namespace std;

bool dp[5010];

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    long long sum = accumulate(begin(a), end(a), 0LL);
    sort(rbegin(a), rend(a));
    dp[0] = true;
    int ans = n;
    for(int i = 0; i < n; i++){
        bool f = false;
        if(sum < k){
            for(int j = k - 1; j >= 0; j--){
                if(dp[j]){
                    if(j + sum < k){
                        f = true;
                    }
                    break;
                }
            }
        }
        if(f){ break; }
        sum -= a[i];
        ans--;
        if(a[i] < k){
            for(int j = k; j >= a[i]; j--){
                dp[j] |= dp[j - a[i]];
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

void rev( bool &a, bool &b )
{
	a = !a;
	b = !b;

	return;
}

int main()
{
	bool cups[] = { true, false, false };

	string buffer;

	while ( cin >> buffer )
	{
		int a, b;

		a = buffer[0] - 'A';
		b = buffer[2] - 'A';

		rev( cups[a], cups[b] );
	}

	for ( int i = 0; i < 3; i++ )
	{
		if ( cups[i] )
		{
			cout << (char)( i + 'A' ) << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
from collections import deque
n,q=map(int,input().split())
edge=[[]for i in range(n+1)]
li=[0]*(n+1)
for i in range(n-1):
    a,b=map(int,input().split())
    edge[a].append(b)
    edge[b].append(a)
for i in range(q):
    p,x=map(int,input().split())
    li[p]+=x

q=deque()
q=[1]
se=set()
while q:
    idx=q.pop()
    se.add(idx)
    for x in edge[idx]:
        if x not in se:
            se.add(x)
            li[x]+=li[idx]
            q.append(x)
            
print(*li[1:])

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,D,X;
ll T[404040];
double F[402020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>D>>X;
	
	FOR(i,2*N+2) {
		T[i+1]=T[i]+D;
		D+=X;
	}
	
	for(x=1;x<=N;x++) {
		F[x] = 1.0/(2*x) + ((x-1.0)/x)*(1+1.0/x)*F[x-1];
	}
	
	_P("%.12lf\n",T[2*N]*F[N]);
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

int main() {
	int N,X,L,p=-INF,a=0;
	cin >> N;
	vector<P> r(N);

	rep(i,N) {
		cin >> X >> L;
		r.at(i) = P(X+L, X-L);
	}
	sort(r.begin(), r.end());

	rep(i,N)
		if(p <= r.at(i).second) {
			++a;
			p = r.at(i).first;
		}

	cout << a << endl;
}

Measured memory_bytes: 1024
import sys
import math
from collections import defaultdict
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def syakutori(array):
    n = len(array)
    r = 1
    res = 0
    now = array[0]
    for l in range(n):
        while 0 < r < n and (r <= l or now^array[r] == now+array[r]):
            now = now ^ array[r]
            r += 1
        res += r-l
        now = now ^ array[l]

        if l == r:
            r += 1

    return res


def main():
    N = NI()
    A = NLI()
    print(syakutori(A))


if __name__ == "__main__":
    main()

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

int main() {
  int N;
  cin >> N;
  int a, b, c, d;
  int r, p;
  p = N;
  r = p % 1000;
  a = (p-r)/1000;
  
  p = r;
  r = p % 100;
  b = (p-r)/100;
  
  p = r;
  r = p % 10;
  c = (p-r)/10;
  
  d = r;
  
  string result = "No";
  if ( b == c ) {
    if ( a == b || c == d ) {
      result = "Yes";
    }
  }
  cout << result << endl;
}

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

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,ma,mb;
    cin >> n >> ma >> mb;
    vector<int> a(n),b(n),c(n);
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    vector<vector<vector<int>>> dp(n,vector<vector<int>>(401,vector<int>(401)));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 401; j++){
            for(int k = 0; k < 401; k++){
                dp[i][j][k] = -1;
            }
        }
    }
    dp[0][0][0] = 0;
    dp[0][a[0]][b[0]] = c[0];
    for(int i = 1; i < n; i++){
        for(int j = 0; j < 401; j++){
            for(int k = 0; k < 401; k++){
                dp[i][j][k] = dp[i-1][j][k];
            }
        }

        for(int j = 0; j < 401; j++){
            for(int k = 0; k < 401; k++){
                if(j + a[i] < 401 && k + b[i] < 401 && dp[i-1][j][k] != -1){
                    if(dp[i][j+a[i]][k+b[i]] == -1 || dp[i][j+a[i]][k+b[i]] > dp[i-1][j][k] + c[i]){
                        dp[i][j+a[i]][k+b[i]] = dp[i-1][j][k] + c[i];
                    }
                }
            }
        }
    }


    /*for(int j = 0; j < 401; j++){
        for(int k = 0; k < 401; k++){
            if(dp[n-1][j][k] != -1){
                cout << "(" << j;
                cout << "," << k;
                cout << ")" << dp[n-1][j][k];
                cout << endl;
            }
        }
    }*/

    int result = -1;

    for(int i = 1; i*ma < 401 && i*mb < 401; i++){
        if(dp[n-1][i*ma][i*mb] != -1){
            if(result < 0){
                result = dp[n-1][i*ma][i*mb];
            }else{
                if(dp[n-1][i*ma][i*mb] < result){
                    result = dp[n-1][i*ma][i*mb];
                }
            }
        }
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 26624
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, K);
    ll a = 0;
    ll x = 7 % K;
    REP(i, K)
    {
        a = (a + x) % K;
        if (a == 0)
        {
            OUT(i + 1);
            return 0;
        }
        x = (10 * x) % K;
    }
    OUT(-1);
}

Measured memory_bytes: 3596
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>

#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <functional>
#include <iostream>

using namespace std;

typedef long long llint;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

const int MAX = 2e5 + 5;
const int mod = 1e9 + 7;

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

  vector<int> v;
  REP(i, N) {
    int x;
    scanf("%d", &x);
    if (v.empty() || x != v.back()) {
      v.push_back(x);
    }
  }

  N = v.size();
  vector<int> dp(N + 1, 0);
  vector<int> prev(MAX, -1);
  dp[N] = 1;
  for (int i = N - 1; i >= 0; --i) {
    dp[i] = dp[i + 1];
    if (prev[v[i]] != -1) {
      dp[i] += dp[prev[v[i]]];
    }
    dp[i] %= mod;
    prev[v[i]] = i;
  }

  printf("%d\n", dp[0]);

  return 0;
}


Measured memory_bytes: 2676
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


int main(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;

    ll ans = 0;

    if(a+b > c*2){
        int n = min(x,y);
        ans += c*2*n;
        x -= n;
        y -= n;
        if(x){
            if(a > c*2){
                ans += c*2*x;
            } else {
                ans += a*x;
            }
        } else if (y){
            if(b > c*2){
                ans += c*2*y;
            } else {
                ans += b*y;
            }
        }
    } else {
        ans += a*x;
        ans += b*y;
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	for (int i = 0; i < 90000; ++i)
	{
		int a,b;
		cin >> a >> b;
		if(a==0){
			break;
		}
		else{
		for (int j = 0; j < a; ++j)
		{
				if(j==0||j==a-1){
					for (int k = 0; k < b; ++k)
					{
						cout << "#" ;
				}
			}
				else{
					for (int k = 0; k < b; ++k)
					{
						if(k==0||k==b-1){
							cout << "#" ;
						}
						else{
							cout << "." ;
						}
						
					}
				}
				cout << "\n" ;
				
			}
			
		}
		cout << "\n" ;
	}
	

}


Measured memory_bytes: 3056
a,b,c,k=map(int,input().split())
s=0
import sys
if k>=a:
    k=k-a
    s=s+a*1
else:
    
    s=s+k*1
    print(s)
    sys.exit()
if k>=b:
    k=k-b
    s=s+b*0
else:
    
    s=s+k*0
    print(s)
    sys.exit()

if k>=c:
    k=k-c
    s=s+c*(-1)
else:
    
    s=s+k*(-1)
    print(s)
    sys.exit()
    
print(s)


Measured memory_bytes: 9200
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

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

const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)


int main() {
	IO;
	string s;
	cin>>s;
	int a=10*(s[0]-'0')+s[1]-'0';
	int b=10*(s[2]-'0')+s[3]-'0';
	bool yymm=false, mmyy=false;
	if(b<=12 && b>0) yymm=true;
	if(a<=12 && a>0) mmyy=true;
	if(yymm&&mmyy) cout<<"AMBIGUOUS\n";
	else if(yymm) cout<<"YYMM\n";
	else if(mmyy) cout<<"MMYY\n";
	else cout<<"NA\n";
	return 0;
}


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

int main() {
  int N, K;
  vector<int> h(100010);
  vector<int> dp(100010);

  int res = 0;

  cin >> N >> K;
  rep(i,N){
    cin >> h.at(i);
  }  
  
  dp.at(1) = dp.at(0) + abs(h.at(1) - h.at(0));
  for(int i = 2; i < N; i++){
    priority_queue<int, vector<int>, greater<int>> tmp_dp_pq;
    if(i < K){
      for(int j = 0; j < i; j++){
        tmp_dp_pq.push(dp.at(i-j-1)+abs(h.at(i) - h.at(i-j-1)));
      }
      dp.at(i) = tmp_dp_pq.top();
    }
    else{
      for(int j = 0; j < K; j++){
        tmp_dp_pq.push(dp.at(i-j-1)+abs(h.at(i) - h.at(i-j-1)));
      }
      dp.at(i) = tmp_dp_pq.top();
    }
  }

  cout << dp.at(N-1) << endl;
  
  return 0;
}

Measured memory_bytes: 1024
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var x = int.Parse(line[0]);
        var a = int.Parse(line[1]);
        var b = int.Parse(line[2]);
        var ax = Math.Abs(x - a);
        var bx = Math.Abs(x - b);
        Console.WriteLine(ax < bx ? "A" : "B");
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
int main() {
  LL N;
  cin >> N;
  vector<LL> A(N), B(N);
  for(auto& i: A) cin >> i;
  for(auto& i: B) cin >> i;
  LL sum = 0;
  for(auto i=0; i<30; ++i) {
    LL T = (1ll << i);
    auto C = B;
    for(auto& i: C) i %= 2*T;
    sort(begin(C), end(C));
    for(auto a: A) {
      a %= 2*T;
      auto l = lower_bound(begin(C), end(C), max(0ll, T-a));
      auto h = lower_bound(begin(C), end(C), 2*T-a);
      LL z = (h-l)&1;
      sum ^= (z << i);
      l = lower_bound(begin(C), end(C), 3*T-a);
      h = lower_bound(begin(C), end(C), 4*T-a);
      z = (h-l)&1;
      sum ^= (z << i);
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 4992
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

import java.util.StringTokenizer;


public class Main {

    private final static FastReader in = new FastReader();
    private static final PrintWriter out = new PrintWriter(System.out);


    public static long solve(long x, long k, long d) {
        if (x < 0) {
            x = -x;
        }
        long val = x / d;
        if (val >= k) {
            return x - (k * d);
        } else {
            long an = x - (val * d);
            an-=d;
            k--;
            if ((k - val) % 2 == 0) {
                return Math.abs(an);
            } else {
                return Math.abs(an+d) ;
            }
        }

    }

    public static void main(String[] args) {

        out.println(solve(in.nextLong(), in.nextLong(), in.nextLong()));

        out.flush();
    }

    private static final class FastReader {
        private static BufferedReader BF;
        private static StringTokenizer ST;

        public FastReader() {
            BF = new BufferedReader(new InputStreamReader(System.in));
            ST = null;
        }


        public final String next() {
            while (ST == null || !ST.hasMoreTokens()) {
                try {
                    ST = new StringTokenizer(BF.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return ST.nextToken();

        }

        final int nextInt() {
            return Integer.parseInt(next());
        }
        final long nextLong() {
            return Long.parseLong(next());
        }
    }


}


Measured memory_bytes: 32900
#include <stdio.h>

int main()
{
  int H,W,i,j;

  while(1){

  scanf("%d", &H);

  scanf("%d", &W);

  
 
  if(H == 0 && W == 0)
    break;
  

  
  for(i = 1; i <= H; i++)
    {
     for(j = 1; j <= W; j++)
    { 
      printf("#");
    }
     printf("\n");
  }
  printf("\n");
  }
  return 0;
}

  

Measured memory_bytes: 572
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	int N;
	int co=0;
	cin>>N;
	REP(i,N){
		int a;
		cin>>a;
		while(a%2==0){
			a/=2;
			co++;
		}
	}
	cout<<co<<endl;
	
	return 0;
}

Measured memory_bytes: 256