akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define sz(s) (int)s.size()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

ll power(ll x,ll y){
	ll t=1;
	while(y>0){
		if(y%2) y-=1,t=t*x%mod;
		else y/=2,x=x*x%mod;
	}
return t;
}

int cnt[26],ans[26];
char s[N];

int main(){
	int n,m;
	scanf("%d",&n);
	scanf("%s",s);
	m=strlen(s);
	REP(i,m)
		ans[s[i]-'a']++;
	// REP(j,26) printf("%d ",ans[j]);
	// printf("\n");
	REP(i,n-1){
		FILL(cnt,0);
		scanf("%s",s);
		m=strlen(s);
		REP(j,m)
			cnt[s[j]-'a']++;
		REP(j,26) ans[j]=min(ans[j],cnt[j]);
		// REP(j,26) printf("%d ",ans[j]);
		// printf("\n");
	}
	REP(j,26){
		REP(k,ans[j]){
			printf("%c",'a'+j);
		}
	}
	printf("\n");
	return 0;
}

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

int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,a,b;
    cin>>n>>a>>b;
    if(abs(a-b)%2==0)
    cout<<abs(a-b)/2;
    else
    {
    	ll d=min(a-1+b-1,n-a+n-b);
    	cout<<d/2+1;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

pair<int,int> operator+(const pair<int,int>&left, const pair<int,int> &right){
	return MP(left.first+right.first,min(left.second,right.second));
}


int h,w,S;
int sal;
pair<int,int> dp[32][32][32][32];
int s[32][32];

int sm(int a,int b,int c,int d){
	if(a==0&&b==0){
		return s[c][d];
	}
	if(a==0){
		return s[c][d]-s[c][b-1];
	}
	if(b==0){
		return s[c][d]-s[a-1][d];
	}
	return s[c][d]-s[c][b-1]-s[a-1][d]+s[a-1][b-1];
}


pair<int,int> saiki(int a,int b,int c,int d){
	if(dp[a][b][c][d]!=MP(-1,-1)){
		return dp[a][b][c][d];
	}
	// cout << a << " " << b << " " << c << " " << d << endl;
	// cout << sm(a,b,c,d) << endl;
	if(sm(a,b,c,d)<sal){
		return dp[a][b][c][d] = MP(0,0);
	}
	pair<int,int> p = MP(1,sm(a,b,c,d)-sal); 
	for(int i=a;i<c;i++){
		if(saiki(a,b,i,d)==MP(0,0))continue;
		if(saiki(i+1,b,c,d)==MP(0,0))continue;
		p = max(p,saiki(a,b,i,d)+saiki(i+1,b,c,d));
	}
	for(int i=b;i<d;i++){
		if(saiki(a,b,c,i)==MP(0,0))continue;
		if(saiki(a,i+1,c,d)==MP(0,0))continue;
		p = max(p,saiki(a,b,c,i)+saiki(a,i+1,c,d));
	}
	return dp[a][b][c][d] = p;
}
int main(){
	while(cin >> h >> w >> S && h!=0){
		Fill(dp,MP(-1,-1));
		Fill(s,0);
		vector<vector<int> > v(h,vector<int>(w));
		sal = 0;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin >> v[i][j];
				sal += v[i][j];
			}
		}
		sal -=S;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(j==0){
					s[i][j] = v[i][j];
				}else{
					s[i][j] = s[i][j-1] + v[i][j];
				}
			}
		}
		for(int i=1;i<h;i++){
			for(int j=0;j<w;j++){
				s[i][j] += s[i-1][j];
			}
		}

		auto x = saiki(0,0,h-1,w-1);

		cout << x.first << " " << x.second << endl;
	}
	return 0;
}


Measured memory_bytes: 11240
# AGC017A - Biscuits
def main():
    n, p = tuple(map(int, input().rstrip().split()))
    A = tuple(map(int, input().rstrip().split()))
    e = sum(i % 2 == 0 for i in A)  # even
    if e == n:
        print(2 ** n if p == 0 else 0)
    else:
        print(2 ** (n - 1))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl a,b,x;
    cin >> x >> a >> b;
    string s;
    if(a >= b)s = "delicious";
    else if(a + x >= b)s = "safe";
    else s = "dangerous";
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
# Your code here!
a = gets.split.map(&:to_i)
# p a
dis = a[3]
if (a[0] - a[1]).abs <= dis && (a[1] - a[2]).abs <= dis
    puts "Yes"
elsif (a[0] - a[2]).abs <= dis
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 1788
L, A, B, M = map(int, raw_input().split())

T = []
for w in range(0, len(str(A+B*(L-1)))):
  l0 = ((10**w-1)-A)/B+1
  l1 = ((10**(w+1)-1)-A)/B+1
  T += [(max(0, min(l1, L)-max(l0, 0)), A+B*max(0, l0), w+1)]
