akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mk make_pair
#define mod 1000000007
//map<int, int>::iterator itr; 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;cin>>n;
    int arr[n+1];
    for(int i=0;i<=n;i++){
        arr[i]=0;
    }
    for(int i=1;i<=100;i++){
        for(int j=1;j<=100;j++){
            for(int k=1;k<=100;k++){
                ll val=i*i+j*j+k*k+i*j+j*k+i*k;
                if(val<=n){
                    arr[val]++;
                }
            }
        }
    }
    for(int i=1;i<=n;i++){
        cout<<arr[i]<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3692
import math
n, k = map(int, input().split())

ans = 0
for i in range(1, n+1):
    if i > k:
        m = 0
    else:
        m = math.ceil(math.log(k, 2) - math.log(i, 2))
    p = (1 / n) * 0.5 ** m
    ans += p

print(ans)


Measured memory_bytes: 2940
#include<stdio.h>
int main(void)
{
	int ps1,ps2,ps3,ju1,ju2;
	
	scanf("%d",&ps1);
	scanf("%d",&ps2);
	scanf("%d",&ps3);
	scanf("%d",&ju1);
	scanf("%d",&ju2);
	
	
	
	
	
	
	int ps,ju;
	
	ps = 0;
	ju = 0;
	
	
	if(ps1 >= ps2 && ps2 <= ps3)
	{
		ps = ps2;
	}
	
	else if (ps2 >= ps3 && ps3 <= ps1)
	{
		ps = ps3;
	}
	else if(ps3 >= ps1 && ps1 <= ps2)
	{
		ps = ps1;
	}
	
	
	if (ju1 >= ju2)
	{
		ju = ju2;
	}
	
	else if(ju2 >= ju1)
	{
		ju = ju1;
	}
	
	
	
	
	int baka;
	
	
	baka = ju + ps - 50;
	
	
	
	printf("%d\n",baka);
	
}


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

int main(){
    int N;
    cin >> N;
    vector<int> p(N);
    for(size_t i = 0; i < N; i++)
    {
        cin >> p[i];
    }
    int max = -1;
    int ret = 0;
    for (auto price : p){
        ret += price;
        if (price > max)
            max = price;
    }
    ret -= max / 2;
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define pi pair<ll,ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define deba(a) cout << #a << " " <<a << endl;
int main()
{
	fast;
#ifndef ONLINE_JUDGE
	freopen("D:\\input.txt", "r", stdin);
	freopen("D:\\output.txt", "w", stdout);
#endif
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		ll z = n * 800;
		ll x = n / 15;
		z -= (200 * x);
		cout << z;
	}
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main() {
  int n, m, x, y;
  scanf("%d %d %d %d", &n, &m, &x, &y);
  for (int i = 0, a; i < n; ++i) {
    scanf("%d", &a);
    x = max(x, a);
  }
  for (int i = 0, a; i < m; ++i) {
    scanf("%d", &a);
    y = min(y, a);
  }
  if (x < y) puts("No War");
  else puts("War");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

long solve(long n, long a, long b) {
    if (a > b) return 0;
    if (a == b) {
        return 1;
    }
    if (n == 1) return 0;
    return (b - a) * (n - 2) + 1;
}

int main() {
    long n, a, b;
    cin >> n >> a >> b;

    cout << solve(n, a, b) << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))

ans = [0 for _ in range(N+1)]
dic = defaultdict(int)
for a in A:
    dic[a]+=1
for k in range(N+1):
    ans[k] = dic[k]*(dic[k]-1)//2

s = sum(ans)
for i in range(N):
    a = A[i]
    print(s-ans[a]+(dic[a]-1)*(dic[a]-2)//2)

Measured memory_bytes: 102736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vvec<int> g(N);
    for(int i=1;i<N;i++){
        int a;
        cin >> a;
        a--;
        g[a].push_back(i);
    }
    int inf = 1e9;
    vec<int> dp(N,0);

    auto dfs = [&](auto&& self,int cur,int par)->void{
        vec<int> c;
        for(auto& to:g[cur]) if(to!=par){
            self(self,to,cur);
            c.push_back(dp[to]);
        }
        if(c.empty()){
            dp[cur] = 0;
            return ;
        }
        sort(c.rbegin(),c.rend());
        int n = c.size();
        for(int i=0;i<n;i++) dp[cur] = max(dp[cur],c[i]+i+1);
    };

    dfs(dfs,0,-1);
//    for(int i=0;i<N;i++) cerr << i << " " << dp[i] << "\n";
    cout << dp[0] << "\n";
}

Measured memory_bytes: 21572
#include<stdio.h>
   
#define N 100000
 
int Partition(int *,int,int);
 
int main(){
  int n,i,p,r;
  int A[N];
 
  scanf("%d", &n);
 for(i = 0; i < n; i++) {
  scanf("%d", &A[i]);
 }
   
  r = Partition(A,p,n-1);
 
  for(i=0; i<n; i++){
    if(i != 0)
      printf(" ");
    if(r == i)
      printf("[%d]",A[i]);
    else
      printf("%d",A[i]);
  }
  printf("\n");
   
  return 0;
}
 
int Partition(int *A,int p,int r){
  int i,j,s,t;
  s=A[r];
  i=p-1;
  for(j=p;j<=r-1;j++){
    if(A[j]<=s){
      i++;
      t=A[i];     
      A[i]=A[j];
      A[j]=t;
    }
 
  }
 
  t=A[i+1];       
  A[i+1]=A[r];
  A[r]=t;
  return i+1;
}

Measured memory_bytes: 992
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

struct edge{
    int from, to, id;
    edge(int from, int to, int id): from(from), to(to), id(id){}
};

int n, m, X[MAX];
pii p[MAX];
vector<edge> G[MAX];
bool used[MAX];
vector<int> ans;

void dfs(int v, edge pe){
    used[v] = true;
    for(auto &e: G[v])if(!used[e.to]) dfs(e.to, e);
    if(X[v] && pe.from != -1){
        X[v] ^= 1;
        X[pe.from] ^= 1;
        ans.push_back(pe.id);
    }
}

int main(){
    scanf("%d%d", &n, &m);
    rep(i, n) scanf("%d%d", &p[i].fi, &p[i].se);
    p[n] = {mod, 0};
    sort(p, p+n+1);
    X[0] = p[0].se;
    For(i, 1, n+1) X[i] = p[i-1].se ^ p[i].se;

    rep(i, m){
        int L, R;
        scanf("%d%d", &L, &R);
        int l = lower_bound(p, p+n+1, make_pair(L, 0)) - p;
        int r = upper_bound(p, p+n+1, make_pair(R, 1)) - p;
        if(l == r) continue;
        G[l].emplace_back(l, r, i);
        G[r].emplace_back(r, l, i);
    }

    memset(used, false, sizeof(used));
    rep(i, n+1)if(!used[i]){
        dfs(i, {-1, i, -1});
        if(X[i] == 1){
            puts("-1");
            return 0;
        }
    }

    sort(ans.begin(), ans.end());
    printf("%d\n", ans.size());
    for(int i: ans) printf("%d ", i+1);
}

Measured memory_bytes: 16128
import sys
import itertools
from collections import deque
from operator import itemgetter

input = sys.stdin.readline
N, M = map(int, input().split())
k = deque()
counter = 0
for i in range(M):
    k.append(list(map(int, input().split())))
p = list(map(int, input().split()))

counter = 0
for i in range(2**N):
    really = deque()
    bin_str = format(i, '012b')
    bin_str = bin_str[2:]
    for i in range(M):
        sum = 0
        for j in range(k[i][0]):
            sum += int(bin_str[10 - k[i][j+1]])
        if sum % 2 == p[i]:
            really.append(1)
        else:
            really.append(0)
    if really == deque([1]*len(really)):
        counter += 1
print(counter)






Measured memory_bytes: 3316
#include<stdio.h>

int main(void)
{
  unsigned int D; //1-365day
  unsigned int d; 
  unsigned int t[365]; 
  int S[365][26] = {0}; //満足度
  unsigned int i; 
  int s_max=0;
  int state;
  int C[26] = {0}; //不満度
  unsigned int c; 

  //input
  scanf("%d",&D);
  for(c=0;c<26;c++){scanf("%d",&C[c]);}
  for(d=0;d<D;d++)
  {
    for(i=0;i<26;i++){scanf("%d",&S[d][i]);}
  }
  //day
  for(d=0;d<D;d++)
  {
  s_max=S[d][0];
  
    for(i=0;i<26;i++)
  {
      state = s_max-C[i]*d;
    if(S[d][i]>=state)
    {
      t[d] = i+1;
      s_max =S[d][i];
    }
  }
    
  printf("%d\n",t[d]);
  
  }
  
  return 0;
}

Measured memory_bytes: 1772
import java.util.Scanner;

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

    int a = scanner.nextInt();
    int b = scanner.nextInt();
    int c = scanner.nextInt();

    if (a<=b) {
      if (b<=c) System.out.printf("%d %d %d\n", a, b, c);
      else if (a<=c) System.out.printf("%d %d %d\n", a, c, b);
      else System.out.printf("%d %d %d\n", c, a, b);
    } else {
      if (a<=c) System.out.printf("%d %d %d\n", b, a, c);
      else if (c<=b) System.out.printf("%d %d %d\n", c, b, a);
      else System.out.printf("%d %d %d\n", b, c, a);
    }
  }
}


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

