akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>


int comparator(const void *a, const void *b);
long long gcd(long long a, long long b);

long long A[1000001];
int main(void) {
  long long N;

  scanf("%lld", &N);
  for(long long i=0;i<N;i++) {
    scanf("%lld", &A[i]);
  }
  qsort(A, N, sizeof(long long), comparator);

  long long lesser = A[0];
  for(long long i=0;i<N;i++) {
    lesser = gcd(lesser, A[i]);
  }
  printf("%lld\n", lesser);

  return 0;
}

long long gcd(long long a, long long b){
  return b!=0 ? gcd(b, a%b): a;
}

int comparator(const void *a, const void *b) {
    long long result = *(long long*)a - *(long long*)b;
    if(result == 0) return 0;
    else if(result < 0) return -1;
    else return 1;
}

Measured memory_bytes: 1788
def main():
    n = int(input())
    d = [list(map(int, input().split())) for _ in range(n)]

    for i in range(n - 2):
        if d[i][0] == d[i][1] and d[i + 1][0] == d[i + 1][1] and d[i + 2][0] == d[i + 2][1]:
            print("Yes")
            break
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 62444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1LL << 60;
const int MOD = 1000000007;

int n, m;
vector<bool> issafe;

int main() {
    cin >> n >> m;
    issafe.assign(n + 1, true);
    rep(i, m) {
        int a; 
        cin >> a;
        issafe[a] = false;
    }

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

    dp[0] = 1;
    if (issafe[1]) dp[1] = 1;

    for(int i = 2; i <= n; i++) {
        if(issafe[i - 1]) dp[i] += dp[i - 1];
        if(issafe[i - 2]) dp[i] += dp[i - 2];
        dp[i] %= MOD;
    }

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


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	long long int n,x,mp;
	cin>>n>>x>>mp;
	map<long long int,long long int> m;
	vector<long long int> a;
	long long int ind=0,sum=x;
	a.push_back(x);
	m[x]=ind;
	ind++;
	x=(x*x)%mp;
	while(ind<n && m.find(x)==m.end())
	{
		sum+=x;
		a.push_back(x);
		m[x]=ind;
		ind++;
		x=(x*x)%mp;
	}
	if(ind==n)
	{
		cout<<sum<<'\n';
	}
	else
	{
		long long int rem=n-a.size();
		long long int newind=m[x];
		long long int sz=a.size()-newind;
		long long int extra=rem%sz;
		long long int newsum=0;
		for(long long int i=0;i<extra;i++)
		{
			newsum+=a[i+newind];
		}
		sum+=newsum;
		for(long long int i=extra;i+newind<a.size();i++)
		{
			newsum+=a[i+newind];
		}
		sum+=newsum*(rem/sz);
		cout<<sum<<'\n';
	}
}


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

#define ll long long
#define debug(x) cout<<":["<<x<<"DE]"<<endl;
#define debug2(x,y) cout<<"["<<x<<" "<<y<<"DE]"<<endl;

using namespace std;

ll father[100005],n,sz[100005],cen1=0,cen2=0,mx=-1,mn=1e18;
vector<ll>adj[100005];

void dfs(int child,int parent)
{
    father[child]=parent,sz[child]=1,mx=0;
    for(int i:adj[child]){
        if(i==parent)continue;
        dfs(i,child);
        sz[child]+=sz[i];
        mx=max(mx,sz[i]);
    }
    mx=max(mx,n-sz[child]);
    if(mx<mn)mn=mx,cen1=child,cen2=0;
    else if(mx==mn)cen2=child;
}
ll nibo;
void dfs2(int child,int parent)
{
    if(adj[child].size()==1){
        nibo=child;return;
    }
    for(int i:adj[child]){
        if(i==parent)continue;
        dfs2(i,child);
    }
}

int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max({(ll)(a*c),(ll)(a*d),(ll)(b*c),(ll)(b*d)})<<endl;
}


Measured memory_bytes: 5968
//#define anjn
//      Anjan Agarwala - anjn98

//#define opti
#ifdef opti
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#endif

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