#for t in T:
#  print t

def f(L, w):
  if L==1:
    return 1
  t = f(L/2, 2*w)*(pow(10, w, M) + 1)%M
  if L%2!=0:
    t = (t*pow(10, w, M) + 1)%M
  return t

def g(L, B, w):
  if L==1:
    return 0
  t = (g(L/2, B*2, w*2)*(pow(10, w, M) + 1) + B*f(L/2, w*2))%M
  if L%2!=0:
    t = (t*pow(10, w, M) + B*(L-1))%M
  return t

ans = 0
w = 0
for t in T[::-1]:
  if t[0]>0:
    ans += (t[1]*f(t[0], t[2]) + g(t[0], B, t[2]))*pow(10, w, M)
    ans %= M
  w += t[2]*t[0]
print ans


Measured memory_bytes: 2696
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs
#include <cstdio>	// require printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;

const int MAX_N = 1000000+1;

int euler[MAX_N];

void euler_phi2 (void )
{
	for (int i = 0; i < MAX_N; i++ )
		euler[i] = i;
	for (int i = 2; i < MAX_N; i++ ){
		if (euler[i] == i ){
			for (int j = i; j < MAX_N; j += i )
				euler[j] = euler[j] / i * (i - 1);
		} // end if
	} // end for
}	

int main()
{

//	cut here before submit 
//	freopen ("testcase.FS2", "r", stdin );
	
	euler_phi2 ();

	int t;
	cin >> t;

	while (t-- ){
		int n;
		cin >> n;
		ll res = 1LL;
		for (int i = 1; i <= n; i++ ){
			res += (ll)euler[i];
		} // end for
		cout << res << endl;

	} // end loop

	return 0;
}

Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using P = pair<int, int>;

signed main() {

    int r;
    cin >> r;

    double ans = (double) (2 * r) * M_PI;

    cout << fixed << setprecision(7) << ans << endl;

    return 0;
}


Measured memory_bytes: 3784
#!/usr/bin/env python

from sys import stdin, stderr

def main():
   A, B = map(int, stdin.readline().split())
   res = 0
   E = 1
   while E < B:
      E -= 1
      E += A
      res += 1

   print(res)

   return 0

if __name__ == '__main__': main()


Measured memory_bytes: 2568
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int n,longth,sub1,sub2,num,mem;
char a[100],b[100],ans[100] = {0};
int main()
{
    scanf("%d",&n);
    for(int i = 0; i < n; i++)
    {
        scanf("%s%s",a,b);
        sub1 = strlen(a);
        sub2 = strlen(b);
        longth = max(sub1,sub2);
        for(int i = 0; i < longth; i++)
        {
            ans[i] = '0';
        }
        if(strlen(a) < longth)
        {
            for(int i = sub1 - 1; i >= 0; i--)
            {
                a[i + longth - sub1] = a[i];
            }
            for(int i = 0; i < longth - sub1; i++)
            {
                a[i] = '0';
            }
        }
        if(strlen(b) < longth)
        {
            for(int i = sub2 - 1; i >= 0; i--)
            {
                b[i + longth - sub2] = b[i];
            }
            for(int i = 0; i < longth - sub2; i++)
            {
                b[i] = '0';
            }
        }
        for(int i = 0; i < longth; i++)
        {
            num = a[longth - 1 - i] - '0' + b[longth - 1 - i] - '0' + ans[i] - '0';
            ans[i] = (num % 10) + '0';
            if(10 <= num)ans[i + 1] = '1';
        }
        mem = strlen(ans);
        if(mem > 80)printf("overflow\n");
        else
        {
            for(int i = mem - 1; i >= 0; i--)
            {
                printf("%c",ans[i]);
            }
            printf("\n");
        }
        for(int i = 0; i < mem; i++)
        {
            ans[i] = 0;
        }
    }
    return 0;
}

