akhauriyash/Code-Regression huggingface dataset:
#pragma region Macros

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

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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;
}
template <class T>
ostream &operator<<(ostream &out, vector<T> const &v) {
    for (auto &&a : v) out << a << " ";
    out << endl;
    return out;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int D;
    cin >> D;

    vi c(26);
    REP(i, 26) {
        cin >> c[i];
    }
    vector<vector<pair<int, int>>> s(D, vector<pair<int, int>>());
    int buff;
    REP(i, D) {
        REP(j, 26) {
            cin >> buff;
            s[i].push_back({buff, j + 1});
        }
    }
    random_device rd;
    int count = 0;
    REP(i, D) {
        set<int> set26;
        REP(j, 26) {
            set26.insert(j + 1);
        }
        while (!set26.empty()) {
            vector<pair<int, int>> sss = s[count];
            sort(ALL(sss), greater<pair<int, int>>());
            int a = 1;
            REP(k, 26) {
                if (set26.count(sss[k].second)) {
                    if (rd() % 10 == 0) {
                        continue;
                    }
                    a = sss[k].second;
                    debug(sss[k].second);
                    break;
                }
            }

            cout << a << "\n";
            set26.erase(a);
            debug(a);
            count++;
            if (count >= D) {
                return;
            }
        }
    }
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 3848
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;

ll f(int n, ll x, vector<ll> &a, vector<ll> &p) {
    if (n == 0) {
        return 1;
    }
    if (x == 1) {
        return 0;
    }
    else if (x <= a.at(n-1)+1) {
        return f(n-1, x-1, a, p);
    }
    else if (x == a.at(n-1)+2) {
        return p.at(n-1)+1;
    }
    else if (x <= 2*a.at(n-1)+2) {
        return p.at(n-1) + 1 + f(n-1, x-2-a.at(n-1), a, p);
    }
    else {
        return 2*p.at(n-1)+1;
    }
}
 
int main() {
    int n = 0;
    ll x = 0;
    cin >> n >> x;
    vector<ll> a(n+1), p(n+1);
    a.at(0) = p.at(0) = 1;
    for (int i=1; i<n+1; i++) {
        a.at(i) = 2*a.at(i-1) + 3;
        p.at(i) = 2*p.at(i-1) + 1;
    }
    cout << f(n, x, a, p) << endl;
    return 0;
}
 

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int Island[52][52];
void solve(int y,int x) {
	Island[y][x] = 0;
	for (int i = -1; i <= 1; ++i) {
		for (int j = -1; j <= 1; ++j) {
			if (Island[y + i][x + j]) solve(y + i, x + j);
		}
	}
}
int main() {
	int w,h;
	while (cin >> w >> h&&w&&h) {
		int cnt = 0;
		for (int i = 0; i < h + 2; ++i) {
			for (int j = 0; j < w + 2; ++j) {
				if (i == 0 || j == 0 || i == h + 1 || j == w + 1) Island[i][j] = 0;
				else cin >> Island[i][j];
			}
		}
		for (int i = 1; i < h + 1; ++i) {
			for (int j = 1; j < w + 1; ++j) {
				if (Island[i][j]) {
					solve(i, j);
					++cnt;
				}
			}
		}
		cout << cnt << endl;
	}
	return 0;
}


Measured memory_bytes: 3148
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]

R = {}
for i in s:
  if i in R:
    R[i] += 1
  else:
    R[i] = 1

for i in t:
  if i in R:
    R[i] -= 1

ans = max(R.values())
print(max(0, ans))

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>

using namespace std;

int main() {
	int i;
	double px[2],py[2],pz[2],x[2],y[2],len,s,pi=3.141592;
	while(cin >> y[0]) {
		if (y[0]==-1) break;
		cin >> x[0] >> y[1] >> x[1];
		for (i=0;i<2;i++) {
			px[i]=cos(pi*y[i]/180); pz[i]=sin(pi*y[i]/180);
			py[i]=sin(pi*x[i]/180)*px[i]; px[i]=cos(pi*x[i]/180)*px[i];
		}
		len=sqrt((px[0]-px[1])*(px[0]-px[1])+(py[0]-py[1])*(py[0]-py[1])+(pz[0]-pz[1])*(pz[0]-pz[1]));
		s=acos(1-len*len/2);
		cout << (int)(6378.1*s+0.5) << endl;
	} 
	return 0;
}

Measured memory_bytes: 1272
n = int(input())
a = list(map(int, input().split()))

le, lo, re, ro = [0], [0], [0], [0]

for i in range(n):
    if i % 2 == 0:
        le.append(le[-1] + a[i])
    else:
        lo.append(lo[-1] + a[i])