typedef long long ll;
typedef unsigned long long int ull;
ll power(ll x,ll y,ll p){ll r=1; x=x%p; while(y){ if(y&1) r= r*x%p; y=y>>1; x=x*x%p; } return r; }
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;*/

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int csrand(int l=0, int r=1e9){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

#define PR(x) cout<<#x<<" : "<<x<<"\n";
#define PR1(x,y) cout<<#x<<" : "<<x<<"  |  "<<#y<<" : "<<y<<"\n";
#define PR2(x,y,z) cout<<#x<<" : "<<x<<"  |  "<<#y<<" : "<<y<<"  |  "<<#z<<" : "<<z<<"\n";
#define ED cout<<'\n';

#define IO              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FILEIO          freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define all(v)          v.begin(),v.end()
#define endl            '\n'
#define fr1(j,n)        for(int j=0;j<n;j++)
#define fr(n)           for(int i=0;i<n;i++)
#define trav(x,s)       for(auto x:s)
#define PB              emplace_back
#define pii             pair<int,int>
#define pll             pair<long long int,long long int>
#define F               first
#define S               second 
#define binf            2000000000000000001

const int N=5e6+99;



int main() 
{
    




    int n;
    cin>>n;
    int a[n],b[n],c[n];

    fr(n) cin>>a[i];
    fr(n) cin>>b[i];
    fr(n-1) cin>>c[i+1];

    ll ans=0;

    for(int i=0;i<n;i++)
    {
        ans+=b[a[i]-1];

        if(i!=0 && a[i]==a[i-1]+1) ans+=c[a[i-1]];

    }
   
    cout<<ans<< endl;



}
    

    





 
    
     

Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  N = parseInt(input[0]);
  S = input[1].split("");
  ans=3*Math.pow(10,5)-1;
  var ecount=0;
  var ecount2=0;
  var wcount=0;
  for(i=0;i<N;i++){
    if(S[i]=="E"){
      ecount++;
    }
  }
  for(i=0;i<N;i++){
    if(S[i]=="W"){
      wcount++;
    }else{
      ecount2++;
    }
    if(S[i]=="W"){
    ans=Math.min(ans,wcount+ecount-ecount2-1);
    }else{
      ans=Math.min(ans,wcount+ecount-ecount2);
    }
  }



  console.log('%s', ans);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 11084
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;

int main()
{
	int ans;
	int h1,h2,h3;
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	int M = max(a,max(b,c));
	for(int i = M; ; i++) {
		int num = 0;
		h1 = i - a;
		h2 = i - b;
		h3 = i - c;
		if(h1 % 2 != 0) num++;
		if(h2 % 2 != 0) num++;
		if(h3 % 2 != 0) num++;
		if(num == 3 || num == 1) continue;
		else if(num == 0){
			ans = h1 / 2 + h2 / 2 + h3 / 2;
			break;
		}
		else {
			ans = h1 / 2 + h2 / 2 + h3 / 2 + 1;
			break;
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;
int a,b=0,n;
int main()
{
	string a,b;
    cin>>a>>b;
    //reverse(a.begin(),a.end());
    if(a==b)
    cout<<"H"<<endl;
    else
    cout<<"D"<<endl;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <algorithm>

std::vector<int> optimal_sub_solutions; // stores at position i the min nb of coins to exchange an amount of i

int optimal_change(std::set<int>& values, int amount) {
	if(optimal_sub_solutions[amount] != -2) return optimal_sub_solutions[amount]; // solution found and stored
	else { // otherwise, try to find solution
		int min = amount; // we use at most "amount" coins of value 1 (if available) to make the change
		bool found_sol = false;
		for(int v: values) {
			if(amount >= v) {
				int sub_solution = optimal_change(values, amount-v);
				if(sub_solution != -1) { // solution found
					min = std::min(sub_solution+1, min);
					found_sol = true;
				}
			}
		}
		if(found_sol)
			optimal_sub_solutions[amount] = min;
		else
			optimal_sub_solutions[amount] = -1; // no optimal solution for this amount
		return optimal_sub_solutions[amount];
	} 
}

void testcase() {
	int amount; std::cin>>amount;
	int n; std::cin>>n;
	std::set<int> values;
	for(int i=0; i<n; i++) {
		int v; std::cin >> v;
		values.insert(v);
	}
	
	optimal_sub_solutions = std::vector<int>(amount+1, -2); // init all to -2;
	optimal_sub_solutions[0] = 0; // best way to change 0 is with 0 coins
	
	/*for(int v: values) {
		std::cout << v << " ";
	}
	std::cout << "\n" << amount;*/
	
	int best_change = optimal_change(values, amount);
	if(best_change != -1)
		std::cout << best_change <<std::endl;
	else
		std::cout << "ERROR" <<std::endl;
}

int main() {
	testcase();
}



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

using namespace std;

bool CanMakeTriangle(const int a, const int b, const int c)
{

    if (a == b || b == c || c == a)
    {
        return false;
    }

    if (!(a + b > c && b + c > a && c + a > b))
    {
        return false;
    }

    return true;
}

int main()
{
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> L[i];
    }
    int ans = 0;
    for (int i = 0; i < N - 2; ++i)
    {
        for (int j = i + 1; j < N - 1; ++j)
        {
            for (int k = j + 1; k < N; ++k)
            {
                if (CanMakeTriangle(L[i], L[j], L[k]))
                {
                    ++ans;
                }
            }
        }
    }
    cout << ans << endl;
}

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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("in.txt","r",stdin)
#define write()         freopen("out.txt","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long int
#define endll           printf("\n")
#define pf              printf
#define pi              acos(-1.0)
#define eps             1e-10
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())

bool Check(unsigned int  N,int pos){return (bool)(N & (1LL<<pos));}
ll  Set(unsigned int N,int pos){    return N=N | (1LL<<pos);}
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MX 100005
#define mod  1000000007
#define mod1 1000000009
#define var    int ii,i,j,k,z=0,c=0,t,x,y,l,r,mid
int dx[8]={0,0,1,-1,-1,1,1,-1};  //8 direction
int dy[8]={1,-1,0,0,1,-1,1,-1};

bool chk(int x,int pos){return (bool)(x&(1<<pos));}
int Set(int x,int pos){return x=x|(1<<pos);}
int clr(int x,int pos){return x=x&~(1<<pos);}

ll int n,m,a[5000];

ll bigmod(ll x,ll y)
{
  if(y==0)return 1;
  ll n=bigmod(x,y>>1);
  n=(n*n)%mod;
  if(y&1)n=(n*x)%mod;
  return n;
}

ll ncr(ll n,ll r)
{
  if(n<r)return 0;
  ll x=(a[r]*a[n-r])%mod;
  x=bigmod(x,mod-2);
  x*=a[n];x%=mod;
  return x;
}

int main()
{
    ll var;
    a[0]=1;
    for(i=1;i<=5000;i++)
    {
      a[i]=a[i-1]*i;a[i]%=mod;
    }
    sfl(n);sfl(k);
    m=n-k;
    for(i=1;i<=k;i++)
    {
      z=ncr(k-1,i-1)*ncr(m+1,i);
      z%=mod;
      cout<<z<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int k;
  
  cin>>k;
  
  long long int a,b;
  
  cin>>a>>b;
  
  int flag=0;
  
  for(int i=a;i<=b;i++)
  {
    if(i%k==0)
    {
      flag=1;
      break;
    }
  }
  
  if(flag)
    cout<<"OK";
  
  else
    cout<<"NG";
  
  return 0;
}

Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>
#include<functional>
using namespace std;

// B = true   W = false

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	string S; cin >> S;
	int Ans1 = 0, Ans2 = 0;
	bool prev, next;
	prev = (S[0] == 'B') ? true : false;
	for (int i = 1; i < S.length();i++) {
		next = (S[i] == 'B') ? true : false;
		if (prev != next) {
			Ans1++;
		}
		prev = next;
	}

	cout << Ans1 << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
struct node
{
    char str[5600];
    int k;
    int id;
    int s;
}a[N];
int cmp1(node a,node b)
{
    return a.id<b.id;
}
int cmp2(node a,node b)
{
    if(strcmp(a.str,b.str)==0)
        return a.k>b.k;
    else if(strcmp(a.str,b.str)>0)
        return 0;
    else
        return 1;
    //return !strcmp(a.str,b.str);
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%s %d",a[i].str,&a[i].k);
        a[i].id=i;
    }
    sort(a+1,a+n+1,cmp2);
    //for(int i=1;i<=n;i++)
     //   printf("%s\n",a[i].str);

    for(int i=1;i<=n;i++)
        a[i].s=i;
    //sort(a+1,a+n+1,cmp1);
    for(int i=1;i<=n;i++)
        printf("%d\n",a[i].id);
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
int main()
{
	int a,b,d,r;
	double f;
	scanf("%d %d",&a,&b);
	d=a/b;
	r=a%b;
	f=r*1.0/b+d;
	printf("%d %d %.5lf\n",d,r,f);
	return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    string s;
    cin >> s;
    cout << s.substr(0, s.size() - 8) << endl;
}


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

using namespace std;

typedef pair<int, int> PP ;
int gridA[25][25];
//int gridB[25][25];
int dist[25][25];
int dx[4] = { 1,-1,0,0 }; int dy[4] = { 0,0,1,-1 };
const int INF = 100000000;

int BFS(int X, int Y) {
	queue<PP>que;
	for (int i = 0; i < 25; i++) {
		for (int j = 0; j < 25; j++) {
			dist[i][j]=INF;
		}
	}
	int maxD = 0;
	que.push(PP(X, Y));
	dist[X][Y] = 0;
	while (que.size()!=0) {
		PP now = que.front();
		que.pop();
		for (int i = 0; i < 4; i++) {
			int nx = now.first + dx[i];
			int ny = now.second + dy[i];
			if (gridA[nx][ny] == 1 && dist[nx][ny] == INF) {
				que.push(PP(nx, ny));
				dist[nx][ny] = dist[now.first][now.second] + 1;
				if (maxD < dist[nx][ny])maxD=dist[nx][ny];
			}
			/*
			if (nx==gx&&ny==gy)return dist[nx][ny];
			*/
		}
	}
	return maxD;
}


int main()
{
	int H, W;
	cin >> H >> W;

	for (int i = 0; i < 25; i++) {
		for (int j = 0; j < 25; j++) {
			gridA[i][j] = 0;
		}
	}

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			char c;
			cin >> c;
			if (c == '.') gridA[i][j] = 1;
		}
	}
	int L = 0;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (gridA[i][j] == 1) {
				int k = BFS(i, j);
				//cout << k<< endl;////////////////////
				if (L < k)L = k;
			}
		}
	}
	cout << L << endl;
}


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

