akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
 
#define INF 10000000
 
int main(){
  int n,i,j,k,l,t,m[101],c,o;
  int mm[101][101];
  
  
  scanf("%d",&n);
  for(i = 1 ; i < n+1; i++){
    scanf("%d%d",&m[i-1],&m[i]);
  }
  
for( i = 1 ; i <= n ; i++ ){
    mm[i][i] = 0;
  }  
  
  for(l = 2 ; l <n+1 ; l++){
  	for(i=1;i<n-l+2;i++) {
  		o=i+l-1;
    mm[i][o] = INF;
  
    for(k = i ; k < o ; k++){
t=mm[i][k] + mm[k+1][o] + m[i-1] * m[k] *m[o];

        if(t < mm[i][o])
          mm[i][o] = t;
        }
      }
    }
  printf("%d\n",mm[1][n]);
  return 0;
  }


Measured memory_bytes: 2056
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <queue>
#include <assert.h>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
using ll = long long;
using ld = long double;
const ll inf = 1000000000000000008;
ll N, A, B, C, D;
vector<ll> mul = {2, 3, 5};

unordered_map<ll, ll> Map;

ll calc(ll n) {
	if(n==0ll) return 0ll;
	if(n==1ll) return D;
	if(Map.count(n)) return Map[n];
    
	ll ret = inf;
	if(n<ret/D) ret = n*D;
	assert(ret>=0);

	for(auto x:mul) {
		ll ex;
		if(x==2) ex = A;
		else if(x==3) ex =B;
		else ex = C;
		if(n%x==0) ret = min(ret, calc(n/x)+ex);
		else {
			ll up = (n/x+1)*x;
			ll down = (n/x)*x;
			ret = min(ret, calc(down/x)+D*(n-down)+ex);
			ret = min(ret, calc(up/x)+D*(up-n)+ex);
		}
	}
	return Map[n] = ret;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll tc; cin>>tc;
	while(tc--) {
		cin>>N>>A>>B>>C>>D;
		cout << calc(N) << '\n';
		Map.clear();
	}
	return 0;
}

Measured memory_bytes: 4156
#include <bits/stdc++.h>
#define ll long long
#define INF (ll) 1e9+7
#define maxn 200009
#define MOD 1000000007
#define inp freeopen("input.txt","r",stdin);
#define out freeopne("output.txt","w",stdout);
using namespace std; 
int n;
ll vet[maxn],dp[maxn][2];
ll solve(int id,bool troca){
    if(id>=n-1)return vet[id];
    if(dp[id][troca]!=-1)return dp[id][troca];
    ll a=solve(id+1,false)+vet[id];
    vet[id+1]*=-1;
    ll b=solve(id+1,true)+(-1)*vet[id];
    vet[id+1]*=-1;  
    dp[id][troca]=max(a,b);
    return dp[id][troca];
}
int main(){
    ios::sync_with_stdio(false);
    memset(dp,-1,sizeof dp);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>vet[i];
    }
    cout<<solve(0,0)<<endl; 
}   

Measured memory_bytes: 9088
#include <stdio.h>


int main(int argc, char **argv)
{
  int n,x,i;
  int kosu = 0;
  int m[1000];
  scanf("%d %d",&n,&x);
  for(i = 0 ; i < n ; i++){
    scanf("%d",&m[i]);
    x = x - m[i];
    kosu++;
  }
  for(i = 0 ; i < n -1 ; i++){
    if(m[i] < m[i + 1])
      m[i + 1] = m[i];
  }
  while(x >= m[n - 1]){
    kosu++;
    x = x - m[n - 1];
  }
  printf("%d\n",kosu);

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int to[200005],dis[200005];
int main()
{
	int n;
	ll k;
	scanf("%d%lld",&n,&k);
	for(int i=1;i<=n;i++)scanf("%d",&to[i]);
	int now=1;
	while((!dis[to[now]])&&to[now]!=1)
		dis[to[now]]=dis[now]+1,now=to[now];
	ll len=dis[now]-dis[to[now]]+1;
	//cout<<now<<" "<<to[now]<<" "<<len<<endl;
	if(k>dis[to[now]])
	{
		k-=dis[to[now]];
		k%=len;
		k+=dis[to[now]];
	}
	now=1;
	//cout<<k<<endl;
	while(k--)now=to[now];
	cout<<now;
	return 0;
}

Measured memory_bytes: 5324
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define fix(n) cout<<fixed<<setprecision(n);
using namespace std;
//using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  while(1){
    int a,b,c; cin>>a>>b>>c;
    if(a==-1 && b==-1 && c==-1) break;
    if(a==-1 || b==-1){
      co("F");
      continue;
    }
    int n=a+b;
    if(n>=80) co("A");
    else if(n>=65) co("B");
    else if(n>=50 || c>=50) co("C");
    else if(n>=30) co("D");
    else co("F");
  }
  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll k,a,b;
  cin>>k>>a>>b;
  if(a/k!=b/k || a%k==0 || b%k==0)
    cout<<"OK"<<endl;
  else
    cout<<"NG"<<endl;

}



Measured memory_bytes: 3652
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		
		double re = Math.pow(K-1,N-1);
		
		int ans = (int)re;
		
		System.out.println(ans * K);
	}
}


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