for i in range(n-1, -1, -1):
    if i % 2 == 0:
        re.append(re[-1] + a[i])
    else:
        ro.append(ro[-1] + a[i])

le_o = [0]
for i in range(len(lo)-1):
    le_o.append(max(0, le_o[-1] + a[2*i+1] - a[2*i]))


if n % 2 == 0:
    n //= 2
    ans = lo[n]
    for i in range(0, n + 1):
        ans = max(ans, le[i] + ro[n-i])

    print(ans)

else:
    n //= 2
    ans = le[n]
    for i in range(0, n+1):
        ans = max(ans, le[i] + ro[n-i])
        ans = max(ans, lo[i] + re[n-i])
        ans = max(ans, le[i] + re[n-i] + le_o[i])

    print(ans)


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    int tmp = n*a;
    cout<<min(tmp,b)<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ls ch[x][0]
#define rs ch[x][1]
#define ll long long
using namespace std;

inline ll read(){
	ll num=0,neg=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')neg=-1;c=getchar();}
	while(isdigit(c)){num=(num<<3)+(num<<1)+c-'0';c=getchar();}
	return num*neg;
}

int main(){
	string str="ACL";
	int n=read();
	for(int i=1;i<=n;i++)  cout<<str;
	return 0;
}


Measured memory_bytes: 3536
#include <iostream>
#include <vector>

int main() {
    int N;
    std::cin >> N;
    std::vector<double> x(N);
    std::vector<std::string> u(N);
    for (int i = 0; i < N; ++i) std::cin >> x[i] >> u[i];
    
    double ans = 0;
    for (int i = 0; i < N; ++i) {
        if (u[i] == "JPY") ans += x[i];
        else ans += x[i] * 380000;
    }
    std::cout << ans << std::endl;
    return 0;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    int N; cin >> N;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    ll s = 0;
    rep(i, N) s ^= a[i];
    ll ans = s;
    rep(i, N) {
      // s で１が立っていたビットを強制的にa[i]を0にビットを変換（考慮しない）
      a[i] &= ~s;
    }
    int r = 0;
    vector<int> top(N);
    for (int i = 60; i >= 0; i--) {
      int j = r;
      for (; j < N; j++) {
        if (a[j] >> i & 1) {
          swap(a[r], a[j]);
          break;
        }
      }
      if (j == N) continue;
      top[r] = i;
      rep(k, N) {
        if (r == k) continue;
        if (a[k] >> i & 1) a[k] ^= a[r];
      }
      r++;
    }
      
    ll x = 0;
    for (int i = 60; i >= 0; i--) {
      ll nx = x | (1ll << i);
      ll b = nx;
      rep(j, r) {
        if (b >> top[j] & 1) b ^= a[j];
      }
      if ((b & nx) == 0) {
        x = nx;
      }
    }
    ans += x * 2;
    cout << ans << endl;
    return 0;

}

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

int main() {
  int n; cin >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  int cnt = 0;
  rep(i,n-1) {
    if (p[i] == (i+1)) {
      swap(p[i], p[i+1]);
      cnt++;
    }
  }
  if (p[n-1] == n) cnt++;
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <cmath>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <limits>
using namespace std;
#define MOD 1000000007
#define INF 1000000009
#define ll long long
#define rep(i_, start, end) for(ll i_=(ll)start; i_<(ll)end; i_++)
#define print(a) cout << a << endl;
#define printarray(a, len) rep(ii,0,len) cout << a[ii] << " ";
#define printarray2(aa, len) rep(ij,0,len) printarray(aa[ij], aa[ij].size()); print("");
 
const ll MAX_N = 110;
const ll MAX_V = 100010;
ll dp[MAX_N][MAX_V];
int main(){
  ll N, W, w, v;
  vector<ll> item[110];
  cin >> N >> W;
  rep(i, 0, N){
    cin >> w >> v;
    item[i].push_back(v);
    item[i].push_back(w);
  }

  rep(i, 0, MAX_N){
    rep(j, 1, MAX_V){
      dp[i][j] = INF;
    }
  }
 
  rep(i, 0, N){
    for(ll value=1; value <= MAX_V; value++){
      if (value - item[i][0] >= 0){
      dp[i+1][value] = min(dp[i+1][value], dp[i][value - item[i][0]] + item[i][1]);
      }
      dp[i+1][value] = min(dp[i][value], dp[i+1][value]);
    }
  }
  
  ll ans=0;
  for (ll i=0; i < MAX_V; i++){
    if(dp[N][i] <= W) ans = i;
  }
  print(ans)
 
  return 0;
}

Measured memory_bytes: 86144
#include<iostream>
#include<string.h>
using namespace std;
int main(){
	int n,m,l;
	while(cin>>n>>m>>l){
		long long a[n][m];
		long long b[m][l];
		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++)
				cin>>a[i][j];
		}
		for(int i=0;i<m;i++){
			for(int j=0;j<l;j++)
				cin>>b[i][j];
		}
		long long c[n][l];
		memset(c,0,sizeof(c));
		for(int i=0;i<n;i++){
			for(int j=0;j<l;j++){
				for(int k=0;k<m;k++){
					c[i][j]+=a[i][k]*b[k][j];
				}
			}
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<l;j++){
				if(j==0)
					cout<<c[i][j];
				else
					cout<<" "<<c[i][j];
			}
			cout<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3324
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
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); }

