akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);

        int a = Integer.parseInt(s.next());
        int b = Integer.parseInt(s.next());
        int k = Integer.parseInt(s.next());

        int min = a < b ? a : b;
        List<Integer> list = new ArrayList<Integer>();
        for (int i = 1; i <= min; i++) {
            if (a % i == 0 && b % i == 0) {
                list.add(i);
            }
        }
        Optional<Integer> an = list.stream()
                .sorted(Comparator.reverseOrder())
                .skip(k - 1)
                .findFirst();

        System.out.println(an.orElse(0));
    }
}

Measured memory_bytes: 27988
#include <cstdio>
#include <algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int n;
int p[30];
int ans;

int main()
{
  scanf( "%d", &n );
  rep( i, n )
    scanf( "%d", p+i );

  rep( i, n-2 ) 
  {
    int mi = std::min( p[i], std::min( p[i+1], p[i+2] ) );
    int ma = std::max( p[i], std::max( p[i+1], p[i+2] ) );

    if( p[i+1] != mi && p[i+1] != ma )
      ++ans;
  }

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

  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int w = 0;
        int l = 0;
        int g = 0;
        int p = 0;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c == 'g') {
                if (g > p) {
                    w++;
                    p++;
                } else {
                    g++;
                }
            } else {
                if (g > p) {
                    p++;
                } else {
                    l++;
                    g++;
                }
            }
        }
        System.out.println(w - l);
    }
}

Measured memory_bytes: 27120
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int A,B;
    scanf("%d%d",&A,&B);
    if(A + B >= 10)
    {
        printf("error\n");
        return 0;
    }
    printf("%d\n",A+B);
    return 0;
}


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

int main(){
    int a[3000],b[3000];
    for(int i=0; i<3000; i++){
        cin >> a[i] >> b[i];
        if(a[i]==0&&b[i]==0)break;
        cout << min(a[i], b[i]) << " " << max(a[i], b[i]) << endl;
    }
    return 0;
}