using namespace std;



int main() {
 int n;
 cin>>n;
 int k;
 cin>>k;
 int s;
 cin>>s;
 if (k==n) {
     while (n--) cout<<s<<" ";
     cout<<endl;
 } else {
     int t=k;
     while (t--) cout<<s<<" ";
     t=n-k;
     
     if (s<100000000) {
         while (t--) cout<<100000000<<" ";
     }
     else {
         while (t--) cout<<1<<" ";
     }
     cout<<endl;
 }
 
 return 0;
}

Measured memory_bytes: 1280
S = input()
N = len(S)

cnt1 = sum([1 for i in range(N) if i%2==0 and S[i]=="0"])
cnt2 = sum([1 for i in range(N) if i%2!=0 and S[i]=="1"])

cnt3 = sum([1 for i in range(N) if i%2==0 and S[i]=="1"])
cnt4 = sum([1 for i in range(N) if i%2!=0 and S[i]=="0"])

ans = min(cnt1 + cnt2, cnt3 + cnt4)
print(ans)

Measured memory_bytes: 3572
// ----- In the name of ALLAH, the Most Gracious, the Most Merciful -----

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

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                 \
  sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(    \
            c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
  eni(!=) cerr << boolalpha << i;
  ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
  sim dor(const c &) { ris; }
#endif
}
;
#define deb(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define memo(dp, val) memset(dp, val, sizeof(dp))
#define NINJA                                                                  \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define all(a) a.begin(), a.end()
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, k, n) for (int i = k; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define dloop(i, n) for (int i = n - 1; i >= 0; i--)
#define iii tuple<int, int, int>
#define vi vector<int>
#define ii pair<int, int>
#define vii vector<ii>
#define int long long
#define ld long double
#define pb push_back
#define endl "\n"
#define setbits __builtin_popcountll
#define mp map<int, int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007
#define inf (int)1e18

bool cmp(ii x, ii y) { return (x.first + x.second) < (y.first + y.second); }

bool cmp2(ii x, ii y) { return (x.first - x.second) < (y.first - y.second); }

int32_t main() {
  NINJA;

  int n;
  cin >> n;

  vii a(n), b(n);

  fo(i, n) {
    cin >> a[i].first >> a[i].second;
    b[i].first = a[i].first;
    b[i].second = a[i].second;
  }

  sort(all(a), cmp);
  sort(all(b), cmp2);

  int pos1 = (a[n - 1].first + a[n - 1].second) - (a[0].first + a[0].second);
  int pos2 = (b[n - 1].first - b[n - 1].second) - (b[0].first - b[0].second);

  cout << max(pos1, pos2) << endl;

  return 0;
}

Measured memory_bytes: 9500
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int a[3];
    REP(i,3)cin >> a[i];
    sort(a,a+3);
    int answer = 0;
    answer += (a[2]-a[0])/2;
    answer += (a[2]-a[1])/2;
    if(((a[2]-a[0])%2 == 1) && ((a[2] - a[1])%2 == 1))cout << answer + 1 <<endl;
    else if(((a[2]-a[0])%2 == 0) && ((a[2] - a[1])%2 == 0))cout << answer <<endl;
    else cout << answer + 2 << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
n = int(input())
mod = 10**9+7
g = [[] for i in range(n)]
g2 = [[] for i in range(n)]
for i in range(n-1):
  x,y = list(map(int,input().split()))
  g[x-1].append(y-1)
  g[y-1].append(x-1)
dp = [[0]* 2 for i in range(n)]
hukasa = [float("inf")]*n
hukasa[0] = 0
def dfs(x,y):
  for i in g[x]:
    if hukasa[i] > y+1:
      hukasa[i] = y+1
      que.append([i,y+1])
      g2[x].append(i)
que = deque([])
que.append([0,0])
while que:
  x,y = que.popleft()
  dfs(x,y)
for i in range(n):
  hukasa[i] = [hukasa[i],i]
hukasa.sort(key = lambda x:-x[0])
for i,j in hukasa:
  if len(g2[j]) == 0:
    dp[j][0] = dp[j][1] = 1
    continue
  tmp = 1
  tmp2 = 1
  for k in g2[j]:
    tmp *= dp[k][0]
    tmp2 *= (dp[k][0]+dp[k][1])
    tmp %= mod
    tmp2 %= mod
  dp[j][1] = tmp
  dp[j][0] = tmp2
print((dp[0][0]+dp[0][1])%mod)

Measured memory_bytes: 102688
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

const int INF = (int)1e18;

signed main(){
	int L;
	cin >> L;
	vector<int> A(L);
	for(int i= 0; i < L; ++i) {
		cin >> A[i];
	}
	vector<vector<int>> dp(5, vector<int>(L + 10, INF));
	for(int i = 0; i < 5; ++i) dp[i][0] = 0;
	for(int i = 0; i < L; ++i) {
		for(int k = 0; k < 5; ++k) {
			int c;
			if (k == 1 || k == 3) {
				if (A[i] == 0) {
					c = 2;
				} else if(A[i] % 2 == 1) {
					c = 1;
				} else {
					c = 0;
				}
			} else if(k == 0 || k == 4) {
				c = A[i];
			} else {
				c = A[i] % 2 == 0 ? 1 : 0;
			}
			//cerr << c << ",";
			dp[k][i + 1] = dp[k][i] + c;
			if (k > 0) {
				dp[k][i + 1] = min(dp[k][i + 1], dp[k - 1][i + 1]);
			}
			//cerr << dp[k][i + 1] << "|";
		}
		//cerr << endl;
	}
	cout << dp[4][L] << endl;
	return 0;
}


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

int main(){
  int a,b,c,x,at=0;
  cin>>a>>b>>c>>x;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        if(500*i+100*j+50*k==x){
          at++;
        }
      }
    }
  }
  cout<<at<<endl;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;
