akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#define maxn 20
#define maxm 100005
#include<cstring>
using namespace std;
int vis[maxn];
int a[maxm];
int main()
{
    int n,k;
    while(~scanf("%d%d",&n,&k))
    {memset(vis,0,sizeof(vis));
        for(int i=1;i<=k;i++)
    {scanf("%d",&a[i]);
    vis[a[i]]=1;
    }
        for(int i=n;;i++)
        {int flag=0;
        int x=i;
            while(x)
            {
                int ans=x%10;
                if(vis[ans])
                {flag=1;
                break;

                }
                x/=10;
            }
            if(flag)
                continue;
            else if(!flag)
            {
                printf("%d\n",i);
                break;
            }
        }
    }
    return 0;
}


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

namespace ConsoleApplication72
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = new List<int>();
            string[] str = Console.ReadLine().Split(' ');
            a.Add(int.Parse(str[0]));
            a.Add(int.Parse(str[1]));
            a.Add(int.Parse(str[2]));
            a.Sort();
            int sum = a[0];
            sum += a[1];
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 13140
# include <iostream>
# include <cstdio>
using namespace std;
const int N = 1e5 + 12;
long long C,ans;
long long x[N << 1],v[N << 1],g[N << 1];
int n,que[N << 1],t,h;
int id(int i){return i <= n ? i : i - n;}
long long f(int i){return g[i] - x[i + 1] + min(x[id(i + 1)],C - x[id(i + 1)]);}
int main()
{
	scanf("%d %lld",&n,&C);
	for(int i = 1;i <= n;i++)scanf("%lld %lld",&x[i],&v[i]),x[n + i] = x[i] + C,v[n + i] = v[i];
	for(int i = 1;i < n * 2;i++)g[i] = g[i - 1] + v[i];
	h = t = 0;
	for(int i = 1;i < n * 2;i++)
	{
		while(h < t && i - que[h] > n)h++;
		ans = max(ans,g[i] - x[i] - f(que[h]));
		while(h < t && f(i) <= f(que[t]))t--;
		que[++t] = i;
	}
	for(int i = 1;i <= n;i++)x[i] = C - x[i];
	for(int a = 1,b = n;a < b;a++,b--)swap(x[a],x[b]),swap(v[a],v[b]);
	for(int i = 1;i <= n;i++)x[n + i] = x[i] + C,v[n + i] = v[i];
	for(int i = 1;i < n * 2;i++)g[i] = g[i - 1] + v[i];
	h = t = 0;
	for(int i = 1;i < n * 2;i++)
	{
		while(h < t && i - que[h] > n)h++;
		ans = max(ans,g[i] - x[i] - f(que[h]));
		while(h < t && f(i) <= f(que[t]))t--;
		que[++t] = i;
	}
	printf("%lld\n",ans);
	
}

Measured memory_bytes: 5632
#include<stdio.h>
typedef struct{
    char name[11];
    int time;
}queue;
int main(void){
    int n,q;
    scanf("%d %d",&n,&q);
    int size=2*n;
    queue Queue[size];
    int pre=0,rear=0,cnt=0;
    for(rear=0;rear<n;++rear){
        scanf("%s %d",Queue[rear].name,&Queue[rear].time);
    }
    while(pre!=rear){
        if(Queue[pre].time<=q){
            cnt+=Queue[pre].time;
            printf("%s %d\n",Queue[pre].name,cnt);
        }else{
            cnt+=q;
            Queue[pre].time-=q;
            Queue[rear]=Queue[pre];
            rear=(rear+1)%size;
        }
        pre=(pre+1)%size;
    }
    return 0;
}


Measured memory_bytes: 3284
<?php
$n = trim(fgets(STDIN));
$a = explode(" ", trim(fgets(STDIN)));
$max = $min = $a[0];
$sum = 0;
for($i = 0; $i < $n; $i++)
{
    if($max <= $a[$i])
    {
        $max = $a[$i];
    }
    if($min >= $a[$i])
    {
        $min = $a[$i];
    }
    $sum += $a[$i];
}
echo $min . " " . $max . " " . $sum . "\n";

Measured memory_bytes: 16744
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>
#include <string>
#include <sstream>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec secondstruct edge{ int u, v, cost; };
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define SORT(x) sort((x).begin(), (x).end())
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

struct edge{ int u, v; double cost; };

bool comp(const edge& e1, const edge& e2){
	return e1.cost < e2.cost;
}
int par[100];
int rank[100];
edge es[10000];
int V, E;

void init(int n){
	rep(i,n){
		par[i] = i;
		rank[i] = 0;
	}
}

int find(int x){
	if(par[x] == x) return x;
	else return par[x] = find(par[x]);
}

