akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divCeil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

int main()
{
  string S;
  cin >> S;
  ll N = S.size();
  ll K;
  cin >> K;

  for (ll i = 0; i < N; i++)
  {
    if (S.at(i) == 'a')
      continue;
    ll d = 'z' - S.at(i) + 1;
    if (K >= d)
    {
      S.at(i) = 'a';
      K -= d;
    }
  }
  K %= 26;
  for (ll i = 0; i < K; i++)
  {
    if (S.back() == 'z')
      S.back() = 'a';
    else
      S.back()++;
  }

  cout << S << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


int main() {
    int n, val;
    cin >> n;
    vector<int> arr(n, 0);
    map<int, int> cnt;
    for(int i = 0; i < n; i++) {
        cin >> val;
        cnt[val] += 1;
    }
    if (cnt.size() > 2 || cnt.rbegin()->first-cnt.begin()->first > 1) {
        cout << "No" << endl;
        return 0;
    }
    if (cnt.rbegin()->first >= n) {
        cout << "No" << endl;
        return 0;
    }
    if (cnt.size() == 2) {
        int sm = cnt.begin()->first;
        int big = cnt.rbegin()->first;
        int unique_color = cnt[sm];
        int common_color = big-unique_color;
        if (common_color > 0 && common_color * 2 <= n-unique_color) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else if (cnt.size() == 1) {
        int freq = cnt.begin()->first;
        if (freq == n-1 || freq*2 <= n)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 5376
{-# LANGUAGE BangPatterns #-}

import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C

main :: IO ()
main = do
  s <- getLine
  print $ solve s

solve :: String -> Int
solve s = 2 * n
  where
    n = min (length $ elemIndices '0' s) (length $ elemIndices '1' s)

-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . C.readInteger) . C.words <$> C.getLine

readNIntegers :: Int -> IO [[Integer]]
readNIntegers = flip replicateM readIntegers

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

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

int main()
{
  int n,m;
  cin>>n>>m;
  if(m==0)
  {
    cout<<0<<" "<<0<<endl;
  }
  else
  {
    int a,b;
    a=0;
    b=0;
    vector<int> q(n);
    vector<int> mis(n);
    vector<pair<int,string>> s(m);
    for(int i=0;i<m;i++)
    {
      cin>>s.at(i).first>>s.at(i).second;
    }
    for(int i=0;i<m;i++)
    {
      if(q.at(s.at(i).first-1)==0)
      {
        if(s.at(i).second=="WA")
        {
          b++;
          mis.at(s.at(i).first-1)++;
        }
        else
        {
          a++;
          q.at(s.at(i).first-1)=1;
        }
      }
    }
    for(int i=0;i<n;i++)
    {
      if(q.at(i)==0)
        b-=mis.at(i);
    }
    cout<<a<<" "<<b<<endl;
  }
}

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

int main() {
    char x[1001];
    while (true) {
        scanf("%s", x);
        if (strcmp(x, "0") == 0) break;
        int i = 0;
        int sum = 0;
        while (x[i]) {
            sum += x[i++] - '0';
        }
        cout << sum << endl;
    }
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define MAX_N 1000010
long long inv[MAX_N];
long long factorial[MAX_N];
long long inv_factorial[MAX_N];

void getInv(){
  for (int i = 1; i < MAX_N; i++) {
    if (i == 1) inv[i] = 1;
    else {
      inv[i] = (mod - (mod / i) * inv[mod % i]) % mod;
      if (inv[i] < 0) inv[i] += mod;
    }
  }
}
void getFactorial(){
  factorial[0] = 1; inv_factorial[0] = 1;
  for (int i = 1; i < MAX_N; i++) {
    factorial[i] = factorial[i-1] * i;
    factorial[i] %= mod;
    inv_factorial[i] = inv_factorial[i-1] * inv[i];
    inv_factorial[i] %= mod;
  }
}

long long cal(int n, int r) {
  long long ret = factorial[n] * inv_factorial[n-r];
  return ret % mod;
}

int main() {
    int n, m; cin >> n >> m;
    long long ans = 1;
    getInv();
    getFactorial();
    vector<int> a(n), b(m);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < m; i++) cin >> b[i];
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    for (int i = 0; i < n-1; i++) {
        if (a[i] == a[i+1]) {
            cout << 0 << endl;
            return 0;
        }
    }
    for (int i = 0; i < m-1; i++) {
        if (b[i] == b[i+1]) {
            cout << 0 << endl;
            return 0;
        }
    }
    /*
    vector< vector<int> > v(n, vector<int>(m, 0));
    int p = 0; int q = 0;
    while (p < n && q < m) {
        if (a[p] == b[q]) v[p][q] = a[p];
        if (a[p] > b[q]) p++;
        if (a[p] < b[q]) q++;
    }
    */
    map<int, int> used;
    vector< pair<int, int> > u = {{0, 0}};
    map<int, int> ma;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (a[i] == b[j]) {
               used[a[i]]++;
                continue;
            }
            ma[min(a[i], b[j])]++;
        }
    }
    for (auto it = ma.begin(); it != ma.end(); it++) {
        u.push_back({it->first, it->second});
    }
    sort(u.rbegin(), u.rend()); int mm = n * m;
    int rest = 0; int count = 0;
    for (int i = 0; i < u.size()-1; i++) {
        int p = u[i].first; int q = u[i].second;
        int np = u[i+1].first;
        for (int k = mm; k > p; k--) {
            if (used[k] == 0) {
                cout << 0 << endl;
                return 0;
            }
        }
        mm = p;
        rest += q;
        int count = 0;
        for (int k = mm; k > np; k--) {
            if (used[k] == 0) {
                count++;
            }
        }
        if (used[p] == 1) {
            ans = ans * cal(rest, count) % mod;
        } else {
            ans = (ans * cal(rest-1, count-1) % mod) * q % mod;
        }
        rest -= count;
        mm = np;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 70656
#include<stdio.h>
#include<stdlib.h>
typedef struct{
  int value;
  char sign;
  int order;
} Card;
int partition(Card*,int,int);
void quickSort(Card*,int,int);
int isStable(Card*,int);

int main() 
{
  int i,n;
  Card *a;
  
  scanf("%d",&n);
  a=(Card*)malloc(sizeof(Card)*n);
  
  for(i=0; i<n; i++) {
    scanf(" %c%d",&a[i].sign,&a[i].value);
    a[i].order = i;
  }
  quickSort(a,0,n-1);
  if(isStable(a,n)) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0; i<n; i++) 
    printf("%c %d\n",a[i].sign,a[i].value);
  
  free(a);
  
  return 0;
}

void quickSort(Card a[],int p,int r) 
{
  int q;
  if(p<r) {
    q = partition(a,p,r);
    quickSort(a,p,q-1);
    quickSort(a,q+1,r);
  }
}

int partition(Card a[],int p,int r)
{
  int x,i,j;
  Card tmp;
  x = a[r].value;
  i = p-1;
  for(j=p; j<r; j++) {
    if(a[j].value<=x) {
      i = i+1;
      tmp = a[i];
      a[i] = a[j];
      a[j] = tmp;
    }
  }
  tmp = a[i+1];
  a[i+1] = a[r];
  a[r] = tmp;
  return i+1;
}

int isStable(Card a[],int n) 
{
  int i;
  for(i=0; i<n-1; i++) {
    if(a[i].value==a[i+1].value && a[i].order > a[i+1].order)
      return 0;
  }
  return 1;
}

Measured memory_bytes: 1680
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <math.h>
#include <functional>
#include <algorithm>

typedef long long Int;
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
using namespace std;

Int F(int n){
	if (n == 1)
		return 1;
	return n*F(n - 1);
}

int main(){
	int a;
	cin >> a;
	cout << F(a) << endl;
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;

int main(void)
{
    int R;
    cin >> R;

    if (R < 1200)
    {
        cout << "ABC" << endl;
    }
    else if (R >= 1200 && R < 2800)
    {
        cout << "ARC" << endl;
    }
    else if (R >= 2800)
    {
        cout << "AGC" << endl;
    }
    return (0);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  ll n,t;
  cin>>n>>t;

  //vector<ll> a(n);
  //vector<ll> b(n);

  using pa=pair<ll,ll>;

  vector< pa > pab(n);

  ll ans=0;

  rep(i,n) cin>>pab[i].first>>pab[i].second;

  //sort(begin(pab),end(pab),greater<pa>());
  sort(begin(pab),end(pab));

  vector<ll> a(n);
  vector<ll> b(n);

  rep(i,n){
    a[i]=pab[i].first;
    b[i]=pab[i].second;
  }

  vector<ll> dp( 6001,0 );
  vector<ll> dp_new( 6001,0 );
  dp[0]=0;
  rep(i,n){
    rep(j,6001){
      if( j-a[i]>=0 && j-a[i] < t && dp[j] < dp[j- a[i] ] + b[i] ){
        dp_new[j]=dp[j- a[i] ] + b[i];
      }
    }
    rep(j,6001){
      //if(j==0) dp[j]=0;
      //else dp[j]=max(dp_new[j],dp[j-1]);
      dp[j]=dp_new[j];
    }
    dp_new.resize(6001,0);
  }
  
  ///*
  rep(i,6001){
    //cerr << dp[i] << " " ;
    chmax(ans,dp[i]);
  }
  //cerr << endl;
  //*/
  cout << ans << endl;

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}


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

int main() {
    long N, A, B;
    cin>>N>>A>>B;
    long C = A+B;
    long nokori = N%C;
    if(nokori >= A){
        cout<<A+A*(N/C)<<endl;
    }
    else {
        cout<<nokori+A*(N/C)<<endl;
    }
}


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    if (a+b+c <= 21)
    {
        cout << "win";
    }
    else
    {
        cout << "bust";
    }

    return 0;

}


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

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

const int MOD = 1e+9 + 7;

int main()
{
    int N;
    cin >> N;
    vector<int> T(N), A(N);
    REP(i, N) cin >> T[i];
    REP(i, N) cin >> A[i];

    if(T[N-1] != A[0]){
        cout << 0 << endl;
        return 0;
    }

    int max_height = A[0];
    int max_pos = lower_bound(T.begin(), T.end(), max_height) - T.begin();
    if(A[max_pos] < max_height){
        cout << 0 << endl;
        return 0;
    }
    
    long long ans = 1;
    FOR(i, 1, N-1){
        if(T[i-1] != T[i] or A[i] != A[i+1]) continue;
        ans *= min(T[i], A[i]);
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scanf("%s", &s)

	fmt.Println(check(s))
}

func check(s string) string {
	for _, c := range s {
		if c == '7' {
			return "Yes"
		}
	}
	return "No"
}


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

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	for (int n = 0; n < N; n++) {
		cin >> A.at(n);
	}

	double sum = 0.0;
	for (int n = 0; n < N; n++) {
		sum += 1.0 / (double)A.at(n);
	}

	double sum2 = 1.0 / sum;

	cout << sum2 << endl;

	return 0;
}


Measured memory_bytes: 256
//愚直なDP (証明しやすい)
#include <iostream>
#include <algorithm>
using namespace std;

int INF = 114514;
int n, Ma, Mb;
int a[40], b[40], c[40];
int dp[41][401][401];

int main() {
	int i, j, k;
	
	cin >> n >> Ma >> Mb;
	for (i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];
	
	for (i = 0; i <= n; i++) for (j = 0; j <= 10 * n; j++) for (k = 0; k <= 10 * n; k++) dp[i][j][k] = INF;
	
	dp[0][0][0] = 0;
	for (i = 0; i < n; i++) {
		for (j = 0; j <= 10 * i; j++) {
			for (k = 0; k <= 10 * i; k++) {
				dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
				dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
			}
		}
	}
	
	int ans = INF;
	for (i = 1; i <= 10 * n; i++) {
		for (j = 1; j <= 10 * n; j++) {
			if (Ma * j == Mb * i) {
				ans = min(ans, dp[n][i][j]);
			}
		}
	}
	if (ans >= INF) { cout << -1 << endl; }
	else { cout << ans << endl; }
	
	return 0;
}

Measured memory_bytes: 25984
#include <cstdio>
#include <algorithm>

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

using namespace std;

int a, b, c, d, e, f;

double normalize(double x){
	if(-0.001 < x && x < 0.001){
		return 0;
	}
	return x;
}

int main(){
	while(scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f) != EOF){
		double det = a * e - b * d;
		double x = (e * c - b * f) / det;
		double y = (-d * c + a * f) / det;
		printf("%.3f %.3f\n", normalize(x), normalize(y));
	}
	return 0;
}

Measured memory_bytes: 1068
#include<stdio.h>
#define N 110000

typedef struct process{
    char name[100];
    int time;
} Proc;

Proc P[N];
int head, tail = 0;

void enqueue(Proc p){
    P[tail] = p;
    tail++;
    if(tail >= N){
        tail = 0;
    }
}

Proc dequeue(){
    Proc tmp = P[head];
    head++;
    if(head >= N){
        head = 0;
    }
    return tmp;
}

int isEmpty(){
    return head == tail;
}

void trace(){
    printf("%d %d\n", head, tail);
    for(int i = head; i < tail; i++){
        printf("%s %d\n", P[i].name, P[i].time);
    }
}

int main(){
    int n, q;
    int elapsed = 0;
    scanf("%d %d", &n, &q);

    for(int i = 0; i < n; i++){
        scanf("%s %d", P[i].name, &P[i].time);
    }
    head = 0;
    tail = n;
 //   trace();

    while(!isEmpty()){
        Proc p = dequeue();
        if(p.time > q){
            p.time -= q;
            enqueue(p);
            elapsed += q;
        }else{
            elapsed += p.time;
            printf("%s %d\n", p.name, elapsed);
        }
    }

}

Measured memory_bytes: 12896
#include<bits/stdc++.h>
using namespace std;
int main () {
	int n,a,b,c;
	cin>>n;
	map<int,pair<int,int> >mp;
	map<int,pair<int,int> >::iterator it;
	for(int i=0; i<n; i++) {
		scanf("%d%d%d",&a,&b,&c);
		mp[a]=make_pair(b,c);
	}
	it=mp.begin();
	int x=0,y=0,t=0,x0,y0,t0;
	while(it!=mp.end()) {
		t0=it->first;
		x0=it->second.first;
		y0=it->second.second;
		if(abs(t0-t)%2!=(abs(x-x0)+abs(y-y0))%2||abs(t0-t)<(abs(x-x0)+abs(y-y0))) {
			puts("No");
			return 0;
		}
		x=x0;
		y=y0;
		t=t0;
		it++;
	}
	puts("Yes");
	return 0;
}

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

int n;
const int MAX = 3010;
double moedas[MAX];
double memo[MAX][MAX];

double pd(int i, int k) {
    if(i >= n) return k >= (n/2+1);
    if(memo[i][k] != -1.0) return memo[i][k];
    return memo[i][k] = ((1.0 - moedas[i]) * pd(i+1, k)) + (moedas[i] * pd(i+1, k+1));
}

int main() {
    cin>>n;
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            memo[i][j] = -1.0;
        }
    }
    for(int i = 0; i < n; ++i) {
        cin>>moedas[i];
    }
    double ans = pd(0, 0);
    printf("%.10f\n", ans);
}