int N,K;

const ll mo=998244353;


ll from[303][606];
ll to[303][606];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S>>K;
	vector<int> V;
	V.push_back(0);
	
	int sum=0;
	FORR(c,S) {
		if(c=='1') V.back()++, sum++;
		else V.push_back(0);
	}
	K=min(K,sum);
	N=V.size();
	
	from[K][300]=1;
	FOR(y,V.size()) {
		int v=V[y];
		//cout<<"#"<<endl;
		ZERO(to);
		for(j=K;j>=0;j--) {
			for(i=300;i<=300+sum;i++) if(from[j][i]) {
				//cout<<"!"<<j<<" "<<(i-300)<<" "<<from[j][i]<<endl;
				for(int tar=0;tar<=min(v+j,sum);tar++) {
					if(y==V.size()-1 && tar>v) break;
					if(tar<=v) {
						(to[j][i+(tar-v)]+=from[j][i])%=mo;
						//cout<<"-go "<<j<<" "<<(i-300)<<" -> "<<j<<" "<<(i+(tar-v)-300)<<" "<<from[j][i]<<endl;
					}
					else {
						(to[j-(tar-v)][i+(tar-v)]+=from[j][i])%=mo;
						//cout<<"+go "<<j<<" "<<(i-300)<<" -> "<<(j-(tar-v))<<" "<<(i+(tar-v)-300)<<" "<<from[j][i]<<endl;
					}
				}
			}
		}
		swap(from,to);
	}
	//cout<<"$$"<<endl;
	/*	for(j=K;j>=0;j--) {
			for(i=300-sum;i<=300+sum;i++) if(from[j][i]) {
				cout<<"!"<<j<<" "<<(i-300)<<" "<<from[j][i]<<endl;
			}
		}
	
*/
	ll ret=0;
	FOR(i,K+1) ret+=from[i][300];
	cout<<ret%mo<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

using namespace std;

#define int long long
#define reg register
#define Raed Read
#define clr(a,b) memset(a,b,sizeof a)
#define Mod(x) (x>=mod)&&(x-=mod)
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define rep(a,b,c) for(reg int a=(b),a##_end_=(c); a<=a##_end_; ++a)
#define ret(a,b,c) for(reg int a=(b),a##_end_=(c); a<a##_end_; ++a)
#define drep(a,b,c) for(reg int a=(b),a##_end_=(c); a>=a##_end_; --a)
#define erep(i,G,x) for(int i=(G).Head[x]; i; i=(G).Nxt[i])
#pragma GCC target("avx,avx2,sse4.2")
#pragma GCC optimize(3)

inline int Read(void) {
	int res=0,f=1;
	char c;
	while(c=getchar(),c<48||c>57)if(c=='-')f=0;
	do res=(res<<3)+(res<<1)+(c^48);
	while(c=getchar(),c>=48&&c<=57);
	return f?res:-res;
}

template<class T>inline bool Min(T &a, T const&b) {
	return a>b?a=b,1:0;
}
template<class T>inline bool Max(T &a, T const&b) {
	return a<b?a=b,1:0;
}
const int N=15,M=1e5+5;

bool MOP1;



bool MOP2;
	
void _main(void) {
//	cerr<<"M="<<(&MOP2-&MOP1)/1024.0/1024.0<<endl;
	int n=Read(),m=Read();
	cout<<(n+m-3)/(n-1);
}

signed main() {
	_main();
}

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

using namespace std;

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

  const long long mod = 1e9 + 7;
  vector<long long> dp(n+1);
  vector<int> l(*max_element(c.begin(), c.end())+1, -1);
  dp[0] = 1;
  for(int i = 0; i < n; ++i) {
    dp[i+1] = dp[i];
    if(l[c[i]] != -1 && l[c[i]] != i) {
      dp[i+1] += dp[l[c[i]]];
      dp[i+1] %= mod;
    }
    l[c[i]] = i+1;
  }
  cout << dp[n] << endl;

  return 0;
}


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

