akhauriyash/Code-Regression huggingface dataset:
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include<bits/stdc++.h>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>*/

#define sz(s) (int)(s.size())
#define all(s) s.begin(), s.end()
#define rep(a, b, c) for(int a = b; a <= c; ++a)
#define per(a, b, c) for(int a = b; a >= c; --a)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;
//using namespace __gnu_pbds;

typedef unsigned long long ull;
typedef long long ll;
/*typedef tree<pair<int, int>, 
null_type, less<pair<int, int>>, 
rb_tree_tag, tree_order_statistics_node_update>
ordered_set;*/
//find_by_order() order_of_key()

const double eps = 1e-7;
const int mod = 1e9+7, MXN = 5e5+17;
const int dx[] = {0,0,1,-1}, dy[] = {1,-1,0,0};

template<typename T>inline bool updmin(T &a, const T &b) {return a > b ? a = b,1 : 0;}
template<typename T>inline bool updmax(T &a, const T &b) {return a < b ? a = b,1 : 0;}

string s;
ll res, pref[15], pw[15];

inline ll get(int l, int r) {
	if(!l) return pref[r];
	return pref[r]-pref[l-1]*pw[r-l+1];
}

int32_t main() { _
#ifdef DanQQQQQ
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	cin >> s;
	pw[0] = 1ll;
	rep(i,1,sz(s)-1) pw[i] = pw[i-1]*10ll;
	pref[0] = s[0]-'0';
	rep(i,1,sz(s)-1) pref[i] = pref[i-1]*10ll+s[i]-'0';
	rep(i,0,(1<<(sz(s)-1))-1) {
		int last = 0;
		rep(j,0,sz(s)-2) if((i>>j)&1)
			res += get(last,j), last = j+1;
		res += get(last,sz(s)-1);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())



int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0,};



// int binary_search(int key){
//  //isOKを満たす要素のうち最小のインデックスを返す。（要ソート）
//   int left = -1;
//   int right = N;
//
//   while(right - left > 1){
//     int mid = left + (right - left)/2;
//
//     if(isOK(mid, key)) right=mid;
//     else left=mid;
//   }
//
//   return right;
// }




int main() {

  string S;
  cin >> S;


  ll ansb = 0;
  ll answ = 0;

  rep(i, S.size()){
    if(i%2==0){
      if(S[i]=='0'){
        ansb++;
      }else{
        answ++;
      }
    }else{
      if(S[i]=='1'){
        ansb++;
      }else{
        answ++;
      }
    }

  }


  ll ans = min(ansb,answ);

  cout << ans << endl;


}

















//


Measured memory_bytes: 512
// depends on: -

/*
usage:

tools::floor(5, 3) // => 1
tools::ceil(5, 3) // => 2
*/

namespace tools {
  template <typename T> constexpr T floor(T lhs, T rhs);
  template <typename T> constexpr T ceil(T lhs, T rhs);

  template <typename T> constexpr T floor(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        lhs / rhs :
      lhs < 0 && rhs >= 0 ?
        -ceil<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -ceil<T>(lhs, -rhs) :
        floor<T>(-lhs, -rhs);
  }

  template <typename T> constexpr T ceil(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        (lhs - 1 + rhs) / rhs :
      lhs < 0 && rhs >= 0 ?
        -floor<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -floor<T>(lhs, -rhs) :
        ceil<T>(-lhs, -rhs);
  }
}
#include <iostream>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <limits>

class difficulty {
public:
  const std::int_fast64_t score_per_problem;
  const std::int_fast64_t problem_count;
  const std::int_fast64_t complete_bonus;
  constexpr difficulty(const std::int_fast64_t score_per_problem, const std::int_fast64_t problem_count, const std::int_fast64_t complete_bonus) :
    score_per_problem(score_per_problem),
    problem_count(problem_count),
    complete_bonus(complete_bonus) {
  }

  class result {
  public:
    const std::int_fast64_t score;
    const std::int_fast64_t problem_count;
    constexpr result(const std::int_fast64_t score, const std::int_fast64_t problem_count) :
      score(score),
      problem_count(problem_count) {
    }
  };
  constexpr result solve(const std::int_fast64_t left_score) const {
    return this->score_per_problem * (this->problem_count - 1) < left_score
      ? result(this->score_per_problem * this->problem_count + this->complete_bonus, this->problem_count)
      : result(this->score_per_problem * tools::ceil(left_score, this->score_per_problem), tools::ceil(left_score, this->score_per_problem));
  }
};

int main() {
  std::int_fast64_t d, g;
  std::cin >> d >> g;
  std::vector<difficulty> difficulties;
  std::vector<std::int_fast64_t> indices;
  for (std::int_fast64_t i = 0; i < d; ++i) {
    std::int_fast64_t p_i, c_i;
    std::cin >> p_i >> c_i;
    difficulties.push_back(difficulty((i + 1) * 100, p_i, c_i));
    indices.push_back(i);
  }

  std::int_fast64_t min_problem_count = std::numeric_limits<std::int_fast64_t>::max();
  do {
    std::int_fast64_t score = 0;
    std::int_fast64_t problem_count = 0;
    for (const std::int_fast64_t& index : indices) {
      const difficulty::result result = difficulties[index].solve(g - score);
      score += result.score;
      problem_count += result.problem_count;
      if (score >= g) break;
    }
    min_problem_count = std::min(min_problem_count, problem_count);
  } while (std::next_permutation(indices.begin(), indices.end()));

  std::cout << min_problem_count << std::endl;
  return 0;
}

