akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;

	char buf[L], *S , *T, c;

	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}

	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}

	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}

	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}

	char B[45], *outs=B+40, *outr=B+40;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;

		if(!a)*--outs = '0';
		else
			while(a)
				*--outs = (a % 10) + 48, a /= 10;

		if(x)
			*--outs = x;

		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
using i128 = i64;
using u128 = u64;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}

template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}

template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

const int MOD = 1000000007;
const int INF = 1000000000;
const int MAXN = 100010;

int main()
{
	
	int N, L;
	cin >> N >> L;
	int sum = 0;
	for (int i = 1; i <= N; ++ i)
	{
		int a = L+i-1;
		sum += a;
	}
	int choose = 1;
	int idx = abs(L);
	for (int i = 1; i <= N; ++ i)
	{
		int a = L+i-1;
		if (abs(a) < idx)
		{
			idx = abs(a);
			choose = i;
		}
	}
	int a = L+choose-1;
	cout << sum-a << endl;
	
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<string>S(N);
  for(int i=0;i<N;i++)
    cin >> S.at(i);
  map<char,int>namae;
  namae['M']=0,namae['R']=1,namae['A']=2,namae['C']=3,namae['H']=4;
  vector<int64_t>kazu(5,0);
  for(int i=0;i<N;i++){
    if(S.at(i).at(0)=='M'||S.at(i).at(0)=='R'||S.at(i).at(0)=='A'||S.at(i).at(0)=='C'||S.at(i).at(0)=='H'){
      kazu.at(namae[S.at(i).at(0)])++;
    }
  }
  int64_t ans=0;
  ans+=(kazu.at(0)*kazu.at(1)*kazu.at(2));
  ans+=(kazu.at(0)*kazu.at(1)*kazu.at(3));
  ans+=(kazu.at(0)*kazu.at(1)*kazu.at(4));
  ans+=(kazu.at(0)*kazu.at(2)*kazu.at(3));
  ans+=(kazu.at(0)*kazu.at(2)*kazu.at(4));
  ans+=(kazu.at(0)*kazu.at(3)*kazu.at(4));
  ans+=(kazu.at(1)*kazu.at(2)*kazu.at(3));
  ans+=(kazu.at(1)*kazu.at(2)*kazu.at(4));
  ans+=(kazu.at(1)*kazu.at(3)*kazu.at(4));
  ans+=(kazu.at(2)*kazu.at(3)*kazu.at(4));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6344
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int N,D,X,A=0;
	cin>>N>>D>>X;
	for(int i=0;i<N;i++)
	{
		int a;
		cin>>a;
		A+=(D/a)+(D%a?1:0);
	}
	cout<<A+X<<endl;
}


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

using ll = long long;

using namespace std;

int main() {
    string s;
    int q;
    cin >> s >> q;
    string sides[2];
    int state = 0;
    for (int i=0; i<q; i++) {
        int t; cin >> t;
        if (t == 1) state ^= 1;
        else {
            int f; char c;
            cin >> f >> c;
            f--;
            sides[(state == f)] += c;
        }
    }
    int front = (state == 0), back = front ^ 1;
    reverse(sides[front].begin(), sides[front].end());
    if (state) reverse(s.begin(), s.end());
    cout << sides[front] + s + sides[back] << '\n';
    return 0;
}

Measured memory_bytes: 1348
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y>a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[1];
int l[1];
int j[1];

long long x,y,z,mod=1000000007;
string r;
//char r[111];

P u[1];
queue<int> q;

stack<int> s;
map<int,int> p;
vector<int> v;

bool as(P a,P b)
{
  if(a.x==b.x)
  return a.y<b.y;
  return a.x<b.x;
}

int f(int n,int m)
{
  if(n<m) return 1;
  return f(n/m,m)+1;
}

int main()
{
  scanf("%d %d",&a,&b);
  printf("%d",f(a,b));
}





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

template <typename T> struct Dijkstra {
  Dijkstra(size_t size) : size(size), G(size) {}

  struct edge {
    edge(int to, T cost) : to(to), cost(cost) {}
    int to;
    T cost;
  };

  using P = pair<T, int>;
  const T inf = numeric_limits<T>::max() / 2;

  size_t size;
  vector<vector<edge>> G;
  vector<T> d;

  void add_edge(int u, int v, T c) {
    G[u].push_back(edge(v, c));
  }

  void build(int s) {
    d.assign(size, inf);
    priority_queue<P, vector<P>, greater<P>> q;

    d[s] = 0;
    q.push(P(0ll, s));

    while (!q.empty()) {
      P p = q.top();
      q.pop();
      int v = p.second;
      if (d[v] < p.first) continue;
      for (auto &e : G[v])
        if (d[e.to] > p.first + e.cost) {
          d[e.to] = p.first + e.cost;
          q.push(P(d[e.to], e.to));
        }
    }
  }

  T operator[](int v) {
    return d[v];
  }
};