#define rep(i, n) for ( int i = 0; i < n; i++ )
#define REP(i, b, e) for ( int i = b; i <= e; i++ )
#define MAX 40
typedef complex<double> Point;
int n, m;
double P[MAX];
static const double PI = acos(-1.0);

double getArea(double r1, double r2, double r3){
    Point p1 = polar(1.0, r1*2*PI);
    Point p2 = polar(1.0, r2*2*PI);
    Point p3 = polar(1.0, r3*2*PI);
    double a = abs(p1 - p2);
    double b = abs(p2 - p3);
    double c = abs(p3 - p1);
    double s = (a + b + c)/2.0;
    return sqrt(s*(s-a)*(s-b)*(s-c));
}

void compute(){
    double M[MAX+1][MAX][MAX];
    double T[MAX][MAX][MAX];
    rep(i, n) rep(j, n) rep(k, n) T[i][j][k] = getArea(P[i], P[j], P[k]);
    double maxv = 0.0;
    rep(k, m+1) rep(i, n) rep(j, n) M[k][i][j] = 0.0;
    REP(k, 2, m-1){
	REP(i, 0, n-2) REP(j, i+1, n-1){
	    int t = (j+1)%n;
	    while(1){
		if ( t == i ) break;
		M[k+1][i][t] = max(M[k+1][i][t], M[k][i][j] + T[i][j][t]);
		//M[k+1][i][t] = max(M[k+1][i][t], M[k][i][j] + getArea(P[i], P[j], P[t]));
		//		M[k+1][t][j] = max(M[k+1][t][j], M[k][i][j] + getArea(P[i], P[j], P[t]));
		t = (t+1)%n;
	    }
	}
    }
    rep(i, n) rep(j, n) maxv = max(maxv, M[m][i][j]);
    printf("%.6lf\n", maxv);
}

