akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define MODA 1000000007 

int main() {
    int n;
    string S, now;
    cin >> n >> S;
    int ans = 0;
    int a[5001] = {};
    a[0] = n;
    REP(offset, n-1){
        now = S.substr(offset);
        //cout << now << endl;
        int i=1,j=0;
        a[0] = now.size();
        for(int m = 1; m <= n; m++) a[m] = 0;
        while(i < now.size()){
            while(i+j < n && now[j] == now[i+j]){++j;}
            a[i] = j;
            //cout << a[i] << endl;
            if(j==0){
                i++;
                continue;
            }
            int k = 1;
            while(i+k < n && k+a[k] < j){
                a[i+k] = a[k];
                k++;
            }
            i += k;
            j -= k;
        }
        for(int i = 1; i<now.size(); i++){
            if(a[i] > ans && i+1 > a[i] ) ans = a[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define dcout cout<<fixed<<setprecision(20)
#define Accepted_MAGIC cin.tie(0);ios::sync_with_stdio(false)

// typedef long long ll;
using Real = long double;
#define int long long

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;
constexpr Real eps = 1e-9, pi = acos(-1);

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

signed main(void){
  Accepted_MAGIC;
  
  int N, M; cin >> N >> M;
  int A[100], sum = 0;
  REP(i, N){
    cin >> A[i]; sum += A[i];
  }
  int cnt = 0;
  REP(i, N){
    if(A[i]*4*M >= sum) cnt++;
  }
  if(cnt >= M) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 3000 + 10;
int r, c, k;
int v[maxn][maxn];
ll f[4][maxn][maxn];
int main()
{
	scanf("%d%d%d", &r, &c, &k);
	while(k--)
	{
		int x, y, val;
		scanf("%d%d%d", &x, &y, &val);
		v[x][y] = val;
	}
	for(int i = 1; i <= r; ++i)
		for(int j = 1; j <= c; ++j)
			for(int p = 3; ~p; --p)
			{
				if(i > 1) f[p][i][j] = max(f[p][i][j], f[3][i - 1][j]);
				if(j > 1) f[p][i][j] = max(f[p][i][j], f[p][i][j - 1]);
				if(p < 3) f[p + 1][i][j] = max(f[p + 1][i][j], f[p][i][j] + v[i][j]);
			}
	printf("%lld\n", f[3][r][c]);
	return 0;
}

Measured memory_bytes: 321252
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)

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

    vector<vector<int>> vec(M);

    for (int i = 0; i < M; ++i)
    {
        int k;
        cin >> k;
        vec[i].resize(k);
        for (int j = 0; j < k; ++j)
        {
            cin >> vec[i][j];
            --vec[i][j];
        }
    }

    vector<int> p(M);
    for (int i = 0; i < M; ++i)
        cin >> p[i];

    int ans = 0;
    for (int i = 0; i < (1 << N); ++i)
    {
        bool ok = true;
        for (int j = 0; j < M; ++j)
        {
            int c = 0;
            for (int id : vec[j])
            {
                if ((i >> id) & 1)
                {
                    ++c;
                }
            }
            c %= 2;
            if (c != p[j])
            {
                ok = false;
            }
        }
        if (ok)
        {
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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){
    return (a / gcd(a, b)) * b;
}

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    int x, y;
    int group1[7] = {1, 3, 5, 7, 8 ,10 ,12};
    int group2[4] = {4, 6, 9, 11};
    int group3[1] = {2};

    cin >> x >> y;
    if ((x == 2 && y == 2)
            || (find(group1, group1 + 7, x) != group1 + 7 && find(group1, group1 + 7, y) != group1 + 7)
            || (find(group2, group2 + 4, x) != group2 + 4 && find(group2, group2 + 4, y) != group2 + 4)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main() {

	int n;
	int a[100000], b[100000];
	int ans = 0;
	ll sum = 0;
	cin >> n;

	rep(i, 0, n) {
		cin >> a[i];
	}

	rep(i, 0, n) {
		cin >> b[i];
		if (a[i] - b[i] < 0) {
			sum += b[i] - a[i];//あとで減らす総量
			ans++;
		}
		b[i] = a[i] - b[i];//あと必要な準備度
	}

	sort(b, b + n);

	if (sum == 0) {
		cout << 0 << endl;
		return 0;
	}

	for (int i = n - 1; i >= 0; i--) {
		ans++;
		if (sum > 0 && b[i] <= 0) {
			cout << -1 << endl;
			return 0;
		}
		else if (sum<=b[i]) {
			cout << ans << endl;
			return 0;
		}
		else {
			sum = sum - b[i];
		}
	}

	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,Q,K,R,W,H,P,L;
string S,T;
ll ans;
ll x[101010];
ll y[101010];
ll a[101010];
ll b[101010];
ll c[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(int to, int cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;


int main() {
	cin>>K>>A>>B;
	if(A+2>=B){
		cout<<1+K<<endl;
	}else{
		ans=(K-A+1)%2;
		ans+=((K-A+1)/2)*(B-A);
		ans+=A;
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=2e3+5;
int n,a[N],x,y;
int main(){
    cin.tie(NULL);
    cout.tie(NULL);
    ios_base::sync_with_stdio(false);
    cin>>n>>x>>y;
    for(int i=0;i<n;i++)
        cin>>a[i];
    if(n>1)
        cout<<max(abs(a[n-2]-a[n-1]),abs(a[n-1]-y) ) <<'\n';
    else
        cout<<abs(a[0]-y)<<'\n';

    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);
		sc.nextInt();sc.nextInt();sc.nextInt();
		int d = sc.nextInt();
		System.out.println((d == 1) ? 1 : 0);
		sc.close();
	}
}

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

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

  string s;
  cin >> s;
  cout << s.at(0) << s.size() - 2 << s.at(s.size() - 1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct node{
    long long x,s;
}a[200005];
long long n,maxn,sum;
long long f[200005];
bool cmp(node a,node b){
    return a.s<b.s;
}
int main(){
    cin>>n;
    for(int i=1;i<=n;i++)
    cin>>a[i].s>>a[i].x;
    sort(a+1,a+n+1,cmp);
    f[1]=maxn=a[1].x;
//  for(int i=2;i<=n;i++){
        for(int j=2;j<=n;j++){
            f[j]=max(f[j-1]+a[j].x-a[j].s+a[j-1].s,a[j].x);
        }
//  }
    for(int i=1;i<=n;i++){
        maxn=max(maxn,f[i]);
    }
    cout<<maxn<<endl;
    return 0;
}

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

int main() {
	long long A,B;
	cin >>A>>B;
	long long C = A,D=B;


	if (A < B) {
		int f = B;
		B = A;
		A = f;
	}
	int t;
	while (A%B != 0) {
		t = B;
		B = A % B;
		A = t;
	}



	cout << C * D / B << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
  
int main(){
    int cost[22][22] = {0};
    int n,m,i,j,k,a,b,c,d;
    char cc;
    cin >> n >> m;
    for(i = 1;i <= n;i++){
        for(j = 1;j <= n;j++){
            cost[i][j] = 1001001;
        }
    }
    for(i = 0;i < m;i++){
        cin >> a >> cc >> b >> cc >> c >> cc >> d;
        cost[a][b] = c;
        cost[b][a] = d;
    }
    for(k = 1;k <= n;k++){
        for(i = 1;i <= n;i++){
            for(j = 1;j <= n;j++){
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
                cin >> a >> cc >> b >> cc >> c >> cc >> d;
            }
        }
    }
    cout << c - d - cost[a][b] - cost[b][a] << endl;
}

Measured memory_bytes: 1160
# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
# pragma GCC target("avx2")
# pragma GCC optimize("O3")
# pragma GCC optimize("unroll-loops")
# define int long long

using namespace std;

const int N = 2e5 + 7;
const int mod = 1e9 + 7;

vector < int > adj[N];
int used[N], cnt, mx;

void dfs( int v ) {
    used[v] = 1;
    cnt++;
    for ( auto u: adj[v] ) {
        if ( !used[u] ) {
            dfs( u );
        }
    }
}

int32_t main() {
    speed;
    int n, m;
    cin >> n >> m;
    for ( int i = 0; i < m; i++ ) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for ( int i = 1; i <= n; i++ ) {
        if ( !used[i] ) {
            cnt = 0;
            dfs( i );
            mx = max( mx, cnt );
        }
    }
    cout << mx;
}


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


int main(){
  int N;
  cin >> N;
  int max_p = 0;
  int ans = 0;
  for(int ii=0; ii<N; ii++){
    int p;
    cin >> p;
    ans += p;
    max_p = max(max_p, p);
  }
  ans -= max_p / 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int A,B,C;
  cin >> A >> B >> C;
  
  if (A == 5 && B == 5 && C == 7 )
    cout << "YES" << endl;
  if (A == 5 && B == 7 && C == 5)
    cout << "YES" << endl;
  if (A == 7 && B == 5 && C == 5)
    cout << "YES" << endl;
  if ( !(A == 5 && B == 5 && C == 7) && !(A == 5 && B == 7 && C == 5) && !(A == 7 && B == 5 && C == 5))
    cout << "NO" << endl;
  
  
}


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

int main() {
  int X,Y;
  cin>>X>>Y;
  int t2 = Y - X*2;
  int k2 = X*4 - Y;
  cout<<(t2>=0 && t2%2 == 0 && k2>=0 && k2%2 == 0 ? "Yes" : "No")<<endl;
  return 0;
}


Measured memory_bytes: 3100
def int_raw():
    return int(input())


def ss_raw():
    return input().split()


def ints_raw():
    return list(map(int, ss_raw()))


a = int_raw()
b = int_raw()
c = int_raw()
d = int_raw()
e = int_raw()
k = int_raw()

if e - a <= k:
    print('Yay!')
else:
    print(':(')


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

typedef int64_t ll;
const double pi = 2 * acos(0.0);

#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define all(x) x.begin(), x.end()
#define pb(x) push_back(x)
#define eb(i, j) emplace_back(i, j)
#define sz(x) (int)(x).size()
#define endl "\n"
#define INF 1000000007
#define EPS 1e-9

//#define sets

inline void solve(){
    string s1, s2;
    cin >> s1 >> s2;
    int ans = 0;
    for(int i = 0; i < sz(s1); i++){
        if(s1[i] != s2[i])ans++;
    }
    cout << ans << endl;
}

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

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w" ,stdout);
    #endif

    #ifdef sets
        int t;
        cin >> t;
        while(t--) solve();
    #else
        solve();
    #endif
}

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

int main(){
    int n,sum=0;
    long long d,x,y;
    cin>>n>>d;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        if(x*x+y*y<=d*d)sum++;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
 
#define mo 1000000007
#define inf 1e18
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rrep(i,s,n) for(ll i=s;i>=n;i--)

ll mod(ll n) { return (n % (ll)mo + (ll)mo)%(ll)mo;}

int main(){

	ll s;
	cin>>s;
	if(s<3) return cout<<0,0;
	ll dp[2][s+1];
	memset(dp,0,sizeof(dp));
	ll ans = 1;
	rep(i,3,s+1) dp[0][i] = 1;
	
	rep(i,4,s+1){
		dp[0][i] += dp[0][i-1]; 
	}

	rep(len,1,s+1){
		rep(sum,3,s+1){
			if(sum>=3) dp[1][sum] = mod(dp[1][sum] + dp[0][sum-3]);

		}
		ans = mod(ans+dp[1][s]);
		rep(i,1,s+1){
			dp[0][i] = dp[1][i];
		
			dp[1][i] = 0;
			
		}
		rep(i,4,s+1){
			dp[0][i] = mod(dp[0][i] + dp[0][i-1]);
		}
		//cout<<len<<" "<<dp[1][s]<<endl;
	
		
	}
	cout<<ans;
	
	
}

Measured memory_bytes: 3580
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string>
#include <vector>
#include <iomanip>

using namespace std;

int main() {

    int n;
    int num;
    double tempSum = 0;
    cin >> n;

    for (int i = 0; i < n; ++i) {
        cin >> num;
        tempSum += 1. / num;
    }

    cout << setprecision(16) << 1. / tempSum << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    private static int[] make_cost = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
    public static void Main()
    {
        int N = NextInt();
        int M = NextInt();
        int[] A = LineInt();
        string[] dp = new string[N + 1];
        dp[0] = "";
        for (int i = 1; i <= N; i++)
        {
            dp[i] = "0";
            foreach (int a in A)
            {
                if (make_cost[a] > i || dp[i - make_cost[a]] == "0") continue;
                int index = Search(dp[i - make_cost[a]], char.Parse(a.ToString()));
                string s = dp[i - make_cost[a]].Substring(0, index) + a + dp[i - make_cost[a]].Substring(index);
                if (Compare(s, dp[i])) { dp[i] = s; }
            }
        }
        Console.WriteLine(dp[N]);
    }
    private static int Search(string s, char c)
    {
        int i = 0;
        for (; i < s.Length; i++) { if (c >= s[i]) return i; }
        return i;
    }
    private static bool Compare(string a, string b)
    {
        if (a.Length > b.Length) { return true; }
        else if (a.Length < b.Length) { return false; }
        for (int i = 0; i < a.Length; i++)
        {
            if (a[i] > b[i]) return true;
            else if (a[i] < b[i]) return false;
        }
        return false;
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


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

int main(){
  
  int arr[150] = {
    0
  };
  
  int n; cin >> n;
  for(int i=0;i<n;i++)cin >> arr[i];
  
  int count = 0;
  for(int i=0;i<n;i++){
    int index = i;
    for(int j=i;j<n;j++){
      if(arr[index]>arr[j])index = j;
    }
    if(index!=i){
      int temp = arr[i];
      arr[i] = arr[index];
      arr[index] = temp;
      count++;
    }
  }
  
  for(int i=0;i<n;i++){
    if(i==n-1)cout << arr[i] << endl;
    else cout << arr[i] << ' ';
  }
  cout << count << endl;
  
  
  return 0;
}


Measured memory_bytes: 3096
// ABC 144-C
// 2019.10.27 bal4u

#include <stdio.h>
#include <math.h>

typedef long long ll;

int main()
{
	ll N; int a, b;
	ll t, ans;
	
	scanf("%lld", &N);
	ans = 0x7ffffffffffffff;
	b = (int)sqrt((double)N);
	for (a = 1; a <= b; a++) {
		if (N % a == 0) {
			t = a + N/a - 2;
			if (t < ans) ans = t;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans


void solve() {
}

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

    int X, N, cnt[1010] = {};
    cin >> X >> N;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        cnt[a]++;
    }

    int asn = 0, MIN = 1010;

    for (int i = 0; i < 111; i++) {
        if (!cnt[i]) {
            if (abs(X - i) < MIN) {
                ans = i;
                MIN = abs(X - i);
            }
        }
    }

    cout << ans << endl;


    solve();
    return 0;
}


Measured memory_bytes: 3660
def d(u):
 global t
 C[u]=1;t+=1;D[u]=t
 for v in range(N):
  if M[u][v]and C[v]==0:d(v)
 C[u]=2;t+=1;F[u]=t
N=int(input())
M=[[0]*N for _ in[0]*N]
for e in[list(map(int,input().split()))for _ in[0]*N]:
 for v in e[2:]:M[e[0]-1][v-1]=1
C,D,F=[0]*N,[0]*N,[0]*N
t=0
for i in range(N):
 if C[i]==0:d(i)
for i in range(N):print(i+1,D[i],F[i])


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

int main() {
	ll h, w;

	while (true) {
		cin >> h >> w;
		if (h == 0 && w == 0)
			break;

		for (ll i = 0; i < h; i++) {
			if (i % 2 != 0) {
				for (ll j = 0; j < w; j++) {
					if (j % 2 == 0)
						cout << ".";
					else
						cout << "#";
				}
			}
			else {
				for (ll j = 0; j < w; j++) {
					if ( j % 2 == 0)
						cout << "#";
					else
						cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}

}




Measured memory_bytes: 3096
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll n,ans;
void solve(){
	cin>>n;
	string s;
	map<string,ll> ma;
	rep(i,0,n){
		cin>>s;
		multiset<int> ss;
		for(auto c:s)ss.insert((int)c);
		s="";
		for(auto c:ss)s+=(char)c;
		ma[s]++;
	}
	for(auto m:ma){
	//	cout<<m.fi<<endl;
		ans+=(m.se-1)*m.se/2;
	}
	cout<<ans;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





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

int main() {
	int a,b;
	cin>>a>>b;
	if(a>=b){
		for(int i=0;i<a;i++){
			cout<<b;
		}
	}else{
		for(int i=0;i<b;i++){
			cout<<a;
		}
	}
	
	return 0;
}

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

using namespace std;
//using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int n;
  cin >> n;
  cout << (n == 1 ? 0 : 1) << "\n";



  return 0;
}

Measured memory_bytes: 3632
package main

import "fmt"

func main() {
	var h1, m1, h2, m2, k int
	fmt.Scan(&h1, &m1, &h2, &m2, &k)

	ans := (h2-h1)*60 + (m2 - m1)
	ans -= k
	fmt.Println(ans)

}


Measured memory_bytes: 1756
import java.util.Scanner;
import java.util.StringJoiner;
import java.util.TreeSet;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        if (scanner.hasNextLine()) {
            int N = Integer.parseInt(scanner.nextLine());

            if (N == 3) {
                System.out.println("3 5 22");
            } else {
                int c6p3 = ((N - 1) / 8) * 2 + 2;
                int c6p2 = (N - c6p3 - 1) / 3 + 1;
                int c6p6 = N - c6p3 - c6p2 - c6p2;

                TreeSet<Integer> set = new TreeSet<>();
                for (int i = 0; i < c6p3; ++i) {
                    set.add(i * 6 + 3);
                }
                for (int i = 0; i < c6p2; ++i) {
                    set.add(i * 6 + 2);
                    set.add(i * 6 + 4);
                }
                for (int i = 0; i < c6p6; ++i) {
                    set.add(i * 6 + 6);
                }
                StringJoiner joiner = new StringJoiner(" ");
                for (Integer v: set) {
                    joiner.add(v.toString());
                }
                System.out.println(joiner.toString());
            }
        }
    }
}

Measured memory_bytes: 27396
S =  input()
flag = 0


for i in range(len(S)):
    if (i % 2) == 0:
        if S[i] == "L":
            flag = 1
    else:
        if S[i] == "R":
            flag = 1

if flag:
    print("No")
else:
    print("Yes")
    
    

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define pb push_back
#define test cout<<"#"

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n, k;
	cin>>n>>k;
	vector<ll> v(n);
	for(ll x = 0; x < n; x++)
		cin>>v[x];
	ll ans[n];
	for(ll x = 0; x < n; x++)
		ans[x] = LONG_LONG_MAX;
	ans[0] = 0;
	for(ll x = 1; x < n; x++)
	{
		for(ll y = 1; y <= k; y++)
		{
			if(x-y>=0)
				ans[x] = min(ans[x], ans[x-y]+abs(v[x]-v[x-y]));
		}
	}
	cout<<ans[n-1];
}

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

int main(){

    int N;
    cin >> N;

    vector<int> a(N+1);
    for(int i=1; i<=N; i++) cin >> a.at(i);

    int cnt = 0;
    for(int i=0; i<=N; i++){
        if((a.at(i)%2 != 0) && (i%2 != 0)) cnt++;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG arc/arc066/c.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

ll mod = 1000000007;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    int N; 
    cin >> N;
    vector<int> a(N);
    rep(i, N){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    if(N % 2 == 0){
        if(a[0] == 0){// ありえない
            cout << 0 << "\n";
            return 0;
        }
        for(int i = 1; i < N; i++){
            if(i % 2 == 1){
                if(a[i] == a[i-1]){
                    continue;
                }else{
                    cout << 0 << "\n";
                    return 0;
                }
            }else{
                if(a[i] == a[i-1]){
                    cout << 0 << "\n";
                    return 0;
                }else{
                    continue;
                }
            }
        }
        ll ans = 1;
        rep(i, N/2){
            ans = (ans * 2) % mod;
        }
        cout << ans << "\n";
        return 0;
    }else{
        if(a[0] != 0){
            cout << 0 << "\n";
            return 0;
        }

        if(N == 1){
            cout << 1 << "\n";
            return 0;
        }

        for(int i = 1; i < N; i++){
            if(i % 2 == 1){
                if(a[i] == a[i - 1]){
                    cout << 0 << "\n";
                    return 0;
                }else{
                    continue;
                }
            }else{
                if(a[i] == a[i - 1]){
                    continue;
                }else{
                    cout << 0 << "\n";
                    return 0;
                }
            }
        }

        ll ans = 1;
        rep(i, N/2){
            ans = (ans * 2) % mod;
        }
        cout << ans << "\n";
        return 0;
    }
    return 0;
}

Measured memory_bytes: 640
/*==============================================*\
ID:          shahidul_brur
 
Name:     Md. Shahidul Islam
Study:      CSE, BRUR
Address:  Rangpur, Bangladesh
 
 mail: shahidul.cse.brur@gmail.com
 FB  : fb.com/shahidul.brur
 Blog: shahidul-brur.blogspot.com(in Bengali),
       shahidul-brur-en.blogspot.com(in English)
\*===============================================*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

const double pi = acos(-1.0);
const double eps = 1e-6;
const int mod = (int)1e9+7;
const int maxn = (int)2e5+5;
const int logn = 20;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n,a,b;
  	cin>>n>>a>>b;
  	cout << min(n*a,b) << "\n";
    return 0;
}


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

#define MAX 101
int tile[MAX][MAX];
tuple<int,int,int> data[MAX];
tuple<int,int,int> start;
int n;
// プロトタイプ宣言
void Solve(void);
// ここまで


int main(){
	cin>>n;
	int x,y,h;
	for(int i=0;i<n;i++){
		cin>>x>>y>>h;
		data[i]=make_tuple(x,y,h);
		if(h) start=make_tuple(x,y,h);
	}


	int ansx=0, ansy=0, ansh=0;
	Solve();
	bool flag=false;

	for(int y=0;y<MAX;y++){
		for(int x=0;x<MAX;x++){
			if(tile[y][x]){
				flag=true;
				ansx=x;
				ansy=y;
				ansh=tile[y][x];
				break;
			}
		}
		if(flag)break;
	}
	printf("%d %d %d\n",ansx,ansy,ansh);

	return 0;
}

void Solve(void){
	// 初期化 {{{
	for(int i=0;i<MAX;i++){
		for(int j=0;j<MAX;j++){
			tile[i][j]=0;
		}
	}
	// }}}
	// 解答 {{{
	// 答えになるかもしれない座標はせいぜい101x101個なので全部試してみる
	bool flag=true;
	int sx=get<0>(start);
	int sy=get<1>(start);
	int sh=get<2>(start);

	for(int i=0;i<MAX;i++){	// マス目:y
		for(int j=0;j<MAX;j++){ // マス目:x
			/*
				初期設定。
			   	とりあえず、いま調べてるマス目の高さを、
			   	start(とある h>0 のデータ)から求められる高さと置く。
			 */

			tile[i][j]=sh + abs(sx-j)+abs(sy-i);
			bool flag=true;

			for(int k=0;k<n;k++){
				int dataX=get<0>(data[k]);
				int dataY=get<1>(data[k]);
				int dataH=get<2>(data[k]);

				int nowH = max(tile[i][j]-abs(j-dataX)-abs(i-dataY), 0);

				if(nowH != dataH){
					flag=false;
					break;
				}
			}
			if(flag==false){
				tile[i][j]=0;
				continue;
			}
		}
	}
	// }}}
}


Measured memory_bytes: 256
a,b,c,d,e,f = map(int,input().split())
sugar = []
for i in range(f//c):
	for k in range(f//d):
		sugartotal = i*c+k*d
		if sugartotal <= f:
			sugar.append([i,k])
n = len(sugar)
ans = []
cans = []
for i in range(n):
	sugartotal = sugar[i][0]*c+sugar[i][1]*d
	watermax = f-sugartotal
	for k in range(watermax//(100*a)+1):
		for p in range(watermax//(100*b)+1):
			if k>0 or p>0:
				watertotal = k*100*a+p*100*b
				if watertotal <= watermax and (watertotal/100)*e>=sugartotal:
					ans.append(sugartotal/(sugartotal+watertotal))
					cans.append([watertotal+sugartotal,sugartotal])

mdensity = max(ans)
ind = ans.index(mdensity)
print(cans[ind][0],cans[ind][1])

Measured memory_bytes: 147440
#include <bits/stdc++.h>
using namespace std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define int        long long
#define inf       ((ll)1e18)
#define mod       (ll)1e9+7
#define double    long double
#define ull       unsigned long long
#define vi        vector<ll>
#define ppi       pair<int,int>
#define pii       pair<pair<int,int>,int>
#define pb        push_back
#define pi        2*acos(0.0)
#define rev       greater<int>()
#define pr(a,x,y) for(int i=x;i<y;i++){cout<<a[i]<<" ";}
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define test      cout<<"THIS_AND_THIS"<<endl;
#define str       string
#define endl      '\n'
#define e         cout<<'\n';
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
int32_t main() {
	kehsihba();
	ll t=1;//cin>>t;
	for(int testcase=1;testcase<=t;testcase++){
		ll n,k;cin>>n>>k;
		ll arr[n];
		for(int i=0;i<n;i++){cin>>arr[i];}
		ull a=1;
		for(int i=0;i<k;i++){
			a+=arr[i];
		}
		ull cur=1;
		for(int i=k;i<n;i++){
			cur=(a+arr[i])-arr[i-k];
			if(cur>a){cout<<"Yes"<<endl;}
			else{cout<<"No"<<endl;}
			a=cur;
		}
	}
}


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

int main() {
  int n; cin >> n;
  double ans = 0;
  for (int i = 0; i < n; i++) {
    double x; string u; cin >> x >> u;
    if (u == "JPY") ans += x;
    else ans += x*380000.0;
  }
  printf("%.10f\n", ans);
  return 0;
}

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

int main() {
    int n, pimp, comp;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    pimp = a.size();
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
    comp = a.size();
    if (pimp == comp) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 4000
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  int a[n+1];
  int b[n+1] = {0};
  int cnt = 0;
  rep(i,n){
    cin >> a[i+1];
    // if(i > n/2){
    //   if(a[i+1] == 1){
    //     b[i+1] = 1;
    //     cnt++;
    //   }
    // }
  }
  for(int i = n; i >= 1; i--){
    int chk = i;
    while(chk+i <= n){
      chk += i;
      b[i] = (b[i] + b[chk])%2;
    }
    if(b[i] == a[i]) b[i] = 0;
    else{
      b[i] = 1;
      cnt++;
    }
  }

  printf("%d\n", cnt);

  for(int i = 1; i <= n; i++){
    if(b[i] == 1) printf("%d ", i);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 2432
import java.util.Scanner;
public class Main{
final static int MAX=100;
	public static void main(String[] args) {
		int i,j,n,pn,num;
		// TODO Auto-generated method stub
		Scanner sca = new Scanner(System.in);
		n=sca.nextInt();
		int[][]graph=new int[MAX+1][MAX+1];
		for(i=1;i<=n;i++){
			num=sca.nextInt();
			pn=sca.nextInt();
			for(j=0;j<pn;j++){
				graph[num][sca.nextInt()]=1;
			}
		}
		for(i=1;i<=n;i++){
			for(j=1;j<=n;j++){
				System.out.print(graph[i][j]);
				if(j+1<=n)System.out.print(" ");
			}
			System.out.println("");
		}

	}

}



Measured memory_bytes: 34776
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 1000000000
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, M, L, R, l = 0, r = INF;

  std::cin >> N >> M;

  for (int i = 0; i < M; i ++) {
    std::cin >> L >> R;

    l = std::max(L, l);
    r = std::min(R, r);
  }

  std::cout << std::max(r - l + 1, 0) << std::endl;
  
  return 0;
}


Measured memory_bytes: 888
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n = ni()
a = na()
mod = 1000000007

s = sum(a)
s2 = 0
for u in a:
    s2 += u*u
print((s*s - s2) // 2 % mod)


Measured memory_bytes: 92216
#!/usr/bin/env python3
import sys

N = int(input())
A = map(int, input().split())

for a in A:
    if a % 2 == 0:
        if a % 3 == 0 or a % 5 == 0:
            continue
        else:
            print("DENIED")
            sys.exit()

print("APPROVED")


Measured memory_bytes: 2940
using System;

public class Hello{
    public static void Main(){
        int i = 1;
        int x = 1;
        while(x != 0){
            x = int.Parse(Console.ReadLine());
            if(x != 0){
              Console.WriteLine("Case "+i+": "+x);
              i = i + 1;
            }
        }
    }
}



Measured memory_bytes: 15932
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace CSharp
{
    static class Program
    {
        static void Main(string[] args)
        {
            int[] array = new[] { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
            int k = ReadInt();
            int ans = array[k - 1];
            Console.WriteLine(ans);
        }

        #region Helpers

        static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();

        static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count).Select(_ => int.Parse(Console.ReadLine())).ToArray();
        static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count).Select(_ => long.Parse(Console.ReadLine())).ToArray();

        static string ReadString() => Console.ReadLine();
        static int ReadInt() => int.Parse(Console.ReadLine());
        static long ReadLong() => long.Parse(Console.ReadLine());

        static void ReadInt(out int first)
        {
            var array = ReadIntArray();
            first = array[0];
        }

        static void ReadInt(out int first, out int second)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
        }

        static void ReadInt(out int first, out int second, out int third)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadInt(out int first, out int second, out int third, out int fourth)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static void ReadLong(out long first)
        {
            var array = ReadLongArray();
            first = array[0];
        }

        static void ReadLong(out long first, out long second)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
        }

        static void ReadLong(out long first, out long second, out long third)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadLong(out long first, out long second, out long third, out long fourth)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        #endregion
    }
}

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

int main() {
  int n, x; cin >> n >> x;
  if (x==1 || x==2*n-1) {
    cout << "No" << endl;
  } else {
  cout << "Yes" << endl;
    for (int i = 0; i < 2*n-1; i++) {
      cout << (x-n+2*n+i-1)%(2*n-1)+1 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1536
import java.text.DateFormat;
import java.text.ParseException;
import java.util.*;
  
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        if (S.compareTo("2019/04/30") > 0) {
            System.out.println("TBD");
        }
        else {
            System.out.println("Heisei");
        }
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#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 rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V, string sep = " ", string end_ = "endl") {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << sep;
    }
    if(end_ == "endl")
        cout << endl;
    else
        cout << end_;
}

template <typename T> T gcd(T a, T b) {
    if(a > b) gcd(b, a);
    T r;
    while(r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B;
    cin >> A >> B;
    ll n = gcd(A, B);
    ll r = ceil(sqrt(n));

    ll c = 1;
    if(n > 1) {
        if(n % 2 == 0) {
            c++;
            while(n % 2 == 0)
                n /= 2;
        }
        for(ll i = 3; i <= r; i += 2) {
            if(n % i == 0) {
                c++;
                while(n % i == 0)
                    n /= i;
            }
        }
        if(n > r) c++;
    }

    cout << c << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int dp[20][1200];
bool pr[1121];
int npr[1121],pos;

int main()
{
  pr[0]=pr[1]=true;
  for(int i=2;i<1121;i++)
  {
    if(pr[i])continue;
    for(int j=i*2;j<1121;j+=i)pr[j]=true;
  }
  for(int i = 0; i < 1121; ++i)
  {
	  if(!pr[i])npr[pos++]=i;
  }

  dp[0][0]=1;
  for(int p = 0; p < pos; ++p)
  {
    for(int k=14;k;k--)
      for(int i=npr[p];i<1121;i++)
		  dp[k][i]+=dp[k-1][i-npr[p]];
  }
  int n,k;
  while(cin>>n>>k,n|k)
	  cout<<dp[k][n]<<endl;
}

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

using namespace std;
#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++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

bool kaibun(string s)
{
    int size = s.size();
    rep(i, size)
    {
        if (s.at(i) != s.at(size - 1 - i))
            return false;
    }
    return true;
}

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    string former = s.substr(0, (n - 1) / 2);
    string latter = s.substr((n + 3) / 2 - 1, (n - 1) / 2);

    if (kaibun(s) && kaibun(former) && kaibun(latter)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leadinz zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
ll bin_pow(ll a,ll b,ll m)
{
    ll res=1;
    a%=m;
    while(b>0){
        if(b&1)res=res*a%m;
        b>>=1;
        a=a*a%m;
    }
    return res;
}
bool miller_rabin(ll d,ll n)
{
    ll a=2+rand()%(n-4);
    ll x=bin_pow(a,d,n);
    if(x==1 || x==n-1)return true;
    while(d!=n-1){
        x=(x*x)%n;
        d*=2;
        if(x==1)return false;
        if(x==n-1)return true;
    }
    return false;
}
bool prime(ll n,ll k)
{
    if(n==1 || n==4)return false;
    if(n<=3)return true;
    ll d=n-1;
    while(d%2==0)d/=2;
    for(int i=0;i<k;i++){
        if(!miller_rabin(d,n))return false;
    }
    return true;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll res=n;
    ll k=0;
    while(res){
        k+=res%10;
        res/=10;
    }
    if(n%k==0)puts("Yes");
    else puts("No");
}


Measured memory_bytes: 256