Measured memory_bytes: 256
def find(x, root)
  return unless @group[x]
  return true if @group[x].include?(root)
  @group[x].each do |m|
    return true if find(m, root)
  end
  false
end

while n = gets.to_i
  break if n == 0
  root = ''
  @group = {}
  n.times do |i|
    g, m = gets.split(':')
    root = g if i == 0
    ms = m[0..-3].split(',')
    ms.each{ |m| @group[m] ||= []; @group[m] << g }
  end
  cnt = 0
  leaf = @group.keys
  @group.values.each{ |vs| vs.each{ |v| leaf.delete(v) } }
  leaf.each do |name|
    if find(name, root)
      cnt += 1
    end
  end
  p cnt
end

Measured memory_bytes: 9256
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <deque>
#include <vector>

bool y(int i) {
  return i >= 0 && i <= 99;
}

bool m(int i) {
  return i > 0 && i <= 12;
}

auto main() -> int {
  std::string S;
  std::cin >> S;

  const auto a = std::stoi(S.substr(0, 2));
  const auto b = std::stoi(S.substr(2, 2));

  const auto yymm = y(a) && m(b);
  const auto mmyy = m(a) && y(b);

  if (yymm && mmyy) {
    std::cout << "AMBIGUOUS" << std::endl;
  } else if (yymm) {
    std::cout << "YYMM" << std::endl;
  } else if (mmyy) {
    std::cout << "MMYY" << std::endl;
  } else {
    std::cout << "NA" << std::endl;
  }
}


Measured memory_bytes: 888
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <iostream>
#include <string>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;

const int MaxN = 2e5;
int n;
LL sum[MaxN + 5], a[MaxN + 5], f[MaxN + 5];

int main() 
{
	scanf("%d", &n);
	sum[0] = 0;
	for(int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		sum[i] = sum[i - 1] + a[i];
	}
	LL ans = 1LL << 60;
	for(int i = 1; i < n; i++) 
		ans = min(ans, abs(sum[n] - 2LL * sum[i]));
	printf("%lld\n", ans);
}

Measured memory_bytes: 3328
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007; 
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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






