akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = [0] + [int(i) for i in input().split()] + [0]

s = 0
for i in range(1, N + 2) :
    s += abs(A[i] - A[i-1])

for i in range(1, N + 1) :
    if min(A[i-1], A[i+1]) <= A[i] <= max(A[i-1], A[i+1]) :
        print(s)
    else :
        print(s - abs(A[i] - A[i-1]) - abs(A[i] - A[i+1]) + abs(A[i-1] - A[i+1]))

Measured memory_bytes: 65900
struct Store {
    price: u32,
    num: u32
}
impl Store {
    pub fn new(price: u32, num: u32) -> Self {
        Store {price:price, num:num}
    }
}

fn main() {
    fn read<T: std::str::FromStr>() -> T {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        s.trim().parse().ok().unwrap()
    }
    fn read_vec<T: std::str::FromStr>() -> Vec<T> {
        read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
    }

    let nm = read_vec::<u32>();
    let n = nm[0];
    let m = nm[1];
    let mut a = vec![0; n as usize];
    let mut b = vec![0; n as usize];
    for i in 0..n {
      let ab = read_vec::<u32>();
      a[i as usize] = ab[0];
      b[i as usize] = ab[1];
    }
    println!("{}", answer(n, m, a, b));
}

fn answer(n:u32, mut m:u32, a:Vec<u32>, b:Vec<u32>) -> u64 {
  let mut ans = 0;
  let mut stores = Vec::new();
  for i in 0..n {
    stores.push(Store::new(a[i as usize], b[i as usize]))
  }
  stores.sort_by(|a, b| a.price.cmp(&b.price));
  for i in 0..n {
    let num = if stores[i as usize].num > m { m } else { stores[i as usize].num};
    ans += (stores[i as usize].price as u64) * (num as u64);
    m -= num;
    if m==0 {
      break;
    }
  }
  ans
}


Measured memory_bytes: 6396
import std.string;
import std.stdio;
import std.conv;
import std.algorithm;
import std.range;

int n,s;
long[1001][11] dp;

void main(){
    dp[0][0] = 1;
    for(int i=0;i<=100;i++){
	for(int j=9;j>=1;j--){
	    for(int k=0;k<=1000;k++){
		if(0<=i+k&&i+k<=1000)
		    dp[j][i+k] += dp[j-1][k];
	    }
	}
    }

    while(true){
	auto ss = split(readln());
	n = to!int(ss[0]);
	s = to!int(ss[1]);
	if(n == 0 && s == 0) break;
	writeln(dp[n][s]);
    }
}

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

vector<int> dp;

int f(int n) {
    if (dp[n]) return dp[n];
    if (n <= 1) return dp[n] = 1;
    return dp[n] = f(n - 1) + f(n - 2);
}

int main() {
    int n;
    cin >> n;
    dp.resize(n + 1);
    cout << f(n) << endl;
}


Measured memory_bytes: 3088
#include<stdio.h>

#define MAX 20
#define N 200

int solve(int,int);

int n;
int A[MAX];

int main()
{
  int q,i,res;
  int B[N];

  scanf("%d",&n);

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

  scanf("%d",&q);

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

  for(i = 0; i < q; i++){
    res = solve(0,B[i]);
    if(res == 1){
      printf("yes\n");
    }
    else if(res == 0){
      printf("no\n");
    }
  }

  return 0;
}

/*1 solve(i, m)
2   if m == 0
3     return true
4   if i >= n
5     return false
6   res = solve(i + 1, m) || solve(i + 1, m - A[i])
7   return res*/

int solve(int i,int m)
{
  int res;
  if(m == 0) return 1;
  if(i >= n) return 0;
  if(solve(i+1,m) == 1 || solve(i+1,m - A[i]) == 1){
    return 1;
  }
  return 0;
}



