akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>  // include all standard C++ libraries

  using namespace std;

  // Loops
  #define _overload3(_1,_2,_3,name,...) name
  #define _rep(i,n) repi(i,0,n)
  #define repi(i,a,b) for(int i=int(a);i<int(b);++i)
  #define _rrep(i,n) rrepi(i,n,0)
  #define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

  #define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
  #define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
  #define each(xi, x) for (auto&& xi : x)
  // Note: we can use rep(i,N) or rep(i,from,to)


  // typedef
  using ll = long long;
  template <class T> using vec = vector<T>;
  using vi   = vector<int>;
  using vvi  = vector<vi>;
  using vvvi = vector<vvi>;
  using pii  = pair<int, int>;


  // Constants

  // Shorter repr for frequently used terms
  #define pb push_back
  #define eb emplace_back
  #define mp make_pair
  #define Fi first
  #define Se second


  // Algorithms
  #define all(x) (x).begin(), (x).end()
  #define uniq(v) v.erase( unique(all(v)), v.end() )
  #define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

  template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
  template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

  template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
  template<class T> inline bool chmin(T &minval, const T &newval) { if (minval<newval) { minval=newval; return 1; } return 0; }

  // Utilities
  // Grid world utilities
  int dx[4]={0,1,0,-1};
  int dy[4]={1,0,-1,0};
  #define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

  inline int in() {int x; cin >> x; return x;} // read int from cin
  inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



  // Debug
  #ifdef LOCAL
    #include "dump.hpp"
    #define debug(x) cerr << #x << ": " << x << '\n'
  #else
    #define dump(...)
    #define debug(x)
  #endif

  // Paste snippets here!!
  vi dfs(vi &a){
    int n=a.size();
    vi ret;
    rep(j,n){
      int i;
      for(i=a.size()-1;i>=0;--i){
        //dump(a, a[i], i+1);
        if(i+1==a[i]){
          a.erase(a.begin()+i);
          ret.push_back(i+1);
          i=-5;
        }
      }
      if(i!=-6){
        vi dummy; return dummy;
      }
    }
    reverse(ret.begin(), ret.end());
    return ret;
  }
  // 

  int main(){
    cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
    int N = in();
    vi a(N);
    rep(i,N){
      cin >> a[i];
    }

    // DFS
    //auto ret = dfs_org(a);
    auto ret = dfs(a);
    if(ret.size())
      rep(i,ret.size()) {cout<<ret[i]<<endl;}
    else
      cout << -1 << endl;  
    return 0;
  }


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    static Node nodeRoot;
    static StringBuilder sb = new StringBuilder();

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        for (int i = 0; i < n; i++) {
            String s = br.readLine();
            if (s.charAt(0) == 'i') {
                int m = Integer.parseInt(s.substring(7));
                if (nodeRoot == null) {
                    nodeRoot = new Node(m);
                    continue;
                }
                insert(m, nodeRoot);
            } else {
                sb.append(" ");
                inorder(nodeRoot);
                sb.deleteCharAt(sb.length() - 1).append("\n").append(" ");
                preorder(nodeRoot);
                sb.deleteCharAt(sb.length() - 1).append("\n");
            }
        }
        System.out.print(sb);
    }

    private static void preorder(Node node) {
        if (node == null) return;
        sb.append(node.value).append(" ");
        preorder(node.left);
        preorder(node.right);
    }

    private static void inorder(Node node) {
        if (node == null) return;
        inorder(node.left);
        sb.append(node.value).append(" ");
        inorder(node.right);
    }

    private static void insert(int m, Node node) {
        if (m > node.value) {
            if (node.right == null) node.right = new Node(m);
            else insert(m, node.right);
        } else {
            if (node.left == null) node.left = new Node(m);
            else insert(m, node.left);
        }
    }

    static class Node {
        int value;
        Node left;
        Node right;
        Node parent;

        public Node(int value) {
            this.value = value;
        }
    }
}


Measured memory_bytes: 102848
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

string s,t;

bool Same(const string& a){
    if(a.size() != t.size()) return false;
    for(int i = 0;i < a.size();i++){
        if(a[i] != t[i] && a[i] != '?') return false;
    }
    return true;
}
    

int main(){
    cin >> s >> t;
    vector<string> vec;
    for(int i = 0;i < s.size();i++){
        if(Same(s.substr(i,t.size()))){
            string bui;
            bui = s.substr(0,i) + t + s.substr(i + t.size() , s.size() - i - t.size());
            for(char& c : bui) if(c == '?') c = 'a';
            vec.push_back(bui);
        }
    }

    if(vec.empty()){
      cout << "UNRESTORABLE" << endl;
      return 0;
    }

    sort(vec.begin(),vec.end());

    cout << vec.front() << endl;
}