main(){
    while(1){
	scanf("%d %d", &n, &m);
	if ( n == 0 && m == 0 ) break;
	rep(i, n) scanf("%lf", &P[i]);
	compute();
    }
}

Measured memory_bytes: 1720
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end());
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;

ll DP[5], DP2[5];
int L;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  Fill(DP, LINF);
  DP[0] = 0;
  cin >> L;
  FOR(i, 0, L){
    Fill(DP2, LINF);
    int a;
    cin >> a;
    int c_z = a, c_o = 1-(a&1), c_e = (a ? (a&1) : 2);

    mins(DP2[0], DP[0] + c_z);

    mins(DP2[1], DP[0] + c_e);
    mins(DP2[1], DP[1] + c_e);

    mins(DP2[2], DP[0] + c_o);
    mins(DP2[2], DP[1] + c_o);
    mins(DP2[2], DP[2] + c_o);

    mins(DP2[3], DP[2] + c_e);
    mins(DP2[3], DP[3] + c_e);

    mins(DP2[4], DP[1] + c_z);
    mins(DP2[4], DP[2] + c_z);
    mins(DP2[4], DP[3] + c_z);
    mins(DP2[4], DP[4] + c_z);

    swap(DP, DP2);
  }
  ll ans = LINF;
  FOR(i, 0, 5) mins(ans, DP[i]);
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>                                                                            
using namespace std;                                                                          
int main(){                                                                                   
  int a, b;                                                                                   
  string mark;                                                                                
  cin >> a >> b;                                                                              
  if(a<b)                                                                                     
    mark = "<";                                                                               
  else if(a>b)                                                                                
    mark = ">";                                                                               
  else                                                                                        
    mark = "==";                                                                              
  cout << "a" << " " << mark << " " << "b" << endl;                                           
}                                                                                             
   


Measured memory_bytes: 3204
import sys
 
class Node():
    def __init__(self,key):
        self.key = key
        self.left = None
        self.right = None
 
def insert(t, z):
    y = None
    x = t
    while x is not None:
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
 
    if y is None:
        return z
    else:
        if z.key < y.key:
            y.left = z
        else:
            y.right = z
        return t
 
def in_order(t):
    s = ""
    l = []
    curr = t
    while True:
        while curr is not None:
            l.append(curr)
            curr = curr.left
        if curr is None and len(l) == 0:
            break
        else:
            curr = l.pop()
            s += " " + str(curr.key)
            curr = curr.right
    return s
 
def pre_order(t):
    s = ""
    l = []
    curr = t
    while True:
        while curr is not None:
            s += " " + str(curr.key)
            l.append(curr)
            curr = curr.left
        if curr is None and len(l) == 0:
            break
        else:
            curr = l.pop()
            curr = curr.right
    return s
 
t = None
n = sys.stdin.readline()
lines = sys.stdin.readlines()
for line in lines:
    com = line.split()
    if com[0] == "insert":
        t = insert(t, Node(int(com[1])))
    else:
        print(in_order(t))
        print(pre_order(t))

Measured memory_bytes: 152028
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
pair<int,int> s[1111];
int main(void){
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> s[i].second >> s[i].first;
  }
  sort(s,s+n);
  int ms = 0;
  int res = 0;
  vector<int> v;
  for(int i = 0; i < n; i++){
    if(ms + s[i].second <= s[i].first){
      res++;
      ms += s[i].second;
      v.push_back(s[i].second);
    }else{
      int best = 0;
      for(int j = 0; j < (int)v.size(); j++){
	best = max(best,v[j]);
      }
      if(ms + s[i].second - best <= s[i].first && s[i].second < best){
	ms -= best-s[i].second;
      }
    }
  }
  cout << res << endl;
}

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