Measured memory_bytes: 2104
--prewritten code: https://github.com/antma/algo
{-# LANGUAGE BangPatterns #-}
{-# Options_GHC -O2 #-}
import Data.ByteString.Builder
import Data.Monoid
import System.IO
import qualified Data.ByteString.Char8 as C
import Data.Char
import Data.Array
import qualified Data.Array.Unboxed as UA
import Data.Int

ru, ri :: C.ByteString -> Int

ru = C.foldl' (\a c -> a * 10 - 48 + ord c) 0
ri s
  | C.head s == '-' = negate $ ru $ C.tail s
  | otherwise = ru s

solve :: [Int] -> Builder
solve (n:z) = (int64Dec $fst $ x ! 0) <> char7 '\n'
  where
    a :: UA.UArray Int Int
    a = UA.listArray (0, n - 1) $ take n z
    f :: Int -> (Int64, Int64)
    f !k = (max (v0 + w) (v1 - w), max (v0 - w) (v1 + w))
      where
        (!v0, !v1) = x ! (succ k)
        !w = fromIntegral $! a UA.! k
    x = listArray (0, n) $ (map f [ 0 .. n - 1]) ++ [(0, div minBound 2)]

main :: IO ()
main = hPutBuilder stdout . solve . map ri . C.words =<< C.getContents


Measured memory_bytes: 39548
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**10
mod = 10**9 + 7


def f():
    a,b = list(map(int, input().split()))
    if a * b == 0 or (a < 0 and b > 0):
        return 'Zero'
    if b < 0 and (a+b) % 2 == 0:
        return 'Negative'
    return 'Positive'

print(f())


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

int main(){
    int A,B,X;
    cin >> A >> B >> X;
    if(A > X){
        cout << "NO" << endl;
    }else{
        if(A + B < X){
            cout << "NO" << endl;
        }
        else{
            cout << "YES" << endl;
        }
    }
    return 0;
}

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

void solve(){
    int n;
    cin>>n;
    int tab[n][3];
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < 3;++j) cin>>tab[i][j];
    }
    int dp[n][3] = {1000000};

    dp[0][0] = tab[0][0]; dp[0][1] = tab[0][1]; dp[0][2] = tab[0][2];
    for(int i = 1; i < n; ++i){
        dp[i][0] = tab[i][0] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = tab[i][1] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = tab[i][2] + max(dp[i-1][1], dp[i-1][0]);
    }
    int cmax = 0;
    for(int i = 0; i < 3; ++i) cmax = max(cmax, dp[n-1][i]);
    cout<<cmax;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int arr[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,last=0;
    cin>>n;
    ll ans=0;
    for(int i=0; i<n; i++)
    {
        int a;
        cin>>a;
        if(i)
        {
            if(a<last)
                ans+=last-a;
        }
        last=max(last,a);
    }
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 3640
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different 
Yours Faithfully
Shobhit Yadav */

#include<bits/stdc++.h>
using namespace std;
#define ll long long 

ll K,N;
/*ll freq[200005];*/
void solve(){
	 /*memset(freq,0,sizeof(freq));*/
  cin>>K>>N;
  ll sum  = 0;
  ll a[N] , dist[N];

  for(ll i = 0 ; i<N ; i++)
    cin>>a[i];

  for(ll i = 0 ; i<N-1 ; i++){
    dist[i] = abs(a[i] - a[i+1]);
    sum += dist[i];
  }

  dist[N-1] = K - a[N-1] + a[0];
  sum += dist[N-1];

  sort(dist , dist+N);

  cout<<sum-dist[N-1]<<'\n';


}



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

	return 0;
}

Measured memory_bytes: 6700
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut scan = Scanner::new(cin);
    
    let n = scan.read::<usize>();
    let q = scan.read::<usize>();
    let s = scan.chars();
    let mut t = vec![];
    let mut d = vec![];
    for _ in 0..q {
        t.push(scan.chars()[0]);
        d.push(scan.chars()[0]);
    }

    let env = Env {n: n, q: q, s: s, t: t, d: d};
    println!("{}", env.n as i32 - (env.left_most() + 1 + env.n as i32 - env.right_most()));
}

struct Env {
    n: usize,
    q: usize,
    s: Vec<char>,
    t: Vec<char>,
    d: Vec<char>
}