Measured memory_bytes: 71040
#include <iostream>
using namespace std;
int main(void){
    int x,y;
    for(int i=0;i<3000;i++){
        cin>>x>>y;
        if(x==0&&y==0){
            break; 
        }
        else if(x>y){
            cout<<y<<" "<<x<<endl;
        }
        else{
            cout<<x<<" "<<y<<endl;
        }
    }
}



Measured memory_bytes: 2988
/**
*    author:  souzai32
*    created: 12.08.2020 15:37:08
**/

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

int main() {

    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);
    sort(a.begin(),a.end());

    int left=1,right=a.at(n-1),mid;
    int count;
    int ans=right;

    while(left<right){
        mid=(left+right)/2;
        count=0;
        for(int i=0; i<n; i++) count+=(a.at(i)-1)/mid;
        if(count<=k){
            ans=min(mid,ans);
            right=mid;
        }
        else left=mid+1;
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4060
import java.util.Scanner;
class Main {
  public static void main(String[] args){
    Scanner input = new Scanner(System.in);
    int a, b, c;
    a = input.nextInt();
    b = input.nextInt();
    c = input.nextInt();

    double rad, l, s, h;
    rad = c * Math.PI / 180.0;
    s = 1 / 2.0 * Math.sin(rad) * a * b;
    l = a + b + Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(rad));
    h = 2 * s / a;

    System.out.println(s + "\n" + l + "\n" + h);
  }
}