using namespace std;

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

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

		int _clockwise_min = min(A[N-1] - A[0], K - (A[1]-A[0]));
		for (int i=1; i<N; i++){
			    int distance = K - (A[i] - A[i-1]);
				if (distance < _clockwise_min) {
						_clockwise_min = distance;
				}
		}

		/*
		int _anticlockwise_min = A[N-1] - A[0];
		for (int i=N-2; i>= 0; i--){
			    int distance = K - (A[i+1] - A[i]);
				if (distance < _anticlockwise_min) {
						_anticlockwise_min = distance;
				}
		}

		cout << min(_clockwise_min, _anticlockwise_min) << endl;
		*/
		cout << _clockwise_min << endl;
}


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

int main(){
int N,v; cin >> N;
priority_queue<double, vector<double>, greater<double>> V;
for(int i=0; i<N; i++){ cin >> v; V.push(v); }
double ans=V.top();V.pop();  
for(int i=1; i<N; i++){ ans=(ans+V.top())/2.0; V.pop(); }
cout << fixed << setprecision(10) << ans << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0;i<n;i++)

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

    int harshad = 0;
    int temp = N;

    harshad += temp % 10;
    while (temp / 10 != 0)
    {
        temp = temp / 10;
        harshad += temp % 10;
    }
    
    if (N % harshad == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    
}

Measured memory_bytes: 888
#include <stdio.h>
int chk(int a,int b,int c);
int main(){
	int sn;
	int a,b,c;
	int i;

	scanf("%d",&sn);
	for(i=1;i<=sn;i++){
		scanf("%d %d %d",&a,&b,&c);
		printf(chk(a,b,c)?"YES\n":"NO\n");
	}
	return 0;
}

int chk(int a,int b,int c){
	return (a*a+b*b-c*c)&&(b*b+c*c-a*a)&&(c*c+a*a-b*b)?0:1;
}

Measured memory_bytes: 580
#include<stdio.h>
int main() {
int a,d,e;
while(1){
scanf("%d%d%d",&a,&d,&e);e+=a+d;
if(e==0)break;
int p[e];
for(a=0;a<e;a++)p[a]=2;
scanf("%d",&d);int s[4][d];
for(a=0;a<d;a++)scanf("%d%d%d%d",&s[0][a],&s[1][a],&s[2][a],&s[3][a]);
for(a=0;a<d;a++)if(s[3][a]==1)p[s[0][a]-1]=1,p[s[1][a]-1]=1,p[s[2][a]-1]=1;
for(a=0;a<d;a++){
if(p[s[0][a]-1]*p[s[1][a]-1]*p[s[2][a]-1]==2){
if(p[s[0][a]-1]==p[s[1][a]-1])
p[s[2][a]-1]=0;
else if(p[s[1][a]-1]==1)
p[s[0][a]-1]=0;
 else p[s[1][a]-1]=0;
}}for(a=0;a<e;a++)printf("%d\n",p[a]);}}

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

typedef long long int ll;

ll fact(ll n){
	return n? n*fact(n-1) : 1 ;
}

int main(){
	string s;
	cin >> s;
	
	int m[256] = {0};
	for(int i=0 ; i < s.size() ; i++ ){
		m[ s[i] ]++;
	}
	
	bool flag = true;
	ll ans = fact(s.size()/2);
	int cnt = 0;
	for(char c = 'a' ; c <= 'z' ; c++ ){
		if( m[c] % 2 == 1 ){
			cnt++;
		}
	}
	if( cnt > s.size() % 2  ) flag = false;
	if( flag ){
		for(char c = 'a' ; c <= 'z' ; c++ ){
			ans = ans / fact( m[c]/2 );
		}
	}
	if( flag )
		cout << ans << endl;
	else
		cout << 0 << endl;
}

Measured memory_bytes: 0
from fractions import gcd

a, b, c, d = list(map(int, input().split() ))

lcm = c * d // gcd(c,d)
temp1 = b - b//c - b//d + b//lcm
temp2 = (a-1) - (a-1)//c - (a-1)//d + (a-1)//lcm

print(temp1 - temp2)


Measured memory_bytes: 5472
#include <cstdio>