impl Env {
    fn left_most(&self) -> i32 {
        let mut ok = -1i32;
        let mut ng = self.n as i32;
        while (ok - ng).abs() > 1 {
            let mid = (ok + ng) / 2;
            if self.left_reach(mid) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        ok
    }

    fn left_reach(&self, mut i: i32) -> bool {
        for j in 0..self.q {
            if i < self.n as i32 && self.t[j] == self.s[uz(i)] {
                match self.d[j] {
                    'L' => i-=1,
                    _ => i+=1
                }
            }
            if i < 0 {return true}
        }
        false
    }

    fn right_most(&self) -> i32 {
        let mut ok = self.n as i32;
        let mut ng = -1i32;
        while (ok - ng).abs() > 1 {
            let mid = (ok + ng) / 2;
            if self.right_reach(mid) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        ok
    }

    fn right_reach(&self, mut i: i32) -> bool {
        for j in 0..self.q {
            if i >= 0 && self.t[j] == self.s[uz(i)] {
                match self.d[j] {
                    'L' => i-=1,
                    _ => i+=1
                }
            }
            if i >= self.n as i32 {return true}
        }
        false
    }
}

// region template
#[allow(dead_code)]
fn uz(i: i32) -> usize { i as usize }

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: i32) -> Vec<T> {
        let mut ret = vec![];
        for _ in 0..n { ret.push(self.read::<T>()) }
        ret
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

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

using namespace std;

#define ll  long long
#define ld  double

#define all(x)  x.begin(),x.end()
#define sz(x)   (int)x.size()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 605;
const int   mod = 1e9 + 7;

void add(int &a,int b)  {
    a += b;
    if (a >= mod)
        a -= mod;
}
void sub(int &a,int b)  {
    a -= b;
    if (a <  0)
        a += mod;
}
int mul(int a,int b)    {
    return  1ll * a * b % mod;
}
int Pow(int a,int b)    {
    int ans = 1;
    while (b)   {
        if(b & 1)   ans = mul(ans,a);
        a = mul(a,a);   b >>= 1;
    }
    return  ans;
}
int inv(int a,int p)    {
    return  a == 1 ? 1 : p - 1ll * p * inv(p % a,a) / a;
}

typedef pair<int,int>   ii;

int l[N];
int f[N][N][N];

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

    int n;  cin >> n;
    int X;  cin >> X;

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

    sort(l + 1,l + 1 + n,greater<int>());

    f[0][0][0] = 1;

    for(int i = 1 ; i <= n ; ++i)
        for(int j = l[i] ; j <= X ; ++j)
        for(int k = 1 ; k <= j / l[i] ; ++k)    {
            int&res = f[i][j][k];

            add(res,mul(f[i - 1][j - l[i]][k - 1],k));          //add a segment
            add(res,mul(f[i - 1][j][k],j - k * (l[i] - 1)));    //put new segments into previous intervals

            for(int x = 1 ; x < l[i] ; ++x) {
                add(res,mul(f[i - 1][j - x][k],2 * k));
                add(res,mul(f[i - 1][j - x + 1][k + 1],(l[i] - x) * k));
            }
        }

    int ans = 0;

    for(int i = 0 ; i <= n ; ++i)
        add(ans,f[n][X][i]);

    cout << ans << endl;
}

Measured memory_bytes: 144256
#include<stdio.h>
int main()
{
    int H,W,i,j;
    while(1){
        scanf("%d %d",&H,&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: 2040
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

#ifdef DEBUG
#define DBG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)
#else
#define DBG(fmt, ...)
#endif

struct point{
    point(){};
    point(int _x,int _y):x(_x),y(_y){};
    int x;
    int y;
};

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;
    cin >> N;

    vector<int> n;
    for(int i = 1; i <= N; i++) n.push_back(i);

    vector<int> P(N);
    vector<int> Q(N);
    REP(i,N){
        cin >> P[i];
    }
    REP(i,N){
        cin >> Q[i];
    }

    ll a, b;
    ll i = 1;
    do{
        if( P == n ){ a = i; }
        if( Q == n ){ b = i; }
        i++;
    }while(next_permutation(n.begin(), n.end()));

    cout << abs(b-a) << endl;
}


Measured memory_bytes: 3576
// 2011/07/27 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int b, r, g, c, s, t;
		cin >> b >> r >> g >> c >> s >> t;
		if(b==0&&r==0&&g==0&&c==0&&s==0&&t==0)
			break;

		int med = 100;			// _ÌiúlÍ100j

		med += (15+(15-2)*5)*b;		// rbO{[iXÉæé
		med += (15+(15-2)*3)*r;		// M[{[iXÉæé
		med += 7*g;			// uhEÉæé
		med += 2*c;			// `F[Éæé

		med -= 3*(t-5*b-3*r-s);		// Q[Éæé¸

		cout << med << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <map>

using namespace std;


int main(){
    map<int,int> as;

    int n;
    cin >> n;

    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        as.insert(make_pair(a,i));
    }
    for(int i=0;i<n;i++){
        int order = as.at(i+1)+1;
        cout << order << " ";
    }
    cout << endl;
    return 0;
}

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

string s;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> s;
    string ns;
    for (auto& i : s) {
        if (i != 'x') ns += i;
    }
        
    int n = ns.size();
    
    if (n == 0) {
        cout << 0;
        return 0;
    }

    // Check if string without x's is a palindrome
    bool palin = false;
    if (n % 2) {
        string fir = ns.substr(0, n / 2), sec = ns.substr(n / 2 + 1, n / 2);
        reverse(sec.begin(), sec.end());
        if (fir == sec) palin = true;
    } else {
        string fir = ns.substr(0, n / 2), sec = ns.substr(n / 2, n / 2);
        reverse(sec.begin(), sec.end());
        if (fir == sec) palin = true;
    }

    if (!palin) {
        cout << -1;
        return 0;
    } 
    
    int l = 0, r = 0, nsi = 0;
    for (int i = 0; i < (int)s.size(); i++) {
        if (s[i] == ns[nsi]) {
            if (n % 2) {
                if (nsi == n / 2) {
                    l = i; r = i;
                    break;
                }
            } else {
                if (nsi == n / 2 - 1) l = i;
                if (nsi == n / 2) r = i;
            }
            nsi++;
        }
    }

    // cout << r << " " << l << '\n';
    int ans = 0;
    while (r < s.size() || l >= 0) {
        int rc = 0, lc = 0;
        while (r < s.size() && s[r] == 'x') {
            r++;
            rc++;
        }
        while (l >= 0 && s[l] == 'x') {
            l--;
            lc++;
        }
        // cout << rc << " " << lc << '\n';
        ans += abs(rc - lc);
        l--; r++;
    }

    cout << ans;
}


Measured memory_bytes: 592
#include <iostream>
#include <string>
#define ll long long
#define str string
using namespace std;
int main(){
	ll a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>=22){
		cout<<"bust";
      return 0;
	}
	else{
		cout<<"win";
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(2*max({a,b,c})==a+b+c)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n;
  scanf("%d",&n);
  const int m=200000;
  const int mod=1000000007;
  int *prev=(int *)calloc(m+1,sizeof(int));
  int i;
  int *dp=(int *)calloc(n+1,sizeof(int));
  dp[0]=1;
  for(i=1;i<=n;i++){
    int c;
    scanf("%d",&c);
    if(prev[c]==0 || prev[c]==i-1){
      dp[i]=dp[i-1];
    } else {
      dp[i]=(dp[i-1]+dp[prev[c]])%mod;
    }
    prev[c]=i;
  }
  printf("%d\n",dp[n]);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 1792
import std.stdio;
import std.conv;
import std.range;
import std.array;
import std.string;
import std.algorithm;

bool is_correct(uint[] nums, bool comb2, uint index, uint rest) {
  if (rest == 0) {
    if (comb2) return true;
    else return false;
  }
  if (nums[index] == 0)
    return is_correct(nums, comb2, index + 1, rest);
  if (nums[index] == 3) {
    nums[index] -= 3;
    if (is_correct(nums, comb2, index, rest - 3)) return true;
    nums[index] += 3;
  }
  if (nums[index] == 2) {
    if (!comb2) {
      nums[index] -= 2;
      if (is_correct(nums, true, index, rest - 2)) return true;
      nums[index] += 2;
    }
  }
  if (index + 2 < nums.length && nums[index] >= 1 && nums[index + 1] >= 1 && nums[index + 2] >= 1) {
    nums[index..(index + 3)] = nums[index..(index + 3)].map!((x) => x - 1).array;
    if (is_correct(nums, comb2, index, rest - 3)) return true;
    nums[index..(index + 3)] = nums[index..(index + 3)].map!((x) => x + 1).array;
  }
  return false;  
}

void main() {
  while(true) {
    string line = readln.chomp;
    if (stdin.eof) break;
    auto nums = line.dup.map!((x) => x.to!(uint) - '0').array;
    uint[] table = new uint[](9);
    uint[] ans = [];
    foreach(n; nums) table[n - 1]++;
    foreach(i; 0..9) {
      table[i]++;
      if (reduce!((max, x) => (max > x) ? max : x)(0, table) > 4) {
        table[i]--;
        continue;
      }
      else if (is_correct(table.dup, false, 0, 14)) ans ~= i;
      table[i]--;
    }
    if (ans == []) writeln(0);
    else ans.map!((x) => (x + 1).to!(string)).join(" ").writeln;
  }
}

Measured memory_bytes: 1096
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int main(){
    int N,K;
    double ans = 0;

    cin >> N >> K;

    for(int i = 1;i <= N;i++){
        int n = 0,x = i;
        while(x < K){
            x *= 2;
            n++;
        }
        ans += 1.0 / N * pow(0.5,n);
    }

    cout << fixed;
    cout << setprecision(12) << ans<< endl;

    return 0;
}

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

using namespace std;

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

string in;
string alp = "abcdefghijk";
//string alp = "abc";
int N = alp.size();

void init(){}

bool input(){
  cin>>in;
  if(in=="#")return false;
  return true;
}

bool has(int s,int i){
  return (s&(1<<i))>0;
}

vector<string> spstr(string& s, int i){
  vector<string> ret;
  ret.push_back(s.substr(1,i-1));
  if(s[i]!='-')ret.push_back(s.substr(i+1, s.size()-(i+2)));
  if(s[i]='-')ret.push_back(s.substr(i+2, s.size()-(i+3)));
  return ret;
}

bool hogo(bool a, bool b){
  if(a && !b)return false;
  return true;
}

bool calc(string s){
  // cout<<s<<endl;
  if(s=="T")return true;
  if(s=="F")return false;
  if(s[0]=='-'){
    return !calc(s.substr(1,s.size()-1));
  }
  int cnt = 0;
  rep(i,s.size()-1){
    if(cnt==1){
      if(s[i]=='*'){
	vector<string> sp = spstr(s,i);
	return calc(sp[0])&calc(sp[1]);
      }
      if(s[i]=='+'){
	vector<string> sp = spstr(s,i);
	return calc(sp[0])|calc(sp[1]);
      }
      if(s[i]=='-'&&s[i+1]=='>'){
	vector<string> sp = spstr(s,i);
	return hogo(calc(sp[0]), calc(sp[1]));
      }
    }
    if(s[i]=='(')cnt++;
    if(s[i]==')')cnt--;
  }
  return false;
}

string solve(){
  bool ans = true;
  rep(i,(1<<N)){
    string s = in;
    rep(j,s.size()){
      rep(k,alp.size()){
	if(s[j]==alp[k]){
	   s[j] = has(i,k) ? 'T' : 'F';
	}
      }
    }

    rep(i,s.size()){
      if(s[i]=='='){
	ans &= (calc(s.substr(0,i))==calc(s.substr(i+1,s.size()-(i+1))));
      }
    }
  }
  return ans ? "YES" : "NO";
}

int main(){
  while(init(),input())cout<<solve()<<endl;
}

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

int main(){
  int k,t;
  cin >> k >> t;
  vector<int> cakes(t);
  for(int i=0; i<t; i++){
    cin >> cakes[i];
  }

  int prev = -1;
  while(1){
    int maxidx=0;
    int maxval=0;
    for(int i=0; i<t; i++){
      if(maxval <= cakes[i] && prev!=i){
        maxval = cakes[i];
        maxidx = i;
      }
    }
    
    if(maxval==0){
      cout << cakes[prev] << endl;
      break;
    }else{
      cakes[maxidx]--;
      prev = maxidx;
    }
  }
  return 0;
}
    


Measured memory_bytes: 256
// Original macro is in https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = || -> String {
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// for adhoc read (ex. https://atcoder.jp/contests/abc112/tasks/abc112_a)
#[allow(dead_code)]
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

#[allow(dead_code)]
fn lcm(a: i64, b: i64) -> i64 {
    a*b / gcd(a, b)
}

fn main() {
    input! { n: usize, a: [usize;n] }

    let mut k =0;
    for i in 0..n {
        if i+1 != a[i] { k+=1; }
    }
    if k > 2 { println!("NO"); } else { println!("YES"); }
}


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

int main(){
	int n;
	scanf("%d", &n);
	vector<pair<int, int> > a;
	for(int i = 0; i < n; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		a.push_back(make_pair(x, y));
	}
	sort(a.begin(), a.end());
	for(int i = 0; i < n; i++)
		printf("%d %d\n", a[i].first, a[i].second);
}



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

int main() {
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  int count =0;
  
  while(A>=B) {count++; B *=2;}
  while(B>=C) {count++; C *=2;}
  
  if(count <=K) cout << "Yes" << endl;
  else cout << "No" << endl;

}

Measured memory_bytes: 3604
class UnionFind:
    def __init__(self, n):
        self.rank = [0]*n
        self.parent = [i for i in range(n)]

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def merge(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        elif self.rank[x] > self.rank[y]:
            self.parent[y] = x
        else:
            self.parent[x] = y
            self.rank[y] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)


n, m = map(int, input().split())
p = list(map(int, input().split()))
info = [list(map(int, input().split())) for _ in range(m)]

uf = UnionFind(n)

for x, y in info:
    uf.merge(p[x-1]-1, p[y-1]-1)

ans = 0
for i in range(n):
    if uf.same(i, p[i]-1):
        ans += 1

print(ans)

Measured memory_bytes: 36084
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;

int main(){
    int n, h, w;
    cin >> n >> h >> w;

    int counter = 0;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            int right =  j + w;
            int bottom = i + h;

            if (right <= n && bottom <= n) counter++;

        }
    }