void unite(int x, int y){
	x = find(x);
	y = find(y);
	if(x == y) return;
	
	if(rank[x] < rank[y]) par[x] = y;
	else{
		par[y] = x;
		if(rank[x] == rank[y]) rank[x]++;
	}
}

bool same(int x, int y){
	return find(x) == find(y);
}

double kruskal(){
	sort(es, es+E, comp);
	double res = 0.0;
	for(int i = 0; i < E; i++){
		edge e = es[i];
		if(!same(e.u, e.v)){
			unite(e.u, e.v);
			res += e.cost;
		}
	}
	return res;
}

void solve(){
	double x[100], y[100], z[100], r[100];
	rep(i,V) cin >> x[i] >> y[i] >> z[i] >> r[i];
	init(V);
	E = 0;
	rep(i,V){
		for(int j = i+1; j < V; j++){
			if((r[j]+r[i])*(r[j]+r[i]) < (x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j])){
				edge e;
				e.u = i;
				e.v = j;
				e.cost = sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]))-r[j]-r[i];
				es[E] = e;
				E++;
			} else{
				unite(i,j);
			}
		}
	}
	printf("%.3f\n", kruskal());
}

int main(){
	while(cin >> V,V) solve();
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  string s;
  cin >> s;

  cout << ((s[0]==s[1] && s[1]==s[2] || s[1]==s[2] && s[2]==s[3]) ? "Yes" : "No") << endl;
  
}



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

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

    long long int u=0;
    int f=n;
    while(f--)
    {   
        long long int a;cin>>a;
        for(int r=a;r;r=r)
        {
            if(r%2==0&&r)
            {
                u++;r/=2;
            }
            else break;
        }
    }
 cout<<u<<"\n";
	// your code goes here
	return 0;
}


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

vector<long long> input(long long N){
    vector<long long> output(N);
    for(long long i=0;i<N;i++)cin>>output[i];
    return output;
}

int main(){
    long long N,i,j;
    long long category=1;
    long long result;
    long long c;
    vector<long long> L;

    cin>>N;
    L=input(N);
    result=N*(N-1)*(N-2)/6;
    sort(L.begin(),L.end());

    for(i=N-1;i>=2;i--){
        for(j=i-1;j>=1;j--){
            c=L[i]-L[j];
            result-=min((long long)distance(L.begin(),upper_bound(L.begin(),L.end(),c)),j);
        }
    }

    cout<<result<<endl;
}

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

#define fi first
#define se second
typedef pair<int, int> ii;

const int len = 1e5+5;
ii arr[len];

int main(){
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++){
        scanf("%d", &arr[i].fi);
        arr[i].se = i;
    }
    sort(arr, arr+n);

    int ans = 0;
    for (int i = 0; i < n; i++)
        if (i%2 != arr[i].se%2) ans++;

    printf("%d\n", ans/2);
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, n) for(int i = 0; i < n; i = i + 2)
#define repv(i, n, v) for(int i = 0; i < n; i = i + v)
#define rrep(i, n) for(int i = n; i >= 0; i--)
#define sortI(a, b, c) c == 0 ? sort(a, a + b) : sort(a, a + b, greater<int>())
#define sortS(s, a) a == 0 ? sort(s.begin(), s.end()) : sort(s.begin(), end(), greater<char>)
#define vi vector<int>
#define vf vector<float>
#define vc vector<char>
#define vs vector<string>
#define ll long long

int digit(int n){
  int res = 0;
  while(n > 0){
    res += n%10;
    n /= 10;
  }
 
  return res;
}

int main(void){

  //入力
  int N, x;
  cin >> N >> x;
  
  //配列
  int a[N];
  rep(i, N) cin >> a[i];
  
  //昇順ソート
  sortI(a, N, 0);
  
  //小さいものから引いていく
  int ans = 0;
  for(int i = 0; i < N; i++){
    x -= a[i];
    ans++;
    if(x < 0) break;
  }
  
  //ちょうど配り終わったんじゃなかったら、余った分を誰かに押し付けるか
  //最後の子にちょうど渡せなかったかで幸せな子が減る
  if(x != 0) ans--;
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
#define f first
#define s second

int n, st, a, b;
deque <pi> dq; //num voters, coord
vector <int> v;
ll ans;

int main() {
	cin >> n >> st;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		dq.push_back(pi(b, a));
	}
	while (!dq.empty() and dq.front().s < st and dq.back().s > st) {
		pi x = dq.front(), y = dq.back();
		if (x.f < y.f) {
			v.push_back(x.s);
			dq.back().f += x.f;
			dq.pop_front();
		} else {
			v.push_back(y.s);
			dq.front().f += y.f;
			dq.pop_back();
		}
	}
	if (!dq.empty()) {
		if (dq.front().s > st) {
			while (!dq.empty()) {
				v.push_back(dq.back().s);
				dq.pop_back();
			}
		} else {
			while (!dq.empty()) {
				v.push_back(dq.front().s);
				dq.pop_front();
			}
		}
	}
	reverse(v.begin(), v.end());
	int pre = st;
	for (auto it:v) {
		ans += llabs(it - pre);
		pre = it;
	}
	cout << ans;
}