int gcd(int x,int y){
	if(y==0) return x;
	else return gcd(y,x%y);
}

int lcm(int x,int y){
	return x*y/gcd(x,y);
}
 
signed main(){
	int n,x;
	cin>>n>>x;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0;i<n;i++){
		if(i==n-1&&x!=a[i]){}
		else if(x>=a[i]){
			ans++;
			x-=a[i];
		}
		else break;
	}
	cout<<ans<<endl;
}

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

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

    A = a + b;
    B = c + d;

    if (A > B)
    {
        cout << "Left" << endl;
    }
    else if (A == B)
    {
        cout << "Balanced" << endl;
    }
    else
    {
        cout << "Right" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 2000000

void maxHeapify(int);

int size, A[MAX];

int main(){
  
  int i;
  
  scanf("%d", &size);
  
  for ( i = 1; i <= size; i++ ){
    scanf("%d", &A[i]);
  }
  
  for ( i = size/2; i >= 1; i-- ) maxHeapify(i);
  
  for ( i = 1; i <= size; i++ ) {
    printf(" %d", A[i]);
  }
  printf("\n");
  
  return 0;
}

void maxHeapify(int i){
  
  int l, r, largest, t;

  l = 2*i;
  r = 2*i+1;

  if ( l <= size && A[l] > A[i] ) largest = l;
  else largest = i;
  if ( r <= size && A[r] > A[largest] ) largest = r;
  if ( largest != i ){
    t = A[i]; A[i] = A[largest]; A[largest] = t;
    maxHeapify(largest);
  }
}

Measured memory_bytes: 2552
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    int n;
    cin >> n;
    int cnt = 0;
    int a, b = 0;
    vi p(n), q(n), r(n);
    rep(i, 0, n) cin >> p[i];
    rep(i, 0, n) cin >> q[i];
    r = q;
    sort(r.begin(), r.end());
    do {
        if (r == p)
            a = cnt;
        if (r == q)
            b = cnt;
        cnt++;
    } while (next_permutation(r.begin(), r.end()));
    cout << abs(a - b) << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
)