    cout << counter << endl;
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    long long int sum=0;
    vector<int> p(n);
    int maxi = 0;
    for(int i=0;i<n;i++){
        cin>>p[i];
        sum += p[i];
        if(maxi < p[i])maxi = p[i];
    }
    long long int ans = sum -0.5*maxi;
    cout<<ans<<endl; 
}

Measured memory_bytes: 256
N=io.read"*n"
K=io.read"*n"
s={0}
for i=1,N do
	table.insert(s,s[i]+io.read"*n"*.5+.5)
end
max=0
for i=1,N-K+1 do
	max=math.max(max,s[i+K]-s[i])
end
print(max)

Measured memory_bytes: 2304
#include "bits/stdc++.h"
using namespace std;
struct ${$(){ios_base::sync_with_stdio(0);cin.tie(0);}}$;
 
const int N = 200005;
 
void go(string t) {
   cout << t << endl;
   exit(0);
}
 
int main() {
   string s;
   cin >> s;
   if((s[0] == s[1] && s[1] == s[2]) || (s[3] == s[1] && s[1] == s[2]))
      go("Yes");
   go("No");
   return 0;
}

Measured memory_bytes: 256
eval'A,B,*C=#'+`tr ' ' ,`
z=x=0
C.map{x^=_1}
999.times{45.downto(0){|i|(x^A^B)[i]>0&&(z+=t=[A[0,i],(~B)[0,i]].min+1
A-=t
B+=t)}}
p A>0?z:-1