template<long long MOD>
struct RollingHash {
	int n;
	long long base;
	vector<long long> pow, hash;
	RollingHash() {}
	RollingHash(const string &s, long long base_ = 10007) { init(s, base_); }
	void init(const string &s, long long base_ = 10007) {
		n = s.size();
		base = base_;
		calc(s.c_str());
	}
	long long get(int x)const { return hash[x]; }
	long long get(int l, int r)const { return (get(r) - get(l)*pow[r - l] % MOD + MOD) % MOD; }
	void calc(const char *s) {
		pow.resize(n + 1);
		pow[0] = 1;
		hash.resize(n + 1);
		hash[0] = 0;
		for (int i = 0; i < n; i++) {
			pow[i + 1] = pow[i] * base % MOD;
			hash[i + 1] = (s[i] + hash[i] * base) % MOD;
		}
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;

	while (s.size() <= t.size()) {
		s += s;
	}
	s += s; // s.size() * 2 > t.size()
	int n = t.size();
	while (s.size() >= t.size()) {
		t += t;
	}
	// s.size() < t.size()
	const int MOD2 = 1000000009;
	RollingHash<MOD> S(s), T(t);
	RollingHash<MOD2> S2(s, 10009), T2(t, 10009);

	auto f = [&](int x) {
		int hash = T.get(0, n * x);
		int hash2 = T2.get(0, n * x);
		rep(i, 0, s.size()) {
			if (i + n * x >= s.size())break;
			if (S.get(i, i + n * x) == hash && S2.get(i, i + n * x) == hash2)
				return false;
		}
		return true;
	};
	auto binarySearch = [&](int ng, int ok) {
		if (f(ng))return ng;
		while (ng + 1 < ok) {
			int m = (ng + ok) / 2;
			if (f(m))
				ok = m;
			else
				ng = m;
		}
		return ok;
	};
	dump(s, t);
	int ans = binarySearch(1, t.size() / n + 1) - 1;
	s += s;
	t += t;
	S = RollingHash<MOD>(s);
	T = RollingHash<MOD>(t);
	S2 = RollingHash<MOD2>(s, 10009);
	T2 = RollingHash<MOD2>(t, 10009);
	int ans2 = binarySearch(1, t.size() / n + 1) - 1;
	int cnt = 0;
	while (ans != ans2 && cnt < 1) {
		ans = ans2;
		s += s;
		t += t;
		S = RollingHash<MOD>(s);
		T = RollingHash<MOD>(t);
		S2 = RollingHash<MOD2>(s, 10009);
		T2 = RollingHash<MOD2>(t, 10009);
		ans2 = binarySearch(1, t.size() / n + 1) - 1;
		cnt++;
	}
	if (ans != ans2) {
		cout << -1 << endl;
	}
	else {
		cout << ans << endl;

	}
	return 0;
}

Measured memory_bytes: 963200
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}

template<int N, typename T, T M>
struct ModFact {
    T fact[N+1];
    T ifact[N+1];
    constexpr ModFact() : fact(), ifact() {
        fact[0] = 1;
        for (int i=0; i<N; ++i)
            fact[i+1] = (fact[i]*(i+1))%M;
        ifact[N] = power(fact[N], M-2);
        for (int i=N-1; i >= 0; --i)
            ifact[i] = (ifact[i+1]*(i+1))%M;
    }
    constexpr T power(T a, T b) {
        T r = 1;
        while (b>0) {
            if((b&1)!=0) r = (r*a)%M;
            a = (a*a)%M;
            b >>= 1;
        }
        return r;
    }
    constexpr T comb(T n, T r) {
        return (((fact[n]*ifact[r])%M)*ifact[n-r])%M;
    }
};
 
ModFact<100000, ll, MOD> fact;

bool f = false;
ll N, ans = 1;
ll cnt = 1;
char S[200000];

