akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.ParseException;
import java.util.Arrays;
import java.util.Collections;

class Main{
	public static void main(String[] a)throws ParseException , IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in ));
		Integer[] mountainHeight = new Integer[10];
	for (int i = 0 ; i <= 9 ; i++) {
mountainHeight[i] = Integer.valueOf(br.readLine());
	}
	Arrays.sort(mountainHeight , Collections.reverseOrder());
	
	for(int i = 0; i < 3 ; i++){
		System.out.println(mountainHeight[i]);
	}
	}
}

Measured memory_bytes: 24396
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
 
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
vint G[2222];
int par[2222];
int A[2222];

constexpr int SIZE=2222;
int dep[SIZE],hev[SIZE],pos[SIZE],head[SIZE],sz[SIZE],r[SIZE],num[SIZE];
vint lis[SIZE];
void dfs(){
    vint vs={0};
    dep[0]=0;
    rep(i,N){
        int v=vs[i];
        for(auto u:G[v]){
            dep[u]=dep[v]+1;
            vs.pb(u);
        }
    }

    for(int i=vs.size()-1;i>=0;i--){
        int v=vs[i];
        sz[v]=1;
        hev[v]=-1;
        int ma=0;
        for(auto u:G[v]){
            if(u==par[v])continue;
            if(ma<sz[u]){
                ma=sz[u];
                hev[v]=u;
            }
            sz[v]+=sz[u];
        }
    }
}


void init(){
    dfs();
    int idx=0;
    rep(i,N){
        if(~par[i]&&hev[par[i]]==i)continue;
        if(par[i]!=-1)r[i]=r[head[par[i]]]+1;
        for(int j=i;~j;j=hev[j]){
            lis[i].pb(j);
            head[j]=i;
            pos[j]=idx++;
            r[j]=r[i];
        }
        reverse(all(lis[i]));
    }
}

bool isfree(int v){
    int k=head[v];
    if(dep[lis[k][0]]-num[k]<dep[v])return false;
    return true;
}

vint ans;
void query(int v){
    ans.pb(v);
    int ei=A[0];
    while(v!=-1){
        swap(ei,A[v]);
        v=par[v];
    }
}

signed main(){
    cin>>N;
    par[0]=-1;
    for(int i=1;i<N;i++){
        cin>>par[i];
        G[par[i]].pb(i);
    }
    rep(i,N)cin>>A[i];
    
    
    init();
    
    for(int d=9;d>=0;d--){
        while(true){
            if(isfree(0)&&r[A[0]]==d){
                int k=head[A[0]];
                int w=num[k];
                while(w>0&&A[lis[k][w-1]]<A[0])w--;
                query(lis[k][w]);
                num[k]++;
                continue;
            }
            
            int v=-1;
            rep(i,N){
                if(r[A[i]]!=d)continue;
                if(!isfree(i))continue;
                if(v==-1||dep[v]<dep[i])v=i;
            }
            if(v==-1)break;
            query(v);
        }
    }
    cout<<ans.size()<<endl;
    for(auto a:ans)cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1LL << 61);
const int inf = 1001001001;
const int mod = 1000000007;

ll dp[1005][1005];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, w;
	cin >> h >> w;
	vector<vector<char>> a(h, vector<char>(w));
	rep(i, h)rep(j, w) cin >> a[i][j];
	dp[0][0] = 1;
	rep(i, h)rep(j, w) {
		if (a[i][j] == '#') continue;
		if(i + 1 < h && a[i + 1][j] == '.') (dp[i + 1][j] += dp[i][j]) %= mod;
		if(j + 1 < w && a[i][j + 1] == '.') (dp[i][j + 1] += dp[i][j]) %= mod;
	}
	cout << dp[h-1][w-1] % mod << endl;
	return 0;
}

Measured memory_bytes: 9088
a=[]
n=int(input())
m=n
if n%2==0:
    m+=1
for i in range(1,n+1):
    for j in range(i+1,n+1):
        if i+j!=m:
            b=(i,j)
            a.append(b)
print(len(a))
for i in a:
    print(str(i[0])+" "+str(i[1]))

Measured memory_bytes: 3592
n,x,y = map(int,input().split())
x -= 1
y -= 1
def d(i,j):
    return min(abs(i-x) + abs(j-y) + 1, j-i)
ans = [0] * (n-1)
for i in range(n-1):
    for j in range(i+1,n):
        ans[d(i,j) - 1] += 1
for i in ans:
    print(i)


Measured memory_bytes: 47452
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 1e17;
const ll fact_table = 800008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
// priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
// #define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
 
//ll mod = 998244353;
ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,ans,a,b,c,d,e,h,r,l,q;
ll k;
ll x[500005], y[500005], z[500005];
char s[500005], t[500005];
ll dp[1005][40005];