int main(int argc, char const *argv[]){
//	freopen("in.txt", "r", stdin);

	char s[21];
	while(scanf("%s", s) != EOF){
		int i = 0;
		while(s[i] != '\0')i ++;
		i --;
		while(i >= 0){
			printf("%c", s[i]);
			i --;
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 936
#include <stdio.h>
#include <vector>
#include <array>
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>

using std::string;
using std::vector;

double toRad(double angle) {
    return angle * M_PI / 180;
}
// a^2 = b^2 + c^2 - 2bc cos A
// b^2 = c^2 + a^2 - 2ca cos B
// c^2 = a^2 + b^2 - 2ab cos C
int main(){
    double a, b, c;
    scanf("%lf %lf %lf", &a, &b, &c);

    const double x = std::sqrt(
        std::pow(a, 2.0) + std::pow(b, 2.0) - (2.0 * a * b * std::cos(toRad(c)))
    );

    const double h = std::sin(toRad(c)) * b;
    const double area = a * h / 2;
    const double circumfrence = a + b + x;
    printf("%lf %lf %lf\n", area, circumfrence, h);
    return 0;
}


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

int main(){
	char s[2][60];
	scanf("%s %s", s[0], s[1]);
	for(int i=0; s[i%2][i/2]!='\0'; i++) putchar(s[i%2][i/2]);
	putchar('\n');
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long a, b, c, d;
    cin >> a >> b >> c >> d;

    long tmp1 = a * c;
    long tmp2 = a * d;
    long tmp3 = b * c;
    long tmp4 = b * d;
    
    long ans = max(tmp1, tmp2);
    ans = max(ans, tmp3);
    ans = max(ans, tmp4);

    cout << ans << endl;
}

Measured memory_bytes: 3632
BUILDGS_COUNT = 4
FLOOR_COUNT = 3
ROOM_COUNT = 10

buildings = [[[0 for i in range(ROOM_COUNT)] for j in range(FLOOR_COUNT)] for k in range(BUILDGS_COUNT)]

n = int(input())
for i in range(n):
  b, f, r, v = list(map(int, input().split()))
  buildings[b-1][f-1][r-1] += v

for i in range(BUILDGS_COUNT):
  for j in range(FLOOR_COUNT):
    for k in range(ROOM_COUNT):
      print(' {}'.format(buildings[i][j][k]), end='')
    print()
  if i != BUILDGS_COUNT-1:
    print('####################')


Measured memory_bytes: 5624
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}
int f[2000];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    memset(f, 0, sizeof(f));
    int n = gi();
    int x = gi()-1;
    int y = gi()-1;
    for (int i = 0; i < n; i++)
        for (int j = i+1; j < n; j++) {
            int d = j-i;
            int d1 = abs(i-x) + 1 + abs(j-y);
            d = MIN(d, d1);
            d1 = abs(i-y) + 1 + abs(j-x);
            d = MIN(d, d1);
            f[d]++;
        }

    for (int i = 1; i < n; i++)
        printf("%d\n", f[i]);

    return 0;
}


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

using namespace std;

const int N=1e6+3;

const double eps=0.000000001;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

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

const int inf=1e9,mod=1e9+7;

int n,m,a[N],b[N],k,q,u,v,x,y,tc,c,l,r,ans,cnt[100005];

char s[N];

void IO(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("test.txt","r",stdin);
	#endif
}

int main(){
	//IO();
	scanf("%s",s);
	char c=s[0];
	for(int i=1;s[i];i++)
		if (s[i]!=c)
			return !printf("Yes\n");
	printf("No\n");	
}


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

int main() {
  int n;
  cin >> n;
  
  int64_t a, b, ans = 0;
  unordered_map<int64_t,int64_t> m;
  for(int i=0; i<n; i++) {
    cin >> a;
    m[a]++;
    ans += a;
  }
  
  int q;
  cin >> q;
  for(int i=0; i<q; i++) {
    cin >> a >> b;
    m[b] += m[a];
    ans += (b-a)*m[a];
    m.erase(a);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 6684
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(i%2==1)
			cnt++;
	}
	double ans=1.0*cnt/n;
	printf("%.10lf\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
  public static void main(final String[] args) {

    Scanner sc = new Scanner(System.in);
    String sNum1 = sc.next();
    String sNum2 = sc.next();
    String sNum3 = sc.next();
    String sReuslt;
    int iResult = 0;
    if (sNum1.equals(sNum2)) {
      iResult++;
    }
    if (sNum2.equals(sNum3)) {
      iResult++;
    }
    if (sNum1.equals(sNum3)) {
      iResult++;
    }
    if (1 == iResult) {
      sReuslt = "Yes";
    } else {
      sReuslt = "No";
    }
    System.out.print(sReuslt);
  }
}


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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, k, n) for (int i = k; i < n; ++i)
#define fore(i,a) for (auto &i : a)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, q;
    cin >> n >> q;
    string S;
    cin >> S;
    vector<char> T(q), D(q);
    rep(i, q) cin >> T[i] >> D[i];

    int left = 0, right = n;
    int t;
    while (left + 1 < right) {
        t = (left + right) / 2;

        int cur = t;
        bool check = false;
        rep(i, q) {
            if (T[i] == S[cur]) {
                if (D[i] == 'L') --cur;
                else ++cur;
            }
            if (cur == -1) {
                check = true;
                break;
            }
            if (cur == n) {
                break;
            }
        }

        if (check) left = t;
        else right = t;
    }

    int ans1 = right;

    left = 0, right = n;
    while (left + 1 < right) {
        t = (left + right) / 2;

        int cur2 = t;
        bool check = false;
        rep(i, q) {
            if (T[i] == S[cur2]) {
                if (D[i] == 'L') --cur2;
                else ++cur2;
            }
            if (cur2 == n) {
                check = true;
                break;
            }
            if (cur2 == -1) {
                break;
            }
        }

        if (check) right = t;
        else left = t;
    }

    int ans2 = left;

    cout << ans2 - ans1 + 1 << endl;

    return 0;
}

Measured memory_bytes: 976
#include <iostream>
using namespace std;
int main ()
{int N;
 cin>>N;
 N%=10;
 if (N==2||N==4||N==5||N==7||N==9)
 {cout<<"hon";}
 else if (N==0||N==1||N==6||N==8)
 {cout<<"pon";}
 else {cout<<"bon";}
return 0;}










Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>