int main() {
    scanf("%lld\n", &N);
    fread_unlocked(S, 1, N*2, stdin);
    if(S[0] == 'B' && S[2*N-1] == 'B') {
        FOR(i, 1, 2*N-1) {
            if(S[i] == S[i-1]) f ^= true;
            // cerr << f << " " << cnt * 2 - i<< endl;
            if(f) ans = (ans * ((cnt << 1) - i)) % MOD;
            else cnt++;
            if(cnt > N) break;
        }
        // cerr << ans << endl;
        if(cnt != N) ans = 0;
        else ans = (ans * fact.fact[N]) % MOD;
    } else ans = 0;
    printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 384
if __name__ == "__main__":
    N, K, Q = map(int, input().split())
    A = list()
    for i in range(Q):
        A.append(int(input()))

    score = [0 for i in range(N)]
    for i in range(Q):
        score[A[i] - 1] += 1
    
    for i in range(N):
        if K - Q + score[i] > 0:
            print('Yes')
        else:
            print('No')


Measured memory_bytes: 8640
s = input()
ans = 0

for i in range(3):
  if s[i] == 'R':
    ans += 1
    break
    
if i == 0:
  if s[1] == 'R':
    ans += 1
    if s[2] == 'R':
      ans += 1
      
elif(i == 1):
  if s[2] == 'R':
    ans += 1
    
print(ans)

Measured memory_bytes: 9116
#include <stdio.h>

int main(void) {
	int n,a[3],b,i;
	
	scanf("%d",&n);
	while(n--){
		scanf("%d %d %d",&a[0],&a[1],&a[2]);
		for(i=0;i<2;i++){
			if(a[i]>a[i+1]){
				b=a[i];
				a[i]=a[i+1];
				a[i+1]=b;
			}
		}
		if(a[0]*a[0]+a[1]*a[1]==a[2]*a[2]){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	
	return 0;
}

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

int main(){
	int a,b,c,d;

	cin >> 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;
	}
	cout << a << " " << b << " " << c <<endl;
    return 0;
}

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

bool prime[100010];
int sum[100010] = {};

int main(void) {
    for (int i = 0; i < 100010; i++) prime[i] = true;
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= 100000; i++) {
        if (prime[i]) {
            for (int j = 2; i * j <= 100000; j++) prime[i * j] = false;
        }
    }
    for (int i = 1; i <= 100000; i++) {
        if (prime[i] && prime[(i + 1) / 2]) sum[i] = sum[i - 1] + 1;
        else sum[i] = sum[i - 1];
    }
    int q;
    scanf("%d", &q);
    
    for (int i = 0; i < q; i++) {
        int l, r;
        scanf("%d%d", &l, &r);
        printf("%d\n", sum[r] - sum[l - 1]);
    }
}


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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

#define INF 1e9
#define MOD 1000000007
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define each(x, v) for (auto& x: (v))
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl

void solve();
void in(){} template<class T, class... U> void in(T &t, U &...u){ cin >> t; in(u...); }
int main() { cin.tie(0); ios::sync_with_stdio(0); solve(); }

void solve() {
  int N;
  in(N);
  string ans = "";
  rep(i, 0, N) {
    char c;
    in(c);
    if (c != ans[ans.length() - 1]) {
      ans += c;
    }
  }
  print(ans.length());
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            
            string[] V = Console.ReadLine().Split(' ');
            int N = int.Parse(V[0]);
            int K = int.Parse(V[1]);

            Console.WriteLine(N-K+1);

        }
    }
}