int main(){
    cin >> h >> n;
    for(ll i=0;i<n;i++){
        cin >> x[i] >> y[i];
    }
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<=3*h+10000;j++){
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    for(ll i=1;i<=n;i++){
        for(ll j=0;j<=3*h+10000;j++){
            if(j - x[i-1] < 0){
                dp[i][j] = dp[i-1][j];
            }else{
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-x[i-1]] + y[i-1]);
                dp[i][j] = min(dp[i][j], dp[i][j-x[i-1]] + y[i-1]);
            }
        }
    }
    ll ans = INF;
    for(ll i=h;i<=3*h+10000;i++){
        ans = min(ans, dp[n][i]);
    }
    p(ans);
    return 0;
}


















Measured memory_bytes: 317696
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define reps(i,n) for(int i=1;i<=int(n);i++)
#define sint(i) scanf("%d",&i);
#define sintt(i,j) scanf("%d%d",&i,&j);
#define sinttt(i,j,k) scanf("%d%d%d",&i,&j,&k);
#define sintttt(i,j,k,m) scanf("%d%d%d%d",&i,&j,&k,&m);
 
#define INF 1010000000
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
 
class S{
    public:
    int a,b,c,d;
    int n;
    S(int p,int n,int t,int k,int i):a(p),b(n),c(t),d(k),n(i){}
     
};
 
char visit[51][51][51][51];
 
int main(){
    while(1){
        int n,m;
        sintt(n,m);
        if(n==0)break;
        int a,b,c,d;
        sintttt(a,b,c,d);
         
        int masu[51][51];
         
        rep(i,51)rep(j,51)masu[j][i]=0;
        reps(i,m){
            reps(j,n){
                sint(masu[j][i]);
            }
        }
         
        queue<S> que;
        que.push(S(a,b,c,d,0));
        rep(i,51)rep(j,51)rep(k,51)rep(p,51)visit[i][j][k][p]=0;
        int ans=0;
        while(1){
            if(que.empty()==1){
                break;
            }
             
             
            S u=que.front();
            que.pop();
             
            //printf("%d %d  %d %d  %d\n",u.a,u.b,u.c,u.d,u.n);
             
            if(visit[u.a][u.b][u.c][u.d]==1){
                continue;
            }
            visit[u.a][u.b][u.c][u.d]=1;
		
		if(u.n>100)break;
             
            if(u.a==u.c && u.b==u.d){
                ans=u.n;
                break;
            }
             
            rep(i,4){
                int dx1=u.a+dx[i];
                int dy1=u.b+dy[i];
                 
                int dx2=u.c+dx[i]*-1;
                int dy2=u.d+dy[i]*-1;
                 
                //printf("push %d %d %d %d\n",dx1,dy1,dx2,dy2);
                 
                if(dx1<=0 || dy1<=0 || dx1>n ||dy1>m|| masu[dx1][dy1]==1){
                    dx1-=dx[i];
                    dy1-=dy[i];
                }
                if(dx2<=0 || dy2<=0 || dx2>n ||dy2>m|| masu[dx2][dy2]==1){
                    dx2-=dx[i]*-1;
                    dy2-=dy[i]*-1;
                }
                 
                //printf("push %d %d %d %d\n",dx1,dy1,dx2,dy2);
                que.push(S(dx1,dy1,dx2,dy2,u.n+1));
            }
        }
        if(ans==0){
            puts("NA");
        }else{
            printf("%d\n",ans);
        }
    }
}

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

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


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

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

    ll a,b,k;
    cin>>a>>b>>k;
    ll t=min(a,k);
    a-=t;
    k-=t;
    b-=min(b,k);
    cout<<a<<' '<<b;
    return 0;
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') cnt++;
    }

    if (cnt >= n / 2 + 1) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;   
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map> 
#include <algorithm>
#include <cstring>

#define ll long long
using namespace std; 

void solve(){
    string S; 
    cin  >> S; 
    if(S[1]=='R'){
      if(S[0]=='R' && S[2]=='R'){
        cout << 3 << "\n"; 
      }else if(S[0]=='R' || S[2]=='R'){
        cout << 2 << "\n"; 
      }else{
        cout << 1 << "\n"; 
      }
    }else{
      cout << (S[0]=='R' || S[2]== 'R' ? 1: 0)<< "\n"; 
    }
} 

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

Measured memory_bytes: 3588
#include<iostream>
#include<math.h>
#include<string>
using namespace std;

#define rep(i,n) for(i=0;i<N;i++)