Measured memory_bytes: 14944
object Main extends App {
  def min(ls: Int*): Int = ls.min
  
  val n = readInt
  val monsters = readLine.split(" ").map(_.toInt)
  val savers = readLine.split(" ").map(_.toInt)
  var fii = scala.collection.mutable.ArrayBuffer[Int]()
  var fij = scala.collection.mutable.ArrayBuffer[Int]()
  
  fii += min(monsters(0), savers(0))
  fij += min(monsters(1), savers(0)-fii.last)
  Range(1,n).foreach{i =>
    fii += min(monsters(i)-fij.last, savers(i))
    fij += min(monsters(i+1), savers(i)-fii.last)
  }
  
  print(fii.foldLeft(0L)(_+_) + fij.foldLeft(0L)(_+_))
}

Measured memory_bytes: 79376
#include <bits/stdc++.h>
#define N 52
using namespace std;
typedef vector<vector<bool> > V;
typedef pair<int,int> P;
typedef pair<P,P> PP;
string mp[N];
vector<PP> A;
int h,w;

bool compare(PP &a,PP &b){
  int w1 = a.second.first - a.first.first+1;
  int h1 = a.second.second - a.first.second+1; 
  int w2 = b.second.first - b.first.first+1;
  int h2 = b.second.second -b.first.second+1;
  return h1*w1 < h2*w2;
}

V v[50][50];
void visit(int x,int y){
  V &D = v[y][x] = V(N,vector<bool>(N,0));
  D[y][x] = 1;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++) {
      if(mp[i][j] == '#')continue;
      if(i)D[i][j] = D[i][j]|D[i-1][j];
      if(j)D[i][j] = D[i][j]|D[i][j-1];
    }
}

void pushA(int x,int y){
  V &D = v[y][x];
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
      if(!D[i][j]||islower(mp[i][j])||tolower(mp[i][j])!=mp[y][x])continue;
      A.push_back(PP(P(x,y),P(j,i)));
    }
}

void mkA(){
  A.clear();
  V &D = v[0][0];
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      if(D[i][j]&&islower(mp[i][j]))pushA(j,i);
  
  sort(A.begin(),A.end(),compare);
}

bool check(PP &a,PP &b){
  int x1=a.first.first,y1=a.first.second;
  int X1=a.second.first,Y1=a.second.second;
  int x2=b.first.first,y2=b.first.second;
  int X2=b.second.first,Y2=b.second.second;
  if((a.first==b.first||a.second == b.second)||
     (x1>=0&&y1>=0&&!v[y1][x1][y2][x2])||
     (!v[Y2][X2][h-1][w-1])||
     (X1<w&&X2<h&&!v[Y2][X2][Y1][X1]))return 0;
  return x1<=x2&&X2<=X1&&y1<=y2&&Y2<=Y1;
}

map<PP,int> mem[1000];
int dfs(int idx,PP sta){  
  if(idx == -1) return 0;
  if(mem[idx].count(sta))return mem[idx][sta];
  int res = dfs(idx-1,sta);
  if(check(sta,A[idx])){
    int a = dfs(idx-1,PP(sta.first,A[idx].first));
    int b = dfs(idx-1,A[idx]);
    int c = dfs(idx-1,PP(A[idx].second,sta.second));
    res = max(res,a+b+c+1);
  }
  return mem[idx][sta] = res;
}