Measured memory_bytes: 11092
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    l = list(map(int, input().rstrip('\n').split()))
    l.sort()
    cnt = 0
    for i in range(0, n * 2, 2):
        cnt += min(l[i], l[i+1])
    print(cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define nl cout << endl
#define pb push_back
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
//debugger
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

int main() {
	fast;
	int n;
	cin >> n;
	vector <int> a(n);
	for (int i=0; i<n; i++) {
		cin >> a[i];
	}
	ll sum=0;
	for (int i=0; i<n; i++) {
		for (int j=i+1; j<n; j++) {
			sum+=1ll*a[i]*a[j];
		}
	}
	cout << sum;nl;
	return 0;
}

//notes
/*
 use these format of input when number of inputs not provided
 *while(scanf("%lld",&n)!=EOF)
 *while using getline(cin,s) for taking input of a string which is 
 having white space characters just write cin>>ws; before geline(cin,s)
 to make it work properly
*/

/*
 use 2-D vector for representing the pair<int,pair<int,int> > kind of things
*/

Measured memory_bytes: 256
//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
//change less to less_equal for non distinct pbds, but erase will bug

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

struct UFDS{
	int p[200005];
	int s[200005];
	
	UFDS(){
		rep(x,0,200005){
			p[x]=x;
			s[x]=1;
		}
	}
	
	int parent(int i){
		if (p[i]==i) return i;
		else return p[i]=parent(p[i]);
	}
	
	void unions(int i,int j){
		i=parent(i),j=parent(j);
		
		if (i==j) return;
		
		p[j]=i;
		s[i]+=s[j];
	}
} ufds;

int n;
ii pos[200005];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin.exceptions(ios::badbit | ios::failbit);
	
	cin>>n;
	rep(x,0,n) cin>>pos[x].fi>>pos[x].se;
	
	vector<int> proc;
	rep(x,0,n) proc.push_back(x);
	
	sort(all(proc),[](int i,int j){
		return pos[i].fi<pos[j].fi;
	});
	
	deque<int> stk;
	
	rep(x,0,n){
		int top=-1;
		while (!stk.empty() && pos[stk.back()].se<pos[proc[x]].se){
			if (top==-1) top=stk.back();
			ufds.unions(stk.back(),proc[x]);
			//cout<<stk.back()<<" "<<x<<endl;
			stk.pop_back();
		}
		if (top==-1) stk.push_back(proc[x]);
		else stk.push_back(top);
	}
	
	rep(x,0,n){
		cout<<ufds.s[ufds.parent(x)]<<endl;
	}
}


Measured memory_bytes: 9008
a = list(map(int,input().split()))
a.sort()
suma = 0
if (a[1] - a[0])%2 == 0:
    suma += (a[1] - a[0])//2
else:
    suma += (a[1] - a[0])//2 + 1
    a[1] -= 1

suma += a[2] - a[1]
print(suma)

Measured memory_bytes: 3060
#include <stdio.h>
#define N 10000
int main(void){
  int i,n,p[N]={0},max=0,sum=0,imax=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&p[i]);
  }
  for(i=0;i<n;i++){
    if(p[i]>max){
      max=p[i];
      imax=i;
    }
  }
  for(i=0;i<n;i++){
    if(i==imax){
      sum+=p[i]/2;
    }else{
      sum+=p[i];
    }
  }
  printf("%d\n",sum);
  return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

LL gcd(LL x, LL y){
  while(x%y){
    LL tmp = x%y;
    x=y;
    y=tmp;
  }
  return y;
}

int main(){
  LL p,q;
  cin >> p >> q;
  p%=q;
  q/=gcd(p,q);
  LL ans=1;
  repp(i,2,sqrt(q)+1){
    if(q%i==0){
      ans*=i;
      while(q%i==0) q/=i;
    }
  }
  if(q>1) ans*=q;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3080
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 9999999999999999;
const ld pi = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct S {//辺の情報を入れる変数
	int from, to, cost;
};
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
int n;
int a[100000];
signed main() {
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	int r=n%2==0?1:0;
	for(int i=0;i<n;){
		int j=i;
		while(j<n&&a[i]==a[j])
			j++;
		int sum=j-i;
		if(a[i]!=r||/*n%2==0*/(n%2==0&&(sum!=2))||/*n%2==1*/(n%2==1&&((a[i]==0&&sum!=1)||(a[i]!=0&&sum!=2)))){
			cout<<0<<endl;
			return 0;
		}
		r+=2;
		i=j;
	}
	int ans=1;
	for(int i=0;i<n/2;i++){
		ans*=2;
		ans%=1000000007;
	}
	cout<<ans<<endl;
	getchar(); getchar();
}


Measured memory_bytes: 1024
import numpy as np
n, m, x = map(int, input().split())
lst = np.array([np.array(list(map(int, input().split()))) for _ in range(n)])
ans = float('inf')
for i in range(1<<n):
    eff = np.array([0] * (m+1))
    for j in range(n):
        if i>>j&1==1:
            eff += lst[j]
    cost = eff[0]
    eff = eff[1:]
    if np.all(eff >= x):
        ans = min(ans, cost)
if ans == float('inf'):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 27360
antena = []
for i in range(5):
    antena.append(int(input()))

k = int(input())
dis = 0

for i in range(4):
    for j in range(i+1, 5):
        dis = antena[j] - antena[i]
        if dis > k:
            print(":(")
            exit()
        dis = 0

print("Yay!")


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

int main(void){
    int n, q;
    int *S;
    int T;
    int i;
    int result = 0;
    int l, r;
    
    cin >> n;
    S = new int[n];
    for(i = 0; i < n; i++) cin >> S[i];
    
    cin >> q;
    for(i = 0; i < q; i++){
        cin >> T;
        l = 0;
        r = n;
        while(l <= r){
            if(S[(l + r) / 2] == T){
                result++;
                break;
            }else if(S[(l + r) / 2] < T){
                l = (l + r) / 2 + 1;
            }else{
                r = (l + r) / 2 - 1;
            }
        }
    }
    
    cout << result << endl;
    delete[] S; S = 0;
    return 0;
}

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

template <typename T>
void print(const T &v);

int main()
{
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] != t[i])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


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