int main() {
  int V, E, r;
  cin >> V >> E >> r;

  Dijkstra<int> G(V);
  for (int i = 0; i < E; ++i) {
    int s, t, d;
    cin >> s >> t >> d;

    G.add_edge(s, t, d);
  }

  G.build(r);

  for (int i = 0; i < V; ++i) {
    if (G[i] == G.inf) {
      cout << "INF" << endl;
    } else {
      cout << G[i] << endl;
    }
  }
}



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

using namespace std;

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

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

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

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

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

ll gcd(ll a, ll b) {
	if (a < b) {
		ll tmp = a;
		a = b;
		b = tmp;
	}

	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

int main() {

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


	ll K;
	cin >> K;
	vvll all_gcd(K + 1);
	for (int i = 1; i <= K; i++)
	{
		all_gcd[i].emplace_back(0);
		for (int j = 1; j <= K; j++)
		{
			all_gcd[i].emplace_back(gcd(i,j));
		}
	}

	ll ans = 0;
	for (int i = 1; i <= K; i++)
	{
		for (int j = 1; j <= K; j++)
		{
			for (int k = 1; k <= K; k++)
			{
				ans += all_gcd[all_gcd[i][j]][k];
			}
		}
	}
	cout << ans;
}





Measured memory_bytes: 3784
#include <bits/stdc++.h>
typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;
int main(void)
{
    int n;
    cin >> n;
    vector<ll> d(n);
    rep(i, 0, n) cin >> d[i];
    int ans = 0;
    rep(i, 0, n) rep(j, i + 1, n) ans += d[i] * d[j];
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int main(){
    int n; cin >> n;
    set<int> st;
    REP(i,n){
        int tmp; cin >> tmp;
        st.insert(tmp);
    }
    cout << st.size() << endl;
}




Measured memory_bytes: 256
#include<stdio.h>
int segmin[1000006], segmax[1000006];
int m;
int min(int a, int b)
{
	if (a < b)
		return a;
	else
		return b;
}
int max(int a, int b)
{
	if (a > b)
		return a;
	else
		return b;
}
int getmin(int l, int r)
{
	int res = 1000000009;
	l += m - 1;
	r += m - 1;
	while (l < r)
	{
		if (l % 2 == 0)
		{
			res = min(res, segmin[l]);
			l++;
		}
		if (r % 2 > 0)
		{
			res = min(res, segmin[r]);
			r--;
		}
		l = (l - 1) / 2;
		r = (r - 1) / 2;
	}
	if (l == r)
		res = min(res, segmin[l]);
	return res;
}
int getmax(int l, int r)
{
	int res = -1;
	l += m - 1;
	r += m - 1;
	while (l < r)
	{
		if (l % 2 == 0)
		{
			res = max(res, segmax[l]);
			l++;
		}
		if (r % 2 > 0)
		{
			res = max(res, segmax[r]);
			r--;
		}
		l = (l - 1) / 2;
		r = (r - 1) / 2;
	}
	if (l == r)
		res = max(res, segmax[l]);
	return res;
}
int main()
{
	int n, k;
	scanf("%d %d", &n, &k);
	int i;
	int p[200005];
	for (i = 0; i < n; i++)
		scanf("%d", &p[i]);
	int s[200005];
	s[0] = 1;
	for (i = 1; i < n; i++)
	{
		if (p[i - 1] < p[i])
			s[i] = s[i - 1] + 1;
		else
			s[i] = 1;
	}
	m = 1;
	while (m < n)
		m *= 2;
	for (i = 0; i < 2 * m - 1; i++)
		segmin[i] = n;
	for (i = 0; i < n; i++)
		segmin[i + m - 1] = p[i];
	for (i = m - 2; i >= 0; i--)
		segmin[i] = min(segmin[2 * i + 1], segmin[2 * i + 2]);
	for (i = 0; i < 2 * m - 1; i++)
		segmax[i] = -1;
	for (i = 0; i < n; i++)
		segmax[i + m - 1] = p[i];
	for (i = m - 2; i >= 0; i--)
		segmax[i] = max(segmax[2 * i + 1], segmax[2 * i + 2]);
	int ans = 0;
	for (i = 0; i < n; i++)
		if (s[i] >= k)
			ans = 1;
	if (s[k - 1] < k)
		ans++;
	for (i = 0; i < n - k; i++)
		if (s[i + k] < k)
			if (p[i] != getmin(i, i + k) || p[i + k] != getmax(i, i + k))
				ans++;
	printf("%d\n", ans);
	return 0;
}

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

int main(){
    int N;  cin >> N;
    int j = 0;
    int ans = 0;
    std::vector<int> v(N);
    for(int i=0; i<N; i++){
        cin >> v[i];
    }
    for(int i=0; i<=N; i++){
        j = v[j] - 1;
        ans++;
        if(j == 1){
            cout << ans;
            return 0;
        }
    }
    cout << -1;
}

Measured memory_bytes: 640
#include<cstdio>

int main(){
    int count[799];
    // for(int i = 0; i < 1201; i++){
    //     count[i] = 0;
 	// }
    char ch;
    while(scanf("%c",&ch) != EOF){
        if(ch >= 'a' && ch <= 'z'){
            count[ch - 'a']++;
        }
        else if(ch >= 'A' && ch <= 'Z'){
            count[ch - 'A']++;
        }
    }
    for(int j = 0;j < 26; j++){
        printf("%c : %d\n",j + 'a',count[j]);
    }
    return 0;
}


Measured memory_bytes: 2700
n = int(input())
c = 0
f = False
for i in range(n):
    x,y = map(int,input().split())
    if x==y:
        c += 1
    else:
        if c>=3:
            f = True
        c = 0
if c>=3:
    f = True
print('Yes' if f else 'No')

Measured memory_bytes: 9184
// https://onlinejudge.u-aizu.ac.jp/courses/lesson/8/ITP2/3/ITP2_3_B
#include <iostream>
#include <algorithm>
#include <vector>

int main()
{
    int n;
    std::cin >> n;
    std::vector<int> A(n);
    for (auto &x : A)
    {
        std::cin >> x;
    }
    int q;
    std::cin >> q;

    for (int i = 0; i < q; i++)
    {
        int com, b, e;
        std::cin >> com >> b >> e;
        if (com == 0)
        {
            std::cout << *std::min_element(A.begin() + b, A.begin() + e) << std::endl;
        }
        if (com == 1)
        {
            std::cout << *std::max_element(A.begin() + b, A.begin() + e) << std::endl;
        }
    }
    return 0;
}




Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

signed main(){
	int X;
	cin >> X;
	LOOP1(i,X){
		if(100*i <= X && X <= 105*i){
			cout << 1 << endl;
			return 0;
		}
	}cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<stdarg.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#define max(x,y) (x)>(y)?(x):(y)
#define min(x,y) (x)<(y)?(x):(y)
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define reps(i,n,k) for((i)=0;(i)<(n);(i)+=(k))
#define MOD ((int)1e9+7)
#define INF INFINITY
typedef long long ll;
typedef unsigned long long ull;
typedef struct pair_{int x,y;}pair_t;
void swap(int *x, int *y){int t=*x;*x=*y;*y=t;}
void debug(char *f, ...){va_list a;va_start(a,f);vfprintf(stderr,f,a);va_end(a);}
int asc_cmp(const void *x, const void *y){int X=*((int*)x),Y=*((int*)y);if(X<Y)return -1;else if(X>Y)return 1;else return 0;}
int desc_cmp(const void *x, const void *y){int X=*((int*)x),Y=*((int*)y);if(X<Y)return 1;else if(X>Y)return -1;else return 0;}

int main(){
    double r;scanf("%lf",&r);
    printf("%lf\n",2*r*3.1415);
}

Measured memory_bytes: 1752
#include<stdio.h>
int main(void){
  char x;
  scanf("%c",&x);
  	if(x=='A')
    printf("T");
    if(x=='C')
    printf("G");
    if(x=='G')
    printf("C");
    if(x=='T')
    printf("A");
      
	return 0;
}


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

const int INF = 1e9;

signed main() {
  int n,m;
  cin >> n >> m;

  vector<vector<pair<int,int>>> G(n);
  vector<int> l(m), r(m), d(m);
  for (int i = 0; i < m; i++) {
    cin >> l[i] >> r[i] >> d[i];
    l[i]--, r[i]--;
    G[l[i]].emplace_back(r[i],d[i]);
    G[r[i]].emplace_back(l[i], -d[i]);
  }

  vector<int> dist(n, INF);

  for (int i = 0; i < n; i++) {
    if(dist[i] != INF) continue;
    if(G[i].empty()) continue;

    dist[i] = 0;
    queue<int> que;
    que.push(i);

    while(!que.empty()) {
      int cur = que.front();
      que.pop();
      for (auto nxt : G[cur]) {
        if(dist[nxt.first] == INF) {
          dist[nxt.first] = dist[cur] + nxt.second;
          que.push(nxt.first);
        }
      }
    }
  }

  bool flag = true;
  for (int i = 0; i < m; i++) {
    if(dist[l[i]] + d[i] != dist[r[i]]) {
      flag = false;
      break;
    }
  }
  if(flag) cout << "Yes" << '\n';
  else cout << "No" << '\n';

  return 0;
}

Measured memory_bytes: 18688
#include <stdio.h>

int main()
{
  int N;
  int i;
  scanf("%d", &N);

  long a = 1;
  for(i = 1; i < N+1; i++) {
    a *= i;
    a %= 1000000007;
  }

  printf("%ld\n", a);
  
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int N = 3e3 + 3;
int dp[N][N];
int main(){
	string s, t, ans = "";
	cin >> s >> t;
	int n = s.size(), m = t.size();
	for(int i = n-1; i >= 0; --i)
		for(int j = m-1; j >= 0; --j)
			if(s[i] == t[j])
				dp[i][j] = 1 + dp[i+1][j+1];
			else
				dp[i][j] = max(dp[i][j+1], dp[i+1][j]);
	int i = 0, j = 0;
	while(i < n || j < m)
		if(s[i] == t[j]){
			ans.push_back(s[i]);
			++i; ++j;
		}
		else if(dp[i][j+1] >= dp[i+1][j] && j < m)
			++j;
		else
			++i;
	cout << ans;
	return 0;
}


Measured memory_bytes: 35456
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

int main() {
    vector<bool> isPrime(100010, true);
    isPrime[0] = isPrime[1] = false;
    REP (i, 2, sqrt(isPrime.size()) + 1) {
        if (isPrime[i]) {
            for (int j = i + i; j < (int)isPrime.size(); j += i) {
                isPrime[j] = false;
            }
        }
    }
    vector<int> nlist(100010, 0);
    for (int i = 1; i < 100010; i += 2) {
        if (isPrime[i] && isPrime[(i + 1) / 2]) nlist[i]++;
    }
    REP (i, 1, nlist.size()) {
        nlist[i] += nlist[i - 1];
    }
    int Q;
    cin >> Q;
    REP (i, 0, Q) {
        int l, r;
        cin >> l >> r;
        cout << nlist[r] - nlist[l - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
	double a,b;
	int d,r;
	double f;
	
	scanf("%lf",&a);
	scanf(" %lf",&b);
	d = a/b;
	r = (int)a%(int)b;
	f = a/b;
	
	printf("%d %d %f\n",d,r,f);
	
	return 0;
}

Measured memory_bytes: 648
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 
 
const int N = 1e6 + 100, OO = 1e16 + 1000, T = 150, M = 1e9 + 7, P = 6151, SQ = 1000, lg = 44;
typedef pair <int, int> pii;
int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int32_t main() {
	use_fast;	
	int n;
	cin >> n;
	cout << a[n - 1] << endl;
	return 0;
} 
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/

Measured memory_bytes: 256
#include <stdio.h>
int main (){
  int A,B,K;
  scanf("%d",&K);
  scanf("%d",&A);
  scanf("%d",&B);
  for(;A<=B;A++){
    if(A%K==0){
      printf("OK");
      return 0;
      }
    }
  printf("NG");
  return 0;
  }

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
signed main(){
	long long a,b,k;
  	cin>>a>>b>>k;
  	a-=k;
  	if(a<0){
      b+=a;
      a=0;
    }
  	if(b<0)
      b=0;
  	cout<<a<<' '<<b<<endl;
    return(0); 
}

Measured memory_bytes: 256
void main()
{
    long n = readln.chomp.to!long;
    long[] a = readln.split.to!(long[]);

    long mod = 10 ^^ 9 + 7;
    auto g = a.sort!"a < b".group.array;
    bool ok = true;
    foreach (i, x; g)
    {
        if (n & 1)
        {
            if (i == 0)
            {
                if (x[0] != 0 || x[1] != 1)
                {
                    ok = false;
                }
            }
            else
            {
                if (x[0] != 2 * i || x[1] != 2)
                {
                    ok = false;
                }
            }
        }
        else
        {
            if (x[0] != 2 * i + 1 || x[1] != 2)
            {
                ok = false;
            }
        }
    }

    long result;
    if (ok)
    {
        result = 1;
        foreach (i; 0 .. n/2)
        {
            result = result * 2 % mod;
        }
    }

    result.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 4412
N = int(input())
A = list(map(int, input().split()))

X = [-1, -1, -1]
ans = 1
for a in A:
    t = X.count(a-1)
    ans = ans * t % 1000000007
    if a-1 not in X:
        print(0)
        exit()
    idx = X.index(a-1)
    X[idx] += 1
print(ans)


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector< map<char, int> > mp(n);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      if (s[j] != s[i]) {
        for (auto& c : {'R', 'G', 'B'}) {
          if (c != s[i] && c != s[j]) {
            ans += (long long) mp[j][c];
            if (j - (i - j) >= 0 && s[j - (i - j)] != s[i] && s[j - (i - j)] != s[j]) {
              ans--;
            }
            break;
          }
        }
      }
    }
    if (i < n - 1) {
      for (auto& c : {'R', 'G', 'B'}) {
        mp[i + 1][c] = mp[i][c];
      }
      mp[i + 1][s[i]]++;
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 4088
import math
from collections import Counter

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

def cmb(r,k):
  if r < k: return 0
  return math.factorial(r) // math.factorial(r-k) // math.factorial(k)

c = Counter()
for a in A:
  c[a] += 1
al = 0
for v in c.values():
  al += cmb(v,2)

for k in range(N):
  print(al - (c[A[k]]-1))


Measured memory_bytes: 114380
import sys
N = int(input())

A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]

if sum(A)<sum(B):
    print(-1)
    sys.exit()

gap = [A[i]-B[i]  for i in range(N)]

minus = []
plus = []
for i in range(0,N):
    if gap[i]<0:
        minus.append(gap[i])

    else:
        plus.append(gap[i])

if minus == []:
    print(0)
    sys.exit()

summinus= sum(minus)

plus.sort(reverse=True)

j = 0
while True:
    summinus += plus[j]
    if summinus >= 0:
        print(N-len(plus)+j+1)
        break

    else:
        j += 1


Measured memory_bytes: 18356
#include "bits/stdc++.h"

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

unsigned long long str_to_int(std::string str) {
	unsigned long long ret;
	std::stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

void solve(){
	int n;
	cin >> n;
	int count = 0;
	rep(i,n){
		int a;
		cin >> a;
		if(a % 2 == 0)count++;
	}
	P(pow(3,n) - pow(2,count));
}

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

Measured memory_bytes: 384
//#define NDEBUG
#define _CRT_SECURE_NO_WARNINGS
#include <cstddef>
#include <cstdint>

template <class T> const T &as_const(const T &v) noexcept { return v; }
class rep {
	const ::std::size_t f, l;

public:
	using value_type = ::std::size_t;
	using reference = value_type;
	class repitr {
		friend rep;
		value_type i;
		repitr(value_type x) noexcept : i(x) {}

	public:
		void operator++() noexcept { ++i; }
		reference operator*() const noexcept { return i; }
		bool operator!=(const repitr x) const noexcept { return i != x.i; }
	};
	explicit rep(value_type first, value_type last) noexcept
		: f(first), l(last) {}
	repitr begin() const noexcept { return repitr(f); }
	repitr end() const noexcept { return repitr(l); }
};
template <class T> bool maxi(T &a, const T &b) {
	return a <= b ? (a = b, 1) : 0;
}
template <class T> bool mini(T &a, const T &b) {
	return b <= a ? (a = b, 1) : 0;
}
template <class T> bool smaxi(T &a, const T &b) {
	return b <= a ? 0 : (a = b, 1);
}
template <class T> bool smini(T &a, const T &b) {
	return a <= b ? 0 : (a = b, 1);
}

using i32 = ::std::int_least32_t;
using i64 = ::std::int_least64_t;
using u32 = ::std::uint_least32_t;
using u64 = ::std::uint_least64_t;

#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
#include <string>
#include <tuple>

template <class T> using vec_alias = ::std::vector<T>;


int main() {
	u32 h, w;
	::std::cin >> h >> w;
	vec_alias<vec_alias<bool>> a(h, vec_alias<bool>(w));
	u32 temp;
	for (const auto i : rep(0, h))
		for (const auto j : rep(0, w))
			::std::cin >> temp, a[i][j] = temp & 1;
	vec_alias<::std::tuple<u32, u32, u32, u32>> ans;
	for (const auto i : rep(0, h)) {
		if (i & 1) {
			for (u32 j = w - 1;j;--j) {
				if (a[i][j]) {
					ans.emplace_back(i, j, i, j - 1);
					a[i][j - 1].flip();
				}
			}
			if (a[i].front() && i != h - 1) {
				ans.emplace_back(i, 0, i + 1, 0);
				a[i + 1].front().flip();
			}
		}
		else {
			for (const auto j : rep(0, w - 1)) {
				if (a[i][j]) {
					ans.emplace_back(i, j, i, j + 1);
					a[i][j + 1].flip();
				}
			}
			if (a[i].back() && i != h - 1) {
				ans.emplace_back(i, w - 1, i + 1, w - 1);
				a[i + 1].back().flip();
			}
		}
	}
	::std::cout << ans.size() << ::std::endl;
	u32 x0, y0, x1, y1;
	for (const auto &e : ans) {
		::std::tie(x0, y0, x1, y1) = e;
		::std::cout << x0 + 1 << " " << y0 + 1 << " "
			<< x1 + 1 << " " << y1 + 1 << ::std::endl;
	}
	return 0;
}


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

using namespace std;

int main() {
		
	int n,ww;
	cin >> n >> ww ;

	vector<int> w(n + 1);
	vector<int> v(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> w[i] >> v[i];
	}

	vector<vector<long long>> dp(n + 1, vector<long long>(ww+1, 0));
	dp[0][0] = 0;
	for (long i = 1; i <= n; i++) {

		for (long j = 0; j <= ww; j++) {

			if (j - w[i] >= 0) {
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
			}
			else {
				dp[i][j] = dp[i - 1][j];
			}
		}
	}

	cout << dp[n][ww] << endl;
	return 0;

}

Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+1;
#define fr(i,low,up,st) for(register int i = low;i <= up;i += st)
#define nfr(i,low,up,st) for(register int i = low;i >= up;i -= st)
#define clr(a) memset(a,0,sizeof a)
#define SZ(a) (a.size())

int m,d;
int main(){
   scanf("%d%d",&m,&d);
   int ans = 0;
   fr(i,1,m,1){
      fr(j,1,d,1){
         if(j%10 >= 2 && j/10 >= 2 && (j/10)*(j%10) == i)++ans;
      }
   }
   printf("%d\n",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn=200005;
ll sum[maxn],a[maxn];
ll n,b,c,d,e;
ll ans=1e15+7;
bool check(ll x,ll y,int i)
{
    if(abs((x+a[i])-(y-a[i]))<abs(x-y))
    return 1;
    return 0;
}
int main()
{
    cin>>n;
    ll s=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        s+=a[i];
        sum[i]=s;
    }
    int j=0,k=2;
    for(int i=1;i<n-2;i++)
    {
        b=sum[j];
        c=sum[i]-sum[j];
        d=sum[k]-sum[i];
        e=sum[n-1]-sum[k];
        while(check(b,c,j+1) && j+1<i)
        {
            j++;
            b=sum[j];
            c=sum[i]-sum[j];
        }
        while(check(d,e,k+1) && k+1<n-1)
        {
            k++;
            d=sum[k]-sum[i];
            e=sum[n-1]-sum[k];
        }
        ll test[10];
        test[0]=b;test[1]=c;
        test[2]=d;test[3]=e;
        sort(test,test+4);
        ans=min(ans,test[3]-test[0]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = int64_t;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = LLONG_MAX / 3;
const double eps = (1e-9);

ll calcNumOfCombination(ll n, ll r){
  ll num = 1;
  for(ll i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

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

  ll n; cin >> n;
  map<string, ll> x;
  rep(i, n) {
    string s; cin >> s;
    vector<char> ss(s.size());
    rep(j, s.size()) ss[j] = s[j];
    sort(ALL(ss));
    rep(j, s.size()) s[j] = ss[j];
    x[s]++;
  }

  ll ans = 0;
  for (auto& p : x) {
    if (p.second < 2) continue;
    ans += calcNumOfCombination(p.second, 2);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 11264
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//幅優先探索のテンプレ.デフォルトではstartからの距離を返す.
//graphは隣接リスト.startは探索開始地点
vector<int> bfs(vector<vector<int>> &graph, int start){
	queue<int> todo;
	vector<int> dist(graph.size(),-1);
	dist[start] = 0;
	todo.push(start);
	while(!todo.empty()){
		int now = todo.front();
		todo.pop();
		for (int i=0;i<graph[now].size();i++){
			int nxt = graph[now][i];
			if (dist[nxt] != -1) continue;
			dist[nxt] = dist[now] + 1;
			todo.push(nxt);
		}
	}
	return dist;
}

int main(){
	int a, b;
	cin >> a >> b;
	int ans = 0;
	int k = 1;
	while (k < b)
	{
		k--;
		k += a;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define pb push_back
#define fs first
#define sc second
#define sz size
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i <= (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using ll = long long;
const ll inf = 1e9+5; 

const double PI =  3.141592653589793;

int main(){
	IO;
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	((a+d-1)/d<(c+b-1)/b)?cout<<"No\n":cout<<"Yes\n";
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""


Measured memory_bytes: 3656
/*AOJ入力
9
0 1 4
1 2 3
2 -1 -1
3 -1 -1
4 5 8
5 6 7
6 -1 -1
7 -1 -1
8 -1 -1

*/

#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node {int p,l,r;};
struct Node T[MAX];
int n;

/*先行順巡回*/
void preParse(int u){
  if(u==NIL)return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

/*中間順巡回*/
void inParse(int u){
  if(u==NIL)return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

/*後行順巡回*/
void postParse(int u){
  if(u==NIL)return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

int main(){
  int i,v,l,r,root;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=NIL;
  }
  
  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;
    if(l!=NIL)T[l].p=v;
    if(r!=NIL)T[r].p=v;
  }
  
  for(i=0;i<n;i++)if(T[i].p==NIL)root=i;
  
  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 2076
#include <iostream>
#include <vector>
#define llint long long
#define mod 1000000007

using namespace std;

llint n;
llint x[100005];

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> x[i];
	
	llint ans = 1, cnt = 0, jump = 1;
	while(cnt < n){
		while(jump < n-1 && x[jump+1] >= 2*(jump+1-cnt)-1) jump++;
		ans *= jump+1 - cnt, ans %= mod;
		cnt++;
	}
	cout << ans << endl;
	
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define forn(low,high,i) for(i = low;i < high;i++)
#define forrev(high,low,i) for(i = high; i >= low;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define prvp(a) for(auto x : a) cout << "{" << x.ff << ',' << x.ss << "}";cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const int inf = 1e9;
const ll INF = 1e18;
const int mod = 1e9 + 7;
const int bit32 = log2(inf) + 3;
const int bit64 = log2(INF) + 3;

inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}
inline int mul(int a, int b){return (int)((long long) a * b % mod);}
inline int modexpo(int a, int b){int res = 1; while(b > 0){ if(b & 1) res = mul(res, a); a = mul(a, a); b /= 2;} return res;}
inline int divide(int a, int b){ return mul(a, modexpo(b, mod - 2));}

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

void pre(){ // Reset each global variable (esp. for graphs)
  
}

void solve(){
  int n, m;
  cin >> n >> m;
  int cnt[n][2];
  memset(cnt, 0, sizeof cnt);
  for(int i = 0; i < m; i++){
    int p; string s; cin >> p >> s;
    p--;
    if(s == "AC"){
      cnt[p][1] = 1;
    }else{
      if(cnt[p][1] == 0){
        cnt[p][0]++;
      }
    }
  }
  int ac, wa;
  ac = wa = 0;
  for(int i = 0; i < n; i++){
    ac += cnt[i][1];
    if(cnt[i][1])
      wa += cnt[i][0];
  }
  cout << ac << ' ' << wa << '\n';
}

int main(){
  fastio

  pre();

  int t = 1;
  // cin >> t;
  while(t--){
    solve();
  }

  ktj();
}


Measured memory_bytes: 1024
# include <iostream>
using namespace std; 
int main(){
  string str, strr; 
  cin>>str; 
  cin>>strr; 
  int n,count,i; 
  n=str.length();
  count=0;
  for(i=0;i<n;i++){
    if(str[i]!=strr[i]){
      count++;
    }
  }
  cout<<count; 
  return 0;
}

Measured memory_bytes: 3912
import sys
input = sys.stdin.readline
from math import sqrt


def Eratosthenes(n):
    """n(>=6)未満の素数列挙 """
    n, correction = n - n % 6 + 6, 2 - (n % 6 > 1)
    sieve = [True] * (n // 3)
    for i in range(1, int(sqrt(n)) // 3 + 1):
        if sieve[i]:
            k = 3 * i + 1 | 1
            sieve[k * k // 3::2 * k] = [False] * ((n // 6 - k * k // 6 - 1) // k + 1)
            sieve[k * (k - 2 * (i & 1) + 4) // 3::2 * k] = [False] * ((n // 6 - k * (k - 2 * (i & 1) + 4) // 6 - 1) // k + 1)
    # return [2, 3] + [3 * i + 1 | 1 for i in range(1, n // 3 - correction) if sieve[i]]
    # x が素数か判定したいとき
    return {2, 3}.union({3 * i + 1 | 1 for i in range(1, n // 3 - correction) if sieve[i]})


sieve = Eratosthenes(10 ** 5 + 1)
ans = [0] * (10 ** 5 + 1)
for i in range(3, 10 ** 5, 2):
    if i in sieve and (i + 1) // 2 in sieve:
        ans[i] += 1
for i in range(3, 10 ** 5):
    ans[i + 1] += ans[i]
q = int(input())
for i in range(q):
    l, r = map(int, input().split())
    print(ans[r] - ans[l - 1])


Measured memory_bytes: 77260
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    long a[n];
    int ans = 0;
    vector<int>num(n+1,0);
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(a[i]<=n)num[a[i]]++;
        else ans++;
    }

    for(int i=1;i<=n;i++){
        if(num[i]>=i)ans += num[i]-i;
        else ans += num[i];
    }
    cout << ans << endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int n, ans=0, tmp;

	cin>> n;

	rep(i, n){
		cin >> tmp;
		if(i%2==0 && tmp%2==1) ans++;
	}

	cout<< ans << endl;
 
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep_r(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define INF 2e9
 
using namespace std;
 
typedef long long ll;

int main(){
	int n,l;
	cin >> n >> l;
	vector<string> v;
	rep(i ,n){
		string a;
		cin >> a;
		v.pb(a);
	}
	sort(all(v));
	rep(i ,n){
		cout << v[i];
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
a,b,c,d,e=[int(input()) for i in range(5)]
a1=a//10
a2=a%10
if a2==0:
    a1-=1
    a2=10
b1=b//10
b2=b%10
if b2==0:
    b1-=1
    b2=10
c1=c//10
c2=c%10
if c2==0:
    c1-=1
    c2=10
d1=d//10
d2=d%10
if d2==0:
    d1-=1
    d2=10
n=e//10
m=e%10
if m==0:
    n-=1
    m=10
min1=min(a2,b2,c2,d2,m)
ans=(a1+b1+c1+d1+n+4)*10+min1
print(ans)


Measured memory_bytes: 3064
import Data.List

main = do
  _ <- getLine
  xs <- map read . words <$> getLine
  let v (x, y) =
        if x < y then x * (y-x) else y * (x-y)
      f x y =
        compare (v x) (v y)
  putStrLn $ (\(x, y) -> show (max x y) ++ " " ++ show (min x y)) $ maximumBy f $ candidate xs

candidate xs =
  map ((,) $ maximum xs) xs

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

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


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

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

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

#endif

// main.cpp

class point {
public:
  i64 x, y;
  point(const i64 x, const i64 y) :
    x(x), y(y) {
  }
};

namespace std {
  std::istream& operator>>(std::istream& is, point& self) {
    return is >> self.x >> self.y;
  }
}

int main() {
  i64 H, W;
  std::cin >> H >> W;
  std::vector<std::string> A;
  tools::read(A, H);

  constexpr i64 INF = std::numeric_limits<i64>::max();
  std::vector<std::vector<i64>> dp(H, std::vector<i64>(W, INF));
  std::queue<point> queue;
  for (i64 y = 0; y < H; ++y) {
    for (i64 x = 0; x < W; ++x) {
      if (A[y][x] == '#') {
        dp[y][x] = 0;
        queue.emplace(x, y);
      }
    }
  }

  while (!queue.empty()) {
    std::vector<point> next;

    while (!queue.empty()) {
      const point point = queue.front();
      queue.pop();
      if (point.y > 0 && dp[point.y][point.x] + 1 < dp[point.y - 1][point.x]) {
        dp[point.y - 1][point.x] = dp[point.y][point.x] + 1;
        next.emplace_back(point.x, point.y - 1);
      }
      if (point.y < H - 1 && dp[point.y][point.x] + 1 < dp[point.y + 1][point.x]) {
        dp[point.y + 1][point.x] = dp[point.y][point.x] + 1;
        next.emplace_back(point.x, point.y + 1);
      }
      if (point.x > 0 && dp[point.y][point.x] + 1 < dp[point.y][point.x - 1]) {
        dp[point.y][point.x - 1] = dp[point.y][point.x] + 1;
        next.emplace_back(point.x - 1, point.y);
      }
      if (point.x < W - 1 && dp[point.y][point.x] + 1 < dp[point.y][point.x + 1]) {
        dp[point.y][point.x + 1] = dp[point.y][point.x] + 1;
        next.emplace_back(point.x + 1, point.y);
      }
    }

    for (const point& next_i : next) {
      queue.push(next_i);
    }
  }

  i64 answer = 0;
  for (i64 y = 0; y < H; ++y) {
    for (i64 x = 0; x < W; ++x) {
      answer = std::max(answer, dp[y][x]);
    }
  }
  std::cout << answer << std::endl;
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> tasks(n);
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        tasks[i] = make_pair(b, a);
    }
    sort(tasks.begin(), tasks.end());
    int sum_time = 0;
    string ans = "Yes";
    for (auto p: tasks) {
        sum_time += p.second;
        if (sum_time > p.first) {
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4848
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	A, B = getlist()
	if B * 2 >= A:
		print(0)
	else:
		print(A - 2 * B)
	


if __name__ == '__main__':
	main()

Measured memory_bytes: 3444
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		for(;;){

			int x = scan.nextInt();
			char ch = scan.next().charAt(0);
			if(ch == '?')
				break;
			int y = scan.nextInt();
			switch(ch){
			case '+':
				System.out.println(x + y);
				break;
			case '-':
				System.out.println(x - y);
				break;
			case '*':
				System.out.println(x * y);
				break;
			case '/':
				System.out.println(x / y);
				break;
			}
		}
	}
}

Measured memory_bytes: 18032
#include<stdio.h>

int main(){
  int N, A, B;
  
  scanf("%d %d %d", &N, &A, &B);
  
  if(N*A < B){
    printf("%d\n", N*A);
  } else {
    printf("%d\n", B);
  }
  
  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);
        int num = sc.nextInt();
        
        for(int i = 1; i <= num; i++){
            if(i % 3 == 0 || new Integer(i).toString().indexOf("3") != -1){
                System.out.print(" " + i);
            }
        }
        System.out.println();
    }
}


Measured memory_bytes: 29344
#include<bits/stdc++.h>
using namespace std;
int n,a[2333333],vis[2333333],ans;
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i],vis[a[i]]++;
	for(int i=1;i<=n;i++){
		int flg=1;
		for(int j=1;j*j<=a[i];j++)
			if(a[i]%j==0){
				if(j!=a[i]&&vis[j]||j==a[i]&&vis[j]>1||a[i]/j!=a[i]&&vis[a[i]/j]||a[i]/j==a[i]&&vis[a[i]/j]>1){flg=0;break;}
			}
		if(flg)ans++;
	}
	cout<<ans<<endl;
}

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

struct s {
    long a, b;
    bool operator<(const s &x) const {
        return (__int128_t)a * x.b > (__int128_t)b * x.a;
    }
};
long e[222222] = {1};
int main() {
    int n, z = 0, p = 1e9 + 7;
    cin >> n;
    map<s, pair<int, int>> m;
    for(int i = 0; i < n; i++) {
        e[i + 1] = e[i] * 2 % p;
        long a, b;
        cin >> a >> b;
        if(!a && !b) {
            z++;
            continue;
        }
        if(b < 0 || a < 0 && !b)
            a = -a, b = -b;
        int h = 0;
        if(a <= 0)
            a = -a, swap(a, b), h++;
        auto &[t, u] = m[{a, b}];
        (h ? u : t)++;
    }
    long r = 1;
    for(auto [k, c] : m) {
        auto [a, b] = c;
        (r *= e[a] + e[b] + p - 1) %= p;
    }
    cout << (r + p + z - 1) % p << endl;
    return 0;
}


Measured memory_bytes: 17652
N, K = map(int, input().split())
mod = 10**9+7
A = list(map(int,input().split()))
cnt1 = 0
cnt2 = 0
for i in range(N):
    for k in range(N):
        if A[i] > A[k]:
            if i+1 <= k < N:
                cnt1 += 1
                cnt2 += 1
            else:
                cnt2 += 1
            cnt1 %= mod
            cnt2 %= mod
#print(cnt1, cnt2)
ans = (cnt1 * K + cnt2 * (K-1)*K // 2) % mod
print(ans)        

Measured memory_bytes: 43356