Measured memory_bytes: 25984
N,M,X,Y = gets.split.map &:to_i
x = readline.split.map &:to_i
y = readline.split.map &:to_i
x_max = x.max
y_min = y.min


if x_max < y_min && x_max < Y && y_min > X
    puts "No War"
else
    puts "War"
end

Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	const int M = 1000000007;

	var tmp = ReadIntArray();
	int n = tmp[0], m = tmp[1];

	int[] stairs = new int[n+1];
	stairs[0] = stairs[1] = 1;

	bool[] broken = new bool[n+1];
	for (int i = 0; i < m; i++)
	{
	    int a = int.Parse(ReadLine());
	    stairs[a] = 0;
	    broken[a] = true;
	}

	for (int i = 2; i <= n; i++)
	{
	    if (!broken[i])
	    {
		stairs[i] = (stairs[i-1] + stairs[i-2]) % M;
	    }
	}

	WriteLine(stairs[n]);
    }
}


Measured memory_bytes: 13536
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define all(v) v.begin(),v.end()
#define int long long 
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
const int mod = 1000000007;
const double PI = 3.1415926535898;

#define N 100005

const int INF = (1LL << 62) - 1;




int n,m;

vector<pair<int,int>> adj[N];
void dijkstra(vector<pair<int, int>> g[], int source)
{
    vector<int> arrival(N, INF), departure(N, INF);
    vector<int> vis(N), parent(N), ans;
    arrival[source] = 0;
    set<pair<int, int>> s;
    s.insert({0, source});
    while(!s.empty())
    {
        pair<int,int> x = *s.begin();
        int u = x.second;
        s.erase(s.begin());
        vis[u] = 1;
        departure[u] = arrival[u];
        for(auto y: g[u])
        {
              int v = y.first;
              int w = y.second;

            if(arrival[v] > departure[u] + w)
            {
                s.erase({arrival[v], v});
                arrival[v] = departure[u] + w;
                s.insert({arrival[v], v});
                parent[v] = u;
            }
        }
    }


     for(int i = 1; i <= n; i++)
      {
        if(!vis[i])
        {
          cout << "No";
          exit(0);
        }
      }


      cout << "Yes" << endl;

      for(int i = 2; i <= n; i++)
      {
        cout << parent[i] << endl;
      }

}