typedef long long ll;
const int N = 100005;
const int M = 1000000007;

int h, w, n;
unordered_map<ll, bool> mp;
unordered_map<ll, int> c;
ll cnt[15];

inline ll get(int x, int y) { return (ll)x * w + y; }

int calc(int x, int y) {
  int ret = 0;
  for (int i = max(1, x - 1); i <= min(h, x + 1); i++) {
    for (int j = max(1, y - 1); j <= min(w, y + 1); j++) {
      ret += mp[get(i, j)];
    }
  }
  return ret;
}

int main() {
  while (~scanf("%d%d%d", &h, &w, &n)) {
    memset(cnt, 0, sizeof(cnt)); mp.clear(); c.clear();
    cnt[0] = (h - 2) * (w - 2ll);
    for (int i = 0, x, y; i < n; i++) {
      scanf("%d%d", &x, &y);
      for (int i = max(2, x - 1); i <= min(h - 1, x + 1); i++) {
        for (int j = max(2, y - 1); j <= min(w - 1, y + 1); j++) {
          cnt[c[get(i, j)]]--;
        }
      }
      mp[get(x, y)] = true;
      for (int i = max(2, x - 1); i <= min(h - 1, x + 1); i++) {
        for (int j = max(2, y - 1); j <= min(w - 1, y + 1); j++) {
          cnt[c[get(i, j)] = calc(i, j)]++;
        }
      }
      //for (int i = 0; i <= 9; i++) { printf("cnt[%d] = %I64d\n", i, cnt[i]); }
    }
    for (int i = 0; i <= 9; i++) { printf("%lld\n", cnt[i]); }
  }
}


Measured memory_bytes: 150608
#include <iostream>