signed main(){
  
  // string s;
  // s = "1111111111111111111111111111111111111111";
  // cout << log2(1000000000000) << endl;
  // cout << s.size() << endl;

  int n;
  cin >> n;

  int x = log2(n);
  int ans = 0;
  while(x){

    ans+=pow(2,x);
    x--;
  }

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LLP;

class BellmanFord {
    private:
        vector<vector<ll>> g;
        vector<ll> d;
        ll V, E;
        bool hasNegative;
    
    public:
        BellmanFord(ll V, vector<vector<ll>> g, ll S);
        ll getCost(ll target);
        bool hasNegativeLoop();
};

BellmanFord::BellmanFord(ll N, vector<vector<ll>> graph, ll S) {
    V = N;
    E = graph.size();
    g = graph;
    d.assign(N, LINF);
    d[S] = 0;
    hasNegative = false;
    ll count = 0;
    while (count <= N) {
        bool update = false;
        rep(i,E) {
            vector<ll> e = g[i];
            if (d[e[0]] < LINF && d[e[1]] > d[e[0]] + e[2]) {
                d[e[1]] = d[e[0]] + e[2];
                update = true;
            }
        }
        if (!update) break;
        count++;
    }
    hasNegative = (count > N);
}

ll BellmanFord::getCost(ll target) {
    return d[target];
}

bool BellmanFord::hasNegativeLoop() {
    return hasNegative;
}

int main() {

    int N, M, P;
    cin >> N >> M >> P;
    vector<vector<ll>> edges(M, vector<ll>(3));
    vector<bool> has_s(N, false), has_g(N, false);
    rep(i,M) {
        cin >> edges[i][0] >> edges[i][1] >> edges[i][2];
        edges[i][0]--;
        edges[i][1]--;
        edges[i][2] -= P;
        edges[i][2] *= -1;
    }
    BellmanFord from(N, edges, 0);
    rep(i,N) has_s[i] = from.getCost(i) < LINF;
    rep(i,M) swap(edges[i][0], edges[i][1]);
    BellmanFord to(N, edges, N - 1);
    rep(i,N) has_g[i] = to.getCost(i) < LINF;
    rep(i,M) swap(edges[i][0], edges[i][1]);

    vector<vector<ll>> g;
    rep(i,M) {
        vector<ll> e = edges[i];
        if (!has_s[e[0]] || !has_g[e[0]]) continue;
        if (!has_s[e[1]] || !has_g[e[1]]) continue;
        g.push_back(e);
    }

    M = g.size();

    BellmanFord bell(N, g, 0);
    if (bell.hasNegativeLoop()) cout << -1 << endl;
    else cout << max((ll)0, (-1) * bell.getCost(N - 1)) << endl;
    
    return 0;
}

Measured memory_bytes: 5224
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		// long t = System.currentTimeMillis();
		new Main().run();
		// System.err.println(System.currentTimeMillis() - t);
	}

	void run() {
		Scanner sc = new Scanner();
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; ++i) {
			a[i] = sc.nextInt();
		}
		System.out.println(f(0, a)[0]);
	}

	long[] f(int cur, int[] a) {
		long[] cnt = new long[2];
		for (int i = a[cur] - 1; i <= a[cur] + 1; ++i) {
			if (i % 2 == 0) {
				++cnt[0];
			} else {
				++cnt[1];
			}
		}
		if (cur == a.length - 1)
			return cnt;
		long[] pre = f(cur + 1, a);
		long[] ret = new long[2];
		ret[0] = (cnt[0] + cnt[1]) * pre[0] + cnt[0] * pre[1];
		ret[1] = cnt[1] * pre[1];
		return ret;
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<int> a(3);
  for (int i = 0; i < 3; i++) cin >> a[i];
  swap(a[0], a[1]);
  swap(a[0], a[2]);
  for (int i = 0; i < 3; i++) {
    cout << a[i];
    char tail = (i == 2) ? '\n' : ' ';
    cout << tail;
  }
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	xs := make([]int, n)
	ys := make([]int, n)
	zs := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&xs[i], &ys[i], &zs[i])
	}

	ans := 0
	for b := 0; b < (1 << 3); b++ {
		ts := make([]int, n)

		for i := 0; i < n; i++ {
			t := 0

			if b&1 == 1 {
				t += xs[i]
			} else {
				t += -xs[i]
			}

			if (b>>1)&1 == 1 {
				t += ys[i]
			} else {
				t += -ys[i]
			}

			if (b>>2)&1 == 1 {
				t += zs[i]
			} else {
				t += -zs[i]
			}
			ts[i] = t
		}

		sort.Ints(ts)
		sum := 0
		for i := 0; i < m; i++ {
			sum += ts[n-i-1]
		}
		ans = max(ans, sum)
	}

	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 640
from collections import deque

def solve(s):
    stack = deque()
    stack.append(s)
    while len(stack) > 0:
        top = stack.pop()
        if top == '':
            return 'YES'

        if top[:5] == 'dream':
            if top[5:7] == 'er':
                stack.append(top[7:])
            stack.append(top[5:])
        elif top[:5] == 'erase':
            if len(top) > 5 and top[5] == 'r':
                stack.append(top[6:])
            else:
                stack.append(top[5:])
    return 'NO'

print(solve(input()))