int32_t main()
{



     

      cin >> n >> m;

      for(int i = 1; i <= m; i++)
      {
        int x,y;
        cin >> x >> y;
        adj[x].push_back(make_pair(y,1));
        adj[y].push_back(make_pair(x,1));
      }


      dijkstra(adj,1);


     







    return 0;
}



Measured memory_bytes: 23844
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<long> a(N);
  long max_a = 0;
  long max_i = -1;
  long min_a = 0;
  long min_i = -1;
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
    if (max_i == -1 or max_a < a[i]) {
      max_a = a[i];
      max_i = i;
    }
    if (min_i == -1 or min_a > a[i]) {
      min_a = a[i];
      min_i = i;
    }
  }

  /*
  cout << "max: " << max_a << endl;
  cout << "min: " << min_a << endl;
  */

  vector<pair<int, int>> operations;
  operations.reserve(2 * N);
  if (abs(max_a) < abs(min_a)) {
    for (int i = N - 2; i >= 0; --i) {
      while (a[i] > a[i + 1]) {
        a[i] += min_a;
        operations.push_back(make_pair(min_i + 1, i + 1));
        if (min_a > a[i]) {
          min_a = a[i];
          min_i = i;
        }
      }
    }
  } else {
    for (int i = 1; i < N; ++i) {
      while (a[i] < a[i - 1]) {
        a[i] += max_a;
        operations.push_back(make_pair(max_i + 1, i + 1));
        if (max_a < a[i]) {
          max_a = a[i];
          max_i = i;
        }
      }
    }
  }

  /*
  for (const auto& ai: a) cout << " " << ai;
  cout << endl;
  */

  cout << operations.size() << endl;
  for (const auto& o: operations) cout << o.first << " " << o.second << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <deque>