int main(){
    int N;
    int i;
    int fo=0;
    int sum=0;
    cin>>N;
    int a,b;
    cin>>a>>b;
    string rank;
    cin>>rank;
    rep(i,N){
        if(rank[i]=='a' && sum<a+b){
            cout<< "Yes"<<endl;
            sum++;
        }else if(rank[i]=='b' && sum<a+b && fo<b){
            cout<<"Yes"<<endl;
            sum++;
            fo++;
        }else{
            cout<<"No"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1000000000
#define  pow(x) pow(10,(x)) 
typedef long long int LL;

int main(){
    string S; cin >> S;
    int cou = 0;
    rep(i,S.size()){
        if(S[i] == 'o'){
            cou++;
        }
    }
    if(8 - cou <= 15 - S.size()){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
import numpy as np
n = int(input())
def prime():
    counter = 0
    primes = [2, 3]

    for n in range(5, 55555, 2):
        isprime = True
        for i in range(1, len(primes)):
            counter += 1
            if primes[i] ** 2 > n:
                break
            counter += 1
            if n % primes[i] == 0:
                isprime = False
                break
        if isprime:
            primes.append(n)
    return primes
primes_list = prime()
cnt = 0
res = []
for i in range(len(primes_list)):
    if primes_list[i] % 5 == 1:
        res.append(primes_list[i])
        cnt += 1
        if cnt == n:
            break
for i in range(n):
    print(res[i], end=' ')

Measured memory_bytes: 14432
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>

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

typedef long long ll;

using namespace std;
int main(){
    int N, M;
    cin >> N >> M;
    int ans[N];
    REP(i, N)
    {
    	ans[i] = 0;
    }
    REP(i, M)
    {
    	int a, b;
    	cin >> a >> b;
    	a--;
    	b--;
    	ans[a]++;
    	ans[b]++;
    }
    
    REP(i, N)
    {
    	cout << ans[i] << endl;
    }
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
a.append(0)
for i in range(len(b)):
    p=b[i]
    if p>=a[i]:
        ans+=a[i]
        p-=a[i]
    else:
        ans+=p
        p=0
    if p>=a[i+1]:
        ans+=a[i+1]
        a[i+1]=0
    else:
        ans+=p
        a[i+1]-=p
print(ans)
    

Measured memory_bytes: 18624
#include<iostream>
#include<algorithm>
using namespace std;
int s[200005],sum,n,x,k;
int cmp(int a,int b){
	return a>b;
}
int main(){
	cin >> n >> k;
	for(int i=1;i<=n;i++){
		cin >> x;
		s[x]++;
	}
	sort(s+1,s+n+1,cmp);
	for(int i=k+1;s[i];i++){
		sum+=s[i];
	}
	cout << sum;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  int n;
  string s;
  cin>>n>>s;
  int l = s.size();
  int result = 0;
  REP(i,n){
    string t;
    cin>>t;
    int shift = 0;
    while(l+shift*(l-1)<=t.size()){
      int sz = l+shift*(l-1);
      int iter = 0;
      while(iter <= t.size()-sz){
        if(t[iter] == s[0]){
          int iter2 = 1;
          while(iter2 < l){
            if(t[iter + iter2*(shift+1)] != s[iter2]){
              break;
            }
            ++iter2;
          }
          if(iter2 == l){
            iter = -1;
            break;
          }
        }
        ++iter;
      }
      if(iter==-1){
        ++result;
        break;
      }
      ++shift;
    }
  }
  cout<<result<<endl;
  return 0;
}

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

long long A[200000];
long long F[200000];
int main(void){
    int N;
    long long K;
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    for(int i = 0; i < N; i++){
        cin >> F[i];
    }
    sort(A, A + N);
    reverse(A, A + N);
    sort(F, F + N);
    
    if(accumulate(A, A + N, (long long) 0) <= K){
        cout << 0 << endl;
        return 0;
    }
    long long left = 0;
    long long right = 1000000000000;
    while(left + 1 < right){
        long long mid = (left + right) / 2;
        long long training_num = 0;
        for(int i = 0; i  < N; i++){
            if(mid < A[i] * F[i]){
                long long diff = A[i] * F[i] - mid;
                if(diff % F[i] == 0){
                    training_num += diff / F[i];
                } else {
                    training_num += diff / F[i] + 1;
                }
            }
        }
        if(training_num <= K){
            right = mid;
        } else {
            left = mid;
        }
    }
    cout << right << endl;
    
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lli long long
#define mp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define MOAE                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);

int main()
{
    MOAE;
    ll n, sum = 0;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        if (i % 3 == 0 || i % 5 == 0)
            continue;
        sum += i;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3652
#include <iostream>

int main()
{
	int K;
	int array[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

	std::cin >> K;

	std::cout << array[K-1];

	return 0;
}


Measured memory_bytes: 3600
N = int(input())
S = input()
ans = [0] * (N + 1)  # ansはi番目までのxの値をメモする配列
for i in range(N):
	if S[i] == "I":
		ans[i + 1] = ans[i] + 1
	if S[i] == "D":
		ans[i + 1] = ans[i] - 1
print(max(ans))


Measured memory_bytes: 3060
#include <map>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>

#define mod 1000000007
#define ll long long int
#define ld long double
#define gch(ch) scanf("%c",&ch)
#define gcharr(arr,n) FOR(i,0,n) gch(arr[i])

#define gi(x) scanf("%d",&x)
#define gi2(x,y) scanf("%d %d",&x,&y)
#define gi3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define pi(x) printf("%d ",x)

#define gll(x) scanf("%lld",&x)
#define gll2(x,y) scanf("%lld %lld",&x,&y)
#define gll3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define pll(x) printf("%lld ",x)

#define gld(x) scanf("%lf",&x)
#define pld(x) printf("%ld ",x)

#define pline printf("\n")
#define fori(i,a,b,c) for(ll i=a;i<b;i+=c)
#define ford(i,a,b,c) for(ll i=a;i>=b;i-=c)
#define mst(a,b) memset(a,b,sizeof a)
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define SYNC ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
using namespace std;
ll gcd (ll a,ll b)
{
    if(b!=0)
        return gcd(b,a%b);
    else
        return a;
}

ll power(ll a,ll b)
{
    if(b==0)
    return 1;
    if(b==1)
    return a;
    if(b%2==0)
    {
        ll t=power(a,b/2);
        return t*t;

    }
    else
    {
        ll t=power(a,b/2);
        return a*t*t;
    }
}
ll powin(ll a,ll b)
{
    if(b==0)
        return 1;
    else if(b==1)
    return a;
    else if(b%2==0)
    {
        ll t=powin(a,b/2);
        return (t*t)%mod;
    }
    else
    {
        ll t=powin(a,b/2);
        return (((t*t)%mod)*a)%mod;
    }
}
#define N 100009
vector<int> v[N];
int a[N];
set<int> st;
int vis[N];
void dfs(int x)
{
    vis[x]=1;
    st.insert(x);
    for(int i=0;i<v[x].size();i++)
    {
        if(vis[v[x][i]]==0)
        {
            dfs(v[x][i]);
        }
    }
}

int main()
{
    SYNC
    int n,m;
    cin>>n>>m;
    int  ans=0;
    memset(vis,0,sizeof vis);
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=0;i<m;i++)
    {
        static int x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    set<int>:: iterator it; 
    for(int i=1;i<=n;i++)
    {
        if(vis[i]==0)
        {
            st.clear();
            dfs(i);
            for(it=st.begin();it!=st.end();it++)
            {
                int t=*it;
                if(st.find(a[t])!=st.end())
                {
                    ans++;
                }
                
            }
            
        }
        
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 14208
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define UB upper_bound
#define LB lower_bound
#define all(x) (x).begin(),(x).end()
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define int ll

signed main(){
    int N,W;
    scanf("%lld%lld",&N,&W);
    int m;
    VL w[4];
    REP(i,N){
        int a,b;
        scanf("%lld%lld",&a,&b);
        if(i==0) m = a;
        w[a-m].pb(b);
    }
    REP(i,4) SORT(w[i]),reverse(all(w[i]));
    REP(i,4) w[i].insert(w[i].begin(),0);
    REP(i,4) REP(j,SZ(w[i])-1) w[i][j+1] += w[i][j];

    int ans = 0;
    REP(i,SZ(w[0])){
    REP(j,SZ(w[1])){
    REP(k,SZ(w[2])){
    REP(l,SZ(w[3])){
        if(m*i+(m+1)*j+(m+2)*k+(m+3)*l<=W){
            ans = max(ans,w[0][i]+w[1][j]+w[2][k]+w[3][l]);
        }
    }
    }
    }
    }

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

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;

#define repi(i,a,b) for(ll i = (a); i < (b); i++)
#define rep(i, n) for(ll i = 0; i < (n); ++i)

int main() {
    ll MOD = 1000000007;
    vector<ll> p2(100001);
    vector<ll> p3(100001);
    ll b2 = 1;
    ll b3 = 1;
    rep(i, 100001) {
        p2[i] = b2;
        p3[i] = b3;
        b2 *= 2;
        b3 *= 3;
        b2 %= MOD;
        b3 %= MOD;
    }
    string s;
    cin >> s;
    ll res = 0;
    int c1 = 0;
    rep(i, s.size()) {
        if (s[i] == '1') {
            res += p2[c1] * p3[s.size() - (1 + i)];
            res %= MOD;
            c1++;
        }
    }
    res += p2[c1];
    res %= MOD;
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int main(){
    int l;
    cin >> l;
    vector<int>v;
    for(int i = 0; i <= 22; i++){
        if(l & (1 << i)){
            v.push_back(i);
        }
    }
    reverse(v.begin(), v.end());
    int p = v.size();
    vector<int>val(p + 3);
    val[0] = 1 << v[0];
    for(int i = 1; i < p; i++){
        val[i] = val[i - 1] + (1 << v[i]);
    }
    vector<pair<pair<int, int>, int> >edgelist;
    for(int i = 2; i <= v[0] + 1; i++){
        edgelist.push_back(make_pair(make_pair(i - 1, i), (1 << (i - 2))));
        edgelist.push_back(make_pair(make_pair(i - 1, i), 0));
    }
    for(int i = 1; i < p; i++){
        edgelist.push_back(make_pair(make_pair(v[i] + 1, v[0] + 1), val[i - 1]));
    }
    cout << v[0] + 1 << ' ' << edgelist.size() << '\n';
    for(int i = 0; i < edgelist.size(); i++){
        cout << edgelist[i].first.first << ' ' << edgelist[i].first.second << ' ' << edgelist[i].second << '\n';
    }
    return 0;
}

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

int main(void) {
  int n;
  cin >> n;
  vector<int> A;
  for (int i=0; i<n; i++) {
    int n;
    cin >> n;
    A.push_back(n);
  }

  sort(A.begin(), A.end());

  int k=1;
  for (vector<int>::iterator it=A.begin(); it!=A.end()-1; it++) {
    if (*it != *(it+1)) {
      k++;
    }
  }

  if (k%2 == 1) {
    cout << k << endl;
  } else {
    cout << k-1 << endl;
  }

  return 0;

}


Measured memory_bytes: 892
#include<stdio.h>
#define N 100000

typedef struct {
  int parent;
  int left;
  int right;
} Node;

Node Tree[N];

int getDepth(int x) {
  int depth = 1;
  if(Tree[x].parent == -1) return 0;
  depth += getDepth(Tree[x].parent);
  return depth;
}

int main() {
  int i, j, n, m, k, p;
  int number, depth, child; 

  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    Tree[i].parent = -1;
    Tree[i].left = -1;
    Tree[i].right = -1;
  }
  for(i = 0; i < n; i++) {
    scanf("%d", &number);
    scanf("%d", &m);
    for(j = 0; j < m; j++) {
      scanf("%d", &child);
      Tree[child].parent = number;
      if(j == 0) {
	Tree[number].left = child;
      }
      else {
	Tree[k].right = child;
      }
      k = child;
    }
  }

  for(i = 0; i < n; i++) {
    depth = getDepth(i);
    printf("node %d: parent = %d, depth = %d, ", i, Tree[i].parent, depth);
    if( Tree[i].parent == -1) {
      printf("root, [");
      if(Tree[i].left != -1) {
	printf("%d",Tree[i].left );
	p = Tree[i].left;
	while(Tree[p].right != -1) {
	  printf(", %d", Tree[p].right);
	  p = Tree[p].right;
	    }
      }
      printf("]\n");
    }
  
    else if(Tree[i].left != -1){
      printf("internal node, [");
      if(Tree[i].left != -1) {
	printf("%d",Tree[i].left );
	p = Tree[i].left;
	while(Tree[p].right != -1) {
	  printf(", %d", Tree[p].right);
	  p = Tree[p].right;
	    }
      }
      printf("]\n");
    }
    else printf("leaf, []\n");
  }
  
  return 0;
}

Measured memory_bytes: 3848
al = ["Q"] + [chr(ord('a') + i) for i in range(26)]
n = int(input())
s = ""
while n:
    if n % 26:
        a = n % 26
        n //= 26
    else:
        a = 26
        n //= 26
        n -= 1
    s += al[a]
print(s[::-1])

Measured memory_bytes: 61872
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

ll dp[51][51][2501];

int main(){
    int N, A;
    cin >> N >> A;
    vi x(N);
    rep(i, N)scanf("%d", &x[i]);

    dp[0][0][0] = 1;
    rep(i, N)rep(j, N)rep(k, 2501){
        ll y = dp[i][j][k];
        if(y == 0)continue;
        dp[i + 1][j + 1][k + x[i]] += y;
        dp[i + 1][j][k] += y;
    }

    ll ans = 0;
    FOR(n, 1, N + 1)rep(sm, 2501){
        if(sm%n == 0 && sm / n == A){
            ans += dp[N][n][sm];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back
#define size(v)  (int) v.size()
#define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power_mod(a,mod-2);}    
ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}
ll dp[(1<<16)+3];
int main()
{
	

	fast;
	int n;
	cin>>n;
	vector< vector<int> > a(n,vector<int>(n));

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

	vector<int> dp(1<<n,0);

    dp[0]=1;

	 for(int mask = 0; mask < ((1<<n)-1); mask++)
	 {
            int count_one = __builtin_popcount(mask);
           
            for(int j=0 ;j<n; j++){
            	if(a[count_one][j]){
                	if(!(mask &(1<<j))){
                		dp[mask+(1<<j)] = (dp[mask+(1<<j)]+dp[mask])%mod;
                	}
              }
            }
	 }
	

	cout<<dp[(1<<n)-1]<<endl;


}

Measured memory_bytes: 8448
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<map>
#include<iostream>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
using namespace std;
#define ll long long
#define f(i,a,b) for(int i=a;i<=b;i++)
inline ll read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
#define d read()
ll x=0;
int main(){
	x=d;
	f(i,-200,400){
		f(j,-200,400){
			if(pow((i-100),5)-pow((j-100),5)==x){cout<<i-100<<" "<<j-100;return 0;}
		}
	}
	return 0;
}


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

ll gcd(ll a, ll b) {
  return b ? gcd(b, a % b) : a;
}

int main() {
  ll a, b;
  cin >> a >> b;
  
  ll g = gcd(a, b);
  
  cout << (a * b / g) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  long long a,b,r,tmp,x;
  scanf("%lld %lld",&a,&b);
  x=a*b;
  if(a>b){
    tmp=a;
    a=b;
    b=tmp;
  }
  r=b%a;
  while(r!=0){
    b=a;
    a=r;
    r=b%a;
  }
  printf("%lld\n",x/a);
  return 0;
}

Measured memory_bytes: 1728
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

const int MAXN = 101;
const int MAXW = 10001;

int main() {
    int N, W;
    vector<int> v(MAXN);
    vector<int> w(MAXN);
    vector<vector<int> > dp(MAXN, vector<int>(MAXW, 0));
    scanf("%d %d", &N, &W);
    for (int i = 0; i < N; ++i) {
        scanf("%d %d", &v[i], &w[i]);
    }
    
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= W; j++) {
            if (j < w[i]) { dp[i + 1][j] = dp[i][j]; }
            else { dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]); }
        }
    }
    

    printf("%d\n", dp[N][W]);
}

Measured memory_bytes: 6252
N = int(input())

if 1<=N<=9:
    print(N)
    exit()

if 10<=N<=99:
    print(9)
    exit()

if 100<=N<=999:
    print(9+N-99)

if 1000<=N<=9999:
    print(909)
    exit()

if 10000<=N<=99999:
    print(909+N-9999)
    exit()

if N ==100000:
    print(90909)
    exit()


Measured memory_bytes: 38464
N, M = map(int,input().split())
par = [i for i in range(N+1)]
size = [1 for _ in range(N+1)]

def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return 1
    par[x] = y
    size[y] += size[x]
    size[x] = 0

for i in range(M):
    x, y, z= map(int,input().split())
    unite(x,y)

Ans = 0
for j in size[1:]:
    if j != 0:
        Ans += 1
print(Ans)


Measured memory_bytes: 14468
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef int64_t llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64


int main(){
    int a,b;
    cin >> a >> b;
    if( a+b >=10) cout << "error" << endl;
    else cout << a+b << endl;
}



Measured memory_bytes: 256
#include <map>
#include <iostream>
#include <cstdio>
#include <queue>
#include <sstream>
#include <string>
#include <algorithm>

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

char buff[1200];

int main(){
  int n = getInt();
  fgets(buff, sizeof(buff), stdin);

  map<string, int> m;
  const char *tanni[] = {
    "yotta",
    "zetta",
    "exa",
    "peta",
    "tera",
    "giga",
    "mega",
    "kilo",
    "hecto",
    "deca",
    "deci",
    "centi",
    "milli",
    "micro",
    "nano",
    "pico",
    "femto",
    "ato",
    "zepto",
    "yocto",
    NULL
  };

  int t[] = {
    24,21,18,15,12,9,6,3,2,1,-1,-2,-3,-6,-9,-12,-15,-18,-21,-24
  };


  for(int i = 0; tanni[i]; i++)
    m[tanni[i]] = t[i];

  while(n --> 0){
    fgets(buff, sizeof(buff), stdin);

    stringstream ss(buff);

    vector<string> v;
    string s;

    while(ss >> s) v.push_back(s);

    int yuukou = 0;
    int p = 0;

    if(v.size() == 3) p = m[v[1]];

    for(char c : v[0]){
      if(c != '.' && (yuukou != 0 || c != '0'))
	yuukou++;
    }

    int npos = find_if(v[0].begin(), v[0].end(), [](char c){ return c != '.' && c != '0'; }) - v[0].begin();
    int dpos = find(v[0].begin(), v[0].end(), '.') - v[0].begin();

    if(npos > dpos)
      p += dpos - npos;
    else
      p += dpos - npos - 1;

    bool first = true;

    for(char c : v[0]){
      if(c == '0' && first){

      }else if(isdigit(c)){
	putchar(c); yuukou--;
	if(first){
	  first = false;
	  if(yuukou != 0) putchar('.');
	}
      }
    }

    while(yuukou){ putchar('0'); yuukou--; }

    printf(" * 10^%d ", p);

    if(v.size() == 2) puts(v[1].c_str());
    else puts(v[2].c_str());
  }

  return 0;
}

Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int main(){
    int n,sum,count=0;
    while(1){
        cin >> n;
        if(!n)  break;
        for(int i=1;i<=n/2;i++){
            sum = 0;
            for(int j=i;sum<n;j++){
                sum+=j;
                if(sum==n)  count++;
            }
        }
        cout << count << endl;
        count = 0;
    }
    return 0;
}


Measured memory_bytes: 2992
<?php 
  //文字列の切り出し
while ($line = fgets(STDIN)) {
    $tmp[] = trim($line);
}
foreach ($tmp as $key => $value) {
  $array[] = explode(" ", $value);
}
$count = $array[0][0];
$n = 0;
$bool = true;
while ($count > $n) {
    $number = $array[1][$n];
    if ($number % 2 === 0) {
        if ($number % 3 === 0 || $number % 5 === 0) {
            $n++;
            continue;
        } else {
            $bool = false;
            break;
        }
    }
    $n++;
}
if ($bool === false) {
    echo "DENIED";
} else {
    echo "APPROVED";
}


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

int main(void) {
	int a, b, c;
	int ans;

	cin >> a >> b >> c;

	if ((a == b) && (b == c) && (c == a))
		ans = 1;
	else if ((a != b) && (b != c) && (c != a))
		ans = 3;
	else
		ans = 2;

	cout << ans << '\n';
	return 0;
}


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

int64_t MAX = 1000000000000000000;

int main()
{
	int n;
	cin >> n;
	vector<int64_t> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
		if (a.at(i) == 0) {
			cout << 0 << endl;
			return 0;
		}
	}

	int64_t ans = 1;
	for (int i = 0; i < n; i++) {
		int jou = 0;
		int64_t temp1 = ans;
		while (true) {
			temp1 /= 10;
			if (temp1 >= 1) {
				jou++;
			} else {
				break;
			}
		}
		int a_jou = 0;
		int64_t temp2 = a.at(i);
		while (true) {
			temp2 /= 10;
			if (temp2 >= 1) {
				a_jou++;
			} else {
				break;
			}
		}
		if (jou + a_jou >= 18 && ans * a.at(i) != MAX) {
			cout << -1 << endl;
			return 0;
		}
		ans *= a.at(i);
		if (ans > MAX) {
			cout << -1 << endl;
			return 0;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 3964
N = int(input())
L = list(map(int,input().split()))

new_L = sorted(L, reverse = True)

k = 0
j = k + 1
i = j + 1
count = 0

while(k < N):

    while(j < N):

        while(i < N):

            if (new_L[k] < (new_L[j] + new_L[i])):
                if(new_L[k] != new_L[j]) and (new_L[j] != new_L[i]) and (new_L[i] != new_L[k]):
                    count += 1

            i += 1
        
        j += 1
        i = j + 1
    
    k += 1
    j = k + 1
    i = j + 1

print(count)

Measured memory_bytes: 9144
#include<bits/stdc++.h>
using namespace std;
int n;
int a[205][205];
int f[205][205];
int color[205];
int dfs(int x,int col,int pre)
{
    color[x]=col;
    for(int i=1;i<=n;i++)
    {
        if(i==pre)continue;
        if(a[i][x]&&color[i]==col)return 0;
        if(a[i][x]&&color[i]==0)if(!dfs(i,col^1,x)) return 0;
    }
    return 1;
}
int maxx;
int main()
{
    memset(f,0x3f,sizeof f);
    char s[205];
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%s",s+1);
        for(int j=1;j<=n;j++)
        {
            a[i][j]=s[j]-'0';
            f[i][j]=a[i][j];
            if(a[i][j]==0)f[i][j]=1e9;
        }
        f[i][i]=0;
    }
    if(!dfs(1,3,-1))
    {
        cout<<"-1";
        return 0;
    }
    for(int k=1;k<=n;k++)
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
                f[i][j]=min(f[i][j],f[i][k]+f[k][j]);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        maxx=max(maxx,f[i][j]);
    }
    cout<<maxx+1;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 2e6 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;


int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
	ll a, b;
	cin >> a>> b;
	ll g = __gcd(a, b);
	cout << a* b / g << endl;
    return (0) ;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
int Q, A, B;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		cin >> A >> B;
		if (A > B) swap(A, B);
		int l = 0, r = 2000000018;
		while (r - l > 1) {
			int m = ((long long)l + r) >> 1;
			int b = m / 2 + 1;
			long long val = (m & 1 ? 1LL * b * b : 1LL * b * (b - 1));
			if (m >= A * 2 - 2) val = (m & 1 ? 1LL * (b + 1) * b : (m == A * 2 - 2 || m == B * 2 - 2 ? 1LL * (b + 1) * (b - 1) : 1LL * b * b));
			if (m >= B * 2 - 1) val = (m & 1 ? 1LL * (b + 1) * (b + 1) : 1LL * (b + 1) * b);
			if (val >= 1LL * A * B) r = m;
			else l = m;
		}
		cout << l << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int mod = 1000000007;
const int INF = 1001001001;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    vector<int> ans(n+1);
    ans[0] = 1;
    rep(i, 0, m){
        cin >> a[i];
        ans[a[i]] = -INF;
    }
    rep(i, 1, n+1){
        if(ans[i] == -INF){
            ans[i] = 0;
            continue;
        }
        ans[i] = (ans[i-1] + ans[i-2]) % mod;
    }
    cout << ans[n] << endl;
    return 0;
}


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

using namespace std;

void trace(vector<int> a, int n)
{
	for (int i = 0;i < n;i++)
	{
		if (i > 0)cout << " ";
		cout << a[i];
	}
	cout << endl;
}


void insertionSort(vector<int> a, int n)
{
	int j, v;
	for (int i = 1;i < n;i++)
	{
		v = a[i];
		j = i - 1;
		while (j >= 0 && a[j] > v)
		{
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
		trace(a, n);
	}
}

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0;i < N;i++)
		cin >> A[i];

	trace(A, N);
	insertionSort(A, N);
		

	return 0;
}

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


using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    int c = (n-1) * (n-2) / 2;
    if (k > c) {
        cout << -1 << '\n';
        return 0;
    } 
    int m = n - 1 + (c - k);
    cout << m << '\n';
    for (int i=2; i<=n; i++)
        cout << 1 << ' ' << i << '\n';
    m -= n-1;
    for (int i=2; i<=n; i++) {
        for (int j=2; j<i; j++) {
            if (m == 0) break;
            cout << j << ' ' << i << '\n';
            m--;
        }
        if (m == 0) break;
    }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int N, M;
  cin >> N >> M;
  map<int, int> ma;
  rep(i, N) {
    int a; cin >> a;
    ma[a]++;
  }
  rep(i, M) {
    int b, c; cin >> b >> c;
    vector<int> zeros;
    each(m, ma) {
      if (m.first >= c) break;
      int cnt = min(m.second, b);
      ma[m.first] -= cnt;
      b -= cnt;
      ma[c] += cnt;
      if (ma[m.first] == 0) zeros.push_back(m.first);
      if (b == 0) break;
    }
    each(v, zeros) {
      ma.erase(v);
    }
  }
  i64 ans = 0;
  each(v, ma) {
    ans += (i64) v.first * v.second;
  }
  cout << ans << '\n';
}


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

using namespace std;

typedef long long int Int;

int main(void)
{
    Int n,t;
    vector<Int> a;

    cin>>n>>t;
    for(int i = 0;i < n;i++)
    {
	Int temp;
	cin>>temp;

	a.push_back(temp);
    }

    if(n == 1)
    {
	cout<<0<<endl;

	return 0;
    }

    Int m = a[0];
    Int cost = -a[0];
    Int count = 1;
    for(int i = 1;i < n;i++)
    {
	Int temp_cost = a[i] - m;
	if(temp_cost == cost)
	    count++;
	else if(temp_cost > cost)
	{
	    count = 1;
	    cost = temp_cost;
	}
	if(a[i] < m)
	{
	    m = a[i];
	}
    }

    cout<<count<<endl;

    return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	// que[R] = {L, index_of_query};
	// um is map such that um[element] = last index the element was seen
	// s - a set that contains the last index as mentioned above
	// code assumes 0 indexed
	// complexity - O(n*log(n))
	unordered_map<int, int>um;
	pbds s;
	int n,q; cin >>n>>q;
	vector<int>a(n);
	for (auto &it : a)
		cin >> it;

	vector<int>ans(q);
	vector<vector<pair<int, int>>>que(n);
	for (int i = 0; i < q; i++)
	{
		int L, R; cin >> L >> R;
		L--;
		R--;
		que[R].push_back({L, i});
	}
	for (int i = 0; i < n; i++)
	{
		if (um.count(a[i]))
			s.erase(um[a[i]]);
		um[a[i]] = i;
		s.insert(i);
		for (auto it : que[i])
			ans[it.second] = s.size() - s.order_of_key(it.first);
	}
	for (int i = 0; i < q; i++)
		cout << ans[i] << endl;
	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if ((a + b) % 2 == 0) 
    cout << (a + b) / 2 << endl;
  else
    cout << (a + b) / 2 + 1 << endl;
}

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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
	return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
	return a / gcd(a, b) * b;
}

string IntToString(int number)
{
	stringstream ss;
	ss << number;
	return ss.str();
}

llint cnt = 0;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int n;
int b[111];
bool checked[111];

int main()
{
    ci >> n;
    rep(i, n) ci >> b[i];

    stack<int> st;
    int m = n;
    
    while(1) {

	if(st.size() == n) break;

	int idx = 1;
	bool flg = true;
	
	for(int i = n - 1; i >= 0; i--) {
	    if(checked[i]) continue;
	    if(b[i] == m - idx + 1) {
		checked[i] = true;
		st.push(b[i]);
		m--;
		flg = false;
		break;
	    }
	    idx++;
	}

	if(flg) {
	    co << -1 << en;
	    return 0;
	}
    }

    while(st.size() > 0) {
	co << st.top() << en;
	st.pop();
    }
    
    return 0;
}









Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try{
            while(true) {
                String[] buff = br.readLine().split("\\s");
                int n = Integer.parseInt(buff[0]), x = Integer.parseInt(buff[1]), count = 0;
                
                if(n==0&&x==0){
                    break;
                }
                
                for(int a=1; a<=n-2; a++) {
                    for(int b=a+1; b<=n-1; b++){
                        for(int c=b+1; c<=n; c++){
                            if(x==a+b+c) {
                                count++;
                            }
                        }
                    }
                }
                
                System.out.println(String.valueOf(count));
            }
        }catch(IOException e){
            e.printStackTrace();
        }
    }
}


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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  int N;
  cin>>N;
  vector<int> vec(N,1);
  int inst=0;
  int a=0;
  FOR(i,0,N){
    cin>>a;
    if(inst==a){
      vec.at(i)=vec.at(i-1)+1;
      vec.at(i-1)=1;
    }
    else inst=a;
  }
  int res=0;
  FOR(i,0,N){
    res = res+vec.at(i)/2;
  }
  cout<<res<<endl;

}


Measured memory_bytes: 256