func main() {
	/*
		3
		100000
		30000
		20000
	*/
	var n, p int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&p)
		if p%2 != 0 {
			fmt.Println("first")
			os.Exit(0)
		}
	}
	fmt.Println("second")
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

class UnionFind {
    vector<int> par, h;
public:
    UnionFind(int size) {
        par.assign(size, 0);
        h.assign(size, 0);
        REP(i, size) par[i] = i;
    }
    void unite(int u, int v) {
        u = root(u), v = root(v);
        if (u == v) return;
        if (h[u] > h[v]) {
            par[v] = u;
        }
        else if (h[u] < h[v]) {
            par[u] = v;
        }
        else {
            ++h[u];
            par[v] = u;
        }
    }
    bool isUnited(int u, int v) {
        return root(u) == root(v);
    }
    int root(int v) {
        if (par[v] == v) return v;
        return par[v] = root(par[v]);
    }
};

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n, K, L; cin >> n >> K >> L;
    vector<UnionFind> uf(2, UnionFind(n));
    REP(i, K) {
        int a, b; cin >> a >> b; --a, --b;
        uf[0].unite(a, b);
    }
    REP(i, L) {
        int a, b; cin >> a >> b; --a, --b;
        uf[1].unite(a, b);
    }
    map<P, int> cnt;
    REP(i, n) {
        cnt[{uf[0].root(i), uf[1].root(i)}]++;
    }
    vector<int> ans;
    REP(i, n) {
        ans.pb(cnt[{uf[0].root(i), uf[1].root(i)}]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 16928
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    string s;
    cin>>s;
    
    if(s.at(2)==s.at(3) && s.at(4)==s.at(5)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<int,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

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

    int n;
    cin >> n;

    map<int, ll> a;
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        a[x] ++;
        sum += x;
    }

    int q;
    cin >> q;

    for (int i = 0; i < q; ++i) {
        ll b, c;
        cin >> b >> c;

        ll x = a[b];
        sum = sum + (c - b) * x;
        a[c] += a[b];
        a[b] = 0;

        cout << sum << "\n";
    }

    return 0;
}

Measured memory_bytes: 9404
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int N = 1001010;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int cost_a = x * a;
  int cost_b = y * b;
  int best = cost_a + cost_b;

  for(int i = 2; (i >> 1L) <= max(x, y); i += 2) {
    int new_cost = i * c + max(x - (i / 2), 0) * a + max(y - (i / 2), 0) * b;
    best = min(best, new_cost);
  }
  cout << best << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 1000000
#define INF 2000000000
using namespace std;
int n,V,x[MAXN+5];
int cnt[25];
int l[25][MAXN+5],r[25][MAXN+5];
int f1[MAXN*5+5],f2[MAXN*5+5];
bool ans[MAXN+5];
void Init()
{
	for(int i=0;i<=MAXN*5+3;i++)
		f1[i]=0,f2[i]=INF;
}
int UpFind(int id,int pos)
{
	pos++;
	int p=upper_bound(l[id]+1,l[id]+cnt[id]+1,pos)-l[id];
	p--;
	if(p<=0)
		return pos;
	return max(r[id][p],pos-1);
}
int LowFind(int id,int pos)
{
	pos--;
	int p=lower_bound(r[id]+1,r[id]+cnt[id]+1,pos)-r[id];
	if(p>=cnt[id]+1)
		return pos;
	return min(l[id][p],pos+1);
}
int main()
{
//	freopen("oase.in","r",stdin);
//	freopen("oase.out","w",stdout);
	Init();
	scanf("%d %d",&n,&V);
	int logV=0;
	for(logV=0;(1<<logV)<=V;logV++);
	for(int i=1;i<=n;i++)
		scanf("%d",&x[i]);
	x[n+1]=INF;
	x[0]=-INF;
	for(int LG=0;LG<=logV;LG++)
	{
		int d=V/(1<<LG);
		cnt[LG]=1;
		l[LG][1]=1;
		for(int i=1;i<=n;i++)
		{
			r[LG][cnt[LG]]=i;
			if(x[i+1]-x[i]>d)
			{
				cnt[LG]++;
				l[LG][cnt[LG]]=i+1;
			}
		}
		cnt[LG]--;
	}
	if(cnt[0]>logV+1)
	{
		for(int i=1;i<=n;i++)
			printf("Impossible\n");
		return 0;
	}
	int all=(1<<(logV+1));
	f1[0]=0,f2[0]=n+1;
	for(int s=0;s<all;s+=2)
		for(int i=0;i<=logV;i++)
		{
			if(!(s&(1<<i)))
				continue;
			f1[s]=max(f1[s],UpFind(i,f1[s-(1<<i)]));
			f2[s]=min(f2[s],LowFind(i,f2[s-(1<<i)]));
		}
	for(int i=1;i<=cnt[0];i++)
	{
		int ln=l[0][i],rn=r[0][i];
		for(int s1=0;s1<all;s1+=2)
		{
			int s2=all-1-s1-1;
			int lpos=f1[s1];
			int rpos=f2[s2];
			if(lpos>=ln-1&&rpos<=rn+1)
			{
				ans[i]=true;
				break;
			}
		}
	}
	int pos=1;
	for(int i=1;i<=n;i++)
	{
		if(ans[pos]==true)
			printf("Possible\n");
		else
			printf("Impossible\n");
		if(x[i+1]-x[i]>V)
			pos++;
	}
	return 0;
}

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

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

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

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

char res[40];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n = gi();
    if (n == 0) {
        printf("0\n");
        return 0;
    }

    memset(res, 0, sizeof(res));
    while (n) {
        ll l = 0, r = 1;
        int p = 1;
        ll nr = 1;
        while (n < l || n >= r) {
            if (p%2) {
                r += (r-l);
            } else {
                l -= (r-l);
            }
            p++;
            nr *= -2;
        }
        res[p-2] = '1';
        n -= nr / -2;
    }

    for (int i = 39; i > 0; i--)
        if (res[i] == '1') {
            for (int j = 0; j < i; j++)
                if (res[j] == 0)
                    res[j] = '0';
            for (int j = 0, k = i; j < k; j++, k--) {
                char t = res[j];
                res[j] = res[k];
                res[k] = t;
            }
            break;
        }

    printf("%s\n", res);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
int gcd(int x, int y) {
	return y ? gcd( y, x % y ) : x;
}
int main(int argc, char const *argv[])
{
	int x, y;
	cin >> x >> y;
	cout << gcd(x, y) << endl; 
	return 0;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    int minv = INF;
    int cnt = 0;
    rep(i, n){
        int in;
        cin >> in;
        if(in < minv){
            cnt++;
            minv = in;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define int long long
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t;
int cev;
string s;
vector<int> v;
map<int,int> PS,PS1,PS2;

main(void){
	fio();
	cin>>n>>s;
	//~ cout<<PS[-1]<<endl;
	for(int i=0;i<n;i++){
		if(s[i]=='R')PS[i]=PS[i-1]+1;
		else PS[i]=PS[i-1];
		if(s[i]=='G')PS1[i]=PS1[i-1]+1;
		else PS1[i]=PS1[i-1];
		if(s[i]=='B')PS2[i]=PS2[i-1]+1;
		else PS2[i]=PS2[i-1];
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			int at=n-j-1;
			if(s[i]==s[j])continue;
			if(s[i]=='R')at-=PS[n-1]-PS[j];
			if(s[i]=='G')at-=PS1[n-1]-PS1[j];
			if(s[i]=='B')at-=PS2[n-1]-PS2[j];
			if(s[j]=='R' && s[i]!=s[j])at-=PS[n-1]-PS[j];
			if(s[j]=='G' && s[i]!=s[j])at-=PS1[n-1]-PS1[j];
			if(s[j]=='B' && s[i]!=s[j])at-=PS2[n-1]-PS2[j];
			if(j+j-i<n){
				if(s[j+j-i]!=s[j] && s[j+j-i]!=s[i])at--;
			}
			//~ cout<<at<<endl;
			cev+=at;
		}
	}
	cout<<cev<<"\n";
	return 0;
}



Measured memory_bytes: 4320
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int n, a, b;
  scanf("%d", &n);

  a = n % 100; b = n / 100;

  if((b >= 13 || b == 0) && 0 < a && a <= 12) printf("YYMM\n");
  else if(0 < b && b  <= 12 && (a >= 13 || a == 0)) printf("MMYY\n");
  else if(0 < a && a <= 12 && 0 < b && b <= 12) printf("AMBIGUOUS\n");
  else printf("NA\n");

  return 0;
}

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


int main(){
	LL N;
	cin >> N;
	LL tmp = N;
	int S = 0;
	while(tmp){
		S += tmp%10;
		tmp /= 10;
	}
	if(N%S==0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;

}










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

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  int B[M];
  for (int i = 0; i < M; i++) cin >> B[i];
  
  int ans = 0;
  int A[M];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      cin >> A[j];
    }
    int sum = 0;
    
    for (int j = 0; j < M; j++) {
      sum += A[j] * B[j];
    }
//    cout << sum + C << endl;
    if (sum + C > 0) ans++;
  }
  
  cout << ans << endl;  
}