Measured memory_bytes: 256
a,b,k=map(int, input().split())
res_a = []
res_b = []
for i in range(1,a+1):
    if a % i == 0:
        res_a.append(i)
for j in range(1,b+1):
    if b % j == 0:
        res_b.append(j)
common = list(set(res_a) & set(res_b))
common.sort(reverse=True)
print(common[k-1])


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,a[N],b[N],id;
vector<int> e[N];
map<int,int> M;
bool vis[N];
void dfs(int x){
	vis[x]=1;
	for (int i=0;i<e[x].size();i++)
	if (!vis[e[x][i]]) dfs(e[x][i]);
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),a[0]^=a[i];
	for (int i=1;i<=n;i++) scanf("%d",&b[i]),b[0]^=b[i];
	for (int i=0;i<=n;i++) M[a[i]]++,M[b[i]]--;
	for (int i=0;i<=n;i++)
		if (M[a[i]]) return puts("-1"),0;
	for (int i=0;i<=n;i++)
		if (!M[a[i]]) M[a[i]]=++id;
	int ans=0;
	for (int i=0;i<=n;i++)
		if (a[i]!=b[i]) e[M[a[i]]].push_back(M[b[i]]),ans++;
	for (int i=1;i<=id;i++)
		if (!vis[i]&&!e[i].empty()) dfs(i),ans++;
	if (!e[M[a[0]]].empty()) ans--;
	if (a[0]!=b[0]) ans--;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 14336
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vii         vector<pair<int,int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define endl '\n'
#define int long long int
using namespace std;
vi adjList[(int)1e5 + 1];
int k;
pii dfs(int cur){
    int ans = 0;
    int dp = 0;
    for(int child: adjList[cur]){
        pii temp = dfs(child);
        ans += temp.first;
        if(temp.second == k - 1){
            ans++;
            temp.second = -1;
        }
        dp = max(dp, 1 + temp.second);
    } 
    return mp(ans, dp);
}
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);

    int n;cin >> n;
    cin >> k;
    vi dest(n);
    FOR(i, n){cin >> dest[i]; if(i != 0)adjList[dest[i]].pb(i + 1);}
    int ans = 0;
    ans += (dest[0] != 1);

    for(int child:adjList[1]){
        ans += dfs(child).first;
    }

    cout << ans;
}




Measured memory_bytes: 11264
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N;
    cin >> N;
    cout << (N * (N - 1)) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0 }, dy[] = { 0,1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑



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

long long lcm(long long a, long long b) {
	long long  g = gcd(a, b);
	return a / g * b;
}


int main() {
	long long n, k[15], ans;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> k[i];
		if (i == 0) { ans = k[0]; }
		else { ans = lcm(ans, k[i]); }
	}

	cout << ans << endl;
}


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