Measured memory_bytes: 3024
//shara's here
//SPEEEEEEEEEED IS KEEEEEEEEEEY
//REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEAD
#include <bits/stdc++.h>
using namespace std;
typedef string s;
typedef long long ll;
typedef long double ld;
#if !defined(ONLINE_JUDGE)
#include "C:\debug.hpp"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define pb push_back
#define ins insert
#define vl vector<ll>
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
int main(){
    speed;
    ll a,b;
    cin>>a>>b;
    cout<<a*b<<endl;










return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/


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

using namespace std;

int lowbit(int x) {
  return x & -x;
}

int Bc(int x) {
  int r = 0;
  while (x) ++r, x -= lowbit(x);
  return r;
}

void Solve(int a, int b, int u, int ext) {
  if (a == b) {
    assert(!u);
    cout << (a | ext) << ' ';
    return;
  }
  assert(Bc(a ^ b) & 1);
  int xo = a ^ b;
  int y = lowbit(xo);
  u ^= y;
  if (a & y) {
    int c = a ^ y ^ lowbit(u);
    Solve(a ^ y, c, u, ext | y);
    Solve(c, b, u, ext);
  } else {
    int c = a ^ lowbit(u);
    Solve(a, c, u, ext);
    Solve(c, b ^ y, u, ext | y);
  }
}

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  if (~Bc(a ^ b) & 1) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  Solve(a, b, (1 << n) - 1, 0);
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 1024
n = int(input())
list_a = [int(i) for i in input().split()]
list_b = [int(j) for j in input().split()]
list_c = [int(k) for k in input().split()]
satisfied = 0
for i in range(0, len(list_a)):
    satisfied += list_b[list_a[i] - 1]
    if i > 0 and list_a[i] == list_a[i - 1] + 1:
        satisfied += list_c[list_a[i - 1] - 1]
print(satisfied)

Measured memory_bytes: 9196
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define LL long long 
#define LD long double
int d1,d2,m1,m2;
int main()
{
	cin>>d1>>m1;
	cin>>d2>>m2;
	cout<<(d1!=d2)<<endl;	
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N 100001
int h[N], f[N], n, k;
int main() {
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; i++) scanf("%d", &h[i]);
    for (int i = 2; i <= n; i++) {
        int minn = 2147483647;
        for (int j = max(1, i - k); j < i; j++)
            minn = min(minn, abs(h[i] - h[j]) + f[j]);
        f[i] = minn;
    }
    printf("%d\n", f[n]);
    return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	VL p(n);
	cin >> p;
	SORT(p);
	p.back() /= 2;
	cout << accumulate(ALL(p), 0) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a,c;
int main()
{
	cin>>n;
	a=n;
	while(n)
	{
		c+=n%10;
		n/=10;
	}
	if(a%c==0)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

double P[3000];
double DP[3000][3000];

int main(){
    int N;
    cin >> N;
    REP(i,N){
        double p;
        cin >> p;
        P[i] = p;
    }

    DP[0][0] = 1-P[0];
    DP[0][1] = P[0];
    for(int i = 1; i < N; i++){
        for(int j = 0; j <= i+1; j++){
            if(j == 0) DP[i][j] = DP[i-1][j] * (1-P[i]);
            else DP[i][j] = DP[i-1][j-1] * P[i] + DP[i-1][j] * (1-P[i]);
        }
    }

    double ans = 0;
    //for(int i = 0; i <= N; i++){
    //    printf("%.3lf ", DP[N-1][i]);
    //}
    //printf("\n");

    for(int i = (N+1)/2; i <= N; i++){
        ans += DP[N-1][i];
    }

    printf("%.14lf\n", ans);
    return 0;
}


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

int main(){
  int n,k;
  cin >>n>>k;
  vector<int>vec(n);
  for(int i=0;i<n;i++) {
    cin >>vec.at(i);
  }
  stable_sort(vec.begin(),vec.end(),greater<int>());
  int p=0;
  for(int i=0;i<k;i++){
    p+=vec.at(i);
  }
  cout << p<<endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
struct UFT{
  vector<int> par;//親
  vector<int> rank;//木の深さ
  vector<int> size;//木の大きさ
  int n;
  
  UFT(int _n)
  {
    n = _n;
    par.resize(n);
    rank.assign(n,0);
    size.assign(n,0);
    rep(i,n){
      par[i] = i;
    }
  }
  
  //xの根を返す
  int find(int x)
  {
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
  }

  //x,yを併合
  void unite(int x,int y)
  {
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(rank[x] < rank[y]){
      par[x] = y;
      size[y] += size[x];
    }
    else{
      par[y] = x;
      size[x] += size[x];
      if(rank[x] == rank[y]) rank[x]++;
    }
  }

  //x,yが同じグループにいるかどうかを返す
  bool same(int x,int y)
  {
    return find(x) == find(y);
  }

  //xの属する木のサイズを探す
  int usize(int x)
  {
    return size[find(x)];
  }
};

int main(){
  int n,q;cin >> n >> q;
  vector<int> c(q),x(q),y(q);
  rep(i,q) cin >> c[i] >> x[i] >> y[i];
  
  UFT uf(n);
  rep(i,q){
    if(c[i]==0) uf.unite(x[i],y[i]);
    else{
      if(uf.same(x[i],y[i])) cout << 1 << "\n";
      else cout << 0 << "\n";
    }
  }
  
  return 0;
}



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

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<pair<int, char>> p;
  for(int i = 0; i < m; i++)
  {
    int si;
    char ci;
    cin >> si >> ci;
    p.push_back(make_pair(si, ci));
  }
  if(n == 1 && m == 0)
  {
    cout << "0\n";
    return 0;
  }
  char number[n];
  for(int i = 0; i < n; i++)
    number[i] = '#';
  for(int i = 0; i < m; i++)
  {
    if(number[p[i].first - 1] != '#' && number[p[i].first - 1] != p[i].second)
    {
      cout << "-1\n";
      return 0;
    }
    else
      number[p[i].first - 1] = p[i].second; 
  }
  if(number[0] == '#')
    number[0] = '1';
  for(int i = 1; i < n; i++)
    if(number[i] == '#')
      number[i] = '0';
  for(int i = 1; i < n; i++)
  {
    if(number[i - 1] == '0')
    {
      cout << "-1\n";
      return 0;
    }
    else
      break;
  }
  for(int i = 0; i < n; i++)
    cout << number[i];
  cout << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define INF (1<<30)-1
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

ll sum(ll l, ll r){
   return (r+l)*(r-l+1)/2;
 }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n,k; cin >> n >> k;
  const int MOD = 1e9+7;
  ll ans = 0;
  for(int i = k; i <= n+1; i++){
    ll l = sum(0,i-1), r = sum(n-i+1,n);
    ans += r-l+1;
    ans %= MOD;
  }
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3628
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#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 _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int gcd(int a, int b){
  if (b>a) swap(a,b);
  if (b==0) return a;
  return gcd(b, a%b);
}

vi divisor(int n){  // 約数全列挙{{{
  vi p,q;
  for(int i=1; i*i<=n; i++){
    if (n%i==0){
      p.pb(i);
      if (i*i!=n) q.pb(n/i);
    }
  }
  reverse(all(q));
  p.insert(p.end(), all(q));
  return p;
}//}}}

vector<int> sieve(int n) {  // エラトステネスのふるい O(NloglogN){{{
  // 素数の集合を得たい場合はsort, uniqueをすればよい。
  vector<int> primes(n);
  for (int i = 2; i < n; ++i)
    primes[i] = i;
  for (int i = 2; i*i < n; ++i)
    if (primes[i])
      for (int j = i*i; j < n; j+=i)
        primes[j] = 0;
  return primes;
}//}}}

bool is_prime(int n) {/*{{{*/
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return n != 1;
}/*}}}*/

int solve(){
  int a,b;cin>>a>>b;
  int g = gcd(a, b);
  dump(g);

  auto d = divisor(g);
  dump(d);

  int n = sz(d);
  map<int, int> gou;
  vi ans;
  rep(i, 1, n){
    if (is_prime(d[i])) ans.pb(d[i]);
  }
  cout << sz(ans)+1 << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	int x;
	cin >> x;
	if(x <= 599) cout << 8 << endl;
	else if(x <= 799) cout << 7 << endl;
	else if(x <= 999) cout << 6 << endl;
	else if(x <= 1199) cout << 5 << endl;
	else if(x <= 1399) cout << 4 << endl;
	else if(x <= 1599) cout << 3 << endl;
	else if(x <= 1799) cout << 2 << endl;
	else cout << 1 << endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

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

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

cnt=0
for i in range(2**n):
  flag=True
  i=format(i,'b')
  i=i.zfill(n)
  for j in range(m):
    ans=0
    for k in range(1,lights[j][0]+1):
      ans+=int(i[lights[j][k]-1])
      ans%=2
    if ans==p[j]:
      continue
    else:
      flag=False
  if flag:
    cnt+=1
print(cnt)    


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define vt vector
#define pq priority_queue
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int N = 1e5 + 5;

int n;
int a[N], dp[N];

int f(int idx) {
    if(idx == n) return 0;
    int &sol = dp[idx];
    if(sol != -1) return sol;
    sol = f(idx + 1) + abs(a[idx + 1] - a[idx]);
    if(idx + 2 <= n) sol = min(sol, f(idx + 2) + abs(a[idx + 2] - a[idx]));
    return sol;
}

void solve() {
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    memset(dp, -1, sizeof(dp));
    cout << f(1) << "\n";
}

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

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

int main() {
  int N;
  cin >> N;
  vector<int> D(100);
  
  for (int i = 0; i < N; i++) {
    int d;
    cin >> d;
    D.at(d - 1) = 1;
  }
  
  int l = 0;
  for (int i = 0; i < D.size(); i++) l += D.at(i);
  cout << l << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



char buf[105];
int table[2][26];

int main(){

	int len;
	scanf("%d",&len);
	scanf("%s",buf);

	int ans = 0;

	for(int right = 0; right <= len-2; right++){
		for(int i = 0; i < 2; i++){
			for(int k = 0; k < 26; k++){

				table[i][k] = 0;
			}
		}

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

			table[0][buf[i]-'a']++;
		}
		for(int i = right+1; i <= len-1; i++){

			table[1][buf[i]-'a']++;
		}
		int tmp = 0;
		for(int i = 0; i < 26; i++){

			if(table[0][i] > 0 && table[1][i] > 0){

				tmp++;
			}
		}
		ans = max(ans,tmp);
	}

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

	return 0;
}


Measured memory_bytes: 3812
n = int(input())
a = list(map(int, input().split()))
s = ([0]*1000001)
a.sort()
for i in a:
    s[i] += 1
ans = 0
for j in range(1000001):
    if s[j] == 1:
        ans += 1
    if s[j] > 0:
        for k in range(j, 1000001, j):
            s[k] = 0
print(ans)

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

double length(double x1, double y1, double x2, double y2){
  return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}

double angle(double len1, double len2, double len3){
  double bunshi = len1*len1 + len2*len2 - len3*len3;
  double bunbo = 2.0 * len1 * len2;
  return acos(bunshi/bunbo);
}

double calc_area(double a, double b, double c, double theta){
  return (a * b * sin(theta))/(a + b + c);
}

double radii(double r, double a, double b, double c){
  double bunshi = r * (1.0 + tan(a/4.0)) * (1.0 + tan(b/4.0));
  double bunbo = 2.0 * (1.0 + tan(c/4.0));
  return bunshi / bunbo;
}

int main(){
  double x1,y1,x2,y2,x3,y3;
  cout.precision(10);
  for(;cin>>x1>>y1>>x2>>y2>>x3>>y3,!((x1==0)&&(y1==0)&&(x2==0)&&(y2==0)&&(x3==0)&&(y3==0));){
    double r,r1,r2,r3;
    double ab,bc,ac;
    double theta_a,theta_b,theta_c;
 //   cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<" "<<x3<< " "<<y3<<endl;
    ab = length(x1,y1,x2,y2);
    bc = length(x3,y3,x2,y2);
    ac = length(x1,y1,x3,y3);
    //cout<<ab<<" "<<bc<<" "<<ac<<endl;
    theta_a = angle(ab,ac,bc);
    theta_b = angle(ab,bc,ac);
    theta_c = angle(ac,bc,ab);
    //cout<<theta_a<<" "<<theta_b<<" "<<theta_c<<endl;
    r = calc_area(ac,bc,ab,theta_c);
 //   cout<<r<<endl;
    r1 = radii(r,theta_b,theta_c,theta_a);
    r2 = radii(r,theta_a,theta_c,theta_b);
    r3 = radii(r,theta_b,theta_a,theta_c);
    cout<<r1<<" "<<r2<<" "<<r3<<endl;
  }
  return 0;
}

Measured memory_bytes: 1396
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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 n,ans=100000;

int main(){
    cin>>n;
    rep(i,n){
        ans*=1.05;
        ans=(ans+999)/1000*1000;
    }
    out(ans);
}



Measured memory_bytes: 3104
N, M, C = (int(x) for x in input().split())
B = [int(x) for x in input().split()]
ans = 0
for i in range(N):
  A = [int(x) for x in input().split()]
  P = C
  for j in range(M):
    P += A[j]*B[j]
  if P > 0:
    ans += 1
print(ans)

Measured memory_bytes: 9112
def resolve():
  base = 998244353
  N, K = map(int, input().split(" "))

  LRs = []
  for _ in range(K):
    (L, R) = map(int, input().split(" "))
    LRs.append((L, R))

  dp = [0] * (N+1)
  dp_sum = [0] * (N+1)
  dp[1] = 1
  dp_sum[1] = 1

  for i in range(2, N+1):
    for lr in LRs:
      left = max(i - lr[1] - 1, 0)
      right = max(i - lr[0], 0)
      dp[i] += dp_sum[right] - dp_sum[left]
      if dp[i] >= base:
        dp[i] %= base
      dp_sum[i] = dp_sum[i-1] + dp[i]
  print(dp[-1])

if __name__ == "__main__":
  resolve()

Measured memory_bytes: 76948
import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        int res = 0;
        for(int i=2; i<=1000000; i++) {
            long div = i;
            while(n % div == 0 && div <= n) {
                n/=div;
                res++;
                div*=i;
            }
            while(n % i == 0) {
                n/=i;
            }
        }
        if(n != 1) res++;
        System.out.println(res);
    }




}

Measured memory_bytes: 35780
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int k = 0;
		Scanner sc = new Scanner(System.in);
		int gyo = sc.nextInt();
		int retu = sc.nextInt();
		while (gyo != 0 || retu != 0){
			for(int i=0;i<gyo;i++){
				if(i==0 || i == gyo - 1) {
					for(int j=0;j<retu;j++){
						System.out.printf("#");
					}
				} else {
					System.out.printf("#");
					for(int j=2;j<retu;j++){
						System.out.printf(".");
					}
					System.out.printf("#");
				}
				System.out.println();
			}
			System.out.println();
			gyo = sc.nextInt();
			retu = sc.nextInt();
		}
	}
}