Measured memory_bytes: 2168
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int n, r;
    cin >> n >> r;
    if (n < 10) {
        cout << r + 100*(10-n) << endl;
    } else {
        cout << r << endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <random>
#include <chrono>
#include <cassert>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

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

struct RandNum {

	mt19937 mt;
	RandNum() : mt(chrono::steady_clock::now().time_since_epoch().count()) {}

	lint operator()(lint a, lint b) {
		uniform_int_distribution<lint> dist(a, b);
		return dist(mt);
	}
	lint operator() (lint b) { return (*this)(0LL, b); }

	template<class Ite>
	void shuf(Ite first, Ite last) { shuffle(first, last, mt); }

};

class Prime {
private:
	void Eratos(lint N) {
		for (lint i = 2; i * i < N; i++) {
			if (Ptb[i]) for (int j = 0; i * (j + 2) < N; j++) Ptb[i *(j + 2)] = 0;
		}
	}
public:
	vector<int> Ptb;
	Prime(lint N) : Ptb(N + 1, 1) { Eratos(N + 1); }

	vector<pair<lint, int>> Pfact(lint num) {
		vector<pair<lint, int>> res;
		for (lint i = 2; i * i <= num; i++) {
			int cnt = 0;
			while (num % i == 0) {
				cnt++;
				num /= i;
			}
			if (cnt) res.emplace_back(i, cnt);
		}
		if (num != 1) res.emplace_back(make_pair(num, 1));
		return res;
	}

	bool isPrime(lint num) {
		if (num < 2) return false;
		else if (num < (int)(Ptb.size())) return (bool)(Ptb[num]);
		else if (num == 2 || num == 3) return true;
		else if (num % 2 == 0 || num % 3 == 0) return false;
		else if (num % 6 != 1 && num % 6 != 5) return false;
		for (lint i = 5; i * i <= num; i += 6) {
			if (num % i == 0) return false;
			if (num % (i + 2) == 0) return false;
		}
		return true;
	}
};

int main() {

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

	int N;
	cin >> N;

	Prime p(300000);

	vector<int> ans;
	int ans_sz = 0;
	for (int i = 2; ans_sz < N; i += 5) {
		if (p.isPrime(i)) {
			ans.emplace_back(i);
			ans_sz = static_cast<int>(ans.size());
		}
	}

	for (const auto &e : ans) cout << e << " ";
	cout << "\n";

	return 0;
}

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

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

    ll n,m;
    cin >> n >> m;
    vector<ll> x(m);
    for (ll i = 0;i < m;i++){
        cin >> x[i];
    }
    sort(x.begin(), x.end());
    
    vector<ll> d(m-1);
    for (ll i = 0;i < m-1;i++){
        d[i] = x[i+1] - x[i];
    }
    sort(d.begin(), d.end());
    ll ans = 0;

    for (ll i = 0; i < max(0LL, m-n); i++){
        ans += d[i];
    }

    cout << ans << endl;

}

Measured memory_bytes: 4784
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

bool query(ll N, ll h, ll n, ll w) {
  return 4 * h * n * w <= N * (n * w + w * h + h * n);
}

ll get_w(ll N, ll h, ll n) {
  ll l = n;
  ll r = 3501;
  while (l + 1 != r) {
    ll m = (l + r) / 2;
    if(query(N, h, n, m)) {
      l = m;
    } else {
      r = m;
    }
  }
  if(4 * h * n * l == N * (n * l + l * h + h * n)) {
    return l;
  }
  return -1;
}