#include <numeric>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
using namespace std;
using namespace __gnu_pbds;
void PUNKS_NOT_DEAD() {
#ifdef PUNK
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void PUNK_WILL_FUCK_ALL() {
    string s, base;
    int k;
    cin >> s >> k;
    base = s;
    int n = s.size();
    ll ans = 0;
    for (int i = 1; i < n; i++) {
        if (s[i] == s[i - 1]) {
            s[i] = '#';
            ans++;
        }
    }
    if (s.back() == '#' || s.back() != s[0]) {
        cout << ans * k;
    } else {
        if (k == 1) {
            cout << ans;
        } else {
            ll ans1 = 0;
            k--;
            s = base;
            s[0] = '#';
            ans1 = 1;
            for (int i = 1; i < n; i++) {
                if (s[i] == s[i - 1]) {
                    ans1++;
                    s[i] = '#';
                }
            }
            if (s.back() == '#') {
                k--;
                cout << ans1 + ans + ans * ((k + 1) / 2) + ans1 * (k / 2);
            } else {
                if (k == 1) {
                    cout << ans1 + ans;
                } else {
                    k--;
                    cout << ans + ans1 + ans1 * k;
                }
            }
        }
    }
}

signed main() {
    PUNKS_NOT_DEAD();
    PUNK_WILL_FUCK_ALL();
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=1e9+7;
const int MAXN=600005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
char st[MAXN];
int main()
{
	int n=read();
	scanf("%s",st);
	ll ans=1,top=0;
	for (int i=0;i<(n<<1);i++)
	{
		if ((st[i]=='B')^(i&1)) ++top;
		else
		{
			if (!top) { puts("0"); return 0; }
			(ans*=top)%=mods;
			top--;
		}
	}
	if (top) { puts("0"); return 0; }
	for (int i=1;i<=n;i++) ans=ans*i%mods;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int dp[3001][3001];
pair<int, int> ans[3001][3001];
bool av[3001], bv[3001];

string a, b;
string s = "";
void get(int i, int j){
	//cout << i << " " << j<< endl;

	if(a[i] == b[j]){
		if(!av[i] && !bv[j])
			s += a[i];
		av[i] = 1, bv[j] = 1;
	}
	if(ans[i][j].first == i && ans[i][j].second == j)
	return;
	
	get(ans[i][j].first, ans[i][j].second);
}
int main(){
	cin >> a >> b; 
	
	if(b.size() > a.size())
		swap(a, b);
	
	dp[0][0] = (a[0] == b[0]);
		
	for(int i = 1; i < a.size(); i++){
		dp[i][0] = (a[i] == b[0]) | (dp[i - 1][0] != 0);
		ans[i][0] = {i - 1, 0};
		dp[0][i] = (a[0] == b[i]);
	}
	
	for(int i = 1; i < a.size(); i++){
		for(int j = 1; j < b.size(); j++){
			dp[i][j] = max(max(dp[i - 1][j], dp[i][j - 1]), dp[i - 1][j - 1] + 			(a[i] == b[j]));
			if(dp[i - 1][j] >= max(dp[i][j - 1], dp[i - 1][j - 1] + 			(a[i] == b[j])))
				ans[i][j] = {i - 1, j};
			else if(dp[i][j - 1] > max(dp[i - 1][j], dp[i - 1][j - 1] + 			(a[i] == b[j])))
				ans[i][j] = {i, j - 1};
			else
				ans[i][j] = {i - 1, j - 1};
		}
	}
	//cout << dp[2][1] << endl << dp[2][2] << endl << dp[3][2]<<endl;
	//cout << dp[a.size() - 1][b.size() - 1] << endl;
	get(a.size() - 1, b.size() - 1);
	reverse(s.begin(), s.end());
	cout << s;
}




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

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

    int res , cnt , n = s.size();
    
    for (int i  = 0;i < n; i++) {
        if ('A' == s[i]) {
            res = i;
            break;
            //cout << res << endl;
        }
    }

    for (int i = n - 1;i >= 0; i--) {
        if ('Z' == s[i]) {
            cnt = i;
            break;
        }
    }

    cout << cnt - res  + 1 << endl;
    return 0;
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

long long INF=LLONG_MAX;

ll dp[102][4][2];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	string s; 
	int K; 
	cin >> s >> K;
	memset(dp,0,sizeof(dp));
	int n = s.length();
	dp[0][0][0] = 1;
	ll sum = 0;
	for(int i = 0; i < n; i++){
		int cur = s[i]-'0';
		for(int j = 0; j <= K; j++){
			for(int k = 0; k < 2; k++){
				if(dp[i][j][k]==0)continue;
				for(int num = 0; num < 10; num++){
					if(k==0&&num>cur)continue;
					if(j+(num>0)>K)continue;
					dp[i+1][j+(num>0)][k|(num<cur)] += dp[i][j][k];
					//cout << i << ' ' << j << ' ' << k << " | "<< num << ' ' <<  i+1 << ' ' << int(j+(num>0?1:0)) << ' ' << int(k|(num<cur?1:0)) << ' ' <<dp[i+1][int(j+(num>0?1:0))][int(k|(num<cur?1:0))] << endl;
				}
			}
		}
	}
	//cout << dp[n][K][0] << ' ' << dp[n][K][1] << endl;
	sum += dp[n][K][0] + dp[n][K][1];
	cout << sum << endl;
}	


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();

        long[] a = new long[n];
        long[] b = new long[m];

        for (int i=0; i<n; i++) a[i] = sc.nextLong();
        for (int i=0; i<m; i++) b[i] = sc.nextLong();

        long[] sumA = new long[n+1];
        long[] sumB = new long[m+1];

        for (int i=0; i<n; i++) {
            sumA[i+1] = sumA[i] + a[i];
        }
        for (int i=0; i<m; i++) {
            sumB[i+1] = sumB[i] + b[i];
        }

//        System.out.print(sumA[3]);

        int cnt = 0;


        for (int i=0; i<n+1; i++) {
            int tmpC = 0;
            long rest = k - sumA[i];
            if (rest < 0) continue;
            tmpC += i;

            int idx = upperbound1(sumB, rest);
//            if (i==n-1) System.out.print(idx);
//            if (sumB[idx]==rest) tmpC += idx
            tmpC += (idx - 1);

            cnt = Math.max(cnt, tmpC);

//            System.out.print(tmpC);

        }

        System.out.print(cnt);

    }

    public static int upperbound1(long[] arr, long value){
        int left = 0;
        int right = arr.length;
        while (left<right){
            int mid = (left+right)/2;
            if (arr[mid]<=value){
                left = mid+1;
            }else {
                right = mid;
            }
        }
        return left;
    }}