Measured memory_bytes: 56244
def solve(string):
    n, x, y = map(int, string.split())
    ans = [0] * n
    for i in range(1, n):
        for j in range(i + 1, n + 1):
            ans[min(j - i, abs(x - i) + 1 + abs(j - y), abs(y - i) + 1 + abs(j - x))] += 1
    return "\n".join(map(str, ans[1:]))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


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

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int,int> pii;

#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define ff it->first
#define ss it->second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(auto i=0;i<n;++i)
#define LOOP_IT(it,s) for(auto it=(s).begin();it!=(s).end();++it)


#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

ll a,b;
ll f(ll n)
{
    ll ans = (n*a)/b - (a*(n/b));
    return ans;
}
int main(int argv, char* argc[])
{
    FASTIO


    ll n,ans;
    ll c1,c2,c3,c4,c5,c6,c7,c8;
    c1=c2=c3=c4=c5=c6=c7=c8=0;
    cin>>a>>b>>n;

    if(a-1<=n)
        c1 = f(a-1);
    if(a+1<=n)
        c2 = f(a+1);
    if(a<=n)
        c3 = f(a);
    if(b-1<=n)
        c4 = f(b-1);
    if(b+1<=n)
        c5 = f(b+1);
    if(b<=n)
        c6 = f(b);
    c7 = f(n);
    c8 = f(n-1);

    ans = max({c1,c2,c3,c4,c5,c6,c7,c8});
    cout<<ans;

    return 0;
}