int main () {
    uint64_t remain;
    cin >> remain;
    uint64_t const N = remain;
    uint64_t sum = 0;
    while (0 < remain) {
        sum += remain % 10;
        remain /= 10;
    } 

    cout << (0 == (N % sum) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n;
vector<lli> a;
int main() {
  cin >> n; read_n(a, n);
  sort(begin(a), end(a));
  lli ans = 0;
  if (n%2) {
    for (lli j=0; j<2; ++j) {
      lli s = 0;
      lli p = a[n/2+1];
      for (lli i=0; i<n/2; ++i) {
        s += abs(p - a[i+n/2+1]);
        p = a[i+n/2+1];
        s += abs(p - a[i]);
        p = a[i];
      }
      s += abs(p - a[n/2]);
      ans = max(ans, s);
      reverse(begin(a), end(a));
    }
  } else {
    lli p = a[n/2];
    for (lli i=0; i<n/2; ++i) {
      ans += abs(p - a[i+n/2]);
      p = a[i+n/2];
      ans += abs(p - a[i]);
      p = a[i];
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1024
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N, K;
  std::cin >> N >> K;
  std::vector<i64> A;
  tools::read(A, N);
  for (i64& A_i : A) {
    --A_i;
  }

  std::unordered_map<i64, i64> path;
  i64 current = 0;
  path.emplace(current, 0);
  while (path.find(A[current]) == path.end()) {
    path.emplace(A[current], path[current] + 1);
    current = A[current];
  }

  i64 head = path[A[current]];
  i64 loop = path[current] - path[A[current]] + 1;
  i64 goal = K < head ? K : (K - head) % loop + head;

  for (const std::pair<i64, i64>& pair : path) {
    if (pair.second == goal) {
      std::cout << pair.first + 1 << std::endl;
      return 0;
    }
  }

  return EXIT_FAILURE;
}

Measured memory_bytes: 12884
import math

n = int(input())
s = input()

if s[0] == 'W' or s[-1] == 'W':
    print(0)
else:    
    s_lr = 'L'
    for i in range(len(s)-1):
        if s[i+1] == s[i]:
            if s_lr[-1] == 'L':
                s_lr += 'R'
            else:
                s_lr += 'L'
        else:
            if s_lr[-1] == 'L':
                s_lr += 'L'
            else:
                s_lr += 'R'    
    l_cnt = 0
    r_cnt = 0
    lst = []
    for i in s_lr:
        if i == 'L':
            l_cnt += 1
            lst.append(0)
        else:
            if l_cnt - r_cnt <= 0:
                print(0)
                break
            else:
                lst.append(l_cnt - r_cnt)
            r_cnt += 1
    else:
        if l_cnt != r_cnt:
            print(0)
        else:
            res = 1
            for i in lst:
                if i > 0:
                    res = res * i % (10**9 + 7)
            print(res * math.factorial(n) % (10**9 + 7) )

Measured memory_bytes: 9180
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int N,K;
vector <int > H;





int main()
{

	cin >> N;
	if(N/100 == N%10)
		cout << "Yes";
	else
		cout << "No";





}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
string s;
long long int hoge(int a, int b, long long int c){
    //a index of s
    //b digit
    //c current sum
    if(a==s.size())return c;
    if(a==0) return hoge(1,1,(s[a]-'0'));
    return hoge(a+1, b+1, c+(s[a]-'0')*((long long int)(pow(10, b))))+hoge(a+1,1, c+(s[a]-'0'));
}
 
int main(){
    cin>>s;
    reverse(s.begin(), s.end());
    cout<<hoge(0,0,0)<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N,Q;
  cin>>N>>Q;
  lint A[N];
  lint X[Q];
  REP(i,N)cin>>A[i];
  REP(i,Q)cin>>X[i];
  lint SA[N];
  SA[0]=A[0];
  FOR(i,1,N)SA[i]=SA[i-1]+A[i];
  lint SO[N];
  SO[0]=A[0];
  for(int i=2;i<N;i+=2)SO[i]=SO[i-2]+A[i];
  SO[1]=A[1];
  for(int i=3;i<N;i+=2)SO[i]=SO[i-2]+A[i];
  int h[N];
  REP(i,N)h[i]=0;
  h[N-1]=A[N-1];
  FOR(i,1,(N+1)/2){
    // l[i]=(A[N-i-1]+A[N-i*2-1])/2+1;
    h[N-1-i]=(A[N-i-1]+A[N-i*2-1])/2;
    cerr<<h[N-1-i];
    cerr<<endl;
  }
  cerr<<endl;
  REP(i,Q){
    int H=N-(lower_bound(h,h+N,X[i])-h);
    lint ans=0;
    ans+=SA[N-1]-SA[N-H-1];
    if(N-2*H-1>=0)ans+=SO[N-2*H-1];
    cout<<ans<<endl;
  }
  return 0;
}


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

int main(){
    int N; cin >> N;
    vector<int> d(N), e(N);
    for (int i = 0; i < N; i++) {
        cin >> d[i] >> e[i];
    }
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if(d[i] == e[i]){
            cnt++;
        }
        else{
            cnt = 0;
        }
        if(cnt >= 3){
            Yes();
            return 0;
        }
    }
    No();

}

Measured memory_bytes: 3632
def resolve():
    N = int(input())
    # cnt[i][j] := 先頭がi, 末尾がjで始まるような数
    cnt = [[0] * 10 for i in range(10)]
    for i in range(1, N + 1):
        a = int(str(i)[0])  # 先頭
        b = int(str(i)[-1])  # 末尾
        cnt[a][b] += 1

    ans = 0
    for i in range(10):
        for j in range(10):
            ans += cnt[i][j] * cnt[j][i]
    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9020
#!/usr/bin/env python

import random

class Dice:
    def __init__(self, top, s, e, w, n, bottom):
        self.top    = top
        self.s      = s
        self.e      = e
        self.w      = w
        self.n      = n
        self.bottom = bottom

    def rotate(self, dist):
        if dist == 'N':
            self.top, self.s, self.n, self.bottom = self.s, self.bottom, self.top, self.n 
        elif dist == 'S':
            self.s, self.bottom, self.top, self.n = self.top, self.s, self.n, self.bottom 
        elif dist == 'E':
            self.top, self.e, self.w, self.bottom = self.w, self.top, self.bottom, self.e 
        elif dist == 'W':
            self.w, self.top, self.bottom, self.e = self.top, self.e, self.w, self.bottom 

if __name__ == '__main__':
    dice = Dice(*map(int, raw_input().split()))

    ref = dict()
    while len(ref)<24:
        ref[(dice.top, dice.s)] = dice.e
        dice.rotate('NSEW'[random.randint(0,3)])

    for _ in range(input()):
        top, s = map(int, raw_input().split())
        print ref[(top, s)]



Measured memory_bytes: 6600
N = int(input())
X_list = list(map(int,input().split()))
X_list.sort()

# M = int(statistics.median(X_list))

def pow(X_list, M):
    P = 0
    for X in X_list:
        P += (X-M)**2
    return P

min_X = min(X_list)
max_X = max(X_list) +1
pow_min=pow(X_list, max_X)
pow_=0
for i in range(min_X,max_X,1):
    pow_ = pow(X_list,i)
    if pow_ <= pow_min:
        pow_min = pow_
print(pow_min)

Measured memory_bytes: 63596
<?php

list($n, $s) = explode(' ', trim(fgets(STDIN)));
$x = explode(' ', trim(fgets(STDIN)));

array_push($x, $s);
rsort($x);

$xd = [];
for($i=0; $i<$n; $i++){
  array_push($xd, $x[$i]-$x[$i+1]);
}

$gcd = $xd[0];
for($i=1; $i<count($xd); $i++){
  $m = $gcd;
  $n = $xd[$i];
  $gcd = gcd($m, $n);
}

echo $gcd;

function gcd($m, $n){
    if($n > $m) list($m, $n) = array($n, $m);
    
    while($n !== 0){
        $tmp_n = $n;
        $n = $m % $n;
        $m = $tmp_n;
    }
    return $m;
}

?>

Measured memory_bytes: 18932
#include<bits/stdc++.h>
using namespace std;
int n,x,y,z,ans,f[1<<15],a[100100],c[20];
vector<int>o;

int main(){
	ios::sync_with_stdio(false);
	scanf("%d", &n);
	for(int i=1;i<n;++i){
		scanf("%d%d%d",&x,&y,&z);
		a[x]^=z,a[y]^=z;
	}
	for(int i=0;i<n;++i)++c[a[i]];
	for(int i=1;i<=15;++i){
		ans+=c[i]>>1;
		if(c[i]&1)o.push_back(i);
	}
	f[0]=0;
	for(int i=1;i<(1<<o.size());++i){
		int x=0,k=0,j=0;
		for(;j<o.size();++j)
			if(i&(1<<j))x^=o[j],++k;
		f[i]=x? 19260817:k-1;
		for(j=i-(i&-i);j;j=(i-(i&-i))&(j-1))
			f[i]=min(f[i],f[j]+f[j^i]);
	}
	printf("%d\n",f[(1<<o.size())-1]+ans);
	return 0;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <string>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	
	cout << max({a + b, a - b, a* b}) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  set<int> set;
  int a;
  for(int i = 0;i < n;i++) {
    cin >> a;
    set.insert(a);
  }
  cout << *rbegin(set) - *begin(set) << endl;
}

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

using namespace std;

int main() {
	string s; cin >> s;
	int ans = 0, num = 0;
	stack<int> st;
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == '*') num = i;
		else if (s[i] == '(') st.push(i);
		else {
			int t = st.top(); st.pop();
			if (num > t) ans++;
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3196
#include <iostream>  
#include <algorithm>   
using namespace std;  
int gcd(int a,int b)
{
	int h;
 	while(a%b!=0)
 	{
 		h=a%b;
 		a=b;
 		b=h;
	 }
	 return b;
}
int main()
{
	long long sum=0;
	int n,i,j,k;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			for(k=1;k<=n;k++)
			{
				sum+=gcd(k,gcd(i,j));
			}
		}
	}
	printf("%lld",sum);
}

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

int main()
{
	int h, n, total=0;
	cin >> h >> n;
	
	int a[n+1];
	for(int i=1; i<=n; i++)
	{
		cin >> a[i];
		total+=a[i];
	}
	
	if(total>=h)
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 640
S = input()
dp = [0, 1]
for s in S:
    i = int(s)
    a = min(dp[0] + i,   dp[1] + 10 - i)
    b = min(dp[0] + i+1, dp[1] + 10 - (i+1))
    dp = [a, b]
    # print(dp)
print(dp[0])

Measured memory_bytes: 5492
import numpy as np

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

not_inc = []

for i in range(-200, 200):
  if i not in P:
    not_inc.append(i)

not_inc_gap = [abs(not_inc[i] - X) for i in range(len(not_inc))]

index = np.argmin(not_inc_gap)

if N == 0:
  print(X)
else:
  print(not_inc[index])

Measured memory_bytes: 27156
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int x,y,N;
int rez;
vector<pair<int,pair<int,int> > > V;
vector<pair<int,int> > X,Y;
int T[100005];
int fi(int x)
{
    if(T[x]<0)return x;
    return T[x]=fi(T[x]);
}
void u(int x,int y,int cost)
{
    x=fi(x);
    y=fi(y);
    if(x==y)return ;
    rez+=cost;
    if(T[x]<T[y]){T[x]+=T[y];T[y]=x;}
    else {T[y]+=T[x];T[x]=y;}
}
int main()
{
    cin>>N;
    for(int i=1;i<=N;i++)
    {
        T[i]=-1;
        cin>>x>>y;
        X.push_back(make_pair(x,i));
        Y.push_back(make_pair(y,i));
    }
    sort(X.begin(),X.end());
    sort(Y.begin(),Y.end());
    for(int i=0;i<N-1;i++)
    {
        V.push_back(make_pair(X[i+1].first-X[i].first,make_pair(X[i].second,X[i+1].second)));
        V.push_back(make_pair(Y[i+1].first-Y[i].first,make_pair(Y[i].second,Y[i+1].second)));
    }
    sort(V.begin(),V.end());
    for(auto it:V)
    {
        u(it.second.first,it.second.second,it.first);
    }
    cout<<rez;
    return 0;
}


Measured memory_bytes: 7400
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		long[] l = new long[3];
		l[0] = sc.nextLong();
		l[1] = sc.nextLong();
		l[2] = sc.nextLong();

		Arrays.sort(l);

		System.out.println(l[0] * l[1] * (l[2] % 2));
	}

}

class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else if (buflen == 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

Measured memory_bytes: 8020
#include<iostream>
using namespace std;
int ans=1e3;
string s;
main()
{
	cin>>s;
	for(int i=0;i<s.size()-2;i++)
	{
		int now=0;
		for(int j=0;j<3;j++)now=now*10+s[i+j]-48;
		now-=753;
		if(now<0)now=-now;
		if(ans>now)ans=now;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <set>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())


using namespace std;

int main(){
	int a,b,c;
	cin>>a>>b;
	c=a*b;
	if(!(c%2==0))
		cout<<"Odd"<<endl;
	else
		cout<<"Even"<<endl;



	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define cinsc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i,k,n)  for(int64 i=k;i<(int)n;i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SQ(x) ((x)*(x))
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
 
//ONLINE_JUDGE   LOCAL
 
int64 powr(int64 x,int64 y,int64 p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0;
    while (y > 0){   
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 
 
void  in_o(){
#ifndef LOCAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	cinsc;
}
 
 

 
int main(){
	//in_o();
	int n,m;
	cin>>n>>m;
	MPII hsh;
	FOR(i,0,n){
		int k;cin>>k;
		FOR(i,0,k){
			int x;
			cin>>x;
			hsh[x]++;
		}
	}
	int ans=0;
	FOREACH(it,hsh){
		if(it->second==n)
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}


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

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b) print(c);
  else if(b==c) print(a);
  else print(b);
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  int i,j;
  for(i=0;i<n;i++)cin>>a[i];
  for(i=0;i<n;i++)cin>>b[i];
  i=0;
  j=0;
  long bstock = 0;
  for(i=0;i<n;i++){
    if(a[i]>=b[i]){
      bstock -= a[i]-b[i];
    }else{
      bstock += (b[i]-a[i])/2;
    }
  }
  if(bstock>=0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=300000 +117;
const int MM= +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("022e.in","r",stdin);
	//freopen("022e.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}

const int mod=1000000000+7;
int m,n;
LL dp[2][3][4]={};//cnt0+cnt1
int main(){
	//open();
	//n=read();
	dp[0][0][0]=1;
	char c=getchar();
	int now=0;
	while(c=='0'||c=='1'||c=='?'){
		now^=1;
		memset(dp[now],0,sizeof dp[now]);
		if(c=='0'||c=='?'){
			for(int i=0;i<2;++i){
				for(int j=0;j<=3;++j){
					dp[now][i+1][j]+=dp[now^1][i][j];
				}
			}
			for(int j=0;j<=3;++j){
				dp[now][1][j]+=dp[now^1][2][j];
			}
		}
		if(c=='1'||c=='?'){
			for(int i=1;i<=2;++i){
				for(int j=0;j<=3;++j){
					dp[now][i-1][j]+=dp[now^1][i][j];
				}
			}
			for(int j=0;j<=3;++j){
				dp[now][0][min(j+1,3)]+=dp[now^1][0][j];
			}
		}
		for(int i=0;i<=2;++i){
			for(int j=0;j<=3;++j){
				dp[now][i][j]%=mod;
			}
		}
		c=getchar();
	}
	LL ans=0;
	for(int i=0;i<=2;++i){
		for(int j=i+1;j<=3;++j){
			(ans+=dp[now][i][j])%=mod;
		}
	}
	printf("%lld\n",ans);
	close();
	return 0;
}

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

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int N,K;






int main()
{

	cin >> N >> K;
	int ans = 1;
	REP(i,N){
		ans = min(ans*2,ans+K);
	}
	cout << ans;




}






Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String str = sc.nextLine();
      if(Character.isUpperCase(str.charAt(0))) {
        System.out.println("A");
      }else {
        System.out.println("a");
      }
  }
}


Measured memory_bytes: 35716
N = int(input())
A = [int(a) for a in input().split()]
d = 0
ans = 1
for i in range(1, N):
    if A[i-1] < A[i]:
        if d < 0:
            ans += 1
            d = 0
        elif d == 0:
            d = 1
    elif A[i-1] > A[i]:
        if d > 0:
            ans += 1
            d = 0
        elif d == 0:
            d = -1
print(ans)

Measured memory_bytes: 14228
import sys

def isGreater(x, y):
    # x > y or not
    if x.find(y) == 0:
        return True
    for xi, yi in zip(x, y):
        if xi == yi:  continue
        else: 
            if xi > yi: return True
    return False


S = input()

alpha = set([chr(ord("a") + i) for i in range(26)])
S_1 = "".join([chr(ord("a") + i) for i in reversed(range(26))]) # -1

if len(set(S)) < 26:
    al = sorted(list((alpha - set(S))))
    print(S + al[0])
elif S == S_1:
    print(-1)
else:
    for i in reversed(range(len(S) -1 )):
        for a in sorted(list(alpha - set(S[:i]))):
            S2 = S[:i] + a
            if isGreater(S2, S):
                print(S2)
                sys.exit()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;

string s, t;
pair<int, ii> dp[3001][3001];
bool sht[3001][3001];

pair<int, ii> f(int i, int j)
{
    if (sht[i][j]) return dp[i][j];
    sht[i][j] = 1;
    
    if (i == 0 || j == 0) return dp[i][j] = {0, {0, 0}};
    
    dp[i][j] = f(i - 1, j);
    if (f(i, j - 1) > dp[i][j]) dp[i][j] = dp[i][j - 1];
    if (s[i - 1] == t[j - 1] && f(i - 1, j - 1).first + 1 > dp[i][j].first) dp[i][j] = {dp[i - 1][j - 1].first + 1, {i, j}};
    
    return dp[i][j];
}

void dfs(ii ij, string &tmp)
{
    if (ij.first)
    {
        dfs(dp[ij.first - 1][ij.second - 1].second, tmp);
        tmp += s[ij.first - 1]; 
    }
}

int main()
{
    cin >> s >> t;
    
    f(s.size(), t.size());
    
    string tmp;
    dfs(dp[s.size()][t.size()].second, tmp);
    
    cout << tmp;
    
    return 0;
}

Measured memory_bytes: 115456
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**5)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    N = gete(int)

    if N & 1 == 1:
        print(0)
        return

    base = 5
    n = N // 2
    ans = 0
    while base <= n:
        ans += n // base
        base *= 5

    print(ans)


if __name__ == "__main__":
    main()

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



void solve(long long N, long long K){
    ll ans =0;
    for(ll i=K;i<=N+1;i++){
        ll min = (i*(i-1))/2;
        ll max = (i*(N+N+1-i))/2;
        // cerr <<"K=" <<K <<"min=" << min << endl;
        // cerr << "max=" << max << endl;
        ans += (max+1-min +MOD);
        ans %= MOD;
    }
    cout << ans << endl;

}

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


Measured memory_bytes: 3764
def selection_sort(nums, n):
    count = 0
    for i in range(n):
        minj = i
        flag = False
        for j in range(i, n-1):
            if nums[minj] > nums[j+1]:
                minj = j+1
                flag = True
        
        if flag:
            tmp = nums[i]
            nums[i] = nums[minj]
            nums[minj] = tmp
            count += 1


    nums_str = map(str, nums)
    print(" ".join(nums_str))
    print(count)

if __name__=="__main__":
    n = int(input())
    nums = list(map(int, input().split()))
    selection_sort(nums, n)



Measured memory_bytes: 5596
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int dist[210][210], r[10], dp[10][1 << 10];
signed main() {
    int N, M, R; cin >> N >> M >> R;
    rep(i,0,R) cin >> r[i], r[i]--;
    for(int i=0; i<N; i++) fill(dist[i], dist[i] + N, INF);
    for(int i=0; i<M; i++) {
        int a, b, c; cin >> a >> b >> c;
        a--; b--;
        chmin(dist[a][b], c);
        chmin(dist[b][a], c);
    }

    rep(k,0,N) rep(i,0,N) rep(j,0,N) {
        chmin(dist[i][j], dist[i][k] + dist[k][j]);
    }

    vector<int> v(R);
    iota(v.begin(), v.end(), 0);

    int ans = INF;
    do {
        int tmp = 0;
        rep(i,1,R) {
            int s = r[v[i-1]], t = r[v[i]];
            tmp += dist[s][t];
        }
        ans = min(ans, tmp);
    }while(next_permutation(v.begin(), v.end()));
    cout << ans << endl;
    return 0;
}

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

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	ll a, b;
	
	cin >> a >> b;
	
	ll gcd = __gcd(a, b);
	
	ll ans = 1;
	ll d = gcd;
	
	for(ll i = 2; i * i <= d && gcd > 1; i++){
		if(gcd % i == 0){
			ans++;
			
			while(gcd % i == 0){
				gcd /= i;
			}
		}
	}
	
	if(gcd > 1) ans++;
	
	cout << ans << endl;
		
	return 0;
}


Measured memory_bytes: 256
N=int(input())
MOD=10**9+7
memo={}

#prev_numがその時点での組み合わせ数
prev_num=1
prev=None

for _ in range(N):
  c=int(input())
  if c==prev:
    continue
  tmp=prev_num
  if c in memo:
    tmp+=memo[c]
  tmp%=MOD
  #memo[c]にそれまでの組み合わせの数が入ることで、
  #次にcが出てきた時にどれぐらい通りが増えるかが分かる
  memo[c]=tmp
  prev_num=tmp
  prev=c
print(prev_num)

Measured memory_bytes: 27100
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    a,b,n=MI()
    x=min(n,b-1)
    if b==1:
        x=1
    print((a*x)//b - a*(x//b))

main()


Measured memory_bytes: 61712
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=3010;
struct fk{int to,nxt;}e[N<<1];
int f[N],n,cnt,head[N],val[N];
void add(int u,int v){e[++cnt].to=v;e[cnt].nxt=head[u];head[u]=cnt;}
void dfs(int u,int fa){
    f[u]=0;
    for(int i=head[u],v;i;i=e[i].nxt)
        if((v=e[i].to)!=fa){
            dfs(v,u);
            if(!f[v]&&val[u]>val[v])f[u]=1;
        }
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&val[i]);
    for(int u,v,i=1;i<n;i++)
        scanf("%d%d",&u,&v),add(u,v),add(v,u);
    for(int i=1;i<=n;i++){
        dfs(i,0);
        if(f[i])printf("%d ",i);
    }
    puts("");
}


Measured memory_bytes: 384
import bisect
n,x = map(int,input().split())

#a[i]:leveru i no sousuuuuu
a = [1, 5, 13, 29, 61, 125, 253, 509, 1021, 2045, 4093, 8189, 16381, 32765, 65533, 131069, 262141, 524285, 1048573, 2097149, 4194301, 8388605, 16777213, 33554429, 67108861, 134217725, 268435453, 536870909, 1073741821, 2147483645, 4294967293, 8589934589, 17179869181, 34359738365, 68719476733, 137438953469, 274877906941, 549755813885, 1099511627773, 2199023255549, 4398046511101, 8796093022205, 17592186044413, 35184372088829, 70368744177661, 140737488355325, 281474976710653, 562949953421309, 1125899906842621, 2251799813685245, 4503599627370493]
#b[i]:leveru i no P sousuuuu
b = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 16777215, 33554431, 67108863, 134217727, 268435455, 536870911, 1073741823, 2147483647, 4294967295, 8589934591, 17179869183, 34359738367, 68719476735, 137438953471, 274877906943, 549755813887, 1099511627775, 2199023255551, 4398046511103, 8796093022207, 17592186044415, 35184372088831, 70368744177663, 140737488355327, 281474976710655, 562949953421311, 1125899906842623, 2251799813685247]


#レベルkのバーがーをしたからx枚食べたときのP
def f(k,x,a,b):
    if x == 0:
        return 0
    elif k == 0:
        return 1
    elif k== 1:
        if x <= 4:
            return x-1
        else:
            return 3
    else:
        if x == (a[k]-1)//2+1:
            return b[k-1] + 1
        elif x < (a[k]-1)//2+1:
            if x <= k:
                return 0
            else:
                return f(k-1,x-1,a,b)
        elif x >= a[k]-k:
            return b[k]
        else:
            return b[k-1] + f(k-1,x-(a[k]-1)//2-1,a,b) + 1

print(f(n,x,a,b))
        


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<int> Q;
    for (int i = 0; i < n; ++i) {
        int x; scanf("%d", &x);
        Q.emplace(x);
    }
    for (int i = 0; i < m; ++i) {
        int x = Q.top(); Q.pop();
        Q.emplace(x/2);
    }
    ll ans = 0;
    while(!Q.empty()) {
        ans += Q.top(); Q.pop();
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 892
//i hate this
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<pl> vpl;
const int MN = 100100;
vpl g[MN];
ll sub[MN];
ll pe[MN];
ll dfa(int u, int p) {
	ll res = 1;
	for(int i=0;i<g[u].size();i++) {
		int v = g[u][i].first;
		if(v == p) {continue;}
		pe[v] = g[u][i].second;
		res += dfa(v,u);
	}
	return sub[u] = res;
}
int main() {
	ll n;
	cin >> n;
	for(int i=1;i<n;i++) {
		ll a,b,c;
		cin >> a >> b >> c;
		a--;b--;
		g[a].push_back({b,c});
		g[b].push_back({a,c});
	}
	ll res = 0;
	dfa(0,0);
	for(int i=1;i<n;i++) {
		res += pe[i]*min(sub[i],n-sub[i])*2;
	}
	int ro = 0;
	while(1) {
		int rer = -1;
		for(int i=0;i<g[ro].size();i++) {
			int v = g[ro][i].first;
			if(sub[v] > n/2) {
				rer = v;break;
			}
		}
		if(rer == -1) {
			break;
		} else {
			pe[ro] = pe[rer];
			sub[ro] = n-sub[rer];
			sub[rer] = n;
			ro = rer;
		}
	}
	ll rev = 1e18;
	int haf = -1;
	for(int i=0;i<g[ro].size();i++) {
		int v = g[ro][i].first;
		if(sub[v]*2 == n) {
			haf = v;
			break;
		}
		rev = min(rev,g[ro][i].second);
	}
	if(haf != -1) {
		rev = pe[haf];
	}
	cout << res-rev << '\n';
}


Measured memory_bytes: 17792
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <iomanip>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define mrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define INF 1000000001
#define MOD 1000000007
#define INF64 1000000000000000001

#define F first
#define S second

#define Pii  pair<SINT32,SINT32>
#define Pll  pair<SINT64,SINT64>
#define Piii pair<SINT32,pair<SINT32,SINT32>>
#define Plll pair<SINT64,pair<SINT64,SINT64>>


using namespace std;

int main() {

	SINT64 N,M;
	cin >> N >> M;

	cout << N+M/2 << endl;
	return 0;
}

//	sort(data.begin(),data.end());
//	sort(data.begin(),data.end(),std::greater<SINT32>());
//	__gcd(A,B);

//	data.emplace_back(BUF);			//後ろに追加

//  data.erase(std::unique(data.begin(), data.end()), data.end());	//ソート後に使用 同じ値を消す

//	data.insert(data.begin() + X, 0);	//X番目の要素に0を挿入


//	vector<vector<SINT32>> data(N,vector<SINT32>(3));	//2次元配列

/*
	vector<Pii> data(N);
	rep(i,0,N) {
		cin >> data[i].F;
		cin >> data[i].S;
	}
	sort(data.begin(),data.end());
*/

/*
	vector<Piii> data(N);
	rep(i,0,N) {
		cin >> data[i].F;
		cin >> data[i].S.F;
		cin >> data[i].S.S;
	}
	sort(data.begin(),data.end());
*/


// posi = lower_bound(data.begin(),data.end(), X) - data.begin();				// X以上を探す
// posi = lower_bound(data.begin(),data.end(),make_pair(X,0)) - data.begin();	//pair


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/
/* 文字列合成
	string N,M;
	cin >> N >> M;
	SINT64 ans = 0;
	ans = stoi(N+M);
*/

/*
//ワーシャルフロイド
vector<vector<SINT32>> dist(N,vector<SINT32>(N));
rep(i,0,N) {
	rep(j,0,N) {
		if (i != j) {
			dist[i][j] = INF;
		}
	}
}
rep(k,0,N) {
	rep(i,0,N) {
		rep(j,0,N) {
			dist[i][j] = MIN(dist[i][j], dist[i][k]+dist[k][j]);
		}
	}
}
*/



/* SET コンテナ
	set<SINT32> DATA;
	for (SINT32 i = 0; i < N; i++) {
		SINT32 buf;
		cin >> buf;
		DATA.insert(buf);
	}

	//全表示
    set<string>::iterator it; //  イテレータを用意
    for(it = DATA.begin(); it != DATA.end(); it++) {
        cout << *it << endl;
    }

	//N番目を一部表示
	set<string>::iterator it; //  イテレータを用意
	it = DATA.begin();
	rep (i,0,N) {
		it++;
	}
	cout << *it << endl;
*/

/* map
	map<string,SINT32> mp;
	SINT32 N = 0;
	SINT32 mx = 0;

	cin >> N;
	for (SINT32 i = 0; i < N; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	for(auto it=mp.begin();it!=mp.end();it++) {
		mx=max(mx,it->second);
	}
*/

/*
	//順列全表示
	//sortしてからでないと全列挙にならない
	sort(DATA.begin(),DATA.end());
	do {
		cout << buf << endl;
		rep(i,0,R) {
			cout << DATA[i] << " ";
		}
		cout << endl;

    } while (next_permutation(DATA.begin(),DATA.end()));
*/

//  桁指定表示
//  ans = ans * M_PI;
//	cout << setprecision(15) << ans << endl;

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

using namespace std;

int main(){
    int x,y,z;
    cin>>x>>y>>z;
    int ans=0;
    
    for(int i=1;i<=x/y;i++){
        if(x>=i*y+(i+1)*z){
            ans=i;
        }
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

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

void solve(ll K) {
  cout << A[K-1] << endl;
}

int main() {
  ll K;
  cin >> K;
  solve(K);
  return 0;
}


Measured memory_bytes: 256