Measured memory_bytes: 110880
#include<iostream>
#include<queue>
#define INF 100000000
using namespace std;
int main(){
  int n;cin>>n;
  int u,k,v,c;
  int mp[101][101],d[101];
  for(int i=0;i<=100;i++){
    d[i]=INF;
    for(int j=0;j<=100;j++)mp[i][j]=INF;
  }
    while(u!=n-1){
    cin>>u>>k;
    for(int i=0;i<k;i++){
      cin>>v>>c;
      mp[u][v]=c;
    }
  }
    
    queue<int>p;
    int mn,s,t[101]={},cn=n-1;
    d[0]=0,t[0]=1,p.push(0);
    while(cn){
      s=p.back();
      mn=INF;
      for(int i=0;i<n;i++){
	if(t[i]==0){
	  if(d[i]>d[s]+mp[s][i])d[i]=d[s]+mp[s][i];
	  if(mn>d[i])mn=d[i],k=i;
	}
      }
      if(mn!=INF)cn--,t[k]=1,p.push(k);
      else p.pop();
    }
    for(int i=0;i<n;i++)cout<<i<<" "<<d[i]<<endl;
    
  return 0;
}

Measured memory_bytes: 1240
fun main(args: Array<String>) {
    val (n,x) = readLine()!!.split(' ').map(String::toLong)
    val lList = readLine()!!.split(' ').map(String::toLong)
    val dList = mutableListOf<Long>()
    dList.add(0)
    (1..n).forEach { dList.add(dList[it.toInt()-1]+lList[it.toInt()-1]) }
    println(dList.count { it<=x })
}

Measured memory_bytes: 36440
from collections import defaultdict

n,x,y=map(int,input().split())
x-=1
y-=1
dic=defaultdict(int)
for i in range(n-1):
    for j in range(i+1,n):
        temp=min(j-i,abs(x-i)+1+abs(y-j),abs(x-j)+1+abs(y-i))
        dic[temp]+=1
for i in range(1,n): print(dic[i])

Measured memory_bytes: 9716
#include<iostream>
#include<climits>
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp> 
#include<ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define f first
#define s second
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vi vector<int>
#define vll vector<ll>
#define endl '\n'
#define SIZE 1000002
#define w(t) int t;cin>>t;while(t--)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define value_at_idx find_by_order
#define idx order_of_key
#define MOD 1000000007
#define inf INT_MAX
#define Maxheap(T) priority_queue<T>
#define Minheap(T) priority_queue<T,vector<T>,greater<T>>
#define mem(name,value) memset(name,value,sizeof(name))
#define pi 3.14159265358979323846
#define IOS ios::sync_with_stdio(0);cin.tie(0);
typedef long long int ll;
using namespace std;
using namespace __gnu_pbds;
const int p1 = 31;

int main() { IOS
   
    //Use long long
    int q;
    cin>>q;
  	map<string ,int > mp;
	while(q--)
	{
		string x;
		cin>>x;
		mp[x]++;
	}
	
	
		cout<<"AC x "<<mp["AC"]<<endl;
		cout<<"WA x "<<mp["WA"]<<endl;
		cout<<"TLE x "<<mp["TLE"]<<endl;
		cout<<"RE x "<<mp["RE"]<<endl;

	
    return 0;
  	
  	
   
            
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
 
int main() {
    long long int N;
    cin >> N;
    if(N%2 == 1){
        cout << 0 << endl;
    }
    else{
        long long int sum =0;
        long long int bunbo = 10;
        while ( bunbo<= N){
            sum += N / bunbo;
            bunbo *= 5;
        }
        cout << sum << endl;
    }
}

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

int main()
{
    int num;
    cin >> num;
    vector<double> array;
    for (int i = 0; i < num; i++)
    {
        int n;
        cin >> n;
        array.push_back(n);
    }

    double counter = 0.0;
    for (int i = 0; i < num; i++)
    {
        double reverse = 1.0 / array[i];
        counter += reverse;
    }

    double ans = 1.0 / counter;
    cout << ans << endl;
}


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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);

const int N = 1e9 +7;

int fun(int n ,int x)
{
	int ans = 0;
	int t = x;
	while(x <= n)
		ans += n/x , x *= t;

	return ans;
}

int isp(int n)
{
	if(n == 2 || n == 3)
		return 1;
	for(int i=2 ; i*i <=n ;i++)
	{
		if(n%i ==0)
			return 0;
	}
	return 1;
}
int32_t main(){
	fast;
	int n;
	cin >> n;
	int ans = 1;
	
	for(int i=2 ; i<=n ; i++)
	{
		if(isp(i))
		{
			ans *= fun(n,i) + 1;
			ans %= MOD;
		}
	}
	cout << ans;
}



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

using lint = long long;

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

    lint x1 = 1000000000LL, y1 = 1LL, x2, y2, x3 = 0LL, y3 = 0LL;
    y2 = (s - 1LL) / x1 + 1LL;
    x2 = x1 * y2 - s;

    cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;

    return 0;
}

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

#define MAX 1000

int lcs(string X, string Y){
    int c[MAX + 1][MAX + 1];
    int m = X.size();
    int n = Y.size();
    int maxl = 0;
    X = ' ' + X;
    Y = ' ' + Y;
    for(int i = 0; i <= m; i++) c[i][0] = 0;
    for(int i = 1; i <= n; i++) c[0][i] = 0;
    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= n; j++){
            if(X[i] == Y[j]){
                c[i][j] = c[i - 1][j - 1] + 1;
            }else{
                c[i][j] = max(c[i - 1][j], c[i][j - 1]);
            }
            maxl = max(maxl, c[i][j]);
        }        
    }
    return maxl;
}