Measured memory_bytes: 3656
s=set()
a=s.add
def f(n):
  for i in range(1,int(n**.5)+1):
    if n%i<1:
      a(i)
      if i!=n//i:a(n//i)
n=int(input())
f(n-1),f(n)
a=0
for i in s-{1}:
  m=n
  while m%i<1:m//=i
  a+=m%i<2
print(a)

Measured memory_bytes: 3952
#include <bits/stdc++.h>
 
using namespace std;
 
#define PB(x)	push_back(x)
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define MP(x)	make_pair(x);
    
#define debug(x) 		cerr << #x << '=' << x << endl;
#define debug2(x, y)	cerr << #x << '=' << x << ' ' << #y << '=' << y << endl;
#define debugn(a)		cerr << #a << ": "; for (auto x: a) cerr << x << ' '; cerr << endl;
#define debugm(a) 		cerr << #a << ":\n"; \
						for (auto v: a) { for(auto x: v) cout << x << ' '; cerr << "\n"; }
 
#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long
 
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vii;
typedef vector<string> vs;
typedef unsigned long long ull;
 
const int INF  = LONG_LONG_MAX;
const int NINF = LONG_LONG_MIN;
const int mmod = 1000000007;

const int N = 15;

vvi T;
vvi X;

int32_t main()
{	
	FAST_IO;
	
	int n;
	cin >> n;
	int a[n];
	for(int& x: a) cin >> x;
	int res = 0;
	for (int b = 0; b < 60; b++) {
		int bit = ((int)1 << b);
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] & bit) {
				cnt++;
			}
		}
		res += ((((bit%mmod) * cnt)%mmod) * (n-cnt))%mmod;
		res %= mmod;
	}
	cout << res;
}
// g++ -Wall -Wextra -Wshadow -fsanitize=undefined 


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