Measured memory_bytes: 256
// Math = ♥️

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define ordered_set                            \
    tree<ll, null_type, less<ll>, rb_tree_tag, \
         tree_order_statistics_node_update>

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

    ll n;
    cin >> n;

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

    ll dp[n][n][2];
    for (int i = 0; i < n; i++) {
        dp[i][i][0] = arr[i];
        dp[i][i][1] = -arr[i];
    }

    for (int gap = 1; gap < n; gap++) {
        for (int i = 0; i + gap < n; i++) {
            dp[i][i + gap][0] = max(dp[i + 1][i + gap][1] + arr[i],
                                    dp[i][i + gap - 1][1] + arr[i + gap]);
            dp[i][i + gap][1] = min(dp[i + 1][i + gap][0] - arr[i],
                                    dp[i][i + gap - 1][0] - arr[i + gap]);
        }
    }

    cout << dp[0][n - 1][0] << "\n";
}


Measured memory_bytes: 140672
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int n;
    string s;
    cin >> n >> s;
    int res = 0, x = 0;
    rep(i, 0, s.size())
    {
        if (s[i] == 'I')
        {
            x++;
            res = max(res, x);
        }
        if (s[i] == 'D')
            x--;
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  string s;
  cin>>s;
  int x,y,z,sum=0;
  x=s[0]-'0';
  y=x-1+(s.size()-1)*9;
  for(int i=0;i<s.size();i++){
    z=s[i]-'0';
    sum+=z;
  }
  cout<<max(sum,y)<<endl;
}

