akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

// lcm = a*(b/gcd) least common multiple                              
// gcd: greatest common divisor                                    
//                                                                  
ll gcd(ll a, ll b) {
  if(a < b) gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}


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

  ll n,m;
  cin >> n >>m;
  ll a[n];
  rep(i,n){
    cin >> a[i];    
  }
  ll two=0;
  ll tmp=a[0];
  while(tmp%2==0){
    two++;
    tmp/=2;
  }
  ll two_p=pow(2,two);
  ll gc=a[0]/2;
  ll lcm = gc;
      
  rep(i,n){
    if(a[i]/two_p * two_p!=a[i]){
      cout << 0 << endl;
      return 0;
    }
    if(a[i]/(two_p)/2 * (two_p*2) == a[i]){
      cout << 0 << endl;
      return 0;
    }
    a[i]/=2;
    gc = gcd(lcm,a[i]);
    lcm = lcm * a[i] /gc;
    //    cout <<"gcd lcm " <<  gc << " " << lcm << endl;
  }
  //  cout << lcm << endl;
  //  cout << m/lcm << endl;
  ll ans = (m/lcm + (m/lcm)%2)/2;
  cout << ans << endl;
  
  
  return 0;
    

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<long long> &v) {
    std::for_each(v.begin(), v.end(),
                  [](long long x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    cin >> N;
    vector<long long> a(N);
    REP(i, N) { cin >> a[i]; }
    deque<long long> d;
    REP(i, N) {
        int p = lower_bound(d.begin(), d.end(), a[i]) -
                d.begin(); //以上の最初の場所
        if(p == 0) {
            d.push_front(a[i]);
        } else
            d[p - 1] = a[i];
    }
    int ans = d.size();
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

string rt(string s){
  string n = s.substr(s.length()-1);
  n.append(s, 0, s.length()-1); 
  return n;
}
 
int main(){
  string s, t;
  cin >> s >> t;
  for(int i=0; i<=s.length(); i++){
    if(s==t){
      cout << "Yes" << endl;
      return 0;
    }
    s = rt(s);
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict, Counter
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

N, M = s_inpl()

print(2**M*(1900*M+100*(N-M)))

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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(preMsg, V)                                                   \
    cout << preMsg;                                                            \
    for (auto v : (V))                                                         \
        cout << v << ' ';                                                      \
    cout << endl;
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */

class WeightedUndirectedGraph {
public:
    WeightedUndirectedGraph(int node_size)
        : graph(node_size, std::vector<Edge>()) {}

    void push_edge(int edge1, int edge2, int weight) {
        if (!isInGraphNode(edge1) || !isInGraphNode(edge2)) {
            return;
        }
        graph[edge1].emplace_back(edge2, weight);
        graph[edge2].emplace_back(edge1, weight);
    }

    [[nodiscard]] const auto dijkstra(int start) {
        std::vector<int> dist(graph.size());
        if (!isInGraphNode(start)) {
            return dist;
        }
        using Point = std::pair<int, int>;
        std::priority_queue<Point, std::vector<Point>, std::greater<Point>> que;
        std::fill(dist.begin(), dist.end(), INT_MAX);
        dist[start] = 0;
        que.push(Point{0, start});
        while (!que.empty()) {
            Point p = que.top();
            que.pop();
            int v = p.second;
            if (dist[v] < p.first)
                continue;
            for (const auto &e : graph[v]) {
                if (dist[e.to] > dist[v] + e.cost) {
                    dist[e.to] = dist[v] + e.cost;
                    que.push(Point{dist[e.to], e.to});
                }
            }
        }
        return dist;
    }

private:
    struct Edge {
        int to;
        int cost;
        Edge(int t, int c)
            : to{t}
            , cost{c} {}
    };
    std::vector<std::vector<Edge>> graph;

    bool isInGraphNode(int node) { return node >= 0 && node < graph.size(); }
};

int main() {
    /* code */
    int N, X, Y;
    cin >> N >> X >> Y;
    WeightedUndirectedGraph graph(N);
    REP(i, N - 1) { graph.push_edge(i, i + 1, 1); }
    graph.push_edge(X - 1, Y - 1, 1);
    vector<ll> ans(N - 1, 0);
    REP(i, N) {
        auto distMap = graph.dijkstra(i);
        for (int j = i + 1; j < N; j++) {
            ans[distMap[j] - 1]++;
        }
    }
    for (auto a : ans) {
        cout << a << endl;
    }
    return 0;
}

Measured memory_bytes: 384
N,K = map(int, input().split())
A = list(map(int, input().split()))
    
l,r = 0, max(A)
while r-l>1:
  mid = (l+r)//2
  cnt = 0
  for i in range(N):
    if A[i]%mid!=0:
      cnt+= A[i]//mid
    else:
      cnt += A[i]//mid - 1
            
  if cnt <= K:
    r = mid
  else:
    l = mid
print(r)

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

int main() {

	while(true) {

		int n;
		cin >> n;
		if ( n == 0 ) break;

		vector<int> number;
		vector<long long int> score;

		for ( int i = 0; i < n; i++ ) {

			int input_number;
			long long int tanka;
			long long int kazu;
			cin >> input_number >> tanka >> kazu;

			for ( int j = 0; j <= number.size(); j++ ) {
				if ( j != number.size() ) {
					if ( number[j] == input_number ) {
						score[j] += tanka * kazu;
						break;
					}
				}else {
					number.push_back(input_number);
					score.push_back(tanka * kazu);
					break;
				}
			}
		}

		bool f = true;
		for ( int i = 0; i < number.size(); i++ ) {
			if ( score[i] >= 1000000 ) {
				cout << number[i] << endl;
				f = false;
			}
		}

		if ( f ) cout << "NA" << endl;

	}

	return 0;
}

Measured memory_bytes: 1248
/***
**   AUTHOR::ASHUTOSH MOUDGIL
***/


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

#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define int long long
//#define ll long long
#define all(x) x.begin(),x.end()
#define rsort(x) sort(all(x)); reverse(all(x));
#define endl '\n'
#define vi vector<int>
#define vlli vector<long long>
#define pii pair<int,int>
#define mod 1000000007
#define LMAX 1e18
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define PI 3.141592654
#define deb1(x) cout << #x <<"="<< x <<endl;
#define deb2(x,y) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<endl;
#define deb3(x,y,z) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<<endl;
#define deb4(x,y,z,a) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<< ", "<<#a <<"="<<a << endl;
#define debarr(x) cout << #x<<"::"<<endl;for(int i : x){cout << i <<" ";} cout <<endl;


void add(int& a, int b){
    a = a+b;
    if(a >= mod)
        a -= mod;
}

int n;
int comp[22][22];

int bits(int x){
    int cnt = 0;
    while(x > 0){
        if(x&1)
            cnt++;
        x /= 2;
    }
    return cnt;
}


void mymain(){
    cin >> n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin >> comp[i][j];
        }
    }

    vi dp(1<<n);
    dp[0] = 1;

    for(int mask = 0; mask < (1<<n)-1; mask++){
        int a = bits(mask);
        for(int i=0;i<n;i++){
            if(!(mask&(1<<i)) && comp[a][i]){
                add(dp[(mask|(1<<i))], dp[mask]);
            }
        }
    }

    cout << dp[(1<<n) - 1] <<endl;

}

signed main(){
IOS;
///freopen("input.txt", "r", stdin);
///freopen("output.txt", "w", stdout);
int t=1;
//cin>>t;

for(int tt=0;tt<t;tt++){
   ///cout << "Case #" << tt+1 <<": ";
   mymain();
   }
return 0;
}
/*

*/


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





int main() {
	string s,ans="Yes";
	cin >> s;


	int n = s.size();
	

	rep(i, n) {
		if (s[i] != s[n -1- i]) ans = "No";
	}

	rep(i, (n - 1) / 2) {
		if (s[i] != s[((n - 3) / 2) - i]) ans = "No";

	}

	cout << ans << endl;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))

# ans = [[0] * w] * h
ans = [[0 for j in range(w)] for i in range(h)]
nextColor = 0
H = 0
W = 0

while nextColor < n:
    # ai回マスを塗る
    for j in range(a[nextColor]):
        ans[H][W] = nextColor+1
        # print("H: " + str(H))
        # print("W: " + str(W))
        # print("ans[H][W]: " + str(ans[H][W]))
        # print(ans)
        W += 1

        # 行末まで来たら次の行の先頭へ
        if W >= w:
            H += 1
            W = 0
    # print("-----------------")
    
    # 塗り終えたら次の色へ
    nextColor += 1

for i in range(h):
    # 奇数行は反転させる
    if i%2 != 0:
        ans[i] = ans[i][::-1]
    print(*ans[i])

Measured memory_bytes: 3920
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
using namespace std;

int main(void)
{
	int n, m;
	for (;;)
	{
		cin >> n >> m;
		if (!n)break;
		vector<int>h, w;
		map<int, int>hei, wid;
		h.push_back(0);
		w.push_back(0);
		for (int i = 0; i < n; ++i)
		{
			int hh;
			cin >> hh;
			h.push_back(hh + h.back());
		}
		for (int i = 0; i < m; ++i)
		{
			int ww;
			cin >> ww;
			w.push_back(ww + w.back());
		}
		for (int r = 1; r <= n; ++r)
		{
			for (int l = 0; l < r; ++l)
			{
				hei[h[r] - h[l]]++;
			}
		}
		for (int r = 1; r <= m; ++r)
		{
			for (int l = 0; l < r; ++l)
			{
				wid[w[r] - w[l]]++;
			}
		}
		long long ans = 0;
		for (auto elm : hei)
		{
			ans += (long long)wid[elm.first] * elm.second;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 33976
#include<stdio.h>
#include<iostream>
using namespace std;

int main(void){

  double a,b,c,d,e,f,x,y;

  while(cin >> a >> b >> c >> d >> e >> f){

    x = (c*e - b*f)/(a*e - b*d);
    y = (c*d - a*f)/(b*d - a*e);

    if(x == -0)
      x = 0;
    if(y == -0)
      y = 0;
    
    printf("%.3lf %.3lf\n",x,y);
  }
    
  return 0;

}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  ll tmp = (c-a-b)*(c-a-b) - 4*a*b;
  if (tmp>0 && c-a-b>0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n; cin >> n;
	map<int, int> mp;
	REP(i, n)
	{
		int a; cin >> a;
		mp[a]++;
	}
	int m; cin >> m;
	bool f = true;
	REP(i, m)
	{
		int a; cin >> a;
		if (mp[a] > 0) mp[a]--;
		else f = false;
	}
	cout << (f ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 9600
from itertools import product as p
c = [list(map(int, input().split())) for _ in range(3)]

a = [-1]*3
a[0] = 0
b = c[0]
a[1] = c[1][0] - b[0]
a[2] = c[2][0] - b[0]

for i, j in p(range(3), range(3)):
    if c[i][j] != a[i] + b[j]:
        print('No')
        break
else:
    print('Yes')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long a,b,x;
	scanf("%lld %lld %lld",&a,&b,&x);
	if(a==0) printf("%lld\n",b/x+1);
	else printf("%lld\n",b/x-(a-1)/x);
}

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

const int INF = 1e9;
const int N = 14;

int C[N];
int A[N][N];

void solve() {
    int n, m, x;
    scanf("%d%d%d", &n, &m, &x);

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

    int ans = INF;
    for (int s = 1; s < (1<<n); s++) {
        int t[N] = {}, cost = 0;
        for (int i = 0; i < n; i++) {
            if ((s>>i)&1) {
                cost += C[i];
                for (int j = 0; j < m; j++) {
                    t[j] += A[i][j];
                }
            }
        }
        bool flag = 1;
        for (int i = 0; i < m; i++) {
            if (t[i] < x) {
                flag = 0;
                break;
            }
        }
        if (flag) ans = min(ans, cost);
    }
    if (ans == INF) ans = -1;
    printf("%d\n", ans);

}

int main(){

    solve();
	return 0;
}


Measured memory_bytes: 3828
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#define FOR(idx, begin, end) for(int idx = (int)(begin), idx##_sz = (int)(end); idx < idx##_sz; ++idx)

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

const int MOD = 1000000007, INF = 1111111111;
const double EPS = 1e-9;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int a, b, h;
	cin >> a >> b >> h;

	cout << (a + b)*h / 2;

	return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

ll modpow(ll x,int n){
  if(n==0)return 1;
  if(n%2)return (modpow(x,n-1)*x)%MOD;
  else{
    ll halfpow=modpow(x,n/2)%MOD;
    return (halfpow*halfpow)%MOD;
  }
}

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

  int N;
  cin>>N;
  vector<ll>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  vector<vector<int>>sum(N+1,vector<int>(60,false));
  for(int i=0;i<N;i++){
    vector<bool>bit(N);
    for(int j=0;j<60;j++)bit[j]=(A[i]>>j)&1;
    for(int j=0;j<60;j++)sum[i+1][j]=sum[i][j]+bit[j];
  }
  /*
  for(int i=0;i<=N;i++){
    for(int j=0;j<N;j++){
      cout<<sum[i][j]<<" ";
    }
    cout<<endl;
  }
  */
  ll ans=0;
  for(int i=0;i<N-1;i++){
    for(int j=0;j<60;j++){
      if((A[i]>>j)&1){
        ans+=(modpow(2,j)*((N-(i+1))-(sum[N][j]-sum[i+1][j])))%MOD;
      }
      else{
        ans+=(modpow(2,j)*(sum[N][j]-sum[i+1][j]))%MOD;
      }
    }
  }
  cout<<ans%MOD<<endl;
  return 0;
}


Measured memory_bytes: 86784
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())
/*unsigned int xor128(void)
{
    static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned int t = (x ^ (x << 11));
    x = y;
    y = z;
    z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
unsigned int xor128rnd(unsigned int m)
{
    return xor128() % m;
}*/

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

ll A[100010], B[100010], C[100010];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    //cout << fixed << setprecision(15);
    int N;
    cin >> N;

    for (int i = 0; i < N; ++i)
        cin >> A[i];
    for (int i = 0; i < N; ++i)
        cin >> B[i];
    for (int i = 0; i < N; ++i)
        cin >> C[i];

    sort(A, A + N);
    sort(B, B + N);
    sort(C, C + N);

    ll cnt = 0;
    for (int i = 0; i < N; ++i)
    {
        ll bigger = (C + N) - upper_bound(C, C + N, B[i]);
        ll smaller = lower_bound(A, A + N, B[i]) - A;
        cnt += bigger * smaller;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
const long long maxn=1e5+5;
const long long inf=0x3f3f3f3f;
vector<long long> p(maxn),c(maxn),s;
long long tot=0;
void dfs(long long x,long long ed)
{
	x=p[x];
	s.push_back(c[x]);
	tot+=c[x];
	if(x==ed)
		return ;
	dfs(x,ed);
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    long long n,k;
    cin>>n>>k;
    for(long long i=0;i<n;i++)
    {
    	cin>>p[i];
    	--p[i];
	}
	for(long long i=0;i<n;i++)
		cin>>c[i];
	long long ans=-inf;
	for(long long si=0;si<n;si++)
	{
		long long x=si;
		s.clear();
		tot=0;
		dfs(x,si);
		long long l=s.size();
		long long t=0;
		for(long long i=0;i<l;i++)
		{
			t+=s[i];
			if(i+1>k)
				break;
			long long now=t;
			if(tot>=0)
			{
				long long e=(k-(i+1))/l;
				now+=tot*e;
			}
			if(ans<now)
				ans=now;
		}
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5088
MOD = 1000000007
N = gets.chomp.to_i

group = Hash.new(0)
worst_iwashi_count = 0

N.times do |i|
  a, b = gets.chomp.split.map(&:to_i)

  if a == 0 && b == 0
    worst_iwashi_count += 1
    next
  end

  if a == 0
    group[[0, -1]] += 1
    next
  end

  if b == 0
    group[[1, 0]] += 1
    next
  end

  gcd = a.gcd(b)
  a /= gcd
  b /= gcd

  if a < 0
    a *= -1
    b *= -1
  end

  group[[a, b]] += 1
end

ans = 1

group.each do |(a, b), count|
  if b < 0
    pair_count = group[[-b, a]]
    group.delete([-b, a])
  else
    pair_count = group[[b, -a]]
    group.delete([b, -a])
  end

  ans *= (2 ** count - 1) + (2 ** pair_count - 1) + 1
  ans %= MOD
end

p (ans + worst_iwashi_count - 1) % MOD


Measured memory_bytes: 34888
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int R;
    cin >> R;
    cout << fixed << setprecision(4) << 2 * M_PI * R << endl;
    return 0;
};


Measured memory_bytes: 3800
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>

#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n"
#define MOD 998244353

const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;

using namespace std;

void solve()
{
    char c;
    cin >> c;

    if('a' <= c && c <= 'z')
    {
        cout << "a\n";
        return;
    }

    cout << "A\n";
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int T = 1;
    //cin >> T;

    while (T--)
    {
        solve();
    }

    return 0;
}



Measured memory_bytes: 3652
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define pb push_back
#define pf push_fron
#define INF 1000000000
typedef long long ll;


int main() {
	/*cin.tie(0);
	ios::sync_with_stdio(false);*/
	
	int a, b, c, x, cnt = 0;
	cin >> a >> b >> c >> x;

	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				if (500 * i + 100 * j + 50 * k == x) cnt++;
			}
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    char c11,c12,c13,c21,c22,c23;
    scanf("%c %c %c %c %c %c",&c11,&c12,&c13,&c21,&c22,&c23);
    if((c11==c23)&&(c12==c22)&&(c13==c21))
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#include<queue>

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


using namespace std;
using ll =long long;
using P = pair<int,int>;

#define MAX_H 1000
#define MAX_W 1000
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

char filed[MAX_H][MAX_W];
bool check_filed[MAX_H][MAX_W];

int main(int argc, const char * argv[]) {
    int h, w;
    cin >> h >> w;
    
    queue<P> que;
    rep(y, h){
        string s;
        cin >> s;
        rep(x, w){
            filed[y][x] = s[x];
            check_filed[y][x] = false;
            if(s[x] == '#'){
                que.push(P(x, y));
                check_filed[y][x] = true;
            }
        }
    }

    int que_size = (int)que.size();
    int que_size_next = 0;
    int count = 0;
    int res = 0;
    while(que.size()){
        P p = que.front();
        que.pop();
        
        rep(i, 4){
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            
            if(0<=nx&&nx<w&&0<=ny&&ny<h&&filed[ny][nx]=='.'&&check_filed[ny][nx]==false){
                check_filed[ny][nx] = true;
                que.push(P(nx, ny));
                que_size_next++;
            }
        }
        
        count++;
        if(count>=que_size){
            que_size = que_size_next;
            if(que_size_next>0) res++;
            count = 0;
            que_size_next = 0;
        }
    }
    
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 10384
from itertools import accumulate
n, k = map(int, input().split())
#BIT
BIT = [0] * (n + 10)
def add(i, x):
    while i <= (n + 10):
        BIT[i] += x
        i += i & -i
def query(i):
    s = 0
    while i > 0:
        s += BIT[i]
        i -= i & -i
    return s
a = [0] + [int(input()) - k for i in range(n)]
a = list(accumulate(a))
b = sorted(a)
b.append(-float("inf"))
cnt = 0
dic = dict()
for i in range(n + 1):
    if b[i] != b[i - 1]:
        cnt += 1
        dic[b[i]] = cnt
answer = 0
for I in range(n + 1):
    answer += query(dic[a[I]])
    add(dic[a[I]], 1)
print(answer)

Measured memory_bytes: 46020
N = int(input())
D = [tuple(map(int, input().split())) for _ in range(N)]
cnt = 0
for d1, d2 in D:
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print('Yes')
        exit()
print('No')

Measured memory_bytes: 9096
#include <bits/stdc++.h>
using namespace std;
const unsigned int M = 1000000007;
#define ll long long
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n,k;
    while(cin>>n>>k){
        int r=n%k;
        if(n>=k)
            if(r)cout<<(n/k +1)<<endl;
            else cout<<n/k<<endl;
        else cout<<"1"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	for(;;){
		int i;
		int n,m;
		scanf("%d %d",&n,&m);
		if (n==0&&m==0){
			return 0;
		}
		int a[n],b[m];
		for (i=0;i<n;i++){
			scanf("%d",&a[i]);
		}
		for (i=0;i<m;i++){
			scanf("%d",&b[i]);
		}
		
		int me=0;
		for (i=0;i<m;i++){
			me=me+b[i];
			if(me>=(n-1)){
				break;
			}
			me=me+a[me];
			if (me>=(n-1)){
				break;
			}
		}
		printf("%d\n",i+1);
	}
}

Measured memory_bytes: 608
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================
	

	ll N, A, B;
	cin >> N >> A >> B;
	vll a(N), b(N), c(N);
	for (int i = 0; i < N; i++) cin >> a[i] >> b[i] >> c[i];

	vector<vector<vector<ll>>> dp; // i個、j,kグラム、最小の金額

	for (int i = 0; i < N; i++)
	{
		vvll temp(401);
		for (int j = 0; j <= 400; j++)
		{
			for (int k = 0; k <= 400; k++)
			{
				temp[j].emplace_back(LLINF);
			}
			temp[0][0] = 0;
		}
		dp.emplace_back(temp);
	}

	dp[0][a[0]][b[0]] = c[0];

	for (int i = 1; i < N; i++)
	{
		for (int j = 0; j <= 400; j++)
		{
			for (int k = 0; k <= 400; k++)
			{
				if (j - a[i] >= 0 && k - b[i] >= 0)
				{
					dp[i][j][k] = min(dp[i - 1][j][k], dp[i - 1][j - a[i]][k - b[i]] + c[i]);
				}
				else
				{
					dp[i][j][k] = dp[i - 1][j][k];
				}
			}
		}
	}

	ll ans = LLINF;
	for (int j = 1; j <= 400; j++)
	{
		for (int k = 1; k <= 400; k++)
		{
			if (j / A == k / B && j % A == 0 && k % B == 0)
			{
				ans = min(ans, dp[N - 1][j][k]);
			}
		}
	}
	
	if (ans == LLINF)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << ans << endl;
	}

}





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

int a[101]={0};

int main(){
	int n,x;
	cin>>n;
	
	for(int i=1;i<=n;i++){
		cin>>x;
		a[x]=1;
	}
	int s=0;
	for(int i=1;i<=100;i++){
		if(a[i]==1) s++;
	}
	
	cout<<s<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  string s; cin >>s;
  ll n=s.size();
  vector<ll> vec(n+1);
  ll ans=0;
  rep(i,n){
    if(s[i]=='<'){
      vec[i+1]=vec[i]+1;
    }
  }
  for(ll i=n-1;i>=0;i--){
    if(s[i]=='>'){
      vec[i]=max(vec[i],vec[i+1]+1);
    }
  }
  rep(i,n+1){
    ans+=vec[i];
  }
  
  
  cout <<ans<<endl;
}


Measured memory_bytes: 4740
fn solve(t: usize, abs: Vec<(usize, usize)>) -> usize {
    use std::cmp::max;

    let mut abs = abs;
    abs.sort_by_key(|x| x.0);

    let mut dp = vec![0; t + 3001];

    for &(a, b) in abs.iter() {
        for i in (0..t).rev() {
            dp[i + a] = max(dp[i] + b, dp[i + a]);
        }
    }

    dp.into_iter().max().unwrap()
}

#[test]
fn solve_test() {
    assert_eq!(solve(60, vec![(10, 10), (10, 20), (10, 30)]), 60);
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let (n, t) = parse_line!(usize, usize);
    let abs = (0..n)
        .map(|_| parse_line!(usize, usize))
        .collect::<Vec<_>>();
    println!("{}", solve(t, abs));
}


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

int main(){
  char str[2048], train[64];
  int n, i, now;
  scanf("%d", &n);
  while(n--){
    for(i = 0;i < 64; i++) train[i] = '\0';
    now = 31;
    scanf("%s", str);
    for(i = 0; i < strlen(str); i += 3){
      train[now] = str[i];
      if(str[i + 1] == '-') now++;
      else if(str[i + 2] == '-') now--;
    }

    for(i = 0; i < 64; i++) printf(train[i] != '\0' ? "%c": "", train[i]);
    puts("");
  }
  return 0;
}

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

using namespace std;

int N,L;
char s[5010];
const int MOD = 1e9 + 7;
typedef long long LL;
LL f[5010][5010];

void upd(LL &x,LL y)
{
    x = (x + y) % MOD;
}

int main()
{
    scanf("%d",&N);
    scanf("%s",s);
    L = strlen(s);
    f[0][0] = 1;
    for (int i=0;i<N;i++)
    {
        for (int j=0;j<=i;j++)
        {
            upd(f[i+1][j+1],2LL*f[i][j]);
            upd(f[i+1][max(0,j-1)],f[i][j]);
        }
    }
    LL ans = f[N][L], rev = (MOD + 1) / 2;
    for (int i=1;i<=L;i++) ans = ans * rev % MOD;
    printf("%lld\n",ans);
}


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

struct Node{
    int key;
    Node *p,*l,*r;
};

Node *root,*NIL;

void insert(int k){
    Node *y=NIL;
    Node *x=root;
    Node *z;

    z=(Node*)malloc(sizeof(Node));
    z->key=k;
    z->l=z->r=NIL;
    while(x!=NIL){
        y=x;
        if(z->key<x->key){
            x=x->l;
        }
        else{
            x=x->r;
        }
    }
    z->p=y;
    if(y==NIL){
        root=z;
    }
    else if(z->key<y->key){
        y->l=z;
    }
    else{
        y->r=z;
    }
}

void inorder(Node *u){
    if(u==NIL) return;
    inorder(u->l);
    cout<<' '<<(u->key);
    inorder(u->r);
}

void preorder(Node *u){
    if(u==NIL) return;
    cout<<' '<<(u->key);
    preorder(u->l);
    preorder(u->r);
}

int main(){
    int m;
    cin>>m;
    for(int i=0;i<m;i++){
        char com[10];
        int a;
        scanf("%s%d",com,&a);
        if(com[0]=='p'){
            inorder(root);
            cout<<endl;
            preorder(root);
            cout<<endl;
        }
        else{
            insert(a);
        }
    }
}


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

int n;

int main() {
  cin >> n;
  vector<T> v(n);
  rep (i, n) {
    cin >> get<0>(v[i]) >> get<1>(v[i]);
    get<2>(v[i]) = i+1;
  }
  sort(v.begin(), v.end(), [](auto const& a, auto const& b) {
    if (get<0>(a) == get<0>(b)) {
      return get<1>(a) > get<1>(b);
    } else {
      return get<0>(a) < get<0>(b);
    }
  });
  rep (i, n) {
    cout << get<2>(v[i]) << endl;
  }
  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    int a,b;
    cin>>s>>t>>a>>b;
    string u;
    cin>>u;
    if(u==s){
        a--;
    }else{
        b--;
    }
    cout << a<<" "<<b<<endl;
    return 0;
}


Measured memory_bytes: 256
n, m  = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(m)]
b = sorted(a, key=lambda x: x[1])
k = b[0][1]
y = 1
for i in range(m):
    if b[i][0] >= k:
        k = b[i][1]
        y += 1
print(y)

Measured memory_bytes: 29848
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N; cin >> N;
    string S, T; cin >> S >> T;
    rep (i,S.size()) {
        cout << S.at(i) << T.at(i);
    }
    cout << endl;
}


Measured memory_bytes: 256
import string

N = int(input())
alph = string.ascii_lowercase

def search(S, mx):
    if len(S) == N:
        yield S
    else:
        for s in alph[: mx]:
            for w in search(S + s, mx):
                yield w
        for w in search(S + alph[mx], mx + 1):
            yield w

ans = list(search('', 0))
print(*ans, sep='\n')


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

using ll=long long;
using vll=vector<ll>;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vpii=vector<pii>;


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

    int a, b, k;
    cin >> a >> b >> k;
    int cnt = 0;
    for (int i=min(a, b); i >= 1; --i) {
        if (a%i == 0 && b%i == 0) {
            ++cnt;
            if (cnt == k) {
                cout << i << "\n";
                return 0;
            }
        }
    }
    assert(false);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
int main() {
    int N ,K;
    cin >> N >>K;
    vector<int>A(N+1, 0);
    set<int>XA;
    rep(i, 0, N){
        int index = 0;
        cin >> index;
        XA.insert(index);
        A[index]++;
    }
    sort(A.begin(), A.end());
    long long size = 0;
    if (XA.size()>K){
        size= XA.size()-K;
    }
    ll ans = 0;
    for(int i = 0; i < A.size(); i++){
        if(size && A[i]){
            ans += A[i];
            size--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10368
'use strict'

function main(s) {

  s = s.split('\n')[0].split(' ').map(x => Number(x));

  const a = s[0];
  const b = s[1];
  let ans = (a <= b) ? a : (a - 1);

  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
import java.util.Scanner;

public class Main{

	public static void main(String args[]){
		int i,j,k,n,c,count;
		Scanner sc=new Scanner(System.in);
		n=Integer.parseInt(sc.next());
		int a[]=new int[n+1];
		for(i=0;i<n;i++){
			a[i]=Integer.parseInt(sc.next());
		}
		
		count=0;
	for(i=0;i<n;i++){
		
		for(j=n-1;j>0;j--){
			if(a[j]<a[j-1]){
			c=a[j];
			a[j]=a[j-1];
			a[j-1]=c;
			count++;
			}
		}
	}
		
		for(i=0;i<n;i++){
			System.out.print(a[i]);
			if(i==n-1){break;}
			System.out.print(" ");
		}
		System.out.println("");
		System.out.println(count);
	}
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll K; cin >> K; K--;
  ll num[32] = {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};
  ll result = num[K];
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
d=[0 for i in range(K)]
A=[[0 for i in range(N)] for i in range(K)]
B=[]
C=[i+1 for i in range(N) ]
for i in range(K):
    d[i]=int(input())
    A=[0 for i in range(d[i])]
    A=[int(i) for i in input().split()]
    C=list(set(C)-set(A))

print(len(C))


Measured memory_bytes: 69848
integer(16) N,X,ans,i
integer(16),allocatable,dimension(:)::Y,K
read*,N,X
allocate(Y(N),K(N))
read*,Y
do i=1,N
  K(i)=abs(Y(i)-X)
end do
ans=K(1)
do i=2,N
  ans=gcd(ans,K(I))
end do
print"(i0)",ans
contains
pure function gcd(a,b)
integer(16),intent(in)::a,b
integer(16) gcd
integer(16)s,t
s=a
gcd=b

t=mod(s,gcd)
do while(t/=0)
  s=gcd
  gcd=t
  t=mod(s,gcd)
end do
end function gcd
end

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

int main() {
	int64_t n, z, w;
	cin >> n >> z >> w;
	int64_t a[n];
	for (auto &i : a) {
		cin >> i;
	}
	if (n == 1) {
		cout << abs(a[0] - w) << endl;
		return 0;
	}
	cout << max(abs(w - a[n - 1]), abs(a[n - 1] - a[n - 2])) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;

int n,m;
vector<int> sum(55);

int main()
{
  cin >> n >> m;
  int a, b;
  rep(i, m){
    cin >> a >> b;
    sum[a]++;
    sum[b]++;
  }
  rrep(i,n) cout << sum[i] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define add push_back
#define endl "\n"
const int INF = 0x3f3f3f3f;
const double pi = acos(-1);
using ll = long long;
using namespace std;

ll n;
int main() {
    IOS
    cin >> n;
    cout << ((n * (n-1))>>1) << endl;
    return 0;
}






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

int main(){
	string s;
	cin>>s;
	deque<char> v;
	deque<char> t;
	bool flag=true;
	for(int i=0;i<s.size();i++){
		if(flag){
			v.push_back('1');
			t.push_back('0');
			flag=false;
			continue;
		}
		else if(!flag){
			v.push_back('0');
			t.push_back('1');
			flag=true;
			continue;
		}
	}
	int cnt=0;
	int res=0;
	for(int i=0;i<s.size();i++){
		if(v[i]!=s[i])cnt++;
		if(t[i]!=s[i])res++;
	}
	cout<<min(res,cnt)<<endl;
	return 0;
}

Measured memory_bytes: 512
//https://atcoder.jp/contests/abc145/tasks/abc145_c
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in");
    //std::ifstream in("./input.txt");
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N; cin>>N;
    vector<pair<ll,ll>> pos(N);
    for(auto&& p:pos){
        cin>>p.first>>p.second;
    }
    vector<int> indicies(N);
    iota(indicies.begin(),indicies.end(),0);

    double sum=0;
    do{
        FOR(pi,0,indicies.size()-1){
            ll i=indicies.at(pi);
            ll i2=indicies.at(pi+1);
            double dx=pos[i].first - pos[i2].first;
            double dy=pos[i].second - pos[i2].second;
            double len2=dx*dx + dy*dy;
            double len = sqrt(len2);
            dump(indicies,len);
            sum += len;
        }
    } while(next_permutation(indicies.begin(),indicies.end()));

    double fact=1;
    FOR(i,1,N+1){
        fact *= i;
    }
    double ans = sum / fact;
    cout<<fixed<<std::setprecision(10)<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int p,q,r;
int Max3(int x,int y,int z){//max # in(x,y,z)
	x=max(x,y);
	return max(x,z);
}
int main(){
	#ifdef FILIN
		#ifndef LOCAL
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>p>>q>>r;
	cout<<p+q+r-Max3(p,q,r)<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a[];
		a = new int[3];
		
		for(int i = 0; i < 3; ++i) {
			a[i] = sc.nextInt();
		}
		
		for(int i = 0; i < 3; ++i) {
			for(int j = i + 1; j < 3; ++j) {
				if(a[i] > a[j]) {
					int tmp = a[i];
					a[i] = a[j];
					a[j] = tmp;
				}
			}
		}
		
		if(a[2] != (a[0] + a[1]))System.out.println("No");
		else System.out.println("Yes");
		
		sc.close();
	}

}


Measured memory_bytes: 20820
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String n = sc.next();
    int[] data = new int[n.length()];

    for (int i = 0; i < n.length(); i++) {
      data[i] = Integer.parseInt(n.substring(i,i+1));
    }

    long sum = 0;
    for (int i = 0; i < n.length(); i++) {
      sum += data[i];
    }

    if (Integer.parseInt(n) % sum == 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(int i=0;i<(n); ++i)
using namespace std;
typedef long long ll;


int main()
{
	ll n, cnt=0,Mcnt=-1;
	cin >> n;
	vector<ll>h(n);
	rep(i, n)cin >> h[i];
	reverse(h.begin(),h.end());
	h.push_back(-1);
	for (ll i = 0; i < h.size()-1; i++) {
		if (h[i+1]-h[i] >= 0) { cnt++; }
		else { Mcnt = max(Mcnt, cnt), cnt = 0; }
	}
	cout << Mcnt << endl;
}

Measured memory_bytes: 1792
function main(){
 
var seats = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
var groupMembers = [2,5,2,2,2];
var eatTimes = [19,39,25,36,22,42];
 
var headGroup = -1;
var pastMinutes = 0;
var waitTime = [];
 
while(waitTime.length < 100){
  // たべおわる
  var slen = seats.length;
  for(; slen--;){
    seats[slen] = mx(seats[slen] - 1, 0);
  }
 
  // 来店
  if(headGroup == -1 && pastMinutes % 5 == 0){
    headGroup = pastMinutes / 5;
  }
 
  // ちゃくせき
  while(headGroup != -1){
    var needsSequencialSeats = groupMembers[headGroup % 5];
    var sequencialSeats = 0;
    var startIndex = -1;
    for(var i = 0, sl = seats.length; i < sl; i++){
      sequencialSeats = seats[i] == 0 ? sequencialSeats + 1 : 0;
 
      if(sequencialSeats == needsSequencialSeats){
        startIndex = i - (needsSequencialSeats - 1);
        break;
      }
    }
 
    if(startIndex != -1){
      // すわれたみたい
      waitTime[headGroup] = pastMinutes - (headGroup * 5);
      for(var i = startIndex, total = (needsSequencialSeats + startIndex); i < total; i++){
        seats[i] = eatTimes[headGroup % 6];
      }
       
      headGroup = (((headGroup + 1) * 5) <= pastMinutes) ? headGroup + 1 : -1;
    }else{
      // すわれなかったみたい
      break;
    }
 
  }
 
  pastMinutes++;
 
}
 
for(var i = 0, ilen = (input.length - 1); i < ilen; i++){
  console.log(waitTime[parseInt(input[i], 10)]);
}
 
}

function mx(a, b){
 var t = (a-b);
 return a - (t & (t >> 31));
}
 
var
input = '';
 
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 8696