Measured memory_bytes: 65300
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n, m;
	int dp[50001] = { 0 };
	cin >> n >> m;
	int c[10000];
	for (int i = 0; i < 50001; i++){
		dp[i] = 1<<20;
	}
	for (int i = 0; i < m; i++){
		cin >> c[i];
	}
	dp[0] = 0;
	for (int i = 0; i < m; i++){
		for (int i2 = 0; i2 <= 50000; i2++){
			if (i2 + c[i] <= n){
				dp[i2 + c[i]] = min(dp[i2 + c[i]], dp[i2] + 1);
			}
		}
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 1376
MOD = 1_000_000_007

$fact = [1]
(1..220000).each do |i|
  $fact << $fact[-1] * i % MOD
end

def exp(n, k)
  x = 1
  while k > 0
    x = x * n % MOD if k & 1 == 1
    n = n * n % MOD
    k >>= 1
  end
  x
end

$inv = (0..220000).map {|i| exp($fact[i], MOD - 2) }

def comb(n, k)
  ($fact[n] * $inv[k] % MOD) * $inv[n-k] % MOD
end

n, m, k = gets.split.map(&:to_i)

answer = 0
(0..k).each do |ke|
  east  = ke == 0 ? 1 : (comb(n + ke * 2, ke) - comb(n + ke * 2, ke - 1)) % MOD
  kn = k - ke
  north = kn == 0 ? 1 : (comb(m + kn * 2, kn) - comb(m + kn * 2, kn - 1)) % MOD
  answer = (answer + east * north * comb(n + m + k * 2, n + ke * 2)) % MOD
end
p answer



Measured memory_bytes: 12452
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,n) for(i=a;i<n;i++)
#define ll long long
#define ld long double
#define deb(x) cout << #x << "=" << x << endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortrev(x) sort(all(x),greater<int>())
#define pi 3.1415926535897932384626

typedef pair<int,int> pii;
typedef pair<ll, ll> pl;
typedef vector<int>	vi;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pl>	vpl;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;


const int mod = 1000000007  ;
const int inf = 100005;
const int N = 3e5, M = N;
ll i,j,n,m,idx,cnt;
char d[31][31];
int dx[] = {-1,1,0,0};
int dy[] = {0,0,-1,1};


void solve() {
 ll n;
 cin>>n;

 vl vec(61);
 ll ans = 0,x;
 cin>>x;
 fo(i,0,61) {
    if(x & (1LL<<i)) vec[i]++;
 }
 ll k;
 fo(i,1,n) {
    cin>>x;
    fo(j,0,61) {
        if(x & (1LL<<j)) {
            k = i - vec[j];
            ans = (ans%mod + ((1LL<<j)%mod * k%mod)%mod)%mod;
            vec[j]++;
        }
        else {
            k = vec[j];
            ans = (ans%mod + ((1LL<<j)%mod * k%mod)%mod)%mod;
        }
    }

 }
 cout<<ans<<"\n";
}

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

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

    return 0;
}




Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int INF = 1 << 30;
int main() {
	int n, m;
	int A[100];
	int T[50000 + 10];
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++)
		scanf("%d", &A[i]);
	for (int i = 0; i <= n; i++)
		T[i] = INF;
	T[0] = 0;
	for (int i = 0; i < m; i++) {
		for (int j = 0; j + A[i] <= n; j++)
			T[j + A[i]] = min(T[j] + 1, T[j + A[i]]);
	}
	printf("%d\n", T[n]);
	return 0;
}


Measured memory_bytes: 3396
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int[][] array = new int[n][20];

        for (int i = 0; i < n; i++) {
            final int tmp = scanner.nextInt();
            final char[] binary = Integer.toBinaryString(tmp).toCharArray();
            for (int j = 0; j < binary.length; j++) {
                array[i][j] = binary[binary.length - j -1] - '0';
            }
        }

        final int[] prePreOneIndex = new int[20];
        final int[] preOneIndex = new int[20];

        for (int i = 0; i < 20; i++) {
            preOneIndex[i] = -1;
            prePreOneIndex[i] = -1;
        }

        long answer = 0;
        for (int i = 0; i < n; i++) {
            final int[] binary = array[i];
            int length = Integer.MAX_VALUE;
            for (int j = 0; j < 20; j++) {
                if (binary[j] == 0) {
                    length = Math.min(length, i - prePreOneIndex[j]);
                } else {
                    length = Math.min(length, i - preOneIndex[j]);
                    prePreOneIndex[j] = preOneIndex[j];
                    preOneIndex[j] = i;
                }
            }
            answer += length;
        }

        System.out.println(answer);
    }
}