int main(){
    string s1, s2;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> s1 >> s2;
        cout << lcs(s1, s2) << endl;
    }
    return 0;
}

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

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

int n;
int k;
int q;
int i;
int j;
cin >> n >> k >> q;

vector<int> a(q);
vector<int> p(n);
/*
for(i=0;i<n;++i){
    p[i]=k;
}
*/

for(i=0;i<q;++i){
    cin >> a[i];
    a[i]--;
    p[(a[i])]++;
    /*
    for(j=0;j<n;++j){
        if(a[i]==j){
            continue;
        }else{
            p[j]--;
        }
    }
    */
}

for(i=0;i<n;++i){
    p[i] = p[i] + k - q;
    if(p[i]<=0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}


//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define bit(x,j) ((x>>j)&1)
using namespace std;
// bitset<8>set1(p);
// __builtin_popcountll(x);
// bitset<100> b("1010");
ll int mod=1e9+7;//998244353;
int mul(ll int x, ll int y)
{
    return (x * 1ll * y) % mod;
}

int add(int x, int y)
{
    x += y;
    while(x >= mod) x -= mod;
    while(x < 0) x += mod;
    return x;
}

long long power(long long a, long long b,ll m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = mul(res,a);
        a = mul(a,a);
        b >>= 1;
    }
    return res%m;
    }


  ll int binomial(ll int n, ll int k) 
{ 
    ll int C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll int i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (int j = min(i, k); j > 0; j--) 
            C[j] = add(C[j],C[j-1]); 
    } 
    return C[k]%mod; 
} 
  vector<int> pr;
  bool prime[10000000];
void Sieve(ll int n) 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            pr.push_back(p);
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 

//It reurns Fn,Fn+1
pair<int, int> fib (int n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    int c = p.first * (2 * p.second - p.first);
    int d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}

 ll int sum(ll int n) 
 { 
    ll int s; 
  
    /* Single line that calculates sum */
    for (s = 0; n > 0; s += n % 10, n /= 10); 
  
    return s; 
 } 

ll int factorial(ll int n,ll int m) 
{ 
    ll int fact = 1; 
    for(int i=2;i<=n;i++) { 
        fact = (fact * i)%m; 
    } 
    return fact%m; 
} 

int reduce(int x, int y) 
{ 
    int d; 
    d = __gcd(x, y); 
  
    x = x / d; 
    y = y / d; 
    return x; 
} 

int main() {
  ios;
  ll int n;
  cin>>n;
  if(n==0)
  {
      cout<<1<<endl;
  }
  else{
      cout<<0<<endl;
  }
}


Measured memory_bytes: 3644
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>
   
using namespace std;

int solve(int p, int q, int a, int n, int max, int mul)
{
    if(p == 0) return 1;
    int ans = 0;
    for(int i = max; mul * i <= a; i++){
        if(n * q < p * i) break;
        if(p * i < q) continue;
        ans += solve(p * i - q, i * q, a, n - 1, i, mul * i);
    }
    // cout << ans << endl;
    return ans;
}

int main()
{
    int p, q, a, n;
    while(1){
        cin >> p >> q >> a >> n;
        if(p == 0 && q == 0 && a == 0 && n == 0) break;
        cout << solve(p, q, a, n, 1, 1) << endl;
    }
}

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

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

typedef long long lint;

using namespace std;

int main(){
  char c;
  cin>>c;
  if((c-'a')*(c-'i')*(c-'u')*(c-'e')*(c-'o')==0)cout<<"vowel"<<endl;
  else cout<<"consonant"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n;
int a[200001],ans[200001];
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	rep(i,n)
	cin>>a[i];
	int s=a[0];
	forn(i,1,n)
	s^=a[i];
	ans[0]=s^a[0];
	forn(i,1,n)
	ans[i]=a[0]^a[i]^ans[0];
	rep(i,n)
	cout<<ans[i]<<" ";
	re 0;
}