void solve(ll N) {
  for(ll h=1; h<=3500; h++) {
    for(ll n=h; n<=3500; n++){
      ll w = get_w(N, h, n);
      if(w != -1) {
        cout << h << " " << n << " " << w << endl;
        return;
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  solve(N);
  return 0;
}


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

int main(){
  int i,N;
  unsigned long long j=2,k=1,l;
  cin >> N;
  
  for(i=0; i<N-1; i++){
    l=j+k;
    j=k;
    k=l;
  }
  if(N==0) l=2;
  if(N==1) l=1;  

  cout << l;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;



const long long INF2 = (((ll)1<<31)-1);

int main(int argc, char* argv[])
{
    int n,q;
    scanf("%d%d", &n, &q);
    
    vector<pair<int, pair<int, pair<int,int> > > > z(q);     // type, s, t, x;
    int i;
    int cnt=0;
    for(i=0; i<q; i++) {
        int type, s, t, x;
        scanf("%d", &type);
        if(type==0) {
            scanf("%d%d%d", &s, &t, &x);
            z[i]=make_pair(type, make_pair(s, make_pair(t,x)));
        }
        else {
            scanf("%d", &s);
            z[i]=make_pair(type, make_pair(s, make_pair(0,0)));
            cnt++;
        }
    }
    int ansnum=cnt;

    set<pair<int,int> > zz;    // val, ansid
    vector<int> ans(ansnum, INF2);
    cnt=ansnum-1;
    for(i=q-1; i>=0; i--) {
        if(z[i].first==0) {
            int s=z[i].second.first;
            int t=z[i].second.second.first;
            int x=z[i].second.second.second;
            auto it=zz.lower_bound(make_pair(s,-INF));
            auto itend=zz.lower_bound(make_pair(t+1,-INF));
            while(it!=itend) {
                ans[it->second]=x;
                auto itnext=it; itnext++;
                zz.erase(*it);
                it=itnext;
            }
        }
        else {
            zz.insert(make_pair(z[i].second.first, cnt));
            cnt--;
        }
    }
    for(i=0; i<ansnum; i++) {
        printf("%d\n", ans[i]);
    }
    return 0;
}



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

#define REP(i,n) for(int (i)=0; i<(int)(n); i++)

int a[410];
long long pre[410];
long long dp[410][410];

int main(void) {
	int N;
	cin >> N;
	memset(dp, 127, sizeof dp);
	REP(i,N) {
		cin >> a[i];
		pre[i] = pre[i-1] + a[i];
		dp[i][i] = 0;
	}
	for (int i = N-2; i >= 0; i--)
		for (int j = i+1; j < N; j++)
			for (int k = i; k < j; k++)
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + pre[j] - pre[i-1]);
	cout << dp[0][N-1] << endl;
	return 0;
}

Measured memory_bytes: 1536
N = input()
n = int(N)//100
if N[0]==N[1]==N[2]:
    print(N)
elif N[0]==N[1] and N[0]>N[2]:
    print(100*n+10*n+n)
elif N[0]>N[1]:
    print(100*n+10*n+n)
else:
    n = n+1
    print(100*n+10*n+n)

Measured memory_bytes: 38384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class BNiceShopping {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int A, B, m; cin >> A >> B >> m;
      vector<int> a(A);
      int amin = INT_MAX;
      rep(i, A) {
        cin >> a[i];
        chmin(amin, a[i]);
      }
      vector<int> b(B);
      int bmin = INT_MAX;
      rep(i, B) {
        cin >> b[i];
        chmin(bmin, b[i]);
      }
      int ans = amin+bmin;
      rep(i, m) {
        int x, y, c; cin >> x >> y >> c;
        x--; y--;
        chmin(ans, a[x]+b[y]-c);
      }
      cout << ans << endl;

    }
};

signed main() {
  BNiceShopping solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 1024
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
s = ins()
p = 1
for i in range(26):
    c = s.count(chr(ord('a')+i))
    p = (p*(c+1))%R
print(p-1)


Measured memory_bytes: 39024
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=100000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u];i;i=sq[i].nxt)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 998244353
#define eps 1e-8
int n,nxt1[500500],nxt2[500500];
char s[500500],t[500500];

int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int calc(char *s,int *nxt)
{
	int k=0;
	rep(i,2,n)
	{
		while ((k) && (s[i]!=s[k+1])) k=nxt[k];
		if (s[i]==s[k+1]) k++;
		nxt[i]=k;
	}
	if (n%(n-nxt[n])) return n;else return n-nxt[n];
}

int chk(int p1,int p2)
{
	int ok1=((nxt1[p1]==0) || (p1%(p1-nxt1[p1])));
	int ok2=((nxt2[p2]==0) || (p2%(p2-nxt2[p2])));
	return ok1&&ok2;
}

int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	int len=calc(s,nxt1);
	if (len==1) {printf("%d\n1",n);return 0;}
	else if (len==n) {printf("1\n1");return 0;}
	else 
	{
		rep(i,1,n) t[n-i+1]=s[i];
		calc(t,nxt2);
		int ans=0;
		rep(i,1,n-1) ans+=chk(i,n-i);
		printf("2\n%d",ans);
	}
	return 0;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}
int ans[100005];
int main(){
    auto t = prime_table(100000);
    for(int i=1;i<=100000;i++)ans[i]=ans[i-1]+(t[i]&t[(i+1)/2]);
    int q;
    cin >> q;
    for(int i=0;i<q;i++){
        int l,r;
        cin >> l >> r;
        cout << ans[r]-ans[l-1] << endl;
    }
}