Measured memory_bytes: 112492
#include <string>
#include <cstdio>
#include <bitset>
#include <iostream>
#include <algorithm>
using namespace std;
#define Maxn 2000
#define Maxk 10000
int n,k;
string s[Maxn+5];
string ans;
bitset<Maxk+5> can[Maxn+5];
pair<int,int> vis[2][Maxn+5];
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>s[i];
	}
	can[n+1][0]=1;
	for(int i=n;i>0;i--){
		can[i]=(can[i+1]|(can[i+1]<<(int)s[i].size()));
	}
	int cnt=0,tot;
	for(int i=1;i<=n;i++){
		if(can[i+1][k-(int)s[i].size()]){
			vis[0][++cnt]=make_pair(i,0);
		}
	}
	char mn_c;
	int tmp=0;
	int id,len;
	int mn_new;
	for(int i=0;i<k;i++){
		mn_c='z';
		for(int j=1;j<=cnt;j++){
			mn_c=min(mn_c,s[vis[tmp][j].first][vis[tmp][j].second]);
		}
		ans+=mn_c;
		tot=0;
		mn_new=n+1;
		for(int j=1;j<=cnt;j++){
			id=vis[tmp][j].first;
			len=vis[tmp][j].second;
			if(s[id][len]!=mn_c){
				continue;
			}
			if(len+1==(int)s[id].size()){
				mn_new=min(mn_new,id);
			}
			else{
				vis[tmp^1][++tot]=make_pair(id,len+1);
			}
		}
		tmp^=1;
		for(int j=mn_new+1;j<=n;j++){
			if(k-(int)s[j].size()-i>0&&can[j+1][k-(int)s[j].size()-i-1]){
				vis[tmp][++tot]=make_pair(j,0);
			}
		}
		cnt=tot;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3968
#include <iostream>

using namespace std;

int main()
{
    long long int a,b = 0,c,d;
    cin >> a;
    b += a/500;
    c = a%500;
    b *= 1000;
    d = c/5;
    d = d*5;
    b += d;
    cout << b << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.IO.Pipes;
using System.Linq;
//今回は足りないが、O(n^2)で良いなら
//18171%2019=kの時、181711%2019=(k+1)%2019になる
//累積和
//a2+...+a5=S5-S1

class Program
{
    public static readonly int m = 2019;//mod
    static void Main()
    {
        string s = Console.ReadLine();
        s = new string(s.Reverse().ToArray());
        int x = 1;//累乗のところ
        int tot = 0;//total
        int[] S = new int[m];//累積和
        long ans = 0;
        //al+..+ar%2019=0にしたいなら
        //S(a-1)-Sr%2019=0,すなわち
        //S(a-1)%2019 = Sr%2019
        //にしたい
        for(int i=0; i < s.Length; i++)
        {
            S[tot]++;//使ったことのあるSrを記録
            tot += (s[i] - '0') * x;//文字コードを使ってcharを無理やりintにする
            tot %= m;
            ans += S[tot];//↑の処理後ののS[tot]はS(a-1)%2019
            x = x * 10 % m;
        }
        Console.WriteLine(ans);
    }
}



//今回は桁ごとに分けて考える
//class Program
//{
//    static void Main()
//    {
//        string s = Console.ReadLine();
//        long[] L = new long[s.Length + 1];
//        for(int i=1; i <= s.Length; i++)
//        {
//            L[i] += int.Parse(s[i - 1].ToString()) + L[i - 1];
//        }
//    }
//}

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

int ans;
vector<int> ansv;
vector<vector<int> > v;

void dfs(int prev, int next, int a, vector<int> vi, set<pair<int,int> > s){
  if(v[prev][next] == -1 || s.find(pair<int,int>(prev,next)) != s.end()) return;
  vi.push_back(next);
  s.insert(pair<int,int>(prev,next));
  s.insert(pair<int,int>(next,prev));
  a += v[prev][next];
  if(ans < a){
    ans = a;
    ansv = vi;
  }
  for(int i=0;i<v.size();i++) dfs(next,i,a,vi,s);
}

int main(){
  int n,m;
  while(cin >> n >> m && n && m){
    ans = 0;
    ansv.clear();
    v.assign(n,vector<int>(n,-1));
    for(int i=0;i<m;i++){
      int a,b;
      cin >> a >> b;
      a--;
      b--;
      cin >> v[a][b];
      v[b][a] = v[a][b];
    }

    for(int i=0;i<n;i++){
      vector<int>vi;
      set<pair<int,int> > s;
      vi.push_back(i);
      for(int j=0;j<n;j++) dfs(i,j,0,vi,s);
    }
    cout << ans << endl;
    cout << ansv[0] + 1;
    for(int i=1;i<ansv.size();i++) cout << " " << ansv[i] + 1;
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 920
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

int main(){
    string s;
    
    int memo[26] = {0};
    int i;
    int flag = 1;
    
    cin >> s;
    
    for(i = 0; i < s.size(); i++){
        memo[(int)s[i]-97]++;
    }
    
    for(i = 0; i < 26; i++){
        if(memo[i]%2 != 0){
            flag = 0;
        }
    }
    
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


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

#define rep(i,n) for(int (i)=0;(i)<(n); ++(i))
using namespace std;

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

    cout << pow(n, 3) << endl;
}

Measured memory_bytes: 512
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if (b-1)%(a-1) == 0 {
		fmt.Println((b - 1) / (a - 1))
	} else {
		fmt.Println((b-1)/(a-1) + 1)
	}
}


Measured memory_bytes: 1768
#include <bits/stdc++.h>
using namespace std;
 
const int MAXN = 500 + 3;
int H[MAXN][MAXN];
bool occ[MAXN][MAXN];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
 
void dfs(int x, int y) {
    int z = H[x][y] + occ[x][y];
    for (int t = 0; t < 4; t++) {
        int x1 = x + dx[t], y1 = y + dy[t];
        if (H[x1][y1] > z) {
            H[x1][y1] = z;
            dfs(x1, y1);
        }
    }
}
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int N;
    cin >> N;
    
    for (int i = 1; i <= N; i++) for (int j = 1; j <= N; j++) {
        H[i][j] = min(min(i, N+1-i), min(j, N+1-j)) - 1;
        occ[i][j] = true;
    }
 
    int res = 0;
    for (int it = 0; it < N*N; it++) {
        int id;
        cin >> id;
        int x = (id+N-1)/N;
        int y = id % N;
        if (y == 0) y += N;
        res += H[x][y];
        occ[x][y] = false;
        dfs(x, y);
    }
    cout << res << "\n";
    
}

Measured memory_bytes: 20248
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef int_fast64_t ll;

constexpr int buff_size = 1 << 21;
char buff[buff_size], *ci, ct;
int A;

inline int readint() {
    A = 0;
    while ((ct = *ci++) >= '0') A = (A << 3) + (A << 1) + ct - '0';
    return A;
}

inline ll solve() {
    int N;
    scanf("%d\n", &N);
    fread_unlocked(buff, 1, (N << 3) + (N << 1) + N, stdin);
    ci = buff;
    int M = 2, cnt;
    ll ans = readint() - 1;
    while(--N) {
        int A = readint();
        if(A == M) M++;
        else if(A < M) continue; 
        else {
            ans += (cnt = A / M);
            if(A == cnt * M) ans--;
        }
    }
    return ans;
}

int main() {
    printf("%lld\n", solve());
	return 0;
}

Measured memory_bytes: 1280
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]

dp = [0] * (n + 10)
dp[0] = 1
mod = 1e9 + 7

ok = [1] * (n + 10)
for i in a:
    ok[i] = 0

for i in range(n):
    if ok[i + 1]:
        dp[i + 1] += dp[i]
        dp[i + 1] %= mod
    if ok[i + 2]:
        dp[i + 2] += dp[i]
        dp[i + 2] %= mod
print(int(dp[n]))


Measured memory_bytes: 8592
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    def kyori(x1,x2,y1,y2):
            return ((x1-y1)**2+(x2-y2)**2)**0.5
    n=int(input())
    l=[list(map(int,input().split())) for i in range(n)]
    import itertools
    ans=0
    cnt=0
    p=itertools.permutations(l)
    for x in p:
        z = list(x)
        cnt+=1
        for y in range(n-1):
            ans+=kyori(z[y][0],z[y][1],z[y+1][0],z[y+1][1])
    print(ans/cnt)
resolve()

Measured memory_bytes: 3188
import java.util.*;
import java.io.*;
public class Main {
    
    public static long sum(long[] arr, int i, int j) {
        long sum = 0;
        for(int k = i; k <= j; k++){
            sum += arr[k];
            
        }
        return sum;
    }

    static long solve(long[] arr, int i, int j,long[][] dp){
        if(i== j)
            return 0;
        if(dp[i][j] != -1)
            return dp[i][j];

        long ans = Long.MAX_VALUE;
        
        for(int k = i; k < j; k++){
          ans =  Math.min(ans, solve(arr,i,k,dp) + solve(arr, k+1, j,dp) + sum(arr,i,k) + sum(arr,k+1,j));
        }

        return  dp[i][j] = ans;
        
    }
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer token;
        int n = Integer.parseInt(br.readLine().trim());
        long[] arr = new long[n];
        token = new StringTokenizer(br.readLine().trim()," ");
        for(int i = 0; i < arr.length; i++){
            arr[i] = Long.parseLong(token.nextToken());
        }
        
        long[][] dp = new long[arr.length][arr.length];
       for(int i = 0; i < dp.length; i++)
           Arrays.fill(dp[i],-1);

       System.out.println(solve(arr, 0, arr.length-1,dp));
    }
}