int main(){
    int A, B, Q; std::cin >> A >> B >> Q;
    std::vector<long long> s(A+2), t(B+2);
    s[0] = t[0] = -LINF;
    s[A+1] = t[B+1] = LINF;
    for(int i(0); i < A; ++i) std::cin >> s[i+1];
    for(int i(0); i < B; ++i) std::cin >> t[i+1];
    long long x;
    for(int q(0); q < Q; ++q){
        std::cin >> x;
        auto its(std::upper_bound(std::begin(s), std::end(s), x));
        auto itt(std::upper_bound(std::begin(t), std::end(t), x));
        std::vector<long long> a{*(its-1), *its}, b{*(itt-1), *itt};
        long long ans(LINF);
        for(int i(0); i < 2; ++i){
            for(int j(0); j < 2; ++j){
                chmin(ans,
                      std::min(std::abs(a[i]-x), std::abs(b[j]-x)) 
                       + std::abs(a[i]-b[j]));
            }
        }
        std::cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 2944
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	int pos = 0;
	while (pos != n && a[pos] > pos) ++pos;
	--pos;
	int cnt = 0;
	for (int i = pos + 1; i < n; ++i) {
		if (a[i] > pos) ++cnt;
	}
	bool f1 = ((a[pos] - pos - 1) % 2 == 1);
	bool f2 = (cnt % 2 == 1);
	cout << (f1 || f2 ? "First\n" : "Second\n");
	return 0;
}

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

using namespace std;
typedef long long int lli;


void solve(){
	int n;
	cin>>n;
	int ar[n];
	for(int i=0; i<n; i++){
		cin>>ar[i];
	}
	int dp[n];
	dp[0]=0;
	dp[1]=abs(ar[1]-ar[0]);
	for(int i=2; i<n; i++){
		dp[i]=min(dp[i-1]+abs(ar[i]-ar[i-1]), dp[i-2]+abs(ar[i]-ar[i-2]));
	}
	cout<<dp[n-1]<<endl;
}

signed main(){
	//#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    //freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    //freopen("output.txt", "w", stdout);
    //#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
}


Measured memory_bytes: 1024
def readinput():
    s = input().split()
    return s

def main(s):
    stack=[]
    ans = 0
    i = 0
    for c in s:
        if (c=='+'):
            op1 = int(stack.pop())
            op2 = int(stack.pop())
            stack.append(str(op1+op2))
        elif(c=='-'):
            op1 = int(stack.pop())
            op2 = int(stack.pop())
            stack.append(str(op2-op1))
        elif(c=='*'):
            op1 = int(stack.pop())
            op2 = int(stack.pop())
            stack.append(str(op1*op2))
        else:
            stack.append(c)
    ans = int(stack.pop())    
    return ans

if __name__=='__main__':
    s = readinput()
    ans = main(s)
    print(ans)



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

int f(int x, int c){
  int res = x;
  for(int i=1; i<c; i++){
    x = x + res*10;
    res = res*10;
  }

  return x;
}


int main(){
  int a, b;
  cin >> a >> b;
  int a2 = f(a, b);
  int b2 = f(b, a); 
  
  if(a2>b2){
    cout << a2 << endl;
  }else{
    cout << b2 << endl;
  }
  

  return 0;
}

Measured memory_bytes: 3484
#include <iostream>
#include <utility>

using namespace std;

int main(void){
	int S[2][100];
	pair<int,int> min;
	for(int n[2];cin >> n[0] >> n[1],n[0]||n[1];){
		int diff=0,sum=0;
		bool mdf=false;
		min=make_pair(100,100);

		for(int i=0;i<2;i++)
			for(int j=0;j<n[i];j++){
				cin >> S[i][j];
				diff+=i==0?S[i][j]:-S[i][j];
			}

		for(int i=0;i<n[0];i++){
			int j;
			for(j=0;j<n[1];j++)
				if(diff==(S[0][i]-S[1][j])*2&&S[0][i]+S[1][j]<min.first+min.second){
					min=make_pair(S[0][i],S[1][j]);
					mdf=true;
				}	
		}

		if(mdf)
			cout << min.first << " " << min.second << endl;
		else
			cout << -1 << endl;

	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
	cout << fixed << setprecision(10);
	ll ans = 0;
	ll n,k;
	cin >> n >> k;
	for(ll i=k; i<=n+1;i++){
		ll left = i*(0+i-1)/2;
		ll right = i*(n+n-i+1)/2;
		ans += right - left + 1;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {

    int N, sum, idx;
    int b[] = {500, 100, 50, 10, 5, 1};
    for (; ;) {
        std::scanf("%d", &N);
        if (N == 0) break;
        N = 1000 - N;
        sum = idx = 0;
        while (N > 0) {
            sum += int(N/b[idx]);
            N %= b[idx];
            idx++;
        }
        std::printf("%d\n", sum);
    }
    return  0;
}



Measured memory_bytes: 3116
n = int(input())
a = list(map(int, input().split()))
if n % 3 == 0:
    d = {}
    for x in a:
        d.setdefault(x, 0)
        d[x] += 1
    if len(d) > 3 or any([d[x] % (n//3) for x in d]):
        print("No")
        quit()
    if len(d) == 1 and 0 not in d:
        print("No")
        quit()
    if len(d) == 2 and d.get(0) != n//3:
        print("No")
        quit()
    if len(d) == 3:
        b = [x for x in d]
        if b[0]^b[1] != b[2] or b[1]^b[2] != b[0] or b[0]^b[2] != b[1]:
            print("No")
            quit()
    print("Yes")
else:
    print("Yes" if all([x == 0 for x in a]) else "No")

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

bool graph[9][9];
//vector<pair<int,int> > root(9);

int dfs(int v,int N,bool visited[9])
{
  bool all_visited=true;
  for(int i=0;i<N;i++)
  {
    if(visited[i]==false) all_visited=false;
  }
  if(all_visited) return 1;

  int ret=0;

  for(int i=0;i<N;i++)
  {
    if(graph[v][i]==false) continue;
    if(visited[i]) continue;

    visited[i] = true;
    ret += dfs(i,N,visited);
    visited[i]=false;
  }
  return ret;
}

int main()
{
  int N,M;
  cin >> N >> M;
  for(int i=0;i<M;i++)
  {
    int a,b;
    cin >> a >> b;
    graph[a-1][b-1] = graph[b-1][a-1] = true;
    //scanf("%d %d",root[i].first,root[i].second);
  }
  bool visited[9];
  for(int i=0;i<N;i++) visited[i] = false;

  visited[0] = true;
  cout << dfs(0,N,visited) << endl;
  return 0;
}


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

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

  int mx = 0;
  for (auto kv : mp) mx = max(mx, kv.second);
  for (auto kv : mp)
    if (kv.second == mx) cout << kv.first << '\n';
  return 0;
}

Measured memory_bytes: 19204
use std::cmp;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };

    let x: usize = sc.read();
    let y: usize = sc.read();
    let z: usize = sc.read();
    let k: usize = sc.read();
    let a: Vec<i64> = sc.vec(x);
    let b: Vec<i64> = sc.vec(y);
    let c: Vec<i64> = sc.vec(z);
    let mut ab = vec![];
    for i in 0..x {
        for j in 0..y {
            ab.push(a[i] + b[j]);
        }
    }
    ab.sort();
    ab.reverse();

    let mut ans = vec![];
    for &ab in (&ab[..cmp::min(k, x * y)]).iter() {
        for i in 0..z {
            ans.push(ab + c[i]);
        }
    }
    ans.sort();
    ans.reverse();
    for i in 0..k {
        println!("{}", ans[i]);
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 44276
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s;
  cin >> s;
  int cnt = 0;
  if (s[0] == '1') cnt++;
  if (s[1] == '1') cnt++;
  if (s[2] == '1') cnt++;
  cout << cnt << endl;
}


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

#include <math.h>
#define PI 3.14159265358979323846264338327950L

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

long long lcm(long long a, long long b)
{
    long long temp = gcd(a, b);

    return temp ? (a / temp * b) : 0;
}




int main() {
    string s;
    cin >> s;
    int n = s.length();
    int i = 0; int j = n - 1;
    int cnt = 0;
    while (i < j) {
        if (s[i++] != s[j--]) cnt++;
    }
    cout << cnt;
    return 0;
}

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

int n, k;
int main() {
  cin >> n >> k;
  
  int cnt = 0;
  int sum = 0;
  ++cnt;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    sum += a;
    if (sum <= k) ++cnt;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
         
        int main() {
          int a, b, c, d;
          cin >> a >> b >> c >> d;
          if ( (a+b) < (c+d) ){
            cout << "Right" << endl;
          }
          else if ( (a+b) == (c+d) ){
            cout << "Balanced" << endl;
          }
          else {
            cout << "Left" << endl;
          }
        }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  ll n, m;
  cin >> n >> m;
  if (n > m / 2)
    cout << m / 2 << endl;
  else
    cout << n + (m - 2 * n) / 4 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using llong = long long;
#define MLIMIT 1000000000000000000
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
llong cal(llong *a, int n)
{
    rep(i, n) if (a[i] == 0) return 0; //0が含まれている場合
    llong ans(1);
    rep(i, n)
    {
        llong tmp = MLIMIT / ans;
        if (a[i] > tmp)
            return -1;
        ans *= a[i];
    }
    return ans;
}
int main()
{
    int n;
    cin >> n;
    llong a[n];
    for (auto &e : a)
        cin >> e;
    cout << cal(a, n) << endl;
}

Measured memory_bytes: 4396
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int k;
  cin >> k;
  int ans = 0;
  for (int i = 0;i<n;i++){
    int x;
    cin >> x;
    if (x < k-x){
      ans += x;
    }
    else{
      ans += k-x;
    }
  }
  cout << ans*2 << endl;
}


Measured memory_bytes: 256
using System;

namespace AtCoderAGC035A
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            bool ans = true;

            string[] s = Console.ReadLine().Split(' ');

            if (N % 3 == 0)
            {
                int[] X = new int[N];

                for (int i = 0; i < N; i++)
                {
                    X[i] = int.Parse(s[i]);
                }

                Array.Sort(X);

                for(int j = 0;j<3;j++)
                {
                    for(int i=1;i<N/3;i++)
                    {
                        if (!(X[j*N/3] == X[j*N/3+i]))
                        {
                            ans = false;
                            break;
                        }
                    }

                    if (!ans)
                        break;
                }

                if(ans)
                {
                    if (!((X[0] ^ X[N / 3 * 2]) == X[N / 3]))
                    {
                        ans = false;
                    }
                    if (!((X[0] ^ X[N / 3]) == X[N / 3*2]))
                    {
                        ans = false;
                    }
                    if (!((X[N/3] ^ X[N / 3 * 2]) == X[0]))
                    {
                        ans = false;
                    }

                }

            }
            else
            {
                for(int i = 1;i<N;i++)
                {
                    if(!s[0].Equals(s[i]))
                    {
                        ans = false;
                        break;
                    }
                }

            }

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


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

int main()
{
  string s;
  cin >>s;
  int n=s.size();
  rep(i,(n-1)/2){
    if(s[i]!=s[i+(n-1)/2+1]){
      cout << "No"<<endl;
      return 0;
    }
  }
  cout << "Yes"<<endl;
}

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

using namespace std;
typedef long long ll;

#define INF (long long)(10e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
    string sd, t;
    cin >> sd >> t;
    int tl = t.size();
    int sdl = sd.size();
    bool f2 = false;
    
    for(int i = sdl - tl; i >=0; i--) {
        bool f = true;
        for(int j = 0; j < tl; j++) {
            if(sd[i+j] == '?' || sd[i+j] == t[j]) {
            } else {
                f = false;
            }
        }
        if(f) {
            REP(j, tl) {
                sd[i + j] = t[j];
            }
            REP(j, sdl) {
                if(sd[j] == '?') sd[j] = 'a';
            }
            f2 = true;
            break;
        }
    }
    if(f2) {
        cout << sd << endl;
    } else {
        cout << "UNRESTORABLE" << endl;
    }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main()
{
    cin>>a>>b>>c;
    if((a<=b&&b<=c)||(b<=a&&a<=c))cout<<a+b;
    else if((a<=b&&c<=b)||(c<=a&&a<=b))cout<<a+c;
    else cout<<c+b;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N, H;
  cin >> N >> H;
  vector<int> a(N), b(N);
  int amax = 0;
  vector<int> strong;
  REP(i, N) {
    cin >> a[i] >> b[i];
    amax = max(amax, a[i]);
  }
  REP(i, N) {
    if (amax <= b[i]) strong.push_back(b[i]);
  }
  sort(ALL(strong));
  reverse(ALL(strong));
  int ans = 0;
  REP(i, strong.size()) {
    ans++;
    H -= strong[i];
    if (H <= 0) {
      cout << ans << endl;
      return 0;
    }
  }
  ans += (H + amax - 1) / amax;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1660
N = int(input())
A = list(map(int, input().split()))
ans = True
for i in range(N):
  if A[i] % 2 == 0:
    if A[i] % 3 != 0 and A[i] % 5 != 0:
      ans = False
if ans:
  print("APPROVED")
else:
  print("DENIED")

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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

void solve(){
   string a,b;
   cin >> a >> b;
   string c = b.substr(0 , sz(b) - 1);
   cout << (a == c ? "Yes" : "No");
}

int32_t main(){
   fast;
   int t = 1;
//   cin >> t;
   while(t--)  solve();   

}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,h,w;
	cin>>n>>h>>w;
	cout<<(n-h+1)*(n-w+1)<<endl;
}

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

main()
{
  int N, T;
  int t;
  int maxv = 0, ans = 0;
  
  cin >> N >> T;

  for(int i = 0; i < N; i++) {
    cin >> t;
    ans += min(T, T - (maxv - t));
    maxv = t + T;
  }

  cout << ans << endl;

  return 0;
}


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

/*
int main() {
    int a;
    string s;
    std::cin >> a >> s;
    if(a<3200){
        std::cout << "red" <<std::endl;
    }
    else{
        std::cout << s << std::endl;
    }
    return 0;
}
 */

int main(){
    int N;
    std::cin >> N;
    double A[N];
    double A_sum = 0;
    double A_prod = 1;
    double ans;
    for(int i=0; i<N; i++){
        std::cin >> A[i];
    }
    for(int i=0; i<N; i++){
        A_prod *= A[i];
    }
    for(int i=0; i<N; i++){
        A_sum += (A_prod/A[i]);
    }
    ans = A_prod/ A_sum;
    std::cout << ans << std::endl;
    return 0;

}

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

int main() {
    long long n, d, x, y;
    long long ans = 0;
    cin >> n >> d;

    for(long i=0; i<n; i++)
    {
        cin >> x >> y;
        if(x*x + y*y <= d*d) ans++;
    }

    cout << ans << endl;

    return 0;
}



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

int main(){
  int n;
  cin >> n;
  string s,t,u;
  cin >> s >> t;
  
  for(int i=0;i<n;i++){
    u+=s.at(i);
    u+=t.at(i);
  }
  cout << u << endl;
}

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int a1 = abs(a[1]-a[0]);
	if(n==2){
		cout<<a1<<endl;
		return 0;
	}
	int a2 = abs(a[2]-a[0]);
	int curr = a2;
	for(int i=3;i<n;i++){
		curr = min(a1+abs(a[i]-a[i-2]),a2+abs(a[i]-a[i-1]));
		a1 = min(a2,a1+abs(a[i-1]-a[i-2]));
		a2 = curr;
	}
	cout<<curr<<endl;
	return 0;
	
}

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

int main(){
    int n;
    cin>>n;
    vector<int> a(n),b(n),c(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    rep(i,n) cin>>c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll ans = 0;
    rep(i,n){
        int bottom = lower_bound(a.begin(),a.end(),b[i])-a.begin();
        int top = n-(upper_bound(c.begin(),c.end(),b[i])-c.begin());
        ans += (ll)bottom*top;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1408
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String c = in.nextLine();
        String base = "abcdefghijklmnopqrstuvwxyz";

        for( int i = 0 ; i < base.length() ; i++ ){
            if( c.charAt(0) == base.charAt( i ) ){
                System.out.println( base.charAt( i + 1) );
                return;
            }
        }

    }

}


Measured memory_bytes: 21716
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<vector<pair<int, int> > > vvp;
typedef vector<pair<int, int> > vp;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<vector<ll> > vvl;
typedef vector<ll> vl;
typedef vector<vector<bool> > vvb;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<string, int> psi;
typedef pair<int, int> pii;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define yn(f) (f?"yes":"no")
#define YN(f) (f?"YES":"NO")
#define Yn(f) (f?"Yes":"No")
#define inf (1000000007)
#define nil -1
int main() {
	int N, M;
	cin >> N >> M;
	vp A(N);
	vvi list(M+1);
	rep(i, 0, N) {
		cin >> A[i].second >> A[i].first;
		if (A[i].second > M)continue;
		list[M - A[i].second].push_back(A[i].first);
	}
	priority_queue<int> P;
	ll count = 0;
	for (int i = M; i >=0; i--)
	{
		for (int j = 0; j < list[i].size(); j++)
		{
			P.push(list[i][j]);
		}
		if (P.empty()) {
			continue;
		}
		else {
			count += P.top(); P.pop();
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 6400
// C - Switches
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;

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

	vi S(M);
	for(int m=0; m<M; ++m){
		int K; cin>>K;
		for(int k=0; k<K; ++k){ int s; cin>>s; S[m] += (1<<(s-1)); }
	}

	vi P(M);
	for(int p=0; p<M; ++p) cin>>P[p];

	int unmatch_count = 0;
	int all = 1<<N;
	for(int s=0; s<all; ++s){//s: sw all pattern
		int b,m;
		for(m=0; m<M; ++m){//S[m]: sw data matching
			int sw = s & S[m];
			b = 0; while(sw){ if(sw&1) ++b; sw/=2; }//count bit '1'
			if(b%2 != P[m]) break;
		}
		if(m<M && b%2 != P[m]) ++unmatch_count;
	}
	cout<< all - unmatch_count <<endl;
}

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

using namespace std;


int main(){
    long n,ans,j;
    cin >> n; 
    ans=n-1;
    double x=sqrt(n);
    for(long i=2;i<=x;i++){
        if(n % i==0){
            j=n/i;
            if(ans>i+j-2){
                ans=i+j-2;
            }
        }
        
    }
   
    cout << ans << endl;
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    int res = 0;
    for (ll i = 2; i * i <= n; i++) {
        int pw = 0;
        while (n && (n % i == 0)) {
            n /= i;
            pw++;
        }
        int iter = 1;
        while (pw > 0) {
            if (pw - iter < 0) break;
            res++;
            pw -= iter;
            iter++;
        }
    }
    if (n != 1) res++;
    cout << res;
    return 0;
}


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

typedef vector<int> vec1;
typedef vector<vector<int>> vec2;
typedef vector<vector<char>> cvec2;
typedef pair<int, int> pairi;

vec1 vecplus(const vec1 &first, const vec1 &second){
  int length = first.size();
  vec1 answer(length);
  rep(i,length){
    answer.at(i) = first.at(i) + second.at(i);
  }
  return answer;
}

vec2 listmake(const int &row, const int &col){
  vec2 list;
  rep(i,row){
    vec1 v(col);
    rep(j,col){
      cin >> v.at(j);
    }
    list.push_back(v);
  }
  return list;
}

int main(){
  int N, M;
  cin >> N >> M;
  int ans = 0;
  using Graph = vec2;
  Graph G(N);
  rep(i,N){
    int H;
    cin >> H;
    G.at(i).push_back(H);
  }
  rep(i,M){
    int A,B;
    cin >> A >> B;
    G.at(A-1).push_back(B-1);
    G.at(B-1).push_back(A-1);
  }
  rep(i,N){
    int len = G.at(i).size();
    bool judge = true;
    for(int j = 0; j < len; j++){
      if(j == 0){
        continue;
      }
      if (G.at(i).at(0) <= G.at(G.at(i).at(j)).at(0)){
        judge = false;
        break;
      }
    }
    if (judge){
      ans++;
    }
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 9284
#include "bits/stdc++.h"
using namespace std;

const int N = 105;
bool chk[N][N];
int w, h, n;


void  f(int x, int y, int a) {
    for(int i = 0; i <= w; ++i) 
        for(int j = 0; j <= h; ++j) {
            if(a == 1 and i <= x) chk[i][j] = 1;
            if(a == 2 and i > x) chk[i][j] = 1;
            if(a == 3 and j <= y) chk[i][j] = 1;
            if(a == 4 and j > y) chk[i][j] = 1;
        }
}

int main() {
    cin >> w >> h >> n;
    while (n--) {
        int x, y, a;
        cin >> x >> y >> a;
        f(x, y, a);
    }

    int res = 0;
    for(int i = 1; i <= w; ++i) 
        for(int j = 1; j <= h; ++j) 
            if(chk[i][j] == false) 
                res++;

    cout << res << endl;
}

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

#define DEBUG if(0)
#define lli long long int

int main()
{
  int s, w;
  scanf("%d%d", &s, &w);
  printf("%s\n", w >= s ? "unsafe" : "safe");
  return 0;
}
/*
  Math skills:
  Tn = n^2 - (n - 1)^2
  Serie: 1 3 5 7 9
  i.e Arithmetic progression -> Sn = (A1 + An) * n / 2;
  (a * b) % n == a % mod * b % mod;
*/

Measured memory_bytes: 3764
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp{
    char name[100];
    int t;
} P;

P Q[LEN];
int head,tail,n;

void enqueue(P x){
    Q[tail]=x;
    tail=(tail+1)%LEN;
}

P dequeue(){
    P x=Q[head];
    head=(head+1)%LEN;
    return x;
}

int min(int a,int b){
    return a<b?a:b;
}

int main(void){
    int elaps=0,c;
    int i,q;
    P u;
    scanf("%d %d",&n,&q);
    for(i=1;i<=n;i++){
        scanf("%s",Q[i].name);
        scanf("%d",&Q[i].t);
    }
    head=1;
    tail=n+1;
    while(head != tail){
        u=dequeue();
        c=min(q,u.t);
        u.t-=c;
        elaps+=c;
        if(u.t > 0)
            enqueue(u);
        else
            printf("%s %d\n",u.name,elaps);
    }
    return 0;
}

Measured memory_bytes: 10756
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <math.h>
#include <string>
#include <iomanip>
#include <locale>
#include <list>
#include <bitset>
#include <tuple>
using namespace std;
#define FORN(i,m,n) for(int i=(m); i<int(n); i++)
#define PRINTVEC(v) FORN(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define PRINTMAT(m) FORN(j,0,m.size()) {PRINTVEC(m[j]);}
typedef long long ll;
 
int main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int n, m; cin>>n>>m;
  string ans(n,'*');
  set<pair<int,int> > s;
  FORN(i,0,m){
    int a, b; cin>>a>>b;
    a--;
    s.insert({a,b});
  }
  for(auto p : s){
    int pos = p.first, val = p.second;
    if(ans[pos] == '*') ans[pos] = char('0'+val);
    else{
      cout<<-1<<endl;
      return 0;
    }
  }
  if(ans[0] == '*') ans[0] = (n > 1 ? '1' : '0');
  else if(ans[0] == '0'){
    if(n > 1){
      cout<<-1<<endl;
      return 0;
    }
  }
  FORN(i,0,n) if(ans[i] == '*') ans[i] = '0';
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

//snippets:tmp,cl,cvl,cs,co,coy,con,cov

int main(){
    ll k;
    cin >> k;
    vll a(k);
    rep(i, k) cin >> a[i];
    reverse(all(a));
    ll min=2;
    ll max=2;
    rep(i,k){
        if(a[i]>max){
            cout << -1 << endl;
            return 0;
        }else if(min<a[i]) min=a[i];
        min=(min+a[i]-1)/a[i]*a[i];
        max=max-max%a[i]+a[i]-1;
    }
    if(min>max){
        cout << -1 << endl;
        return 0;
    }
    cout << min<<" "<<max << endl;
}

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

using namespace std;

//#define MD 10

int main(){
    char c;
    cin>>c;
    if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
        cout<<"vowel"<<endl;
    }else{
        cout<<"consonant"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int N;
    cin >> N;
    deque<int> b;
    vector<int> A(N);
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0) {
            b.push_back(A.at(i));
        }
        else {
            b.push_front(A.at(i));
        }
    }
    if (N % 2 == 0) {
        for (int i = 0; i < N; i++) {
            cout << b.front() << " ";
            b.pop_front();
        }
    }
    else {
        for (int i = 0; i < N; i++) {
            cout << b.back() << " ";
            b.pop_back();
        }
    }
    cout << endl;
}


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

int isPrime(int x) {
  if (x < 2) return 0;
  else if (x == 2) return 1;
  else if (x % 2 == 0) return 0;

  for (int i = 3; i*i <= x; i += 2) {
    if (x % i == 0) return 0;
  }

  return 1;
}

int main() {
  int n, cnt = 0;
  cin >> n;
  for (int i = 0; i < n; i ++) {
    int x;
    cin >> x;
    if (isPrime(x)) cnt ++;
  }

  cout << cnt << endl;
}



Measured memory_bytes: 3088
#define rep(i,n) for (int i=0; i<(int)(n); ++i)

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

int main(){
    vector<int> vec(32);
    vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;

    cout << vec.at(K-1) << endl;
}

Measured memory_bytes: 256
N = int(input())
a = [0] * N
for i in range(N):
    k = int(input())
    li = [i+1,k]
    a[i] = li
a.insert(0,[0,0])
import sys
sys.setrecursionlimit(100000000)
seen = [False] * (N+1)
def dfs(i):
    seen[i] = True
    if seen[a[i][1]] == False:
        dfs(a[i][1])
dfs(1)
def search(a):
    import collections
    from collections import deque
    que = deque()
    count = 0
    que.append(1)
    while len(que) != 0:
        i = que.popleft()
        if i != 2:
            count+=1
            que.append(a[i][1])
        if i == 2:
            return count
if seen[2]:
    k = search(a)
    print(k)
else:
    print(-1)

Measured memory_bytes: 118348
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int A, B, C; cin >> A >> B >> C;
    if (A == B) cout << C << endl;
    else if (B == C) cout << A << endl;
    else cout << B << endl;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=0
for i in range(N):
  ans+=B[A[i]-1]
  if i>0 and A[i]==A[i-1]+1:
    ans+=C[A[i-1]-1]
print(ans)


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

using ll = long long int;
using P = pair<int, int>;
using P3 = pair<ll,P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9) + 7;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr double EPS = 1e-8;

ll power(ll x, ll n, ll p){
    ll res = 1;
    while(n > 0){
        if(n&1){
            res = res*x%p;
        }
        x = x*x%p;
        n >>= 1;
    }
    return res;
}

bool solve(){
    int n, p;
    string s;
    cin >> n >> p >> s;
    ll ans = 0;
    if(p==2 || p==5){
        for(int i=0;i<n;i++){
            if((s[i]-'0')%p==0){
                ans += i+1;
            }
        }
    }else{
        reverse(s.begin(),s.end());
        vector<ll> cnt(p,0);
        cnt[0] = 1;
        int r = 0;
        for(int i=0;i<n;i++){
            r = (r+(s[i]-'0')*power(10,i,p))%p;
            ans += cnt[r];
            cnt[r]++;
        }
    }
    cout << ans << endl;
    return false;
}

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

Measured memory_bytes: 640
#n = int(input())
a,b,c,k = map(int,input().split())
#a_L = list(map(int,input().split()))

ans = 0
if k-a <= 0:
    ans = 1*k
    print(ans)
    exit()

k = k-a
ans = 1*a
#print(ans)

if k-b <= 0:
    print(ans)
    exit()
k = k-b


print(ans+k*(-1))


Measured memory_bytes: 61628
n, q = map(int, input().split())
s = input()

ac_counter = [0] * n
counter = 0
for i in range(n - 1):
    # ac_counter[i] = counter
    if s[i:i+2] == "AC":
        counter += 1
    ac_counter[i + 1] = counter

for i in range(q):
    l, r = map(int, input().split())
    print(ac_counter[r - 1] - ac_counter[l - 1])
# print(ac_counter)

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

using namespace std;

map <string,int> ma[20];

int main(){
        int n;
        string s;
        cin>>n>>s;
        for(int i=0;i<(1<<n);i++){
                string cur;
                int n1=0;
                for(int j=0;j<n;j++) if ((i>>j)&1){
                        cur.push_back(s[j]);
                        n1++;
                }
                for(int j=n-1;j>=0;j--) if (!((i>>j)&1))
                        cur.push_back(s[j]);
                ma[n1][cur]++;
        }
        long long ans=0;
        for(int i=0;i<(1<<n);i++){
                string cur;
                int n1=0;
                for(int j=n-1;j>=0;j--) if (!((i>>j)&1)){
                        cur.push_back(s[n+j]);
                        n1++;
                }
                for(int j=0;j<n;j++) if ((i>>j)&1)
                cur.push_back(s[n+j]);
                ans+=ma[n1][cur];
        }
        cout<<ans;

}


Measured memory_bytes: 73984
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int n, s = 0;
    scanf("%d", &n);
    vector<int> a(n);
    for (int i = 0; i < n - 1; i++)
    {
        scanf("%d ", &a[i]);
    }
    scanf("%d", &a[n - 1]);
    for (int i = 0; i < n; i++)
    {
        int mini = i;
        for (int j = i + 1; j < n; j++)
        {
            if(a[mini] > a[j])
            {
                mini = j;
            }
        }
        if(i != mini)
        {
            swap(a[mini], a[i]);
            s++;
        }
    }
    for (int i = 0; i < n - 1; i++)
    {
        printf("%d ", a[i]);
    }
    printf("%d\n%d\n", a[n - 1], s);
}


Measured memory_bytes: 3192
import java.util.*;

public class Main {
    public static void main(String args[]) {
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int rem = n%10;
        if(rem==3){
            System.out.println("bon");
        }else if(rem==0 ||rem==1 ||rem==6 ||rem==8){
            System.out.println("pon");
        }else{ System.out.println("hon");
           
        }
    }
}

Measured memory_bytes: 35756
#include <stdio.h>

int main(void)
{


	int a,b,c,i,j;
	int n;

	for(i=0;scanf("%d",&a)!=EOF;i++){
		scanf("%d",&b);
		c=a+b;
		n=1;
		while(1){
				if(c<10){
					break;
				}
				c=c/10;
				n++;
			}
		printf("%d\n",n);
	}

return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <float.h>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <fstream>
#include <queue>
#include <math.h>
#include <set>
#include <stdlib.h>
#include <time.h>
#include <list>
#include <stack>
#include <queue>

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define SORT(c) sort((c).begin(),(c).end())
#define vi(m,a) vector<int> m(a)
#define vti(m,a,i) vector<vector<int>> m(a,vector<int>(i))
#define ALL(it,a) for(auto it = a.begin(); it!=a.end(); it++)
#define Fe(it,a) for(auto &it : a)
#define all(a) begin(a),end(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define WARU 1000000007;

int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };

int main() {
	string a, b;
	cin >> a >> b;
	if (a.length() > b.length()) {
		cout << "GREATER";
	}
	else if (a.length() < b.length())
		cout << "LESS";
	else {
		if (a > b) {
			cout << "GREATER";
		}
		else if (a < b) {
			cout << "LESS";
		}
		else
			cout << "EQUAL";
	}
	cout << endl;

}



Measured memory_bytes: 256
#include <stdio.h>
#define N 2000

int A[N],n;

int solve(int, int);

int main()
{
  int q,m,flag = 0;
  scanf("%d",&n);
  for(int i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(int i = 0; i < q; i++){
    scanf("%d",&m);
    if(solve(0,m) == 1) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

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



Measured memory_bytes: 2108