Measured memory_bytes: 2592
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int use[10004][1300]; 
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  while(cin>>N>>M,N||M) {
    CLR(use);
    int r; cin >> r;
    FOR(i,0,r) {
      int t, n , m , s;
      cin >> t >> n >> m >> s;
      if(s == 1) {
        use[m][t]++;
      } else {
        use[m][t]--;
      }
    }
    FOR(i,1,M+1) {
      FOR(j,0,1299) {
        use[i][j+1] += use[i][j];
      }
    }
    int q; cin >> q;
    FOR(i,0,q) {
      int ts, te, m;
      cin >> ts >> te >> m;
      int ans = 0;
      FOR(j,ts,te) {
        if(use[m][j] > 0) ans++;
      }
      cout << ans << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 53844
#include <algorithm>
#include <iostream>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <deque>
#include <list>
#include <iterator>
#include <cctype>
#include <cstdio>
#include <cstring>
#define rep(counter, limit) for (int counter = 0; counter < limit; counter++)
typedef long long ll; using namespace std;const int INF=1001001001;
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
int main() {

  int n,m;
  cin>>n>>m;
  int sum=0;
  rep(i,m){
    int input;
    cin>>input;
    sum+=input;
  }
  if(n-sum > -1){
    cout<<n-sum<<endl;
  }else{
    cout<<"-1"<<endl;
  }


}


Measured memory_bytes: 3680
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>

using namespace std;
using ll = long long;

ll gcd( ll m, ll n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd

ll lcm( ll m, ll n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm

int main(){
    ll n,m;
    string s,t;
    cin >> n >> m;
    cin >> s;
    cin >> t;
    ll num=lcm(m,n);
    ll gc=gcd(n,m);
    for(long int i=0;i<gc;i++){
        if(s[i*n/gc]!=t[i*m/gc]){
            cout<<-1<<endl;
            return 0;
        }
  }
    cout << num << endl;
	return 0;
}

Measured memory_bytes: 512
/**
Md: Jubayer Hossen Jame
**/

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

int main()
{
    int ara1[] = {1, 3, 5, 7, 8, 10, 12};
    int ara2[] = {4, 6, 9, 11};

    int b, e;
    bool flag_b = false, flag_e = false;
    cin >> b >> e;

    for(int i = 0; i < 7; ++i)
    {
        if(ara1[i] == b)flag_b = true;
        if(ara1[i] == e)flag_e = true;
    }
    if(flag_b && flag_e)
    {
        cout << "Yes\n";
        return 0;
    }


    flag_b = flag_e = false;
    for(int i = 0; i < 4; ++i)
    {
        if(ara2[i] == b)flag_b = true;
        if(ara2[i] == e)flag_e = true;
    }
    if(flag_b && flag_e)
    {
        cout << "Yes\n";
        return 0;
    }

    if(b == 2 and e == 2)
    {
        cout << "Yes\n";
        return 0;
    }

    cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int a[50][26];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        string s;
        cin >> s;
        for (char c : s)
            a[i][c - 'a']++;
    }
    for (int i = 0; i < 26; ++i)
    {
        int mi = 1e9;
        for (int j = 0; j < n; ++j)
            mi = min(mi, a[j][i]);
        cout << string(mi, 'a'+i);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 100000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    ll N, M;
    cin >> N >> M;
    VL ans(N + 1);
    VVL graph(N + 1);
    rep(i, 0, M){
        ll A, B;
        cin >> A >> B;
        graph[A].pb(B);
        graph[B].pb(A);
    }
    VL first = graph[1];
    ans[1] = 1;
    queue<pair<ll, ll>> que;
    for(ll i : first) que.push(make_pair(i, 1));
    while(!que.empty()){
        pair<ll, ll> q = que.front();
        que.pop();
        if(!ans[q.first]){
            ans[q.first] = q.second;
            VL g = graph[q.first];
            for(ll i : g){
                if(!ans[i]){
                    que.push(make_pair(i, q.first));
                }
            }
        }
    }

    for(int i = 2; i < ans.size(); i++){
        if(!ans[i]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    for(int i = 2; i < ans.size(); i++){
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 14956
N, K = map(int, input().split())
*A, = map(int, input().split())
dp = [0]*(K+1)
dp[0] = 1
MOD = 10**9 + 7
for i in range(N):
    c = sum(dp[K-A[i]:K+1]) % MOD
    for j in range(K, -1, -1):
        v = dp[j]
        dp[j] = c
        c -= v
        if j-A[i]-1 >= 0:
            c += dp[j-A[i]-1]
        c %= MOD
print(dp[K])

Measured memory_bytes: 44748
if __name__ == '__main__':
    try:
        n = int(raw_input())
    except:
        print 'the first input must be integer value!'
        exit()

    genoms = set([])
    answers = []
    for _ in range(n):
        values = raw_input().split()
        order = values[0]
        genom = values[1]
        if order == "insert":
            genoms.add(genom)
        else:
            # TODO: fasten here!
            answers.append('yes' if genom in genoms else 'no' )

    # print(genoms)
    # print(answers)

    for answer in answers:
        print answer

Measured memory_bytes: 63760
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

void add(ll &a, ll b) {
  a += b;
  if (a >= mod) a -= mod;
}

int main(){
	string s;cin>>s;
	ll n = s.size();
	vector<vector<ll>> dp(3LL * n ,vector<ll>(5,0LL));
	dp[0][0] = 1LL;
	for(int i = 0; i < n; i++) {
		if (s[i] == '?'){
			for(int j = 0; j < 4; j++) {
				if (j != 0){
					dp[i + 1][j] = ((dp[i][j - 1] + (3LL * dp[i][j] % mod)) % mod);
				}
				else{
					dp[i + 1][j] = ((3LL * dp[i][j]) % mod);
				}
			}
		}
		else{
			int index = (s[i] - 'A') + 1;
			for(int j = 0; j < 4; j++) {
				if (j == index){
					dp[i + 1][j] = ((dp[i][j - 1] + dp[i][j]) % mod);
				}
				else{
					dp[i + 1][j] = dp[i][j];
				}
			}
			
			
		}
	}
	cout << dp[n][3] << endl;
	return 0;
}

Measured memory_bytes: 21504
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 
int main() {
  int a[10],b[10],adj[10]={};
  for(int i=0; i<3; i++){
    cin >> a[i] >> b[i];
    if(a[i]==1) adj[1]+=1; if(b[i]==1) adj[1]+=1;
    if(a[i]==2) adj[2]+=1; if(b[i]==2) adj[2]+=1;
    if(a[i]==3) adj[3]+=1; if(b[i]==3) adj[3]+=1;
    if(a[i]==4) adj[4]+=1; if(b[i]==4) adj[4]+=1;
  }
  if(adj[1]==1 && adj[2]==2 && adj[3]==2 && adj[4]==1){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    private static void solve() {
        final Scanner scanner = new Scanner(System.in);

        while (true) {
            int math = scanner.nextInt();
            int algorithm = scanner.nextInt();
            int impl = scanner.nextInt();
            math += scanner.nextInt();
            algorithm += scanner.nextInt();
            impl += scanner.nextInt();
            if (math + algorithm + impl == 0) {
                break;
            }
            int maximum = math / 3 + algorithm / 3 + impl / 3;
            maximum += Math.min(Math.min(math % 3, algorithm % 3), impl % 3);
            if (math % 3 == 2 && algorithm % 3 == 2 && impl % 3 == 0 && impl > 0 ||
                algorithm % 3 == 2 && impl % 3 == 2 && math % 3 == 0 && math > 0 ||
                impl % 3 == 2 && math % 3 == 2 && algorithm % 3 == 0 && algorithm > 0) {
                maximum++;
            }
            System.out.println(maximum);
        }
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 13000
mod = 1000000007

def sgn(v):
    return (v > 0) - (v < 0)

def solve():
    v.sort(key=abs, reverse=True)
    res = 1
    flag = 1
    for i in range(k):
        res *= v[i]
        res %= mod
        flag *= sgn(v[i])
    if flag >= 0:
        return res
    if max(v) <= 0:
        res = 1
        for i in range(-k, 0, 1):
            res *= v[i]
            res %= mod
        return res

    def get(comp):
        i = k - 1
        while i >= 0 and comp(v[i]):
          i -= 1
        j = k
        while j < n and not comp(v[j]):
          j += 1
        if j == n: j = i
        return i, j
      
    i, j = get(lambda w: w >= 0)
    i2, j2 = get(lambda w: w <= 0)
    if i2 >= 0 and v[j] * v[i2] < v[i] * v[j2]:
        i = i2
        j = j2

    res = v[j]
    for a in range(k):
        if a != i:
            res *= v[a]
            res %= mod
    return res

n, k = map(int, input().split(" "))
v = list(map(int, input().split(" ")))
print (solve())

Measured memory_bytes: 31680
// finish date: 2018/01/28
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000

#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;


int main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int count = 0;
    rep(i, A+1) {
        rep(j, B+1) {
            rep(k, C+1) {
                if (500 * i + 100 * j + 50 * k == X) count++;
            }
        }
    }
    cout << count << endl;


    return 0;
}



Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
#define int long long int
int mod = INT_MAX;
int memo[3005][3005];
int n;
int top(int a[], int i, int j)
{
	int &ans = memo[i][j];
	if (i > j)
		return 0;
	if (ans != -1)
		return ans;
	int turn = (n - 1 - (j - i)) % 2;
	if (turn == 0) //player 1 turn
	{
		ans = ((max(a[i] + top(a, i + 1, j), a[j] + top(a, i, j - 1)))) ;
	}
	else//player 2 turn
	{
		ans = (min(top(a, i + 1, j), top(a, i, j - 1)));
	}
	return ans ;
}
int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	cin >> n;
	int a[n];
	int sum = 0;
	memset(memo, -1, sizeof(memo));
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	int x = top(a, 0, n - 1);
	int y = sum - x;
	//cout << x << " " << y << " " << sum << endl;
	cout << (x - y);
	return 0;
}
// 3 8
// 3 30
// 4 50
// 5 60

Measured memory_bytes: 71040
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#include<ctime>
#include<queue>
using namespace std;
#define int long long
#define pii pair <int, int>
#define XX first
#define YY second

// constants:
const int mn = 200005;
const int mod = 1000000007;
const long long inf = 4444444444444444444;
const int sminf = 1111111111;
const bool is_multitest = 0;
const bool is_interactive = 0;

// i/o methods:
const bool input_from_file = 0;
const bool output_to_file = 0;
#define filename ""
#define in_extension "inp"
#define out_extension "out"

// data preprocessing: (e.g.: divisor generating, prime sieve)
void preprocess()
{
    
}

// global variables:
string s;
// main solution goes here:
void execute(int test_number)
{
    cin>>s;
    if (s=="RRR") cout<<3;
    else if (s[1] == 'R' && (s[0] == 'R' || s[2] == 'R')) cout<<2;
    else if (s=="SSS") cout<<0;
    else cout<<1;
}
// REMEMBER TO CHOOSE TEST METHODS
// PLEASE REMOVE cout AND cerr DEBUG LINES BEFORE SUBMITTING PROBLEMS
// Solution by low_



















signed main()
{
#ifdef lowie
    if (!is_interactive)
    {
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    }
#else
    if (input_from_file) freopen(filename"."in_extension, "r", stdin);
    if (output_to_file) freopen(filename"."out_extension, "w", stdout);
#endif
    if (!is_interactive)
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }

    preprocess();
    int ntest;
    if (is_multitest) cin >> ntest;
    else ntest = 1;

    for (int testno = 1; testno <= ntest; testno++)
    // use for instead of while to serve facebook hacker cup test format
    {
        execute(testno); // only start coding in this function, not in main
    }
}
// Template by low_
// Contact me via mail: ttuandung1803@gmail.com
// ...or codeforces: www.codeforces.com/profiles/low_
// ...or if you're interested in food: www.instagram.com/lowie.exe/

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define LB(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define UB(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 

ll mod = 1e9 ;

#define each(a,x) for( auto &a:(x))
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define rep2r(i, l, r) for (ll i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()
// cout<<endl;


int main()
{
	fastio();
	ll n, k, s;
	cin>>n>>k>>s;
	rep(i, k)
	{
		cout<<s<<" ";
	}
	rep(i, n-k) 
	{
		if(s != mod)
			cout<<mod<<" ";
		else
			cout<<1<<" ";
	}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;
int main()
{
  int N, A, answer;
  cin >> N >> A;
  answer = N % A == 0 ? N / A : (N / A )+ 1;
  cout << answer << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
 
  if((a==1)&&(b==1))
    	cout<<1000000;
  else if((a==1)&&(b==2))
    	cout<<500000;
  else if((a==1)&&(b==3))
    	cout<<400000;
  else if((a==2)&&(b==1))
    	cout<<500000;
  else if((a==2)&&(b==2))
    	cout<<400000;
  else if((a==2)&&(b==3))
    	cout<<300000;
  else if((a==3)&&(b==1))
    	cout<<400000;
  else if((a==3)&&(b==2))
    	cout<<300000;
  else if((a==3)&&(b==3))
    	cout<<200000;
  else if((a==1)&&(b>3))
    	cout<<300000;
  else if((a==2)&&(b>3))
    	cout<<200000;
  else if((a==3)&&(b>3))
    	cout<<100000;
   else if((b==1)&&(a>3))
    	cout<<300000;
  else if((b==2)&&(a>3))
    	cout<<200000;
  else if((b==3)&&(a>3))
    	cout<<100000;
  else 
    	cout<<0;
  
  
  
}


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

using namespace std;
typedef long long ll;

int H, W;
int dp[101][101];
char s[101][101];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> H >> W;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> s[i][j];
            dp[i][j] = 10000;
        }
    }
    if(s[0][0] == '.'){
        dp[0][0] = 0;        
    }else{
        dp[0][0] = 1;
    } 
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(s[i][j] == '.'){
                if(i+1 < H && s[i+1][j] == '.') dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
                if(i+1 < H && s[i+1][j] == '#') dp[i+1][j] = min(dp[i+1][j], dp[i][j]+1);
                if(j+1 < W && s[i][j+1] == '.') dp[i][j+1] = min(dp[i][j+1], dp[i][j]);
                if(j+1 < W && s[i][j+1] == '#') dp[i][j+1] = min(dp[i][j+1], dp[i][j]+1);
            }else{
                // cout << i << ' ' << j << endl;
                if(i+1 < H && s[i+1][j] == '.') dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
                if(i+1 < H && s[i+1][j] == '#') dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
                if(j+1 < W && s[i][j+1] == '.') dp[i][j+1] = min(dp[i][j+1], dp[i][j]);
                if(j+1 < W && s[i][j+1] == '#') dp[i][j+1] = min(dp[i][j+1], dp[i][j]);
            }
            // cout << dp[i][j] << ' ';
        }
        // cout << endl;
    }
    cout << dp[H-1][W-1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <algorithm>
#include <queue>

using namespace std;

#define INT_MAX 2147483647

//long gcd(long m, long n);
//long lcm(long m, long n);

int main(void) {

	double a, b;
	double ans;
	cin >> a >> b;
	ans = a / b;



	cout << ans << endl;
	return 0;

}

// 2番目から3要素だけ抜き出した部分文字列を取得する
//std::string result = s.substr(2, 3);  
#if 0
//最大公倍数
long gcd(long m, long n)
{
	long temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
long lcm(long m, long n)
{
	return m * n / gcd(m, n);
}
#endif

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const int mod=998244353;
int main(){
    ll a,b,c;cin>>a>>b>>c;
    if(a+b+c>=22)cout<<"bust"<<endl;
    else cout<<"win"<<endl;
}

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

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

	std::vector<std::vector<double>> dp(n+1, std::vector<double>(n+1));
	// dp[i][j]: i個中、j個が表の確率
	dp[0][0] = 1.0;
	for(int i=0; i<n; i++){
		for(int j=0; j<=i; j++){
			dp[i+1][j+1] += p[i]*dp[i][j]; 
			dp[i+1][j] += (1.0-p[i])*dp[i][j];
		}
	}

	double ans = 0;
	for(int i=n/2+1; i<=n; i++){
		ans += dp[n][i];
	}
	printf("%.10f \n", ans);
	return 0;
}

Measured memory_bytes: 70656
n = int(input())
ab = [list(map(int,input().split())) for _ in range(n)]
cd = [list(map(int,input().split())) for _ in range(n)]
ab.sort(key = lambda x: x[1] ,reverse =True)
cd.sort(key = lambda x: x[0])
ab_bool = [True]*n
cnt = 0
for i in range(n):
  for j in range(n):
    if cd[i][0] > ab[j][0] and cd[i][1] > ab[j][1] and ab_bool[j]:
      cnt += 1
      ab_bool[j] = False
      break
print(cnt)

    
  

Measured memory_bytes: 3188
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
 
const int N=505;
struct node{
    int go[2];
    node(){go[0]=go[1]=0;}
};
vector<node> trie(2);
char num[256];
void add(const string&s){
    int v=1;
    for(char c:s){
        if(!trie[v].go[c-'0']){
            trie[v].go[c-'0']=sz(trie); 
            trie.pb();
        }
        v=trie[v].go[c-'0'];
    }
    // trie[v].term=1;
}
int g(int v,int d){
    int s=0,c=0;
    forn(i,2){
        int to=trie[v].go[i];
        if(to)c++,s^=g(to,d-1);
    }
    if(c&1){
        int x=__builtin_ctzll(d)+1;
        s^=x;
    }
    return s;
}
int32_t main(){
    int n,len;
    cin>>n>>len;
    string s;
    forn(i,n){
        cin>>s;
        add(s);
    }
    int k=g(1,len);
    if(k)cout<<"Alice\n";
    else cout<<"Bob\n";
    return 0;
}

Measured memory_bytes: 9736
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
typedef unsigned long long ll;

int my_gcd(int n , int m){
  if(n < m){
    int tmp = n;
    n = m;
    m = tmp;
  }
  int l  = n % m;
  while(l != 0){
    n = m;
    m = l;
    l = n % m;
}
return m;
}

int main(){
	int N; cin >> N;
	vector<int> A(N);
	rep(i,N) cin >> A[i];
	int ans = 0;
	rep(i,N-1){
		A[i+1] = my_gcd(A[i] , A[i+1]);
	}
		cout << A[N-1] <<endl;
	}	

Measured memory_bytes: 640
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		

	 		StringTokenizer st = new StringTokenizer(bf.readLine());
	 		int a = Integer.parseInt(st.nextToken());
	 		int b = Integer.parseInt(st.nextToken());
	 		int c = Integer.parseInt(st.nextToken());
	 		
	 	int k = Integer.parseInt(bf.readLine());
 		int count = 0;
 		while(b <= a){
 			b*=2;
 			count++;
 		}
 		while(c <= b){
 			c*=2;
 			count++;
 		}
 		
 		out.println(count<=k ? "Yes" : "No");
	 		
 		out.close();
 		
 		
 		
 	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	




Measured memory_bytes: 25444
package main

import (
	"io"
	"bufio"
	"fmt"
	"os"
	"strconv"
)

/*******************
マージソートを応用する。
********************/

const (
	SENTINEL = 2000000000
)

func main() {
	fmt.Println(answer(os.Stdin))
}

func answer(r io.Reader) string {
	sc := bufio.NewScanner(r)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	A := make([]int, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		A[i], _ = strconv.Atoi(sc.Text())
	}
	return strconv.Itoa(mergeSort(A, n, 0, n))
}

func merge(A []int, n, left, mid, right int) int {
	n1 := mid - left
	n2 := right - mid
	L, R := make([]int, n1+1), make([]int, n2+1)
	for i := 0; i < n1; i++ {
		L[i] = A[left+i]
	}
	for i := 0; i < n2; i++ {
		R[i] = A[mid+i]
	}
	L[n1], R[n2] = SENTINEL, SENTINEL

	cnt := 0
	i, j := 0, 0
	for k := left; k < right; k++ {
		if L[i] <= R[j] {
			A[k] = L[i]
			i++
			continue
		}
		A[k] = R[j]
		j++
		cnt += n1 - i
	}
	return cnt
}

func mergeSort(A []int, n, left, right int) int {
	if left+1 < right {
		mid := (left + right) / 2
		v1 := mergeSort(A, n, left, mid)
		v2 := mergeSort(A, n, mid, right)
		v3 := merge(A, n, left, mid, right)
		return v1 + v2 + v3
	}
	return 0
}



Measured memory_bytes: 8052
#include<bits/stdc++.h>
#define fi first
#define se second
#define mk make_pair
using namespace std;
const int MAXN = 1e3 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
typedef long long LL;
typedef pair<int, int> PII;
char s[MAXN], k;
int dp[MAXN][4][2];


int main() {
    scanf("%s%d", s + 1, &k);
    int len = strlen(s + 1);
    dp[0][0][1] = 1;
    for(int i = 1; i <= len; ++i){
        for(int j = 0; j <= 3; ++j){
            for(int r=0; r <= 1; ++r){
                int up = r ? s[i] - '0' : 9;
                if(j == k)  up = 0;
                for(int h = 0; h <= up; ++h){
                    dp[i][j + (h!=0)][r&&(h==up)] += dp[i-1][j][r];
                }
            }
        }
    }
    printf("%d\n", dp[len][k][0] + dp[len][k][1]);
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

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

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

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

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

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

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

const MODULO: i64 = 1_000_000_007;

fn main() {
  input! {
    n: usize,
    k: usize,
    aa: [usize; n]
  }
  let mut dp = vec![vec![0i64; k+1]; 2];
  dp[0][0] = 1;
  for (i, &a) in aa.iter().enumerate() {
    dp[(i+1)%2][0] = 1;
    for c in 0 .. k {
      let x = dp[(i+1)%2][c] + dp[i%2][c+1];
      dp[(i+1)%2][c+1] = if x >= MODULO { x - MODULO } else { x };
      if let Some(d) = c.checked_sub(a) {
        let y = dp[(i+1)%2][c+1] - dp[i%2][d];
        dp[(i+1)%2][c+1] = if y < 0 { y + MODULO } else { y };
      }
    }
  }
  println!("{}", dp[n%2][k]);
}


Measured memory_bytes: 6396
n = int(input())
t = [int(input()) for _ in range(n)]

def gcd(a,b):
    if b == 0:
        return a
    return gcd (b, a%b)

#2数の積/最大公約数=最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

if n == 1:
    print(t[0])
    exit(0)
ans = lcm(t[0], t[1])
for i in range(1, n-1):
    ans = lcm(ans, t[i+1])
print(ans)

Measured memory_bytes: 3064
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
const int MAX_N =1001;

//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int V,d;
int dp[MAX_N+1];
int par[1001];
void fib(){
  dp[0] =2;
  dp[1] =3;
  for(int i = 2;i <=MAX_N;i++){
    dp[i] =(dp[i-1]+dp[i-2])%MAX_N;
  }
}

void init(int v){
  for(int i = 0;i <=v;i++){
    par[i] = i;
  }
}
int find(int x){
  if(par[x]==x){
    return x;
  }else{
    return par[x]=find(par[x]);
  }
}

void unit(int x,int y){
  x = find(x);
  y = find(y);
  if(x!=y){
    par[y] = x;
  }else{
    return;
  }
}
bool same(int x,int y){
  return (find(x)==find(y));
}
int main()
{
  fib();
  while(cin>>V>>d){
    init(V);
    int memo[MAX_N+1]={0};
    for(int i = 0;i <V;i++){
      for(int j = i+1;j <V;j++){
	if(abs(dp[i]-dp[j])<d){
	  unit(i,j);
	}
      }
    }
    int ans = 0;
    for(int i =0;i <V;i++){
      int root =find(i);
      if(memo[root] ==0){
	memo[root] = 1;
	ans++;
      }
    }
    cout <<ans<<endl;
  }

  
  return 0;
}

Measured memory_bytes: 1168
#include <cstdio>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <climits>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <deque>
#include <vector>
#include <string>
#include <bitset>
#define y0 qvya13579
#define y1 qvyb24680
#define j0 qvja13579
#define j1 qvjb24680
#define next qvne13579xt
#define prev qvpr13579ev
#define INF 1000000007
#define PI acos(-1.0)
#define endl "\n"
#define IOS cin.tie(0);ios::sync_with_stdio(false)
#define M_P make_pair
#define P_B push_back
#define U_B upper_bound
#define L_B lower_bound
#define P_Q priority_queue
#define FIR first
#define SEC second
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP_R(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZ(x) ((int)(x).size())
#define COUT(x) cout<<(x)<<endl
#define CIN(x) cin>>(x)
#define CIN2(x,y) cin>>(x)>>(y)
#define CIN3(x,y,z) cin>>(x)>>(y)>>(z)
#define CIN4(x,y,z,w) cin>>(x)>>(y)>>(z)>>(w)
#define SCAND(x) scanf("%d",&(x))
#define SCAND2(x,y) scanf("%d%d",&(x),&(y))
#define SCAND3(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define SCAND4(x,y,z,w) scanf("%d%d%d%d",&(x),&(y),&(z),&(w))
#define SCANLLD(x) scanf("%lld",&(x))
#define SCANLLD2(x,y) scanf("%lld%lld",&(x),&(y))
#define SCANLLD3(x,y,z) scanf("%lld%lld%lld",&(x),&(y),&(z))
#define SCANLLD4(x,y,z,w) scanf("%lld%lld%lld%lld",&(x),&(y),&(z),&(w))
#define PRINTD(x) printf("%d\n",(x))
#define PRINTLLD(x) printf("%lld\n",(x))
typedef long long int lli;
using namespace std;

int ctoi(char c)
{
  if( c >= '0' and c <= '9' )
    {
      return (int)(c-'0');
    }

  return -1;
}

int alphabet_pos(char c) 
{
  if( c >= 'a' and c <= 'z' )
    {
      return (int)(c-'a');
    }

  return -1;
}


int alphabet_pos_capital(char c)
{
  if( c >= 'A' and c <= 'Z' )
    {
      return (int)(c-'A');
    }

  return -1;
}


vector<string> split(string str, char ch)
{
  int first = 0;
  int last = str.find_first_of(ch);
  
  if(last == string::npos)
    {
      last = SIZ(str);
    }

  vector<string> result;

  while( first < SIZ(str) )
    {
      string Ssubstr(str, first, last - first);
      result.push_back(Ssubstr);
      first = last + 1;
      last = str.find_first_of(ch, first);

      if(last == string::npos)
	{
	  last = SIZ(str);
	}
    }
  
  return result;
}

/*--------------- the end of the template --------------------*/









int main()
{
  //IOS; /* making cin faster */
  int N,K;
  SCAND2(N,K);
  
  vector<int> x(N);
  
  REP(i,N)
    {
      SCAND(x[i]); 
    }

  int dist = INF;

  REP(i,N-K+1)
    {
      if( min( abs(x[i]) + abs(x[i] - x[i+K-1]) , abs(x[i+K-1]) + abs(x[i] - x[i+K-1]))  < dist )
	{
	  dist = min( abs(x[i]) + abs(x[i] - x[i+K-1]) , abs(x[i+K-1]) + abs(x[i] - x[i+K-1]));
	  
	}
        
	
    }

  PRINTD(dist);
  

}


Measured memory_bytes: 640
#include <iostream>/*{{{*/
#include <bits/stdc++.h>
#define REP(i, x) for(int i = 0; i < (int)(x); i++)
#define REPS(i,x) for(int i = 1; i <= (int)(x); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x,y) memset(x,y,sizeof(x))
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define PB(a) push_back(a)
#define debug(x) cerr << __LINE__ << ": " << #x << " -> " << x << '\n'
#define INF 999999999
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};/*}}}*/

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

  ll x,y;
  cin >> x >> y;

  ll z = y/x;
  int res = 0;
  while (true){
    if (z==1){
      break;
    }

    z >>= 1;
    res += 1;
  }

  cout << res + 1 << endl;

  return 0;
}


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

int main() {
	string s;
	cin >> s;
	int now = 15 - s.size();
	int cont = 0; 
	for (int i = 0; i <= s.size()-1; i++) {
		if (s[i] == 'o')
			cont++;
	}
	cout << (cont+now >= 8 ? "YES" : "NO") << endl;
}

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

int main()
{
	int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=k;i<n;i++)
    {
        if(a[i]>a[i-k])
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 4412
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 1000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define stp setprecision(15)
#define eps 0.000001
#define endl '\n'
#define ll lli
 
using namespace std ;
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
#define N 8
  
int main() 
{ 

/////////////////////////////////////
    
    fastio;
 
/////////////////////////////////////    

  lli a,b;
  cin>>a>>b;

  if((a+b)%2 == 0) cout<<(a+b)/2;
  else cout<<"IMPOSSIBLE"<<endl;  
 
} 

Measured memory_bytes: 256