int main() {
	char str[11];
	int num[10];
	while(std::cin >> str) {
		// Load the numbers
		for( int i=0; i<10; i++) num[i] = str[i] - '0';
		
		for( int i=0; i<10; i++) for( int j=0; j<9-i; j++) num[j] = (num[j] + num[j+1])%10;

		std::cout << num[0] << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1136
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

int main() {
    ll N, P; cin >> N >> P;

    vector<pair<ll, ll>> G;
    for (ll a = 2; a * a <= P; a++) {
        if (P % a != 0) continue;
        ll ex = 0;
        while (P % a == 0) {
            ex++;
            P /= a;
        }

        G.push_back(make_pair(a, ex));
    }
    if (P != 1) G.push_back(make_pair(P, 1));

    ll res = 1;
    for (auto x: G) {
        if (x.second < N) continue;

        ll cnt = x.second / N;
        for (ll i = 0; i < cnt; i++) {
            res *= x.first;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 3616
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <utility>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cstdio>
#include <math.h>
#include <stdio.h>
#include <deque>

using namespace std;

#define REP(i,n,m) for( long long int i = (n); i < (m); i++ )
#define REV(v) for (auto itr = v.rbegin(); itr != v.rend(); itr++)
#define ll long long
#define ALL(a) (a).begin(), (a).end()
#define SORT(v) sort( ALL(v) );
#define LAST(v) v[v.size()-1]
#define ZERO(a) memset(a,0,sizeof(a));
#define MINUS(a) memset(a,-1,sizeof(a));
#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 pi pair<int, int>
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define IIN(a) int a; cin >> a;
#define LIN(a) ll a; cin >> a;
#define SIN(a) string a; cin >> a;
#define VL(v,n) vector<ll> v(n);
#define Read_VL(v,n) vector<ll> v(n);REP(i,0,n)cin>>v[i];
#define sumV(v,n) Vl(acm,n) REP(i,0,n) acm[i] = v[i] + ( i == 0 ? 0 : acm[i - 1]);
#define EPS (1e-10)
#define INF 1000000000000LL

void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}


template<class T=ll>struct Graph{
	int n;
	vector<vector<tuple<ll,T>>>edge;
	Graph(int N=1):n(N){edge.resize(n);}
	void add(ll f,ll t,T c,bool d=false){
		edge[f].emplace_back(t,c);
		if(!d)edge[t].emplace_back(f,c);
	}
	void view(){
		REP(i,0,n)for(auto&e:edge[i])
			puta(i,"=>",get<0>(e),", cost :",get<1>(e));
	}
};


bool length_cmp( string &a, string &b ){
  return a.size() < b.size();
}

ll StoLL( string s )
{
	ll num=0;
  REP( i, 0, s.size() ){
    num = num * 10 + ( s[i] ^ 48 );
  }
  return num;
}

ll CtoLL( char c )
{
	if( 'a' <= c && c <= 'z'){
		return (ll)( c ^ 96 ) ;
	}
	else if( 'A' <= c && c <= 'Z'){
		return (ll)( c ^ 64 );
	}
  return 0;
}

ll mod=1000000007;
ll dx[4] = { 1, 0, -1, 0 };
ll dy[4] = { 0, 1, 0, -1 };
//I ASCII code: '0' = 48; 'A' = 65; 'a' = 97


signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    SIN(s)
    REP(i,0,s.size() ){
      if( s[i] == '1' ){
        s[i] = '9';
      }else if( s[i] == '9'){
        s[i] = '1';
      }
    }
    puta( s );
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1'000'000'000'000'000'000;
namespace utils{
    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
    using V_Set = unordered_set<int>;
    using E_Set = unordered_map<int, V_Set>;

#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
}
using namespace utils;


void sub_main(istream &is) {
    ll A, B, C;
    ll zero = 0;
    is >> A >> B >> C;
    if(!is) return;
    ll rem = A - B;
    cout << max(C - rem, zero) << endl;


}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    string test_cases = "test_A.txt";
    cerr << "DEBUG MODE" <<  endl;
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int lp = 0;
    while(fs) {
        lp++;
        cout << lp <<  "#------\n";
        sub_main(fs);
    }
    cout << "------#" << endl;
    if(lp <= 1) sub_main(cin);
#else
    sub_main(cin);
#endif
    return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

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

  int key = 1;
  int a, broken = 0;
  REP1(i, N) {
    cin >> a;
    if (a == key) {
      key++;
    } else {
      broken++;
    }
  }
  cout << (N == broken ? -1 : broken) << endl;
  return 0;
}


Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int ans = 0;
		for (int i = 0; i < n; i++) {
			int a = in.nextInt();
			if (i % 2 == 0 && a % 2 == 1)
				ans++;
		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 35956
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int a,
		b;
		
		a = scan.nextInt();
		b = scan.nextInt();
		
		int x=a*b;
		int y=2*a+2*b;
		
		System.out.println(x + " " + y);
				

	}

}



Measured memory_bytes: 26072
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] s = new int[n];
        int[] t = new int[m];
        for (int i = 0; i < n; i++) {
            s[i] = sc.nextInt();
        }
        for (int i = 0; i < m; i++) {
            t[i] = sc.nextInt();
        }
        int mod = 1_000_000_007;
        long[][] a = new long[n+1][m+1];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                a[i][j] = (a[i][j-1] + a[i-1][j] - a[i-1][j-1]+mod) %mod;
                if(s[i-1] == t[j-1]){
                    a[i][j] = (a[i][j] + a[i-1][j-1] + 1) % mod;
                }
            }
        }
        System.out.println(a[n][m] + 1);
        sc.close();

    }

}


Measured memory_bytes: 84976
#include<iostream>
#include<string>

using namespace std;

int main()
{
	int N;

	cin >> N;

	if(N%111 == 0)
	{
		cout << N << endl;
	}
	else
	{
		cout << N + (111 -N%111) << endl;
	}

	return 0;
}

Measured memory_bytes: 764
use std::io;
use std::cmp;

macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn input_vector<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let s = input_line_str();
        let split_result = s.split_whitespace();
        let mut vec_line: Vec<T> = Vec::new();
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            vec_line.push(buf);
        }
        v.push(vec_line);
    }
    v
}

fn main() {
  let n:usize;
  let x:usize;
  input!(n,x);
  let mut sum:usize=0;
  let mut min:usize=9999;

  for i in 0..n{
      let m:usize;
      input!(m);
      sum += m;
      min = cmp::min(min,m);
  }
  println!("{}",n+(x-sum)/min);


}

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

int main()
{
	int n, k, m = 0;
	string s;
	bool f = 0;

	cin >> n >> k >> s;

	for (int i = 0; i < n; i++) {
		if (i < n - 1 && s[i] == 'R' && s[i + 1] == 'R')
			m++;
		else if (i > 0 && s[i] == 'L' && s[i - 1] == 'L')
			m++;
	}

	if (n - m >= k * 2 + 2)
		m += k * 2;
	else
		m = n - 1;

	cout << m << endl;

	return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	int m_module = 1000000007;
	vector<struct Memo> memo;
public:
	int calculate(int, int);
	Combination1(int, int);
};
int Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, int module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_Odds_of_Oddness(void) {

	int N; cin >> N;
	
	cout << setprecision(20) << (double)((N + N % 2) / 2) / (double)N << flush;
	return;
}