#define REP(i, n) for ( int i = 0; i < (n); i++ )
const int INF = 1e9;

const int con_type = 26;
int D = 365;
int C[con_type];
int S[365][con_type];
int ans[con_type];

void solve() {
  REP(d, D) {
    int ma = -INF;
    int id = 0;
    REP(i, con_type) {
      if ( ma < S[d][i]+C[i] ) {
        ma = S[d][i]+C[i];
        id = i;
      }
    }

    ans[d] = id;
  }
}

void input() {
  cin >> D;
  REP(i, con_type) cin >> C[i];
  REP(i, D) REP(j, con_type) cin >> S[i][j];
}

void output() {
  REP(i, D) cout << ans[i]+1 << endl;
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  input();
  solve();
  output();

  return 0;
}


Measured memory_bytes: 3688
#include<bits/stdc++.h>
#define MAX 3000
#define ll unsigned long long
#define mod (1000000000+7)
#define Fast ios_base::sync_with_stdio(false); cin.tie(NULL);
//#define N 500001;

double dp[3005][3005];

using namespace std;

double solve(double a[],int n)
{
    int i,j;
    int x=(n+1)/2;
    for(i=0;i<=x;i++)
    dp[0][i]=0.0;
    for(i=0;i<=n;i++)
    dp[i][0]=1.0;
    dp[0][0]=1.0;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=x;j++)
        {
            dp[i][j]=a[i]*dp[i-1][j-1]+(1-a[i])*dp[i-1][j];
        }
    }
    /*for(i=0;i<=n;i++)
    {
        for(j=0;j<=x;j++)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<"\n";
    }*/
    return dp[n][x];
}
int main() {
    int n,i;
    cin>>n;
    double a[3005];
    for(i=1;i<=n;i++)
    cin>>a[i];
    memset(dp,-1,sizeof(dp));
    double k=solve(a,n);
    cout<<fixed<<setprecision(10)<<k<<"\n";
	return 0;
}


Measured memory_bytes: 70784
# -*- coding:utf-8 -*-

def solve():
    N, M = list(map(int, input().split()))
    A = []
    B = []

    for i in range(N):
        A.append(list(input()))
    for i in range(M):
        B.append(list(input()))
    
    # 左上から順に走査する
    for i in range(N-M+1):
        for j in range(N-M+1):
            if A[i][j] == B[0][0]:
                is_contained = True
                for k in range(0, M):
                    for l in range(0, M):
                        if A[i+k][j+l] != B[k][l]:
                            is_contained = False
                            break
                    if not is_contained: break
                if is_contained:
                    print("Yes")
                    return
    print("No")


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3064
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <map>