Measured memory_bytes: 256
s = input()
l = r = 0
for i in range(len(s)):
    if s[i] == 'A':
        l = i
        break
for i in range(len(s)):
    if s[len(s) - i - 1] == 'Z':
        r = len(s) - i
        break
print(r - l)

Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
int main() {
  int n;
  string s;
  cin >> n >> s;
  int minn = 300000;
  vector<int> E(n+1), W(n+1);
  rep(i,n){
    if(s[i]=='E') {
      E[i+1] = E[i] + 1;
    }
    else E[i+1] = E[i];
    if(s[n-i-1]=='W'){
      W[i+1] = W[i] + 1;
    }
    else W[i+1] = W[i];
  }
  rep(i,n) {
    minn = min(minn, n-1-E[i]-W[n-i-1]);
    //cout << E[i] << " " << W[n-i-1] << " " << minn << endl;
  }
  cout << minn << endl;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
#define fin ios_base::sync_with_stdio(false); cin.tie(NULL);
int main()
{
  fin;
  ll n,k,i,mini,j;
  cin>>n>>k;
  int a[n];
  mini=INT_MAX;
  for(i=0;i<n;i++)
  {
    cin>>a[i];
    if(a[i]<mini)
      mini=a[i];
  }
  int dp[k+1];
  memset(dp,0,sizeof(dp));
  for(i=0;i<=k;i++)
  {
    for(j=0;j<n;j++)
    {
      if(i-a[j]>=0 && !dp[i-a[j]])
        dp[i]=1;
    }
  }
  if(dp[k])
    cout<<"First";
  else
    cout<<"Second";
  }


Measured memory_bytes: 640
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>
#include <limits>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;
//エイリアス
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

//定数
const int intmax = numeric_limits<int>::max();
const ll llmax = numeric_limits<ll>::max();
const ll mod = 1e9 + 7;
const double pi = M_PI;

map<int, int> memo;

bool check(int a) {
  for(int i = 2; i * i <= a; i++) {
    if (a % i == 0) {
      if (memo.count(i)) {
        return false;
      }
      if (memo.count(a / i)) {
        return false;
      }
    }
  }
  if (memo[a] != 1) return false;
  if (a != 1 && memo.count(1)) return false;
  return true;
}

int main()
{
  int n;
  cin >> n;
  v a(n, 0);
  rep(i, n) {
    cin >> a[i];
    memo[a[i]]++;
  }
  int count = 0;
  rep(i, n) {
    bool result = check(a[i]);
    if(result) count++;
  }
  cout << count << endl;
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<string> svec;

#define IN_LL(in) ll in; cin >> in
#define IN_STR(in) string in; cin >> in
#define IN_VEC(in, size) vec in; for(int i = 0; i < (size); ++i){int ____cur; cin >> ____cur; in.push_back(____cur); } 0
#define IN_SVEC(in, size) svec in; for(int i = 0; i < (size); ++i){string ____cur; cin >> ____cur; in.push_back(____cur); } 0

#define OUT(out) cout << (out)
#define OUT_VEC(out) for(ll i = 0; i < (out).size(); ++i) cout << (out)[i]

string func(ll n, string s){
	if(s.length() <= n){
		return s;
	} else {
		return s.substr(0, n) + "...";
	}
}

int main(void){
	IN_LL(k);
	IN_STR(s);

	string ret = func(k, s);

	OUT(ret);
	return 0;
}


Measured memory_bytes: 3632
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC154A solver = new ABC154A();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC154A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            String S = in.next();
            String T = in.next();
            int A = in.Int();
            int B = in.Int();
            String U = in.next();
            if (S.equals(U)) {
                A--;
            } else {
                B--;
            }
            out.println(A + " " + B);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22868
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstring>

typedef long long ll;
constexpr double PI = 3.141592653589793;
constexpr ll INF = 1e18 + 10;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}

using namespace std;
//    cout << setprecision(20) << ans << "\n";

vector<pair<ll, ll>> primeFactorize(ll N)
{
    vector<pair<ll, ll>> res;
    for (ll a = 2; a * a <= N; ++a)
    {
        if (N % a != 0)
            continue;
        ll ex = 0;

        while (N % a == 0)
        {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }

    if (N != 1)
        res.push_back({N, 1});
    return res;
}

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

    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int diffx = x2 - x1;
    int diffy = y2 - y1;
    int x3 = x2 - diffy;
    int y3 = y2 + diffx;
    int x4 = x1 - diffy;
    int y4 = y1 + diffx;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << "\n";
    return 0;
}


Measured memory_bytes: 3668
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello{
    public static void Main(){
        int[] hoge=System.Console.ReadLine().Trim().Split(' ').Select(x=>int.Parse(x)).ToArray();
        if(hoge[0]+hoge[1]>=hoge[2] && hoge[0]<=hoge[2]) System.Console.WriteLine("YES");
        else System.Console.WriteLine("NO");
    }
}

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

const int N = 2 * 100 * 1000 + 2;
long long n, k, l, dpL[N], dpR[N], visK[N], visL[N];
vector <int> adjK[N], adjL[N];
map <pair<int, int>, int> ans;

void dfsK(int u, int num) {
	visK[u] = num;
	for (int v: adjK[u])
		if (visK[v] == 0)
			dfsK(v, num);
}

void dfsL(int u, int num) {
	visL[u] = num;
	for (int v: adjL[u])
		if (visL[v] == 0)
			dfsL(v, num);
}

void readInput() {
	cin >> n >> k >> l;
	for (int i = 0, u, v; i < k; i++) {
		cin >> u >> v;
		adjK[u].push_back(v);
		adjK[v].push_back(u);
	}
	for (int i = 0, u, v; i < l; i++) {
		cin >> u >> v;
		adjL[u].push_back(v);
		adjL[v].push_back(u);
	}
}

void moalefeK() {
	for (int i = 1, num = 1; i <= n; i++)
		if (visK[i] == 0)
			dfsK(i, num), num++;
}

void moalefeL() {
	for (int i = 1, num = 1; i <= n; i++)
		if (visL[i] == 0)
			dfsL(i, num), num++;
}

void solve() {
	for (int i = 1; i <= n; i++)
		ans[{visK[i], visL[i]}]++;
}


void writeOutput() {
	for (int i = 1; i <= n; i++)
		cout << ans[{visK[i], visL[i]}] << ' ';
}

void runProgram() {
	readInput();
	moalefeK();
	moalefeL();
	solve();
	writeOutput();
}

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

Measured memory_bytes: 31360
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	while(cin>>s)
	{
		if(s=="Sunny")
		cout<<"Cloudy"<<endl;
		else if(s=="Cloudy")
		cout<<"Rainy"<<endl;
		else
		cout<<"Sunny"<<endl;
	}
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20190308_01 {
    class Program {
        static void Main(string[] args) {
            var s = Console.ReadLine();
            var compare = "2019/04/30";
            if (s.CompareTo(compare) == 1) {
                Console.WriteLine("TBD");
            } else {
                Console.WriteLine("Heisei");
            }
        }
    }
}


Measured memory_bytes: 13280
#include <stdio.h>
int main(void){
int a,b[10],i,c,d,e;
c=0,e=0;
for(i=0;i<10;i++){
b[i]=0;
}
scanf("%d",&a);
for(i=0;i<a;i++){
scanf("%d",&b[i]);
e=e+b[i];
if(c<b[i])
c=b[i];
}
d=c/2+e-c;
printf("%d",d);
return 0;
}


Measured memory_bytes: 128
import bisect

S = input().strip()
T = input().strip()

x = [[] for j in range(26)]

for i, s in enumerate(S):
    x[ord(s) - ord('a')].append(i)

sett = list(set(T))

for t in sett:
    if len(x[ord(t) - ord('a')]) == 0:
        print(-1)
        exit()

c = 0
z = 0

for t in T:
    y = bisect.bisect_left(x[ord(t) - ord('a')], c)
    if y == len(x[ord(t) - ord('a')]):
        z += 1
        c = x[ord(t) - ord('a')][0] + 1
    else:
        c = x[ord(t) - ord('a')][y] + 1

print(z * len(S) + c)


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main(){
	int n;
	cin >> n;
	vi a(n);
	rep(i,n) cin >> a[i];

	int p = -1;
	for(int i = 0; i < n; i++){
		if(a[i] == 1 && p == -1) p = i;
	}
	if(p == -1){
		cout << -1 << endl;
	}else{
		int cnt = 0,tmp = 2;
		for(int i = p+1; i < n; i++){
			if(a[i] != tmp) cnt++;
			else tmp++;
		}
		cout << p+cnt << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
N, K = map(int, input().split())
P = list(map(int, input().split()))
# print(P)
E = [(p*(p+1))/(2*p) for p in P]
# print([sum(E[i:i+K]) for i in range(N-K+1)])
S = [0]
for i in range(N):
    S.append(S[i] + E[i])
print(max([S[i+K] - S[i] for i in range(N-K+1)]))


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

using namespace std;

using ll = long long;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"

int solve (int n) {
    int ans = 0;
    while (n) {
        int pop = __builtin_popcount (n);
        n %= pop;
        ans++;
    }
    return ans;
}
const int N = 2e5;
int conf[1 + N];
int n;
int getReminder (int d) {
    if (d == 0)
        return -1;
    int ans = 0;
    for (int i = 1; i <= n; i++)
        ans = (ans * 2 + conf[i]) % d;
    return ans;
}

int lgput (int a, int b, int d) {
    int ans = 1;
    while (b) {
        if (b & 1) ans = 1ll * ans * a % d;
        a = 1ll * a * a % d;
        b /= 2;
    }
    return ans;
}

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

    cin >> n;
    string x;
    cin >> x; x = " " + x;
    int nr1 = 0;
    for (int i = 1; i <= n; i++) {
        conf[i] = x[i] - '0';
        nr1 += conf[i];
    }
    int reminderPlus = getReminder (nr1 + 1);
    int reminderMinus = getReminder (nr1 - 1);
    for (int i = 1; i <= n; i++) {
        if (conf[i] == 0) {
            /// +
            int reminder = (reminderPlus + lgput (2, n - i, nr1 + 1)) % (nr1 + 1);
            cout << solve (reminder) + 1 << "\n";
        }
        else {
            /// -
            if (reminderMinus == -1)
                cout << 0 << "\n";
            else {
                int reminder = (reminderMinus - lgput (2, n - i, nr1 - 1) + nr1 - 1) % (nr1 - 1);
                cout << solve (reminder) + 1 << "\n";
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4484
#include <stdio.h>

int factorial(int a, int i)
{
	if(a % 5 == 0) return factorial(a/5, i+1);
	else return i;
}

int main()
{
	int n, k;

	while(1){
		k = 0;
		scanf("%d", &n);

		if(n == 0) break;

		for(int i = 1; i <= n; i++) {
			k += factorial(i, 0);
		}

		printf("%d\n", k);
	}
	
	return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;

void solve() {

}

int main() {
  string s;
  cin >> s;
  if( s[2] == s[3] && s[4] == s[5] ) {
    puts("Yes");
  } else {
    puts("No");
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;

typedef vector<pair<int, int>> vpi;
typedef vector<pair<ll, ll>> vpl;
typedef vector<tuple<int, int, int>> vti;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<pair<pair<string, int>, int>> p(n);
    rep(i, n){
        cin >> p[i].first.first >> p[i].first.second;
        p[i].first.second = 100 - p[i].first.second;
        p[i].second = i+1;
    }
    sort(p.begin(), p.end());
    rep(i, n) cout << p[i].second << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define M1 1000000007
#define M2 998244353

#define fl(i,a,b)  for(ll i=a;i<b;i++)
#define bfl(i,a,b) for(ll i=b-1;i>=a;i--)
#define f(i,n)     for(int i=0;i<n;i++)
#define bf(i,n)    for(int i=n-1;i>=0;i--)


#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define bn "\n"

//------------------------------------------------------------------------ 
// #define V(a) vector<a>
// #define vt() vector< tuple < int ,int ,int > > ;
// #define vector< int ,int > pv;
// vector< pair <int,int> > vect;


//------------------------------------------------------------------------

ll modI(ll a,ll m);
ll gcd(ll a,ll b);
ll powM(ll x,ll y,ll m);
ll swap(ll a,ll b);

void swap(ll& a,ll& b)
{
    ll tp=a;
    a=b;
    b=tp;
}

ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}

ll powM(ll x,ll y,ll m)
{
    ll ans=1,r=1;
    x%=m;
    while(r>0&&r<=y)
    {
        if(r&y)
        {
            ans*=x;
            ans%=m;
        }
        r<<=1;
        x*=x;
        x%=m;
    }
    return ans;
}
 
ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}

//---------------------------------------------------------------------------

// variable = Expression1 ? Expression2 : Expression3
// max = (n1 > n2) ? n1 : n2; 
// (n>m) ? cout<<"True"<<endl:cout<<"false"<<endl ;

// ---------------------------------------------------------------------------	

// int n;cin>>n;int a[n];for(int i=0;i<n;i++)cin>>a[i];    
// for(int i=0;i<n;i++)cout<<a[i];
// int a,b;cin>>a>>b;   

//----------------------------------------------------------------------------

// vector< tuple < int ,int ,int > > tv;
// vector< int ,int > pv;


//----------------------------------------------------------------------------


int main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	int tt=1;
   // cin>>tt;
	while(tt--)
	{
	    ll n1; cin>>n1;
      ll ans = 0;
      for(ll j=2;j*j<=n1;j++)
      {
        if(n1%j==0)
        {
            ll num = 0;
            while(n1%j==0){ n1/=j; num++; }
            long double bb = 8.0*num + 1.0; bb = sqrt(bb);
            bb = bb-1.0; bb = bb/2.0;
            ll gg = bb;
            ans += gg;
        }
     }
    if(n1>1) ans++;
    p1(ans);
	   
	   
	   
	    
	}
	
	return 0;
}


Measured memory_bytes: 3696
S = [
    (1, 2, 4, 3), # 0
    (0, 3, 5, 2), # 1
    (0, 1, 5, 4), # 2
    (0, 4, 5, 1), # 3
    (0, 2, 5, 3), # 4
    (1, 3, 4, 2), # 5
]

*L, = map(int, input().split())
q = int(input())
for i in range(q):
    a, b = map(int, input().split())
    for i in range(6):
        if L[i] == a:
            for k in range(4):
                if L[S[i][k]] == b:
                    print(L[S[i][k-3]])



Measured memory_bytes: 5604
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << "\n"; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}


#line 2 "abc168_d.cpp"

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

  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  REP(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  // now;
  queue<int> q;
  q.push(0);
  vi ans(n, -1);
  ans[0] = 0;
  while (!q.empty()) {
    auto p = q.front();
    q.pop();
    for (const auto e : g[p]) {
      if (ans[e] != -1)
        continue;
      ans[e] = p;
      q.push(e);
    }
  }
  cout << "Yes" << endl;
  FOR(i, 1, n) { cout << ans[i] + 1 << endl; }
}


Measured memory_bytes: 10328
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}
import java.lang

import scala.annotation.tailrec
import scala.collection.mutable.ArrayBuffer
import scala.reflect.ClassTag

object Main {
  def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {
    converter(in.readLine)
  }

  def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {
    get[String].split("\\s+").map(converter)
  }

  implicit val intConverter: String => Int = s => Integer.parseInt(s)
  implicit val longConverter: String => Long = s => lang.Long.parseLong(s)

  def get[T1, T2](
                   implicit in: BufferedReader,
                   converter1: String => T1,
                   converter2: String => T2
                 ): (T1, T2) = {
    getArray[String] match {
      case Array(v1, v2) => (converter1(v1), converter2(v2))
    }
  }

  def get[T1, T2, T3](
                       implicit in: BufferedReader,
                       converter1: String => T1,
                       converter2: String => T2,
                       converter3: String => T3
                     ): (T1, T2, T3) = {
    getArray[String] match {
      case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))
    }
  }

  implicit class TimesInt(val n: Int) {
    def times(f: Int => Unit): Unit = {
      for (i <- 0 until n) {
        f(i)
      }
    }
  }

  def primes(n: Long): ArrayBuffer[Long] = {
    val buf = ArrayBuffer.empty[Long]
    val s = Math.sqrt(n).toInt

    var v = n
    for (i <- 2 to s) {
      if (v == 1 || v == 0) {
        return buf
      } else {
        while (v % i == 0) {
          buf.append(i)
          v /= i
        }
      }
    }
    if (v > s) {
      buf.append(v)
    }
    buf
  }

  def toBitArray(n: Int, width: Int): Array[Boolean] = {
    val buf = ArrayBuffer.fill(width)(false)

    @tailrec
    def inner(n: Int, i: Int): Array[Boolean] = {
      buf(i) = (n & 1) == 0
      if (i == 0) {
        buf.toArray
      } else {
        inner(n / 2, i - 1)
      }
    }

    inner(n, width - 1)
  }

  def main(args: Array[String]): Unit = {
    implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val (n, m) = get[Long, Long]

    out.println(
      if (n == 1) {
        if (m == 1) {
          1
        } else {
          m - 2
        }
      } else {
        if (m == 1) {
          n - 2
        } else {
          (m - 2) * (n - 2)
        }
      }
    )

    out.flush()
  }
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		a.push_back(x);
	}
	int l, r, ans = 0;
	for (l = 0; l < n; l = r) {
		r = l;
		while (r < n && a[l] == a[r]) {
			r++;
		}
		ans += (r - l) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256