Measured memory_bytes: 5200
#include<bits/stdc++.h>
#define ll long long
#define mo 1000000007
#define N 200010
using namespace std;
int n,m,a[N],b[N],nb;
ll dp[N],s[N],ans;
int main(){
	cin>>n>>m;
	for (int i=1;i<=m;i++){char ch=getchar();while (ch!='R'&&ch!='B')ch=getchar();a[i]=(ch=='R');}
	for (int la=0,i=1;i<=m;i++)if (a[i]!=a[1]){b[++nb]=i-la-1;la=i;}
	if (nb==0){
		s[0]=s[1]=ans=1;
		for (int i=2;i<n;i++)s[i]=(s[i-1]+s[i-2])%mo;
		for (int j=0;j<n-1;j++)ans=(ans+s[j])%mo;ans=(ans+s[n-2])%mo;
	}else{
		int ma=b[1];
		for (int i=2;i<=nb;i++)if (b[i]%2)ma=min(ma,b[i]);
		if (ma%2==0)ma++;ma++;
		dp[0]=1;s[0]=1;
		for (int i=1;i<=n;i++){
			if (i%2)dp[i]=0;
			else{dp[i]=s[i-1];if (i-ma-1>=0)dp[i]=(dp[i]-s[i-ma-1]+mo)%mo;}
			s[i]=(s[i-1]+dp[i])%mo;
		}
		for (int j=n-2;j>=0;j-=2)if (n-j<=ma)ans=(ans+dp[j]*(n-j))%mo;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String T = sc.next();

    if (S.equals(T.substring(0,S.length()))){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


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

int main(){
    string str;
    cin >> str;
    if(str.substr(0, 4) == "YAKI"){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>

#define INV(A,N) \
  ( (N) - (A) - 1 )
#define MIN(A,B) \
  ( (A) < (B) ? (A) : (B) )
#define MINI(A,B,N) \
  ( MIN( INV(A,N), \
         MIN( INV(B,N), \
              MIN(A,B) ) ) )

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int x, y;
  int d;

  scanf ( "%d", &d );
  while ( d-- )
  {
    int n;

    scanf ( "%d", &n );

    for ( y = 0; y < n; ++y )
    {
      for ( x = 0; x < n; ++x )
      {
        int ch = ' ';

        if ( MINI( x, y, n ) % 2 == 0 ) ch = '#';
        if ( x == n - y )
        {
          if ( y * 2 >  n ) ch = '#';
          if ( y * 2 >= n && !( INV( n, y ) % 2 ) ) ch = ' ';
        }

        putchar ( ch );
      }
      puts ( "" );
    }

    if ( d )  puts ( "" );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int a[200010];
int cnt[200010];
int main(){
	memset(cnt,0,sizeof(cnt));
	int n;
	cin>>n;
	for(int i=2;i<=n;i++){
		cin>>a[i];
		cnt[a[i]]++;
	}
	for(int i=1;i<=n;i++)cout<<cnt[i]<<endl;
	return 0;
}

Measured memory_bytes: 5192
#include <stdio.h>
#include <string.h>
int main(void) {
  char S[100];
  scanf("%s", S);
  int l = strlen(S);
  for (int i = 0; i < l; i++) {
    S[i] = 'x';
  }
  printf("%s\n", S);
  return 0;
}

Measured memory_bytes: 1612
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;


int main()
{
	int a, b;
	cin >> a >> b;
	printf("%d", 6 - a - b);

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  
  /* input data */
  string S;
  cin>> S;
  
  S.at(0)='2';
  S.at(1)='0';
  S.at(2)='1';
  S.at(3)='8';
  
  cout << S << endl;
  
  return 0;
}

Measured memory_bytes: 256
A,B,K = map(int,input().split())
if A+K > B:
    for i in range(A,B+1):
        print(i)
else:
    for i in range(A,A+K):
        print(i)
    if A+K > B-K:
        for i in range(A+K,B+1):
            print(i)
    else:
        for i in range(B-K+1,B+1):
            print(i)

Measured memory_bytes: 3060
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] s = new int[n];
    for(int i = 0; i < n; i++) {
      s[i] = sc.nextInt();
    }
    int q = sc.nextInt();
    List<Integer> t = new ArrayList<>();
    for(int i = 0; i < q; i++) {
      int a = sc.nextInt();
      if(!t.contains(a)) {
        t.add(a);
      }
    }
    int count = 0;
    loop: for(int i = 0; i < t.size(); i++) {
      int key = t.get(i);
      int left = 0;
      int right = n - 1;
      int middle = n / 2;
      while(key != s[middle]) {
        if(key < s[middle]) {
          right = middle - 1;
          middle = (left + right) / 2;
        } else {
          left = middle + 1;
          middle = (left + right) / 2;
        }
        if(left > right) {
          continue loop;
        }
      }
      count++;
    }
    System.out.println(count);
  }
}



Measured memory_bytes: 69748
#include<iostream>
long long t[1001]={0},a[1001]={0};
using namespace std;
int main()
{
	long long n,yes,no,b;
	cin>>n;
	for(long long i=1;i<=n;i++)
	{ 
		cin>>t[i];
		cin>>a[i];
	} 
	for(long long i=1;i<=n;i++)
	{ 
		if(t[i]<=t[i-1]||a[i]<=a[i-1])
		{
			if(t[i-1]%t[i]!=0)
			{
				yes=1;
			}
			else
			{
				yes=0;
			}
			if(a[i-1]%a[i]!=0)
			{
				no=1;
			}
			else
			{
				no=0;
			}
			if(a[i]<a[i-1]&&t[i]<t[i-1])
			{
				b=max(a[i-1]/a[i]+no,t[i-1]/t[i]+yes);
				t[i]=b*t[i];
				a[i]=b*a[i];
				//cout<<"ta[i]"<<"1"<<" ";
			}
			else if(t[i]<t[i-1])
			{
				b=t[i-1]/t[i]+yes;
				//cout<<t[i-1]/t[i]+yes<<" ";
				a[i]=b*a[i];
				t[i]=b*t[i];
				//cout<<"t[i]"<<" "<<"1"<<" ";
			}
			else
			{
				b=a[i-1]/a[i]+no;
				t[i]=b*t[i];
				a[i]=b*a[i];
				//cout<<"a[i]"<<"2"<<" ";
			}
		}
	} 
	//for(long long i=1;i<=n;i++)
	//{
		//cout<<t[i]<<" "<<a[i]<<endl;
	//}
	cout<<t[n]+a[n];
	return 0;
} 

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

using namespace std;

int a[100010][3];
int dp[100010][3];

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

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

    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<3;j++)
        {
            for(int k=0;k<3;k++)
            {
                if(j != k)
                    dp[i][j] = max(dp[i][j],dp[i-1][k]+a[i][j]);
            }
        }
    }

    cout << max(dp[n][0],max(dp[n][1],dp[n][2])) << endl;
}

Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main() {
    int k; cin >> k;
    int a[k]; for (int i = 0; i < k; i++) cin >> a[i];
    long long lb = 2, ub = 3;
    if (a[k-1] != 2) { cout << "-1\n"; return 0; }
    for (int i = k-2; i >= 0; i--) {
        if (lb % a[i] != 0 && ub / a[i] == lb / a[i]) { cout << "-1\n"; return 0; }
        lb = a[i] + (lb - 1) / a[i] * a[i];
        ub = a[i] - 1 + ub / a[i] * a[i];
    }
    cout << lb << " " << ub << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e9;
const ll MOD = 998244353;
double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

ll powMod(ll n, ll x) {
    if(x == 1) return n;
    else if(x == 0) return 1;
    if(x&1) return powMod(n*n%MOD,x/2)*n%MOD;
    else return powMod(n*n%MOD,x/2);
}

int main(){
    int n;
    cin >> n;
    vi d(n);
    rep(i, n) cin >> d[i];
    if(d[0] != 0) {
        cout << 0 << endl;
        return 0;
    }
    vl cnt(n);
    rep(i, n) cnt[d[i]]++;
    if(cnt[0] != 1) {
        cout << 0 << endl;
        return 0;
    } 
    ll ans = 1LL;
    REP(i, 1, n) {
        if(cnt[i] == 0) continue;
        if(cnt[i-1] == 0) {
            cout << 0 << endl;
            return 0;
        }
        (ans *= powMod(cnt[i-1], cnt[i])) %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
mod = 10**9 + 7
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

n, a, b = map(int, input().split())

ans = pow(2,n,mod) -1
ncr = 1
for i in range(1,max(a,b)+1):
  ncr = ncr * (n-i+1) * modinv(i) % mod
  if i == a or i == b:
    ans -= ncr
    if (ans < 0):
      ans += mod
print(ans)

Measured memory_bytes: 3064
#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[i];

int ans = 0;

for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
        ans += d[i] * d[j];
    }
if (i == N-2 )
cout << ans << endl;
}


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
//#define MOD 1000000007
const int INF = 1LL<<30;

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

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

    vector<int> ans;
    for(int i=2;i<55555;i++){
        if(is_prime(i) && i%5==1) ans.push_back(i);
    }
    //cout<<ans.size()<<endl;

    rep(i,n) cout<<ans[i]<<" ";
    cout<<endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <queue>

using namespace std;

struct Process {
    string name;
    int time;
};

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

    queue<Process> qu;

    for (int i = 0; i < n; i++) {
        Process process;
        cin >> process.name >> process.time;
        qu.push(process);
    }

    int timeCount = 0;
    while (!qu.empty()) {
        Process process = qu.front();
        qu.pop();

        process.time -= q;
        if (process.time > 0) {
            qu.push(process);
            timeCount += q;
        }
        else {
            timeCount += q + process.time;
            cout << process.name << " " << timeCount << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 6224
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        int a = sc.nextInt();
        List<String> list = new ArrayList<>();
        StringBuilder ss = new StringBuilder(s1);
        for(int i=0; i < a; i++) {
            String s2 = sc.next();
            int b1 = sc.nextInt();
            int b2 = sc.nextInt();
            switch(s2) {
            case "print":
                String s3 = ss.substring(b1, b2+1);
                list.add(s3);
                break;
            case "reverse":
                String ss1 = ss.substring(b1, b2+1);
                StringBuilder ss2 = new StringBuilder(ss1);
                ss2.reverse();
                ss = ss.replace(b1, b2+1, ss2.toString());
                break;
            case "replace":
                String b3 = sc.next();
                ss = ss.replace(b1, b2+1, b3);
                break;
            default:
                break;
            }
        }
        for(String s : list) {
            System.out.println(s);
        }
    }
}


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

int main() {
  int n,count;
  cin>>n;
  count=0;
  long long a[n];
  for(int i=0;i<n;i++){
    int k;
    cin>>k;
    a[i]=abs(k);
    if(k<0)count++;
  }
  sort(a,a+n);
  long long ans;
  if(count%2==0)ans=a[0];
  else ans=a[0]*(-1);
  for(int i=1;i<n;i++){
    ans+=a[i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
K = int(input())
remainder = 0
ans = -1
 
if K % 2 == 0 or K % 5 == 0:
    ans = -1
else:
    for n in range(1,10**6):
      remainder = (remainder*10 + 7) % K
      if remainder == 0:
          ans = n
          break
      if n == 10**6-1:
          ans = -1
print(ans)

Measured memory_bytes: 9080