Measured memory_bytes: 4008
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<cctype>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b + c || b == a + c || c == b + a)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
using ll = long long;
#define int ll
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
signed main(){
    int a,b,c,x,y; cin >> a >> b >> c >> x >> y;
    int temp = 2 * max(x,y)*c;
    if(a+b<=2*c){
        cout << min(temp,a*x + b*y )<< endl;
    }else{
        int res = min(x,y);
        x -= res;
        y -= res;
        cout << min(temp,res*2*c +(x)*a +(y)*b) <<endl;
    }
}



Measured memory_bytes: 888
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int w = 0;
		w = a;
		a = b;
		b = w;
		w = a;
		a = c;
		c = w;
		System.out.println(a + " " + b + " " + c);
	}
}

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

main() {
    int N; cin >> N;
    vector<pair<string,int>> p,p2;
    rep(i,N){
        string s; int a;
        cin >> s; cin >> a;
        p.push_back(make_pair(s,-a));
        p2.push_back(make_pair(s,-a));
    } 
    sort(p.begin(),p.end());
    rep(i,N){
        rep(j,N){
            if(p[i]==p2[j]) cout << j+1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace abc173c
{
    class Program
    {
        static void Main(string[] args)
        {
            var ln1 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var H = ln1[0];
            var W = ln1[1];
            var K = ln1[2];
            var cells = Enumerable.Repeat(0,H).Select(x => Console.ReadLine()).ToArray();

            var ans = 0;

            // マスクパターン
            for (var mr = 0; mr < (1 << H); ++mr) {
                for (var mc = 0; mc < (1 << W); ++mc) {
                    int black = 0;

                    // マスクの全要素を探索
                    for (var r = 0; r < H; ++r) {
                        for (var c = 0; c < W; ++c) {
                            // マスクがかかっているセルはスキップ
                            if (((mr >> r) & 1) == 1) continue;
                            if (((mc >> c) & 1) == 1) continue;
                            // 空いてるマスが#ならカウントアップ
                            if (cells[r][c] != '#') continue;

                            ++black;
                        }
                    }
    // Console.WriteLine("[ {0} {1} ] {2}", Convert.ToString(mr, 2).PadLeft(H,'0'), Convert.ToString(mc, 2).PadLeft(W,'0'),black);
                    
                    if (black == K) {
                        ++ans;
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }
}


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

int main() {
	int n,m,i,j,t[128]={};
	char a,b;
	string s;
	
	while(cin>>n,n){
		s="";
		for(i=0;i<128;++i)t[i]=i;
		for(i=0;i<n;++i){
			cin>>a>>b;
			t[a]=b;
		}
		cin>>m;
		for(i=0;i<m;++i){
			cin>>a;
			s+=(char)t[a];
		}
		cout<<s<<endl;
	}
}

Measured memory_bytes: 1324
a , b = map(int,input().split())

a_hairetu = ''
b_hairetu = ''

for i in range(a):
  b_hairetu = b_hairetu + str(b)
b_sin = int(b_hairetu)
  
for i in range(b):
  a_hairetu = a_hairetu + str(a)
a_sin = int(a_hairetu)

if a>=b:
  print(b_sin)
else:
  print(a_sin)


Measured memory_bytes: 3060
// C: Travelling Plan
// OK
"use strict";

const DEBUG_MODE = false;
const INPUT_LIST_LENGTH_INDEX = 0;
const INPUT_LIST_INDEX = 1;
const INPUT_LIST_DELIMITER = " ";

const inputRaw = DEBUG_MODE
  ? "6\n-679 -2409 -3258 3095 -3291 -4462".split("\n")
  : require("fs")
      .readFileSync("/dev/stdin", "utf8")
      .trim()
      .split("\n");
const inputListLength = parseInt(inputRaw[INPUT_LIST_LENGTH_INDEX]);
const inputList = inputRaw[INPUT_LIST_INDEX].split(INPUT_LIST_DELIMITER).map(
  item => parseInt(item)
);

const process = (inputList, inputListLength) => {
  // memoize!
  let paddedList = [0, ...inputList, 0];

  let totalSteps = 0;

  // index 1 until last the padded 0 suffix
  for (let i = 1; i < inputListLength + 2; i++) {
    totalSteps = totalSteps + Math.abs(paddedList[i] - paddedList[i - 1]);
  }

  // from the total steps,
  // 1. subtract the distance of path to and from the skipped node
  // 2. add the distance from the path before the skipped node to the node after the skipped node
  for (
    let skippedIndex = 1;
    skippedIndex < inputListLength + 1;
    skippedIndex++
  ) {
    // subtracted path is distance(i-1, i) to distance (i, i+1)
    const itemBeforeSkipped = paddedList[skippedIndex - 1];
    const skipped = paddedList[skippedIndex];
    const itemAfterSkipped = paddedList[skippedIndex + 1];

    const pathToSkippedIndex = Math.abs(skipped - itemBeforeSkipped);
    const pathFromSkippedIndex = Math.abs(skipped - itemAfterSkipped);

    const pathToSubtract = Math.abs(pathToSkippedIndex + pathFromSkippedIndex);
    const pathToAdd = Math.abs(itemBeforeSkipped - itemAfterSkipped);

    console.log(totalSteps - pathToSubtract + pathToAdd);
  }
};

process(inputList, inputListLength);


Measured memory_bytes: 31500
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

long t, a, b, c, d;

//gcd
long gcd(long a, long b){
	if(b > a){
		std::swap(a, b);
	}
	if(a % b == 0){
		return b;
	}else{
		return gcd(b, a%b);
	}
}

void solve(){
	scanf("%ld%ld%ld%ld", &a, &b, &c, &d);
	long g = gcd(b, d);
	if(a >= b && a % g + d >= b){
		if(a - c - 1 < 0){
			a += ((c-1)/d + 1) * d;
		}
		if((a - c - 1) % g + c + 1 >= b){
			printf("Yes\n");
			return;
		}
	}
	printf("No\n");
	return;
}

int main(){
	scanf("%ld", &t);
	for(int i = 0; i < t; i++){
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<string>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::map<std::string, int> m;
  int N; std::cin >> N;
  for(int i = 0; i < N; ++i) {
    std::string s; std::cin >> s;
    std::sort(s.begin(), s.end());
    ++m[s];
  }
  int64_t ans = 0;
  for(auto k: m) ans += (int64_t)k.second*(k.second-1)/2;
  fin(ans);
  return 0;
}


Measured memory_bytes: 11136
#include <algorithm>
#include <functional>
#include <iostream>
#include <set>
#include <utility>
#include <vector>

using namespace std;

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

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

    vector<pair<int, int>> q(n);
    for (int i = 0; i < n; i++) {
        q[i] = make_pair(p[i], i + 1);
    }

    sort(q.begin(), q.end(), greater<pair<int, int>>());

    multiset<int> s;
    s.insert(0);
    s.insert(0);
    s.insert(n + 1);
    s.insert(n + 1);

    long long res = 0;
    for (int i = 0; i < n; i++) {
        multiset<int>::iterator j = s.lower_bound(q[i].second);
        j--; j--;
        long long w = *j; j++;
        long long x = *j; j++;
        long long y = *j; j++;
        long long z = *j;

        res += q[i].first * ((x - w) * (y - q[i].second) + (q[i].second - x) * (z - y));
        s.insert(q[i].second);
    }

    cout << res << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define N 100010
int n;
int a[N];
vector<int> A[N];
int f[N];
int B[N];

void end() {
	puts ("NO");
	exit(0);
}

void ff(int x, int y) {
	for (vector<int>::iterator i = A[x].begin(); i != A[x].end(); i ++)
		if (*i != y) ff(*i, x);
	int c = 0;
	ll S = 0;
	for (vector<int>::iterator i = A[x].begin(); i != A[x].end(); i ++)
		if (*i != y) {
			B[c++] = f[*i];
			S += f[*i];
		}
	if (c == 0) {
		f[x] = a[x];
		return;
	}
	if (S < a[x]) end();
	ll w = S-a[x];
	if (a[x] < w) end();
	sort(B, B+c);
	ll ma = S/2;
	ma = min(ma, S-B[c-1]);
	if (ma < w) end();
	f[x] = a[x]-w;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i ++) cin >> a[i];
	for (int i = 1; i < n; i ++) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		A[x].pb(y);
		A[y].pb(x);
	}
	if (n == 2) {
		puts (a[0] == a[1]?"YES":"NO");
		return 0;
	}
	int r = 0;
	for (int i = 0; i < n; i ++)
		if ((int) A[i].size() > 1) r = i;
	ff(r, -1);
	puts (f[r] == 0?"YES":"NO");
	return 0;
}

Measured memory_bytes: 12160
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	string S;
	cin >> S;
	if (S[S.size() - 1] == 's') {
		cout << S << "es" << endl;
	}
	else {
		cout << S << "s" << endl;
	}

}

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

#define ll long long
#define pb push_back
#define mp make_pair

void solve(){

	int x;
	int n;
	cin >> x >> n;
	int a[105] = {0};
	for(int i = 0;i<n;i++){
		int b;
		cin >> b;
		a[b] = 1;
	}
	int l,r;
	l = x;
	r = x;
	for(int i = 0;i<100;i++){
		if(l<0){
			cout << l << endl;
			break;
		}
		if(a[l] == 0){
			cout << l << endl;
			break;
		}
		if(a[r] == 0){
			cout << r << endl;
			break;
		}
		l--;
		r++;
	}

    
}


int main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);

    ll T;
    T = 1;
    //cin >> T;
    while(T--){
        solve();
    }

   
    

}


Measured memory_bytes: 3648
def euclid(a, b):
    if a == b:
        return a
    elif b > a:
        return euclid(b, a)
    else:
        while b > 0:
            temp = a % b
            a = b
            b = temp
        return a


d = {}
def euclid_memo(a, b):
    if a > b:
        c = b
        b = a
        a = c
    if a in d:
        if not b in d[a]:
            d[a][b] = euclid(a, b)
    else:
        d[a] = {}
        d[a][b] = euclid(a, b)
    return d[a][b]

def calc(K):
    x = 0
    for i in range(1, K + 1):
        for j in range(1, K + 1):
            for k in range(1, K + 1):
                d = euclid_memo(i, j)
                e = euclid_memo(d, k)
                x += e
    return x


K = int(input())
print(calc(K))

Measured memory_bytes: 68864
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
    }
    let mut sum = 0;
    for i in 1..n+1 {
        sum += i;
        if sum >= n {
            let ng = sum-n;
            for j in 1..i+1 {
                if j != ng {
                    println!("{}", j);
                }
            }
            return;
        }
    }
}


Measured memory_bytes: 4352
const binarySearch = (key, arr, N) => {
  let mid;
  let left = 0;
  let right = N;
  if (key < arr[0] || arr[N-1] < key) return 0;
  while (left < right) {
    mid = Math.floor((left + right) / 2);
    if (key < arr[mid]) right = mid;
    else if (key > arr[mid]) left = mid + 1;
    else return 1;
  }
  return 0;
}


(function() {
  const input = require('fs').readFileSync('/dev/stdin', 'utf8');
  const Arr = (input.trim()).split("\n");
  const N1 = Number(Arr[0]);
  const arr1 = Arr[1].split(" ").map(Number);
  // const N2 = Number(Arr[2]);
  const arr2 = Arr[3].split(" ").map(Number);
  const summing = (a, b) => a + b;
  console.log(arr2.map(e => binarySearch(e, arr1, N1)).reduce((a, b) => a + b, 0));
})();



Measured memory_bytes: 34936
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;

int main(){
  string t,p;
  cin>>t;
  cin>>p;
  for(int i=0;i<(int)t.size()-(int)p.size()+1;i++){
    int j;
    for(j=0;j<(int)p.size();j++){
      if(t[i+j]!=p[j])break;
    }
    if(j==(int)p.size()) cout<<i<<endl;
  }
  return 0;
}



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

int main(){
  int A,B,ans;
  cin >> A >> B;
  ans=A+B;
  if(ans<A-B){
    ans=A-B;
  }
  if(ans<A*B){
    ans=A*B;
  }

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

Measured memory_bytes: 256
//
// Created by 倉澤　一詩 on 2020/04/03.
//
#include <iostream>
#include <string>


int main(){

    std::string s;
    std::getline(std::cin, s);

    uint64_t index = s.length();

    uint64_t i = 0;
    while (i < index) {

        if (s.substr(s.length()-5) == "dream"){
            for (int j = 0; j < 5; ++j) {
                s.pop_back();
            }
            i += 5;

        } else if (s.substr(s.length()-5) == "erase"){
            for (int j = 0; j < 5; ++j) {
                s.pop_back();
            }
            i += 5;

        } else if (s.substr(s.length()-6) == "eraser"){
            for (int j = 0; j < 6; ++j) {
                s.pop_back();
            }
            i += 6;

        } else if (s.substr(s.length()-7) == "dreamer"){
            for (int j = 0; j < 7; ++j) {
                s.pop_back();
            }
            i += 7;

        } else {

            std::cout << "NO";
            return 0;
        }

    }

    std::cout << "YES";

    return 0;
}


Measured memory_bytes: 512
N = int(input())
cnt = 0
for i in range(1,N+1) :
    if i % 3 == 0 and i % 5 == 0 :
        pass
    elif i % 3 == 0 :
        pass
    elif i % 5 == 0 :
        pass
    else :
        cnt += i
print(cnt)

Measured memory_bytes: 9108
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}

int main() {
  int n;
  cin>>n;
  if(n<=999){
    cout<<"ABC"<<endl;
    return 0;
  }
  cout<<"ABD"<<endl;
}    


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main{
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N=scanner.nextInt();
    int H[] = new int[100];
    int ans=1;
    int flg=0;

    for(int i=0;i<N;i++){
      H[i]=scanner.nextInt();
    }
    for(int i=1;i<N;i++){
      flg=0;
      for(int j=0;j<=i-1;j++){
        if(H[j]>H[i]){
          flg=1;
          break;
        }
      }
      if(flg==0) ans++;
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 21716
module Main;

import std.stdio;
import std.string;
import std.conv;
import std.array;
import std.math;
import std.algorithm;



void main() {
    string input;
    immutable limitList = 50022;
    bool[] listPrimeNumber = new bool[](limitList);
    int number, primeNumberSmaller, primeNumberBigger;

    listPrimeNumber.fill(true);
    foreach (i; 2..limitList.to!double.sqrt.to!int) {
        if (listPrimeNumber[i]) {
            for (int j = i*2; j < limitList; j += i) listPrimeNumber[j] = false;
        }
    }

    while ((input = readln.chomp).length != 0) {
        number = input.to!int;

        primeNumberSmaller = getPrimeNumber(listPrimeNumber, number, false);
        primeNumberBigger  = getPrimeNumber(listPrimeNumber, number, true);

        writeln(primeNumberSmaller, " ", primeNumberBigger);
    }
}

int getPrimeNumber(in bool[] list, in int input, in bool flagBigger) {
    int temp;
    if (flagBigger) {
        temp = input + 1;
    } else {
        temp = input - 1;
    }

    if (list[temp]) {
        return temp;
    } else {
        return getPrimeNumber(list, temp, flagBigger);
    }
}

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

typedef long long ll;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define yes "Yes"
#define yse "Yes"
#define no "No"

#define pb push_back
#define mp make_pair

#define NIL -1

#define list_itr list<ll>::iterator

#define rep(i, l, n) for (int i = (l); i < (n); i++)
#define rep_cs(i, l, n) for (int i = (l); i <= (n); i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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;
}

const int MOD = 1000000007;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(v.begin(), v.end());
// int sum = accumulate(v, v + v.size(), 0);

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

bool binary_search(int a[], int n, int key)
{
    int l = 0;
    int r = n;
    int middle;
    while (l < r)
    {
        middle = (l + r) / 2;
        if (key == a[middle])
        {
            return true;
        }

        if (key > a[middle])
        {
            l = middle + 1;
        }
        else if (key < a[middle])
        {
            r = middle;
        }
    }
    return false;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

void com_init()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long combination(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_C = 1000;
long long Com[MAX_C][MAX_C];

void combination_for_small()
{
    memset(Com, 0, sizeof(Com));
    Com[0][0] = 1;
    for (int i = 1; i < MAX_C; ++i)
    {
        Com[i][0] = 1;
        for (int j = 1; j < MAX_C; ++j)
        {
            Com[i][j] = (Com[i - 1][j - 1] + Com[i - 1][j]) % MOD;
        }
    }
}

int main()
{
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;

    if (s == u)
    {
        a--;
    }
    else if (t == u)
    {
        b--;
    }
    cout << a << " " << b << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){    

    vi v(5);
    fo(i,5) cin>>v[i];
    fo(i,5){
    	if(v[i]==0){
    		cout<<i+1;
    		break;
    	}
    }
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 3624
use std::collections::HashMap;
fn main() {
    let n = read::<usize>();
    let mut hm = HashMap::new();
    for _ in 0..n {
        let a = read::<u32>();
        let c = hm.entry(a).or_insert(0);
        *c += 1;
    }
    let ans = hm.into_iter().filter(|&(_, v)| v % 2 != 0).count();
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 8444
M =[]
H,W = map(int, input().split())  
tate=[False]*H
yoko=[False]*W
for i in range(H):
    M.append(list(input()))

for i in range(H):
    for j in range(W):
        if M[i][j]=='#':
            tate[i]=True
            yoko[j]=True

for i in range(H):
    if tate[i]:
        out = ''
        for j in range(W):
            if yoko[j]:
                out = out + M[i][j]
        print(out)





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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)
#define REP(i, n, m) for (long long i = (long long)(n); i < (long long)(m); i++)

namespace solver {
  using namespace std;
  typedef long long ll;

  ll N, W, ws[110], vs[110], dp[2][100010];

  void init() {
    cin >> N >> W;
    rep(i, N) cin >> ws[i] >> vs[i];
  }

  void solve() {
    ll V = 100000;
    rep(j, V+1) dp[0][j] = LINF;
    dp[0][0] = 0;
    rep(i, N) rep(j, V+1) {
      if(j<vs[i]) dp[(i+1)%2][j] = dp[i%2][j];
      else dp[(i+1)%2][j] = min(dp[i%2][j], dp[i%2][j-vs[i]]+ws[i]);
    }
    ll ans = 0;
    rep(j, V+1) if(dp[N%2][j] <= W) ans = max(ans, j);
    cout << ans << endl;
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<char> c(N);
    int i = 0;
    int R = 0;
    for(i=0;i<N;i++){
        cin >> c.at(i);
        if(c.at(i) == 'R'){
            R++;
        }
    }
    int count = 0;
    for(i=0;i<R;i++){
        if(c.at(i) == 'W'){
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 3584