void B_Roller_Coaster(void) {

	int N, K; cin >> N >> K;
	vector<int>h(N); for (int& it : h) cin >> it;

	sort(h.begin(), h.end());
	for (int index = 0; index < N; index++) {
		if (h[index] >= K) {
			cout << N - index << flush;
			return;
		}
	}
	cout << 0 << flush;
	return;
}

void C_Go_to_School(void) {

	int N; cin >> N;
	struct Student {
		int index;
		int A;
		bool operator<(const Student& right) { return (A < right.A); }
	};
	vector<Student>student(N); 
	for (int index = 0; index < N;index++) {
		student[index].index = index + 1;
		cin >> student[index].A;
	}

	sort(student.begin(), student.end());
	
	for (Student he : student) cout << he.index << " ";
	cout << flush;
	return;
}

int main(void) {

	//A_Odds_of_Oddness();
	//B_Roller_Coaster();
	C_Go_to_School();
	return 0;
}


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

 int master(int data){
 if(data>=0)
	 return data;
 return -data;
 }
int main(){
    int D,N,T[201],A[201][3];
    int dp[201][101];
    cin >> N >> D ;
    for(int i=0;i<N;i++){
        cin >>T[i];
    }
    for(int i=0;i<D;i++){
        for(int j=0;j<3;j++){
            cin >>A[i][j];
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<200;j++){
            dp[i][j]=-9999;
        }
    }
    for(int l=0;l<D;l++){
        if(T[0]>A[l][0] && T[0]<A[l][1] ){
            dp[ 0 ][ A[l][2] ]=0;
             
 
        }
    }
    for(int i=1;i<N;i++){
        for(int j=0;j<D;j++){
            if(T[i]>=A[j][0] && T[i]<=A[j][1] ){
                for(int l=0;l<=100;l++){
                    if(dp[i-1 ][ l ]>=0)
                        dp[ i ][ A[j][2] ]=max(dp[ i ][ A[j][2] ],dp[ i-1 ][ l ]+master(l-A[j][2]));//テッツセツεッツスツ、テッツセツづッツスツサテッツセツづァツ板佚ッツスツ」テッツセツ?テッツスツセテッツセツεッツスツ」テッツセツ?テッツスツァテッツセツεッツスツ」テッツセツ?テッツスツョテッツセツεッツスツヲテッツセツづヲツ??テッツスツゥテッツセツづッツスツォテッツセツづ、ツスツ堙ッツスツ」テッツセツ??テッツスツ、テッツセツづッツスツサテッツセツづァツ板佚ッツスツ・テッツセツづ・ツエツ「?
                     
 
                }
            }
        }
    }
    int answer=0;
    for(int j=0;j<101;j++)
    {
		
        answer=max(answer,dp[ N-1 ][j]);
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int  long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 998244353
// order_of_key and *find_by_order
#define N 100001
int32_t main() {
	fast;
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int to = 0;
	sort(a, a + n);
	multiset < pair<int, pair<int , int > > > s;
	s.insert({a[n - 2], {a[n - 1], a[n - 2]}});
	s.insert({a[n - 2], {a[n - 1], a[n - 2]}});
	to += a[n - 1];
	for (int i = n - 3; i >= 0; i--) {
		pair<int , pair<int, int > > pi = *s.rbegin();
		to += pi.first;
		s.erase(s.lower_bound(pi));
		s.insert({min(pi.second.first, a[i]), {a[i], pi.second.first}});
		s.insert({min(pi.second.second, a[i]), {a[i], pi.second.second}});
	}
	cout << to;


}











Measured memory_bytes: 17696
let n, m = Scanf.scanf " %d %d" @@ fun a b -> a, b
let xys = Array.init m @@ fun _ -> Scanf.scanf " %d %d" @@ fun a b -> a - 1, b - 1
let rs, cs = Array.(make n 0, make n 1)
let _ = rs.(0) <- 1; Array.(iter (fun (x, y) -> if rs.(x) = 1 then rs.(y) <- 1; cs.(y) <- cs.(y) + 1; cs.(x) <- cs.(x) - 1; if cs.(x) = 0 then rs.(x) <- 0) xys; fold_left (+) 0 rs) |> Printf.printf "%d\n"

Measured memory_bytes: 7680
N = int(input())
cnt = [0] * 10001

for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            value = x*x + y*y + z*z + x*y + y*z + z*x
            if value <= 10000:
                cnt[value] += 1
for i in range(1,N+1):
    print(cnt[i])

Measured memory_bytes: 74740