using namespace std;

typedef pair<int, int> Point;

int n;
set<Point> data;
vector<Point> node;

main(){
  while(cin >> n && n){
    data.clear();
    node.clear();
    for(int i=0;i<n;i++){
      Point in;
      cin >> in.second >> in.first;
      node.push_back(in);
      data.insert(in);
    }
    int ans = 0;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	int a = node[i].first - node[j].first;
	int b = node[i].second - node[j].second;
	if(data.find(Point(node[j].first-b, node[j].second+a)) != data.end() && 
	   data.find(Point(node[i].first-b, node[i].second+a)) != data.end())
	  ans = max(ans, a*a+b*b);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main() {
  int A,B;
  int answer = 0;
  string op;
  cin >> A >> op >> B;
  
  if (op == "+") {
    answer = A + B;
  }
  if (op == "-") {
    answer = A - B;
  }
  
  cout << answer << endl;
 }

Measured memory_bytes: 3572
#include <iostream>
#include <queue>

using namespace std;

priority_queue<int> q;

vector<vector<int>> jobs;

int main(void) {
	int n, m;
	cin >> n >> m;
	jobs = vector<vector<int>>(100001);
	for (int a = 0; a < n; a = a + 1) {
		int ai, bi;
		cin >> ai >> bi;
		jobs[ai].push_back(bi);
	}

	int ans = 0;

	for (int a = 1; a <= m; a = a + 1) {
		for (auto day : jobs[a]) q.push(day);

		if (!q.empty()) {
			ans += q.top();
			q.pop();
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

int main()
{
	fastIO
//	inp_out();
	ll a,b;
	cin>>a>>b;
	for(ll i=1;i<100000;++i)
	{
		ll v1=(i*8)/100;
		ll v2=(i*10)/100;
		if((a==v1)&&(b==v2))
		{
			cout<<i;
			return 0;
		}
	}
	cout<<-1;
	return 0;
}



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

int main(){
	int n;
	double ans = 0;
	cin >> n;
	vector<int> v(n);
	for(int i=0; i<n; i++){
		cin >> v[i];
	}

	sort(v.begin(), v.end());
	ans = (v[0]+v[1])/((double) 2);
	for(int i=2; i<n; i++){
		ans = (ans + v[i])/((double) 2);
	}
	cout << fixed << setprecision(7);
	cout << ans << endl;
}



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

typedef long long ll;
int N,Q;
ll p[100001];
ll x[100001];
ll tmp[100001];
int K[100001];
ll R[43][100003];
ll T[43][100003];

#define MOD (1000000007)


ll lcm(ll a,ll b){
  return a / __gcd(a,b) * b;
}

struct seg{
  ll d[(1<<18)];
  int n;
  void init(int _n){
    n = 1; while( n < _n ) n*=2;
    for(int i=0;i<2*n;i++) d[i] = 1LL;
  }
  void set(int id,ll k){
    id+=n-1;
    d[id] = k;
    while( id > 0 ){
      id = (id-1)/2;
      d[id] = lcm(d[2*id+1],d[2*id+2]);
    }
  }
  ll query(int a,int b,int k,int l,int r){    
    if( b <= l || r <= a ) return 1LL;
    else if( a <= l && r <= b ) return d[k];
    else {
      ll vl = query( a, b, 2*k + 1, l, (l+r)/2 );
      ll vr = query( a, b, 2*k + 2, (l+r)/2, r );
      //       cout << a << " " << b << " "<< k << " " << l << " " << r<< " " << vl << " "<< vr << " " << lcm(vl,vr) << endl;
      return lcm(vl,vr);
    }
  }
  ll query(int a,int b){
    return query(a,b,0,0,n);
  }
};

seg S;


void view(){
  for(int k=0;k<=5;k++){
    for(int i=0;i<=N;i++)
      cout << R[k][i] << " ";
    cout << endl;
  }

  for(int k=0;k<=5;k++){
    for(int i=0;i<=N;i++)
      cout << T[k][i] << " ";
    cout << endl;
  }

}

int main(){
  cin >> N >> Q;
  S.init(N);
  for(int i=0;i<N;i++) {
    cin >> p[i]; p[i]--;
    x[i] = i;
  }
  memset(K,-1,sizeof(K));
  for(int k=1;k<=41;k++){
    for(int i=0;i<N;i++) tmp[i] = p[x[i]];
    for(int i=0;i<N;i++) x[i] = tmp[i];
    for(int i=0;i<N;i++) if( x[i] == i && K[i] < 0 ) K[i] = k;
    for(int i=0;i<N;i++) R[k][i+1] = (R[k][i] + x[i]+1LL)%MOD;
  }

  for(int k=0;k<=41;k++)
    for(int i=0;i<=N;i++)
      R[k+1][i] = (R[k][i] + R[k+1][i])%MOD;

  for(int k=1;k<=40;k++){
    for(int i=0;i<=N;i++){
      ll sum = 0;
      if( K[i] == k )
        sum = R[k][i+1]-R[k][i]+MOD; sum%=MOD;      
      T[k][i+1] = (T[k][i] + sum)%MOD;
    }
  }
  
  //  view();
  
  for(int i=0;i<N;i++) S.set(i,K[i]);  

  for(int i=0;i<Q;i++){
    int l,r;
    cin >> l >> r; --l; --r;
    if( l > r ) swap(l,r);
    ///    cout << "[ " << l << " , " << r+1 << " ) " << endl;
    ll num = S.query(l,r+1);

    ll res = 0;
    for(int k=1;k<=40;k++){
      ll ks = num/(ll)k;
      ks %= MOD;
      if( num % (ll)k ) continue;
      //cout << num << " " << ks << endl;
      //cout << T[k][r+1] - T[k][l] << endl;
      res += (ks * (T[k][r+1] - T[k][l] + MOD)%MOD ) %MOD;
      res %= MOD;
      //      ll rs = num%(ll)k;
      //res += rsum + (R[rs][r+1]-R[rs][l]+MOD)%MOD;
      //res %= MOD;
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 73152
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
struct data{
    int a,b,c;
};

//降順
int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}
#define MAXSIZE 200000
int list[MAXSIZE];
int tail;

void Init(void){
    tail=0;
}
int Top(void){
    return 0;
}

int Next(int pos){
    if(pos<tail-1){
        return pos+1;
    }else{
        return -1;
    }
}
int Count(void){
    return tail;
}

int Item(int pos){
    if((pos>=0)&&(pos<tail)){
        return list[pos];
    }else{
        return 0;
    }
}
void Add(int value){
    if(tail<MAXSIZE){
        list[tail]=value;
        tail++;
    }
}
void Delete(int pos){
    if((pos>=0)&&(pos<tail)){
        int i;
        for(i=pos;i<tail-1;i++){
            list[i]=list[i+1];
        }
        tail--;
    }
}

int main(){
    int N;
    scanf("%d",&N);
    int pos[N];
    rep(i,N){
        scanf("%d",&pos[i]);
    }
    int min=100000000;
    rep(i,100){
        int sum=0;
        rep(j,N){
            sum+=(i-pos[j])*(i-pos[j]);
        }
        if(min>sum)
            min=sum;
    }
    printf("%d",min);
}


Measured memory_bytes: 1672
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int s[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<s[k-1];




    return 0;
}


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

Measured memory_bytes: 596
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		List<List<Integer>> list = new ArrayList<>(n);
		for (int i = 0; i < n; i++) {
			list.add(new ArrayList<>());
		}
		for (int i = 0; i < m; i++) {
			sa = br.readLine().split(" ");
			int a = Integer.parseInt(sa[0]) - 1;
			int b = Integer.parseInt(sa[1]) - 1;
			list.get(a).add(b);
		}
		br.close();

		int ans = n + 1;
		int idx = -1;
		for (int i = 0; i < n; i++) {
			Queue<Integer> que = new ArrayDeque<>();
			que.add(i);
			int[] d = new int[n];
			Arrays.fill(d, n + 1);
			d[i] = 0;
			label:
			while (!que.isEmpty()) {
				Integer cur = que.poll();
				List<Integer> list2 = list.get(cur);
				for (int next : list2) {
					int alt = d[cur] + 1;
					if (next == i) {
						if (alt < ans) {
							ans = alt;
							idx = i;
						}
						break label;
					}
					if (d[next] == n + 1) {
						que.add(next);
						d[next] = alt;
					}
				}
			}
		}
		if (ans == n + 1) {
			System.out.println(-1);
		} else {
			System.out.println(ans);
			Queue<List<Integer>> que = new ArrayDeque<>();
			List<Integer> listA = new ArrayList<>();
			listA.add(idx);
			que.add(listA);
			while (!que.isEmpty()) {
				List<Integer> cur = que.poll();
				List<Integer> list2 = list.get(cur.get(cur.size() - 1));
				for (int next : list2) {
					if (next == idx) {
						for (int i : cur) {
							System.out.println(i + 1);
						}
						return;
					}
					List<Integer> listN = new ArrayList<>(cur.size() + 1);
					listN.addAll(cur);
					listN.add(next);
					que.add(listN);
				}
			}
		}
	}
}


Measured memory_bytes: 44596
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	long long a, b, k;
	cin >> a >> b >> k;
	set<long long> hoge;
	REP(i, k) {
		hoge.insert(min(a + i, b));
		hoge.insert(max(a, b - i));
	}
	for (auto i = hoge.begin(); i != hoge.end(); ++i) {
		cout << *i << endl;
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = ll(1e9+7);
#define REP(i, n) for (int i = 0; i < n; i++)

ll n, x, s[205], dp[205][100005];  // i番目の数までみて値をjにする通り

int main() {
    cin >> n >> x;
    REP(i,n){
        cin >> s[i];
    }
    // 降順にみる。 a<b ならば x%a%b = x%a よりbを無視できるため
    sort(s,s+n);
    reverse(s,s+n);

    dp[0][x] = 1;
    REP(i,n){
        REP(j,x+1){
            // 使う遷移
            dp[i+1][j%s[i]] += dp[i][j];
            dp[i+1][j%s[i]] %= MOD;
            // 使わない遷移
            // これより後のどこかで使う
            dp[i+1][j] += dp[i][j] * (n-i-1);
            dp[i+1][j] %= MOD;
        }
    }
    ll ans = 0;
    REP(i,x+1){
        ans += dp[n][i] * i % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 157184
import java.util.*;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = Long.parseLong(sc.nextLine());
        Stream<Long> stream = Arrays.stream(sc.nextLine().split(" ")).map(Long::parseLong);
        sc.close();
        List<Long> lists = stream.collect(Collectors.toList());
        Long[] arrays = lists.toArray(new Long[lists.size()]);

        Arrays.sort(arrays);

        for (int i = 0; i < N; i++) {
            long tt = arrays[i];
            if (i != N - 1) {
                long nt = arrays[i + 1];
                if (tt == nt) {
                    System.out.println("NO");
                    break;
                }
            } else {
                System.out.println("YES");
            }
        }
    }
}

Measured memory_bytes: 67640
n=int(input())
l0=2
l1=1
l2=0
if n==0:
    print(2)
    exit()
if n==1:
    print(1)
    exit()
    
for i in range(2,n+1):
    l2=l1+l0
    l0=l1
    l1=l2
print(l2)    

Measured memory_bytes: 61836
N = int(input())
X = list(map(int, input().split()))
Y = X.copy()
Y.sort()
for i in range(len(Y)):
	if X[i] < Y[int(N / 2)]:
		print(Y[int(N / 2)] )
	else:
		print(Y[int(N / 2 - 1)])

Measured memory_bytes: 25556
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a[404];
ll dp[404][404];
ll pr[404];

ll f(int l , int r)
{
	if(l == r)return dp[l][r] = 0;
	if(r - l == 1)return a[l] + a[r];
	
	
	if( dp[l][r] != -1 )return dp[l][r];
	
	ll res = LONG_LONG_MAX;
	
	for(int i = l; i < r; i++){
		res = min( res , f(l,i) + f(i+1,r) );
	}
	
	return dp[l][r] = res + (pr[r] - pr[l-1]);
	
}

main()
{
	memset( dp , -1 , sizeof dp );
	
	
	int n;
	cin >> n;
	
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		pr[i] = a[i] + pr[i - 1];
	}
	
	
	
	cout << f(1 , n) << endl;
	
}


Measured memory_bytes: 1536
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools
import numpy as np




def main():
    num, lim_weight = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(num)]

    dp = np.full(10 ** 5 + 1, np.inf)

    for i in range(num):
        weight, value = data[i]
        prev = dp.copy()
        dp[:value] = np.minimum(prev[:value], weight)
        dp[value:] = np.minimum(prev[value:], prev[:-value] + weight)

        # print(dp[:100])
    ans = np.max(np.where(dp <= lim_weight)) + 1
    print(ans)

if __name__ == '__main__':
    main()



Measured memory_bytes: 15188
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<queue>
#include<list>
#include<stack>
#include<cstdio>
#include<fstream>
#include<numeric>
#include<functional>
#include<utility>
#include<memory>
#include <cstring>
#include<bits/stdc++.h>
using namespace std; 
  
#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;

int main() 
{
	int n,sum=0;
	cin>>n;
	if (n==10 ||n==100 || n==1000 || n==10000 || n==100000)
	{
		cout<<10<<endl;
		return 0;
	}
	while (n>0)
	{
		int x=n%10;
		sum+=x;
		n/=10;
	}
	cout<<sum<<endl; 
	return 0;
}

Measured memory_bytes: 256