int main(){
  while(1){
    cin>>h>>w;
    if(!h&&!w)break;
    for(int i=0;i<h;i++)cin>>mp[i];
    for(int i=0;i<1000;i++)mem[i].clear();

    visit(0,0);
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)if(isalpha(mp[i][j]))visit(j,i);
    
    mkA();
    if(!v[0][0][h-1][w-1]) cout<<-1<<endl;
    else cout<<dfs(A.size()-1,PP(P(-1,-1),P(w,h)))<<endl;
  }
}

Measured memory_bytes: 145912
import sys
from itertools import permutations
INPUT = lambda: sys.stdin.readline().rstrip()
MAP = lambda: map(int, INPUT().split())
sys.setrecursionlimit(10 ** 9)


def main():
    N, M = MAP()
    edges = set()

    for _ in range(M):
        u, v = MAP()
        edges |= {(u-1, v-1), (v-1, u-1)}

    print(sum(all((u, v) in edges for u, v in zip(p, p[1:])) for p in permutations(range(N)) if p[0] == 0))


if __name__ == '__main__':
    main()

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

int main(){
	string N; cin >> N;
	string ans = "Good";
	rep(i,3){
		if(N[i]==N[i+1]){
			ans = "Bad";
		}
	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 384
def main():
    n = int(input())
    a = [int(input()) for _ in [0]*n]
    xor = 0
    for i in a:
        xor ^= i
    i = 1
    cnt = 0
    while True:
        if xor >= i:
            i *= 2
            cnt += 1
        else:
            break
    ans = 0
    for i in range(cnt-1, -1, -1):
        j = (xor & 2**i) // (2**i)
        if j == 1:
            for k in a:
                if (k & 2**i) // (2**i) == 1 and k % (2**i) == 0:
                    xor ^= k
                    xor ^= k-1
                    ans += 1
                    a.remove(k)
                    break
            else:
                print(-1)
                return 0
    print(ans)


main()

Measured memory_bytes: 7900
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <numeric>
#include <bitset>
#include <sstream>
#include <deque>
#include <iomanip>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <iterator>
#include <utility>   // std::pair, std::make_pair
#include <stdlib.h>  //atoi
using namespace std;
typedef long long ll;
const  double PI = 3.141592654;
#define rep(i,x) for(int(i)=0;(i)<(ll)(x);(i)++)
#define all(s)      (s).begin(),(s).end()
#define allv(v)      (v).begin(),(v).end()
#define pb          push_back
#define sz          s.size()
#define vz          v.size()
//x = atoi(a.c_str())
void fast()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL), cout.tie(NULL);
}
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
int main()
{
	fast();
	string s, ss, f, ff;
	int x, y;
	cin >> x >> y >> s;
	int i = 0;
	while (isdigit(s[i]) && i < sz)
		f += s[i], i++;
	while (s[i] == '-' && i<sz)
		ff += s[i], i++;
	while (i < s.size() && isdigit(s[i]) && i < sz)
		ss += s[i], i++;
	if ((f.size() >= x ) && (ss.size() >= y) && ff.size() == 1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


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

int main(){
  long double a, b, x;
  cin >> a >> b >> x;

  long double c, xx;
  long double theta;
  
  if(x*2 > a*a*b){
    c = 2.0f*(a*a*b-x)/(a*a);
    theta = (long double)atan(c/a);
  }
  else{
    theta = (long double)atan(0.5*a*b*b/x);
  }
  theta *= (long double)(45.0/atan(1.0)); 
  
  cout << fixed << setprecision(10) << theta << endl;
  return 0;
}

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

int main(){
  int n, l;
  cin >> n >> l;
  
  vector<string> data(n);
  for(int i = 0; i < n; i++){
    cin >> data.at(i);
  }
  
  sort(data.begin(), data.end());
  
  for(int i = 0; i < n; i++){
    cout << data.at(i);
  }
  cout << endl;
}

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

int main()
{
  int a, b;
  cin >> a >> b;
  
  if (a < 1 || a > 9)
  {
    cout << "-1" << endl;
    return 0;
  }
  if (b < 1 || b > 9)
  {
    cout << "-1" << endl;
    return 0;
  }
  
  for(int i = 1; i <= 9; i ++)
  {
    for(int j = 1; j <= 9; j ++)
    {
      if(i * j == a * b)
      {
        cout << i * j << endl;
        return 0;
      }
    }
  }
  
  cout << "-1" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define F first
#define S second
#define endl "\n"
#define nl cout<<endl
#define pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define Knucklehead ios_base::sync_with_stdio(false);cin.tie(NULL);
#define txti freopen("input.txt", "r", stdin);
#define txto freopen("output.txt", "w", stdout);
//#define mod 100000007

#define mat vector<vector<ll>>
mat cn(ll n, ll m){return vector< vector<ll> >(n, vector<ll>(m));}
bool compare(char &s1,char &s2){return s1 > s2;} 

bool sortmahstyle(const pair<ll,ll> &a,  const pair<ll,ll> &b) 
{ 
    if(a.second > b.second )
        return true;
    if( a.second==b.second && a.first > b.second )
       return true;
 
    return false;
 }
//me
ll const mod = 1e9+7;
ll const inf = 1e6+2;
ll fact[inf];
void factfill()
{
    fact[0]=1;
    for(ll i=1; i<inf; i++)
        fact[i] = ( fact[i-1]*i ) % mod;
}

ll powmod(ll a, ll b)
{
    ll res = 1;
    while(b){
        if(b%2) res = ( res*a )%mod;
        a = (a*a)%mod;
        b/=2;
    }
    return res;
}

ll inv(ll x)
{
    return powmod(x,mod-2) % mod;
}

ll choose(ll n, ll r)
{
    return ( (fact[n]* inv(fact[n-r] ) )%mod *inv(fact[r]))%mod;
}
void solve()
{   

   ll n; cin >> n;

   if(n>=30)
    cout << "Yes";
else
    cout << "No";
}

int main() {
Knucklehead 
//*
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
/**/


        //factfill();
        ll t;
        /**/t=1;
        /*/cin>>t;/**/
        f(testcases,0,t){
            solve();
        }
 
 
 
 
    return 0;
}

Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication9
{
    class Program
    {
        static void Main(string[] args)
        {
            String str = Console.ReadLine();
            int x =int.Parse(str);
            x = x * x * x;
            Console.WriteLine(x);
         

        }
    }
}

Measured memory_bytes: 5596
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(str(b))
        b = b + 1
    if n > 1:
        fct.append(str(n))
    return fct

n = int(input())
ans = factorize(n)
# str_ans = str(ans)
# print(''.join(str_ans))
# print(str_ans)
# print(*ans)
print(str(n) + ': ' + ' '.join(ans))



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

namespace ABC131A
{
    class Program
    {
        static void Main(string[] args)
        {
            int s, a, b, c, d;

            var word = Console.ReadLine().Split(' ');
            s = int.Parse(word[0]);

            a = s / 1000;
            b = (s - 1000 * a )/ 100;
            c = (s - 1000 * a - 100*b) / 10;
            d = (s - 1000 * a - 100 * b - 10 * c);

            if ((a == b) || (b == c) || (c == d))
                Console.WriteLine("Bad");
            else
                Console.WriteLine("Good");
        }
    }
}

Measured memory_bytes: 11092
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    n = S()
    t = n[-1]
    if t == '2' or t == '4' or t == '5' or t == '7' or t == '9':
        print('hon')
    elif t == '3':
        print('bon')
    else:
        print('pon')

main()



Measured memory_bytes: 10916
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> l(n);
	for (int i = 0; i < n; i++) cin >> l.at(i);

	sort(l.begin(), l.end());
	int longest = 0;
	for (int i = 0; i < k; i++) {
		longest += l.at(n - i - 1);
	}
	cout << longest << endl;
}

Measured memory_bytes: 256
N = int(input())
P = list(map(float, input().split()))
dp = [[0] * (N+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(N):
    p = P[i]
    for j in range(i+1):
        dp[i+1][j+1] += dp[i][j] * p
        dp[i+1][j] += dp[i][j] * (1-p)

ans = sum(dp[N][i] for i in range(N//2+1, N+1))
print("{:.10f}".format(ans))


Measured memory_bytes: 253576
n,m  = map(int,input().split())
a = [int(x) for x in input().split()]

ans1 = [1]
temp = 0
visit = [0]*(n+1)
visit[1] = 1
while(True):
    ans1 += [a[temp]]

    if visit[a[temp]] == 1:
        break

    visit[a[temp]] = 1
    temp = a[temp]-1


    if len(ans1) == m+1:
        print(ans1[len(ans1)-1])
        exit()


num1 = ans1.index(a[temp])
ans2 = ans1[num1:len(ans1)-1]

num = len(ans2)

print(ans2[(m-num1)%num])


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

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

template<class T> T read() {
	T t;
	cin >> t;
	return t;
}

int main(){
	// rep(i, 5){
	int a = read<int>(), b = read<int>(), c = read<int>();
	if((a&&b)||c){
		cout << "Open" << endl;
	}else{
		cout << "Close" << endl;
	}
	// }
}

Measured memory_bytes: 1156
N,K = map(int, input().split())
h = [int(x) for x in input().split()]
cost = [0] * N

cost[0] = 0
cost[1] = abs(h[1] - h[0])


for i in range(N - 1):
    min = cost[i] + 10000
    for j in range(K):
        if j < i + 1:
            c1 = cost[i - j] + abs((h[i + 1] - h[i - j]))
            if min > c1:
                min = c1
    cost[i + 1] = min

print(min)


Measured memory_bytes: 52460
from functools import reduce

n = int(input())
t = [int(input()) for _ in range(n)]

def gcd(x, y):
    if x < y:
        x, y = y, x
    while y > 0:
        x, y = y, x % y
    return x

def lcm(x, y):
    return (x*y) // gcd(x, y)

res = reduce(lcm, t)

print(res)

Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int k;
    cin >> k;

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

    cout << a[k - 1] << endl;

    return 0;
}


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

using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;

ll M = 1000000007;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n, k;
  cin >> n >> k;
  vi a(n), b(2001);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[a[i]]++;
  }
  for (int i = 1; i <= 2000; i++)
    b[i] += b[i - 1];
  ll s = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      s += a[i] > a[j];
  ll c = 0;
  for (int i = 0; i < n; i++)
    c += b[a[i] - 1];
  ll m = k * (k - 1) / 2 % M;
  s = (s * k + c * m) % M;
  cout << s << "\n";
}


Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}
import Control.Monad
import Control.Monad.State
import Control.Monad.Reader
import Control.Arrow
-- import Control.Comonad
import Data.Maybe
import Data.List
import Data.Bool
import Data.Fixed
import Data.Tuple
import Data.Ratio
import qualified Data.Map.Strict as M
import qualified Data.Array.IO as IA
import qualified Data.Vector as V
 
getI = read <$> getLine :: IO Int
getIs = map read . words <$> getLine :: IO [Int]
getD = read <$> getLine :: IO Double
getDs = map read . words <$> getLine :: IO [Double]
getInt = read <$> getLine :: IO Integer
getInts = map read . words <$> getLine :: IO [Integer]
 
type Row = Integer
type Col = Integer
type PointI = (Integer, Integer)
type Point = (Int, Int)
 
mmm = 1000000007
fact n
    | n < 1 = 1
    | True = foldr1 (*) [1..n]
fi = fromInteger
fig = fromIntegral
rf = realToFrac
 
(.<.) f g -- combination
    | f < g = 0 
    | g < 1 || f < 1 = 1
    | True = foldr1 (*) (take g [f,f-1..]) `div` fact g
(.>.) f g --combination with repetition
    | g < 1 || f < 1 = 1
    | True = fact (f + g - 1) `div` (fact (f - 1) * fact g)
comb = (.<.)
combWp = (.>.)
 
unique a = unique_ (reverse . sort $ a) [] Nothing
    where
        unique_ [] arr _ = arr
        unique_ (x:xs) arr n
            | n == Just x = unique_ xs arr n
            | otherwise = unique_ xs (x:arr) $ Just x
 
zeroume keta num
    | (length . show $ num) > keta = show num
    | otherwise = do 
        let zeros = take keta $ repeat '0'
        reverse . take keta $ (reverse . show $ num) ++ zeros
 
i2b num
    | num < 2 = show num
    | otherwise = i2b_ num []
        where
            i2b_ num str
                | num == 0 = str
                | num == 1 = '1':str
                | otherwise = do
                    let next = num `div` 2
                    let this = if odd num then '1' else '0'
                    i2b_ next (this:str)
 
mapIncr = mapPlus 1
mapPlus n Nothing = Just n
mapPlus n a = (+) n <$> a
 
countIf f = length . filter f
 
-- 
--
--

main = do
  i <- getI
  putStrLn . show $ (div i 2) * (div (i + 1) 2)


Measured memory_bytes: 380
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main() {
    int n;
 
 
   cin >> n;
   
 
  
   while(1){
     
     string a = to_string(n);
     
     if(a[0]==a[1]&&a[1]==a[2]){
       
       
       break;
       
     }
     
      n++;
   }
  
    cout << n << endl;
  
  return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
if h%3==0 or w%3==0:
    print(0)
else:
    ans=min(h,w)
    if w%2==0:
        ans=min(ans,w//2)
    if h%2==0:
        ans=min(ans,h//2)
    if w%2==1 and h%2==1:
        H=h//2
        for x in range(w+1):
            ans=min(ans,abs(max(x*(H+1),(w-x)*h)-min(x*H,(w-x)*h)))
    print(ans)


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

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

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}




void _main() {
        string s;
        cin >> s;
        for (int i = 0; i < s.size(); i++) {
                if ((i % 2 == 0 && s[i] == 'L') || (i % 2 && s[i] == 'R')) {
                        cout << "No";
                        return;
                }
        }
        cout << "Yes";
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for(int i=1;i<=n;++i)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
using namespace std;

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  cout << min(a*n,b) << endl;
  return 0;
}


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

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    int one = N % 10;
    if (one == 3)
    {
        cout << "bon" << endl;
    }
    else if (one == 1 || one == 6 || one == 8 || one == 0)
    {
        cout << "pon" << endl;
    }
    else
    {
        cout << "hon" << endl;
    }
}


Measured memory_bytes: 3604
unittest
{
	assert( [ "3 2", "100 50 200" ].parse.expand.solve == 1 );
	assert( [ "5 8", "50 30 40 10 20" ].parse.expand.solve == 2 );
	assert( [ "10 100", "7 10 4 5 9 3 6 8 2 1" ].parse.expand.solve == 2 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	auto ans = 0L;
	auto d = 0L;
	auto m = long.max;
	foreach( i, a; as )
	{
		if( a < m )
		{
			m = a;
		}
		else
		{
			auto dd = a - m;
			if( d < dd )
			{
				ans = 1;
				d = dd;
			}
			else if( d == dd )
			{
				ans++;
			}
		}
	}
	return ans;
}


Measured memory_bytes: 6324
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e5 + 5, MOD = 1e9 + 7;
int n, m, a, b, ans, f[N], divs[N];
int ksm (int x, int y) {
	int now = x, ret = 1;
	while (y) {
		if (y & 1)
			ret = ret * now % MOD;
		now = now * now % MOD;
		y >>= 1;
	}
	return ret;
}
int C (int x, int y) {
	return (f[x] * divs[y] % MOD) * divs[x - y] % MOD;
}
int ways (int sa, int sb, int fa, int fb) {
	int x = (fa - sa) + (fb - sb), y = (fa - sa);
	return C (x, y);
}
signed main () {
	f[0] = 1;
	divs[0] = 1;
	for (int i = 1; i <= 2e5; i ++) {
		f[i] = f[i - 1] * i % MOD;
		divs[i] = ksm (f[i], MOD - 2);
	}
	scanf ("%lld%lld%lld%lld", &n, &m, &a, &b);
	ans = ways (1, 1, n, m);
	for (int i = 1; i <= b; i ++) {
		int now = ways (1, 1, n - a, i) * ways (n - a + 1, i, n, m) % MOD;
		while (ans < now)
			ans += MOD;
		ans -= now;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6848