Measured memory_bytes: 26788
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;


int main() {
    int a, b;
    int max = 0;
    int min = 1000000000;
    scanf("%d", &a);
    int i;
    for(i = 0; i < a; i++){
        scanf("%d", &b);
        if(max < b) max = b;
        if(min > b) min = b;
    }
    
    cout << max - min << "\n";
    
    return 0;
}



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

#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define FORW(a, b, c) for(int a = b; a >= c; --a)
#define fi first
#define se second
#define pb push_back
#define int long long

typedef pair<int, int> ii;
typedef pair<int, ii> iii;

const int N = 2e5 + 100;
const int oo = 1e18;
const int mod  = 1e9 + 7;

int a[200];

signed main()  {
//    freopen("test.inp", "r", stdin);
//    freopen("test.out", "w", stdout);
    ios_base::sync_with_stdio(false); cout.tie(0);
    int n, k; cin >> n >> k;
    if(n > k) {
        n -= k * (n / k);
    }
    cout << min(k - n, n);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
    int R[MAX],n;
    
    cin >> n;
    for(int i = 0; i < n; i++) cin >> R[i];
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for(int i=1;i<n;i++){
        maxv = max(maxv,R[i] - minv);
        minv = min(minv,R[i]);
    }
    
    cout << maxv << endl;
    
    return 0;
}


Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int main(){
    db N;
    cin >> N;
    int a = (N + 1) / 2;
    cout << fixed << setprecision(10) << (db)a / N << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
#define ll long long
#define fast_io cin.tie(0);cout.tie(0);ios::sync_with_stdio(0)
using namespace std;

int main(){
	fast_io;
	ll a,b,c;
	cin>>a>>b>>c;
	ll s1=0,s2=0,s3=0;
	s1 = a+b;
	s2 = b+c;
	s3 = a+c;
	ll ans;
	ans = min(min(s1,s2),s3);
	cout<<ans;
}

Measured memory_bytes: 256