#define N 100

int main() {
	static char s[N + 1][16], t[N + 1][16];
	int n, m, h, i, j, max, cnt;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%s", s[i]);
	scanf("%d", &m);
	for (j = 0; j < m; j++)
		scanf("%s", t[j]);
	max = 0;
	for (h = 0; h < n; h++) {
		cnt = 0;
		for (i = 0; i < n; i++)
			if (strcmp(s[h], s[i]) == 0)
				cnt++;
		for (j = 0; j < m; j++)
			if (strcmp(s[h], t[j]) == 0)
				cnt--;
		if (max < cnt)
			max = cnt;
	}
	printf("%d\n", max);
	return 0;
}


Measured memory_bytes: 128
from operator import mul

n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = []
count = 0
for i in range(n):
  a.append(list(map(int, input().split())))
for j in range(n):
  if sum(list(map(mul, b, a[j])))+c > 0:
    count += 1
print(count)

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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
using vvl = vector<vl>;
using pll = pair<ll,ll>;
using vb = vector<bool>;

const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;

#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define xx first
#define yy second

#define has(c,i) ((c).find(i) != end(c))
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define FORD(i,a,b) for (int i=int(b)-1; i>=(a); i--)

#define rv(type,name,count) vector<type> name(count); FOR(_i,0,count) cin >> name[_i];
#define grid(type,name,c1,c2) vector<vector<type>> name(c1, vector<type>(c2)); FOR(_i,0,c1)FOR(_j,0,c2)cin >> name[_i][_j];

int main() {
	ll n, k;
	cin >> n >> k;
	vl v(n);
	FOR(i,0,n) cin >> v[i];
	vl best(n);
	best[0] = 0;
	FOR(i,1,n) {
		best[i] = best[i-1] + abs(v[i] - v[i-1]);
		FOR(kk, 1, k+1) {
			if (i-kk >= 0)
				best[i] = min(best[i], best[i-kk] + abs(v[i]-v[i-kk]));
		}
	}
	cout << best[n-1] << endl;
}


Measured memory_bytes: 1792
/**
 *　　　　　　　　┏┓　　 　┏┓
 * 　　　　　　　┏┛┗━━━━━━━┛┗━━━┓
 * 　　　　　　　┃　　　　　　　┃ 　
 * 　　　　　　　┃　　　━　　 　┃
 * 　　　　　　　┃　＞　　　＜　┃
 * 　　　　　　　┃　　　　　　　┃
 * 　　　　　　　┃...　⌒　... 　┃
 * 　　　　　　　┃　　　　　　　┃
 * 　　　　　　　┗━┓　　　┏━┛
 * 　　　　　　　　　┃　　　┃　Code is far away from bug with the animal protecting　　　　　　　　　　
 * 　　　　　　　　　┃　　　┃   神兽保佑,代码无bug
 * 　　　　　　　　　┃　　　┃　　　　　　　　　　　
 * 　　　　　　　　　┃　　　┃  　　　　　　
 * 　　　　　　　　　┃　　　┃
 * 　　　　　　　　　┃　　　┃　　　　　　　　　　　
 * 　　　　　　　　　┃　　　┗━━━┓
 * 　　　　　　　　　┃　　　　　　　┣┓
 * 　　　　　　　　　┃　　　　　　　┏┛
 * 　　　　　　　　　┗┓┓┏━┳┓┏┛
 * 　　　　　　　　　　┃┫┫　┃┫┫
 * 　　　　　　　　　　┗┻┛　┗┻┛
 */ 
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#define inc(i,l,r) for(int i=l;i<=r;i++)
#define dec(i,l,r) for(int i=l;i>=r;i--)
#define link(x) for(edge *j=h[x];j;j=j->next)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define eps 1e-12
#define succ(x) (1<<x)
#define lowbit(x) (x&(-x))
#define sqr(x) ((x)*(x))
#define mid (x+y>>1)
#define NM 200005
#define nm 7000000
#define pi 3.1415926535897931
using namespace std;
const ll inf=1000000;
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}
 

ll n,k,ans;
int main(){
	n=read();k=read();
	inc(i,k+1,n){
		if(n%i){
			ll t=n/i;
			ans+=t*(i-k);
			if(n%i>=k)if(k)ans+=n%i-k+1;else ans+=n%i;
		}else{
			ll t=n/i;
			ans+=t*(i-k);
		}
	}
	printf("%lld\n",ans);
	return 0;
}


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

using namespace std;

int main()
{
//    freopen("TEST.INP", "r", stdin);
    int n;
    cin >> n;
    set <string> s;
    string m;
    while (n--)
    {
        cin >> m;
        s.insert(m);
    }
    cout << s.size();
    return 0;
}


Measured memory_bytes: 19052
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2005;
const int MOD = 1e9 + 7;	
#define LL long long
int n,ans,C[N][N];
inline LL qpow(LL a,int x) {
	LL res = 1;
	for(;x;x >>= 1) (x & 1) && (res = res * a % MOD),a = a * a % MOD;
	return res;
}
inline int calc(int sum,int len) {
	return C[sum-1][len-1];
}
signed main() {
	scanf("%lld",&n);
	if(n <= 2) return puts("0"),0;
	C[0][0] = 1;
	for(int i = 1;i <= n;++i) {
		C[i][0] = C[i][i] = 1;
		for(int j = 1;j < i;++j)
			C[i][j] = (C[i-1][j-1] + C[i-1][j]) % MOD;
	}
	for(int len = 1;len*3 <= n;++len)
		(ans += calc(n-len*2,len)) %= MOD;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 26444
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

int a[1000001];
int insertionSort(int n,int g){
	int ct = 0;
	FOR(i,g,n){
		int v = a[i];
		int j = i-g;
		while(j>=0&&v<a[j]){
			a[j+g]=a[j];
			j-=g;
			ct++;
		}
		a[j+g] = v;
	}
	return ct;
}

int shellSort(int n){
	int G[100];
	int m = 0;
	for(int h = 1;;){
		if(h>n)break;
		G[m++] = h;
		h = 3*h+1;
	}
	int ct = 0;
	RREP(i,m)ct+=insertionSort(n,G[i]);

	cout << m << endl;
	REP(i,m){if(i)cout << ' ';cout << G[m-1-i];}
	cout << '\n';
	cout << ct << endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n;cin>>n;
	REP(i,n)cin>>a[i];
	shellSort(n);
	REP(i,n)cout << a[i] << endl;
  return 0;
}

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


int main(){
  int N,L;
  cin>>N>>L;
  string str[110];
  for(int i=0;i<N;i++){
    cin>>str[i];
  }
  sort(str,str+N);
  for(int i=0;i<N;i++){
    cout<<str[i];
  }
  cout<<endl;
  return 0;
}


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

int main(){
	int N;
	cin >> N;
	int d[N];
	for(int i = 0; i < N; i++) cin >> d[i];
	int center = N / 2;
	sort(d, d+N);
	int res = d[center] - d[center - 1];
	cout << res << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
//#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
int ans = 0;
signed main() {
	string s; cin >> s;
	reverse(all(s)); s += '0';
	//cerr << s << endl;
	for0(i, s.size()) {
		if (s[i] > '9') {
			s[i] = s[i] - '9' + '0' - 1;
			s[i + 1]++;
		}
		if (s[i] > '5') {
			ans += '9' - s[i] + 1;
			s[i + 1]++;
		}
		else if (s[i] == '5') {
			int j = i;
			while (s[j] == '5')j++;
			if (j - i >= 2 || s[j] > '5') s[i + 1]++;
			ans += 5;
		}
		else {
			ans += s[i] - '0';
		}
		s[i] = '0';
		cerr << s << ' ' << ans << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,d;
    cin>>n>>d;
    vector<long long> x(n),y(n);
    for(int i=0; i<n; i++) cin>>x[i]>>y[i];
    int ans=0;
    for(int i=0; i<n; i++){
        double tmp = sqrt(x[i]*x[i] + y[i]*y[i]);
        if(tmp <= d) ans++;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 6464
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n, k;
    cin >> n >> k;
    vector<int> a;
    REP(i, n)
    {
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    sort(a.begin(), a.end());
    int ans = a[k - 1] - a[0];
    REP(i, n)
    {
        if (k - 1 + i >= n)
            break;
        ans = min(ans, a[k - 1 + i] - a[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 892
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	LL N;
	cin >> N;
	vector<LL> P;
	for(int i=0; i<N; i++){
		LL p;
		cin >> p;
		P.push_back(p);
	}
	sort(P.begin(), P.end());

	LL ans = 0;
	for(int i=0; i<N; i++){
		if(i == N-1){
			ans += P[i]/2;
		}
		else{
			ans += P[i];
		}
	}
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 3688
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

int N;
vector<int> edge[10010];
vector<int> p(100010, -1);
vector<int> c(100010);

int cnt = 0;
void dfs(int now){
  rep(i, edge[now].size()){
    int next = edge[now][i];
    if(cnt == N) break;
    if(p[next] != -1) continue;
    p[next] = c[cnt++];
    dfs(next);
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  int a, b;
  rep(i, N-1){
    cin >> a >> b;
    a--, b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  rep(i, N) cin >> c[i];
  sort(c.begin(), c.end());
  reverse(c.begin(), c.end());
  dfs(0);

  ll ans = 0;
  rep(i, N){
    rep(j, edge[i].size()){
      ans += min(p[i], p[edge[i][j]]);
    }
  }
  cout << ans / 2 << endl;
  rep(i, N) cout << p[i] << " ";
  cout << endl;
}


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

int main(){
    int n;
    cin>>n;
    vector<int>d(n);
    for(int i=0;i<n;i++){
        cin>>d.at(i);
        }
    int t,ans=10000000;
    for(int i=0;i<=100;i++){
        t=0;
        for(int j=0;j<n;j++){
        t+=(d.at(j)-i)*(d.at(j)-i);
        }
        ans=min(ans,t);
        }
    cout<<ans<<endl;
    }


Measured memory_bytes: 256