akhauriyash/Code-Regression huggingface dataset:
n,k=map(int,input().split())

if k/2==k//2:
    p=n//(k//2)

    if p==0:
        print(0)
    elif p==1:
        print(1)
    elif p==2:
        print(2)
    elif p==3:
        print(9)
    elif p==4:
        print(16)
    else:
        m=16
        for i in range(5,p+1):
            m+=1+6*((-(-i//2))-1)+6*((-(-i//2))-1)*(-(-i//2)-2)//2
        print(m)
    
else:
    p=n//k

    if p==0:
        print(0)
    elif p==1:
        print(1)
    elif p==2:
        print(8)
    else:
        m=8
        for i in range(3,p+1):
            m+=1+6*(i-1)+6*(i-1)*(i-2)//2
        print(m)


Measured memory_bytes: 39280
#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>

#define PI 3.14159265359
using namespace std;
class dice{
public:
	int d[6];
	void set(int n, int x){
		d[n] = x;
	}
	int get(int n){
		return d[n];
	}
	void rotate(char c){
		int tmp;
		if (c == 'W'){
			tmp = d[3];
			d[3] = d[0];
			d[0] = d[2];
			d[2] = d[5];
			d[5] = tmp;
		}
		else if (c == 'E'){
			tmp = d[5];
			d[5] = d[2];
			d[2] = d[0];
			d[0] = d[3];
			d[3] = tmp;
		}
		else  if (c == 'N'){
			tmp = d[0];
			d[0] = d[1];
			d[1] = d[5];
			d[5] = d[4];
			d[4] = tmp;
		}
		else {
			tmp = d[4];
			d[4] = d[5];
			d[5] = d[1];
			d[1] = d[0];
			d[0] = tmp;
		}
	}
};

int main(){
	int tmp;
	dice d;
	for (int i = 0; i < 6; i++){
		cin >> tmp;
		d.set(i, tmp);
	}
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) d.rotate(s[i]);
	cout << d.get(0) << endl;
}

Measured memory_bytes: 3204
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int max = 0;
		for(int i=N-1;i>=0;i--){
//Console.WriteLine(S.Substring(i));
//Console.WriteLine(T.Substring(0,N-i));
			if(S.Substring(i) == T.Substring(0,N-i)){
				max = N - i;
			}
		}
		Console.WriteLine(N*2 - max);
	}
	int N;
	String S,T;
	public Sol(){
		N = ri();
		S = rs();
		T = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 2776
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

typedef pair<int,int> P;

//long long gcd(long long a,long long b){
//	if(b==0) return a;
//	return gcd(b,a%b);
//}
//
//long long lcm(long long a,long long b){
//	
//	return a/gcd(a,b) * b;
//}

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

	string s;
	cin >> s;

	int low=0;
	int numc=0;
	if(s[0] == 'A' && islower(s[1])){
		for(int i=2;i<s.size()-1;i++){
			if(s[i] == 'C') numc++;
			else if(!islower(s[i])){
				cout << "WA\n";
				return 0;
			}
		}
		if(numc != 1){
			cout << "WA\n";
			return 0;
		}
		if(islower(s[s.size()-1])){
			cout << "AC\n";
		}else{
			cout << "WA\n";
		}
		return 0;
	}
	cout << "WA\n";
	
	return 0;
}

Measured memory_bytes: 256
num_inputs = int(input())
l_origin = input().split(' ')

flag = True
l_bubble = l_origin[:]
while flag:
    flag = False
    for i in reversed(range(1, num_inputs)):
        if int(l_bubble[i][-1:]) < int(l_bubble[i - 1][-1:]):
            buf = l_bubble[i]
            l_bubble[i] = l_bubble[i - 1]
            l_bubble[i - 1] = buf
            flag = True
print(' '.join(l_bubble))
print('Stable')

l_selection = l_origin[:]
for j in range(num_inputs):
    mink = j
    for k in range(j, num_inputs):
        if int(l_selection[k][-1:]) < int(l_selection[mink][-1:]):
            mink = k
    if mink != j:
        buf = l_selection[j]
        l_selection[j] = l_selection[mink]
        l_selection[mink] = buf
print(' '.join(l_selection))

is_stable = True

for l in range(num_inputs):
    if l_bubble[l] == l_selection[l]:
        pass
    else:
        is_stable = False
        break

if is_stable:
    print('Stable')
else:
    print('Not stable')



Measured memory_bytes: 5604
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<map>
#include<set>
#include<bitset>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
bool water[3010], sugar[3010];
double maxparsent;
double small = 0.00000001;
int ans1, ans2;
int main() {
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	a *= 100;
	b *= 100;
	for (int i = 0; i <= f; i += a) {
		for (int j = 0; j <= f - i; j += b)water[i + j] = true;
	}
	for (int i = 0; i <= f; i += c) {
		for (int j = 0; j <= f - i; j += d)sugar[i + j] = true;
	}
	for (int i = 1; i <= f; i++) {
		for (int j = 1; j <= f - i; j++) {
			if (!water[i] || !sugar[j])continue;
			if ((double)e / (100 + e) < (double)j / (i + j))continue;
			if (maxparsent < (double)j / (i + j) + small) {
				maxparsent = (double)j / (i + j);
				ans1 = i + j;
				ans2 = j;
			}
		}
	}
	if (maxparsent <= 0)cout << a << " " << 0 << endl;
	else cout << ans1 << " " << ans2 << endl;
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll n, T;
  cin >> n >> T;
  vector<ll> t(n);
  for(int i=0;i<n;i++)
    cin >> t[i];
  ll ans = t[n-1] + T;
  for(int i=0;i<n-1;i++) {
    if(t[i+1]-t[i] > T)
      ans -= (t[i+1]-t[i]-T);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const long long maxn=1e5+5;
const long long inf=0x3f3f3f3f;
long long a[maxn];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	long long n;
	cin>>n;
	for(long long i=1;i<=n;i++)
		cin>>a[i];
	long long sell=0,mon=1000,flag=0;
	for(long long i=1;i<=n-1;i++)
	{
		if(a[i+1]>=a[i])
		{
			sell+=mon/a[i];
			mon=mon%a[i];
		}
		if(a[i+1]<a[i]&&a[i-1]<=a[i])
		{
			mon=mon+sell*a[i];
			sell=0;
		}
	}
	if(a[n-1]<=a[n])
	{
		mon=mon+sell*a[n];
		sell=0;
	}
	cout<<mon<<endl;
	return 0;
}




Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

const ll DICE_SIZE = 6;

const map<pair<ll, ll>, ll> tf2r = {
    {{0, 1}, 2},
    {{0, 2}, 4},
    {{0, 3}, 1},
    {{0, 4}, 3},

    {{1, 2}, 0},
    {{1, 3}, 5},
    {{1, 5}, 2},

    {{2, 4}, 0},
    {{2, 5}, 4},

    {{3, 4}, 5},
    {{3, 5}, 1},

    {{4, 5}, 3}
};

ll get_right(ll top, ll front){
    if(front < top){
        return 5 - get_right(front, top);
    }
    return tf2r.at({top, front});
}

struct Dice{
    array<ll, DICE_SIZE> i2v;
    ll top, front, right;
    map<ll, ll> v2i;
    Dice(const array<ll, DICE_SIZE>& num) : i2v(num), top(0), front(1), right(2) {
        REP(i, DICE_SIZE){
            v2i[i2v.at(i)] = i;
        }
    }

    void move(char c){
        if(c == 'N'){
            const ll old_top = top;
            top = front;
            front = 5 - old_top;
        }else if(c == 'S'){
            const ll old_front = front;
            front = top;
            top = 5 - old_front;
        }else if(c == 'W'){
            const ll right = get_right(top, front);
            top = right;
        }else{
            assert(c == 'E');
            const ll right = get_right(top, front);
            top = 5 - right;
        }
    }

    ll get_top() const { return i2v.at(top); }

    bool operator==(const Dice& other) const {
        REP(t, DICE_SIZE){
            REP(f, DICE_SIZE){
                if(t == f || t == 5 - f){ continue; }
                const ll r = get_right(t, f);
                array<ll, DICE_SIZE> tmp = {
                    i2v.at(t),
                    i2v.at(f),
                    i2v.at(r),
                    i2v.at(5 - r),
                    i2v.at(5 - f),
                    i2v.at(5 - t)
                };
                if(tmp == other.i2v){
                    return true;
                }
            }
        }
        return false;
    }
};


int main(){
    ll n;
    cin >> n;
    vector<Dice> d;
    REP(i, n){
        array<ll, DICE_SIZE> num;
        REP(i, DICE_SIZE){
            cin >> num.at(i);
        }
        d.emplace_back(num);
    }

    REP(i, n){
        for(ll j = i + 1; j < n; ++j){
            if(d.at(i) == d.at(j)){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 3152
// In god we trust

#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>


#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define INF 1000000000
#define int long long

using namespace std;
using namespace std::chrono;


signed main(){
  string s;
  int q;
  cin >> s >> q;
  int n = s.size();
  string begin;
  string end;
  bool reverse = false;
  for (int i = 0; i < q; i++){
    int a;
    cin >> a;
    if (a == 1)
      reverse = not reverse;
    else {
      int b;
      char c;
      cin >> b >> c;
      if (b == 1 and not reverse)
	begin += c;
      else if (b == 1 and reverse)
	end += c;
      else if (b == 2 and not reverse)
	end += c;
      else
	begin += c;
    }
  }
  if (not reverse){
    for (int i = 0; i < begin.size(); i++)
    cout << begin[begin.size() - 1 - i];
  cout << s;
  for (int i = 0; i < end.size(); i++)
    cout << end[i];
  cout << endl;
  }else{
    for (int i = 0; i < end.size(); i++)
      cout << end[end.size() - 1 - i];
    for (int i = 0; i < n; i++)
      cout << s[n - 1 - i];
    cout << begin;
    cout << endl;
  }
  
}


Measured memory_bytes: 1088
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}

ll gcd(ll a,ll b){return b ? gcd(b,a%b) :a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

ll kosuu(ll a){
    ll sum=0;
    for(ll i=1;i*i<=a;i++){
        if(a%i==0){
            if(a!=1&&i*i!=a){
            sum+=2;
            }else{
             sum++;   
            }
        }
    }
    return sum;
}
ll ans=-1000000000;



int main()
{
 string s;
 cin>>s;
 ll n;
 cin>>n;
 ll cnt=0;
 rep(i,n){
  ll a;
  cin>>a;
  if(a==1)cnt++;
  if(a==2){
      ll b;
      string c;
      cin>>b>>c;
      if(cnt%2==1){
          if(b==1)b=2;
          else b=1;
      }
      if(b==1)s=c+s;
      if(b==2)s+=c;
  }
 }
 if(cnt%2==1)reverse(s.begin(),s.end());
cout<<s<<endl;
}



Measured memory_bytes: 4640
def saiki(n, pattern, count) 
  if n < pattern[1] then
    if n <  pattern[0] then
      return count + n
    else
      return count + n + 1 - pattern[0]
    end
  end
 
  newP = pattern.select{|i| i <= n}
  one = newP[-1]
  two = newP[-2]
  #puts n, one, two
  count1 = saiki(n-one, pattern, count + 1) 
  count2 = saiki(n-two, pattern, count + 1)
  count = count1 < count2 ? count1 :count2
end

n = gets.to_i
count = 0
rui6 = [*1..6].map {|item|  6**item }
rui9 = [*1..5].map {|item|  9**item }
pattern = [].concat(rui6).concat(rui9).sort
count = saiki(n, pattern, 0)
puts count




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

int main(){
	int n,l,r;
	//while(scanf("%d%d%d",&n,&l,&r),n){
	cin>>n>>l>>r;
	while(n!=0){
	int A[1000];
	//scanf("%d%d%d",&A[0],&A[1],&A[2]);
	for(int i=0;i<n;i++) cin>>A[i];
	int Unum=0;
	for(int i=l;i<=r;i++){
		int count=0;
		for(int k=0;k<n;k++){
			if(i%A[k]==0){
				count++;
				if(k%2==0){
					Unum++;
				}
				break;
			}
		}
		if(count==0&&n%2==0){
				Unum++;
			}
	}
	//printf("%d\n",Unum);
	cout<<Unum<<endl;
	cin>>n>>l>>r;
	}

	return 0;
}



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

using i64 = long long;
using P = pair<i64, i64>;

i64 gcd(i64 a, i64 b){
    //
    // Euclidean Algorithm (かっこいい) O(logN)
    // i64 a, b: GCDを求める数 a > b を仮定している
    //
    if(a % b == 0) return b;
    else return gcd(b, a % b);
}

i64 lcm(i64 a, i64 b){
    //
    // a * b / gcd(a, b) O(logN)
    //
    return a * b / gcd(a, b);
}


void solve(long long A, long long B){
    cout << lcm(A, B) << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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

int main()
{
  int n,k;
  char s[15];
  scanf("%d",&n);
  scanf("%s",s);
   scanf("%d",&k);
  int i;
  k--;
  for(i=0;i<n;i++)
    if(s[i] != s[k])
      s[i] = '*';

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


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
  int n; cin>>n;
  vll a(n); rep(i,n) cin>>a[i];
  ll mon=1000;
  ll c=0;
  ll x=0;
  if(n==1){
    cout<<1000<<endl;
    return 0;
  }
  rep(i,n){
    if(i==0||a[i-1]<=a[i]){
      x=(mon/a[c])*(a[i]-a[c]);
      //cout<<x<<endl;
    }else{
      mon+=x;
      x=0;
      c=i;
    }
  }
  mon+=x;
  cout<<mon<<endl;
}


Measured memory_bytes: 3584
A=[]
bingo=[]
for i in range(3):
    A.append(list(map(int,input().split())))
    bingo.append([False]*3)
N=int(input())
B=[]
for i in range(N):
    B.append(int(input()))

for b in B:
    for i in range(3):
        for j in range(3):
            if A[i][j]==b:
                bingo[i][j]=True

ans = False
if bingo[0][0]==bingo[0][1]==bingo[0][2]==True:
    ans=True
if bingo[1][0]==bingo[1][1]==bingo[1][2]==True:
    ans=True
if bingo[2][0]==bingo[2][1]==bingo[2][2]==True:
    ans=True
if bingo[0][0]==bingo[1][0]==bingo[2][0]==True:
    ans=True
if bingo[0][1]==bingo[1][1]==bingo[2][1]==True:
    ans=True
if bingo[0][2]==bingo[1][2]==bingo[2][2]==True:
    ans=True
if bingo[0][0]==bingo[1][1]==bingo[2][2]==True:
    ans=True
if bingo[2][0]==bingo[1][1]==bingo[0][2]==True:
    ans=True
print('Yes' if ans else 'No')
            





Measured memory_bytes: 38384
N, M = map(int, input().split())

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

A_dict = {}

#Aをhash
for i in A:
    if i in A_dict:
        A_dict[i] += 1
    else:
        A_dict[i] = 1


for i in range(M):
    b, c = map(int, input().split())
    if c in A_dict:
        A_dict[c] += b
    else:
        A_dict[c] = b

A_dict = sorted(A_dict.items(), key=lambda x: -x[0])


card = 0
ans = 0
for i in A_dict:
    if card == N:
        break
    elif card + i[1] > N:
        ans += (N - card) * i[0]
        break
    else:
        ans += i[0] * i[1]
        card += i[1]
print(ans)

Measured memory_bytes: 49440
s=list(input())
t=list(input())
s.sort()
t.sort(reverse=True)
l=min(len(s), len(t))
for i in range(l):
  if s[i]==t[i]:
    continue
    
  if s[i]<t[i]:
    print("Yes")
    exit()
  else:
    print("No")
    exit()
if len(s)>=len(t):
  print("No")
else:
  print("Yes")


Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>

#define MAX 1000000

void merge(int[],int,int,int);
void mergeSort(int[],int,int);

int count = 0;
int n;
int L[MAX/2],R[MAX/2];

int main(){
    int A[MAX];

    scanf("%d",&n);

    for(int i = 0;i < n;i++){
        scanf("%d",&A[i]);
    }


    mergeSort(A,0,n);

    for(int i = 0;i < n;i++){
        printf("%d",A[i]);
        if(i < n-1)printf(" ");
    }
    printf("\n");

    printf("%d\n",count);

    return 0;
}

void merge(int A[MAX],int left,int mid,int right){
    int i,j;
    int n1,n2;

    n1 = mid - left;
    n2 = right - mid;

    for(i = 0;i < n1;i++)L[i] = A[left + i];
    for(i = 0;i < n2;i++)R[i] = A[mid + i];
    L[n1] = 1e9+1;
    R[n2] = 1e9+1;

    i = 0;
    j = 0;

    for(int k = left;k < right;k++){
        count++;
        if(L[i] <= R[j]){
            A[k] = L[i];
            i++;
        }
        else {
            A[k] = R[j];
            j++;
        }
    }
}

void mergeSort(int A[MAX],int left,int right){
    int mid;

    if(left + 1 < right){
        mid = (left + right) / 2;
        mergeSort(A,left,mid);
        mergeSort(A,mid,right);
        merge(A,left,mid,right);
    }
}


Measured memory_bytes: 5612
#include <iostream>

using namespace std;

bool b[110];
int n;

int main() {
    b[1] = true;
    b[2] = true;
    b[3] = true;
    b[5] = true;
    b[6] = true;
    b[9] = true;
    b[10] = true;
    b[13] = true;
    b[17] = true;
    cin >> n;
    if (n > 17) {
        cout << "Yes" << endl;
        return 0;
    }
    if (b[n] == true) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include<set>  
#include<map>  
#include<cmath>  
#include<cstdio>  
#include<queue>
#include<vector>  
#include<cstring>  
#include<climits>  
#include<iostream>  
#include<algorithm>  
using namespace std; 
#define eps 1
#define MAXN 100000
int read(){  
	int f=1,x=0;  
    char c=getchar();  
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}  
    while('0'<=c&&c<='9') x=x*10+c-'0',c=getchar();  
    return f*x;  
}
int main(){
	int a=read(),b=read(),k=read(),tmp=b-k+1;
	if(b-a+1<=k)
	{
		for(int i=a;i<=b;i++)
			printf("%d\n",i);
		return 0;
	}
	for(int i=a;i<=a+k-1;i++)
		printf("%d\n",i);
	if(b-k+1<=a+k-1) tmp=a+k;
	for(int i=tmp;i<=b;i++)
		printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pub push_back
#define pob push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}


ll i,j,k,ii,jj;
ll n,m;
ll a,b,c,d,e,g,h,w,r;
ll l,ans,num;
ll x[1000005],y[500005],z[500005];
bool dame,flag;
char s[500005],t[500005];
bool used[500005];

int main(){
    cin >> a >> b >> c;
	if(c <= a + b){
		p(b + c);
	}else{

		p(a + b + 1 + b);
	}
	
	return 0;
}

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

int N;
vector<int> a;

int main()
{
  cin >> N;
  a.resize(3 * N);
  for (int i = 0; i < 3 * N; i++)
  {
    cin >> a[i];
  }

  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  long long int ans = 0;
  for (int i = 0; i < N; i++)
  {
    ans += a[2 * i + 1];
  }

  cout << ans << endl;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i32 N;
    cin >> N;
    Vec<i32> a(N);
    for (u32 i = 0; i < N; i++) cin >> a[i];
    i32 count = 0;
    for (u32 i = 0; i < N; i++) {
        if (a[i] == count + 1) {
            count++;
        }
    }
    if (count == 0) cout << -1 << endl;
    else cout << N - count << endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << bitset<64>(x) << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int A, B; cin >> A >> B;
    if(A == B){
        Out(1);
        return 0;
    }
    
    IREP(i, 60){
        if((A & bit(i)) != (B & bit(i))){
            A &= bit(i + 1) - 1;
            B &= bit(i + 1) - 1;
            break;
        }
    }
    
    int nA = 0, nB = 0;
    while(A >= bit(nA)) nA++;
    while(B >= bit(nB)) nB++;

    int a = bit(nB - 1) + A;
    int b = bit(nB) - 1;

    //debug(A);
    //debug(B);
    //debug(a);
    //debug(b);
    
    REP(i, nB - 1) if(B & bit(i)) B |= bit(i + 1) - 1;

    int ans = b - A + 1;
    if(B < a) ans -= a - B - 1;
    Out(ans);

    return 0;
}


Measured memory_bytes: 256
inp=input().split(" ")
H=int(inp[0])
W=int(inp[1])
A=int(inp[2])
B=int(inp[3])
mod=10**9+7
fact=[1]
fact_r=[1]
for i in range(1,H+W-1):
    fact.append(i*fact[i-1]%mod)
    fact_r.append(pow(fact[i],10**9+5,mod))
const=fact_r[H-A-1]*fact_r[A-1]%mod
ans=sum(fact[H+i-A-1]*fact_r[i]*fact_r[W-i-1]*fact[W-i-2+A]%mod for i in range(B,W))
print(ans*const%mod)

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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] a = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);

		int minsum = Integer.MAX_VALUE;

		for (int i = a[0]; i <= a[n - 1]; i++) {
			int tmpsum = 0;
			for (int j = 0; j < n; j++) {
				tmpsum += Math.abs((a[j] - i) * (a[j] - i));
				//System.out.println("i=" + i + ", j=" + j + ", a[j]=" + a[j] + ", tmpsum=" + tmpsum);
			}
			if (minsum > tmpsum) {
				minsum = tmpsum;
			}
		}

		System.out.print(minsum);

		sc.close();
	}
}

Measured memory_bytes: 22996
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    N,=pin()
    temp=100
    for i in range(1,1000000):
        temp=(temp*1.01)//1
        #print(temp)
        if temp>=N:
            print(i)
            break
#%%submit!
resolve()

Measured memory_bytes: 9252
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;
vector<ll> a(114514);
vector<ll> memo(114514, -1ll);

ll dp(int x) {
    if (x < 0) return 0ll;
    if (memo[x] != -1ll) return memo[x];

    if (a[x] == 1) {
        return memo[x] = 0ll;
    }
    if (x == 0) {
        return memo[x] = 1ll;
    }
    
    return memo[x] = (dp(x-1)+dp(x-2))%MOD;
    
}

int main(int argc, char const *argv[]) {
    int n,m;
    cin >> n >> m;
    // 1が壊れている
    REP(i,m) {
        int x;
        cin >> x;
        a[x] = 1;
    }
    cout << dp(n) << endl;
    return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18

int main () {
    double n ;
    cin >> n ;
    vector<double> v (n) ;
    rep(i, n) cin >> v[i] ;
    sort(v.begin(), v.end()) ;
    rep(i, n -1){
        v[i + 1] = (v[i + 1] + v[i])/2 ;
    }
    cout << fixed << setprecision(10) ;
    cout << v[n - 1] << endl ;
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;

int main() {
    ll a,b; cin >> a >> b;
    if(a*b % 2 == 1) puts("Odd");
    else puts("Even");
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        String ans = "No";
        if(a+b==c||a+c==b||b+c==a) ans = "Yes";
        System.out.println(ans);
    }
}


Measured memory_bytes: 22868
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define vvv vector<vector<vector<long long int>>>
#define vvvl(a, b, c, d) vector<vector<vector<long long int>>>(a, vector<vector<long long int>>(b, vector<long long int> (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, a;std::cin >> n >> a;
  vll x(n);re(i, n) std::cin >> x[i];
  sort(x.begin(), x.end());
  vvv dp = vvvl(n+1, n+1, 2501, 0);
  dp[0][0][0] = 1;
  for(int i=1;i<=n;i++){
    for(int j=0;j<=n;j++){
      for(int k=0;k<=2500;k++){
        dp[i][j][k] = dp[i-1][j][k];
        if(k<x[i-1]||j==0) continue;
        dp[i][j][k] += dp[i-1][j-1][k-x[i-1]];
      }
    }
  }
  ll ans = 0;
  for(int i=1;i<=n;i++) {
    if(i*a>2500) continue;
    ans += dp[n][i][i*a];
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 52224
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int inf=0x3f3f3f3f;
int map1[109][109];
int flag[109];
int result[109];
int main(){
    int n;
    int u,v,w,k;
    while(scanf("%d",&n)!=EOF){
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
                if(i==j)
                    map1[i][j]=0;
                else
                    map1[i][j]=inf;
        for(int i=0;i<n;i++){
            scanf("%d%d",&u,&k);
            for(int j=0;j<k;j++){
                scanf("%d%d",&v,&w);
                if(map1[u][v]>w)
                    map1[u][v]=w;
            }
        }
        u=108;
        memset(flag,0,sizeof(flag));
        flag[0]=1;
        for(int i=0;i<n;i++)
            result[i]=map1[0][i];
        for(int i=0;i<n;i++){
            int minn=inf;
            for(int j=0;j<n;j++)
                if(!flag[j]&&result[j]<minn){
                    minn=result[j];
                    u=j;
                }
                flag[u]=1;
                for(int k=0;k<n;k++)
                    if(map1[u][k]!=inf&&result[k]>result[u]+map1[u][k])
                        result[k]=result[u]+map1[u][k];
        }
        for(int i=0;i<n;i++)
            printf("%d %d\n",i,result[i]);



    }
    return 0;
}



Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>w(n);
    for(int i=0;i<n;i++)cin >> w[i];
    int weigh=100000000;
    for(int i=0;i<n-1;i++){
        int now_up=0;
        int now_down=0;
        for(int j=0;j<=i;j++){
            now_down+=w[j];
        }
        for(int j=i+1;j<=n-1;j++){
            now_up+=w[j];
        }
        int now=abs(now_up-now_down);
        if(now<weigh)weigh=now;
    }
    cout << weigh;
}

Measured memory_bytes: 256
def ABC145B():
    N = int(input())
    S = input()

    if N % 2 == 1:
        print('No')
        return()
    else:
        l = N // 2
        if S[:l] == S[(-1 * l):]:
            print('Yes')

        else:
            print('No')

ABC145B()


Measured memory_bytes: 2940
import java.util.*;
import java.io.*;

import static java.lang.Character.isUpperCase;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int[] d = new int[N];
        int product = 0 ;
        for(int i =0 ; i< N; i++)
        {
            d[i]=in.nextInt();
        }


            for (int i = 0; i<N; i++)
        {
            for(int j=i+1; j<N; j++)
            {
                product = product + d[i]*d[j];

             }
        }
              System.out.println(product);





    }







    }

















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

#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>;

int n;
ll a[2 * 100000];
ll dp[2 * 100000 + 1];

int main()
{
  cin >> n;
  rep(i, n) {
    cin >> a[i];
  }
  map<ll, ll> m;
  for(ll i = 1; i <= n; i++) {
    ll want = i - a[i - 1];
    m[i + a[i - 1]]++;
    if(m.count(want)) {
      dp[i] = dp[i - 1] + m[want];
    }else{
      dp[i] = dp[i - 1];
    }
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 19184
#include<iostream>
using namespace std;
int main() {
 int a[5]={0};
  
  int b;
  int i=1;
  while (i<7) {
    cin >> b;
    a[b]=a[b]+1;
    
    i=i+1;
  }
  
  if (a[1]<3 && a[2]<3 && a[3]<3 && a[4]<3) cout << "YES";
  else cout << "NO";
  cout << endl;
  
  
  
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <bitset>
using namespace std;

typedef long long ll;
const ll INF = 1000000000;
const ll MOD = 1000000000 + 7;
const ll MAX_N = 100 + 2;
const ll MAX_W = 100000 + 2;
ll dp[MAX_N][MAX_W];
ll v[MAX_N];
ll w[MAX_N];

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

  ll N, W;
  cin >> N >> W;

  for (ll i = 1; i <= N; i++) cin >> w[i] >> v[i];
  
  for (ll i = 1; i <= N; i++) {
    for (ll j = 0; j <= W; j++) {
      if (j - w[i] >= 0) {
	dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
      }
      else dp[i][j] = dp[i - 1][j];
    }
  }
  
  ll ans = 0;
  for (ll j = 0; j <= W; j++) ans = max(ans, dp[N][j]);
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 81240
#include <bits/stdc++.h>
#define pb emplace_back
#define fi first
#define se second
#define int long long
using namespace std;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int l) { uniform_int_distribution<int> uid(0, l - 1); return uid(rang); }

int32_t main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10); srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	int n; cin >> n;
	vector<int> a(n); for (int o = 0; o < n; o++) { cin >> a[o]; }
	int su = 0;
	for (int i = 0; i < n; ++i) {
		su += a[i];
	}	
	su /= 2ll;
	for (int i = 1; i < n - 1; i += 2) {
		su -= a[i];
	}
	cout << su * 2 << " ";
	for (int i = 1; i < n; ++i) {
		su = a[i - 1] - su;
		cout << su * 2 << " ";
	}
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

int solve(VI & v){
  int c = 0;
  int ans = 0;
  rep(i,v.size()){

    ans += (abs(v[i]) + 1)  * (abs(v[i]) ) / 2;
    if(v[i] < 0){

      if(abs(v[i]) <= c){
        ans -= abs(v[i]);
      }
      else{
        ans -= c;
      }
      c = 0;
    }
    else {
      c = v[i];
    }
  }
  return ans;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  vector<int> v(n+1);
  rep(i,n){
    if(s[i] == '<'){
      v[i+1] = v[i] + 1;
    }else {
      v[i+1] = 0;
    }
  }
  VI a = v;
  fill(all(v), 0);

  for(int i = n-1; i >= 0; i--){
    if(s[i] == '>'){
      v[i] = v[i+1] + 1;
    }else {
      v[i] = 0;
    }
  }
  ll ans = 0;
  rep(i,n+1) ans += max(a[i],v[i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4764
import java.util.*;

class Main{
	public static void main(String[] args){
		Solve s = new Solve();
		s.solve();
	}	
}

class Solve{
	Solve(){}
	
	Scanner in = new Scanner(System.in);

	void solve(){
		int sum = 0;
		for(int i = 0; i < 5; i++){
			int a = in.nextInt();
			sum += Math.max(a,40);
		}
		System.out.println(sum/5);
	}

	
}

Measured memory_bytes: 26268
#include<bits/stdc++.h>
using namespace std;
signed main(){
  vector<int> v(10);
  for(int i=0;i<10;i++) cin>>v[i];
  sort(v.rbegin(),v.rend());
  for(int i=0;i<3;i++) cout<<v[i]<<endl;
  return 0;
}



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

using namespace std;

#define llong long long int
#define ldouble long double
#define ternary(condition, x, y) ((condition) ? x : y) 
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

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

    int n, a;
    cin >> n >> a;
    vector<int> X(n);
    rep(i, n) {
        cin >> X[i];
    }

    dp[0][0][0] = 1;
    rep(i, n) {
        rep(j, n) {
            rep(k, 2500) {
                if (dp[i][j][k]) {
                    dp[i + 1][j][k] += dp[i][j][k];
                    dp[i + 1][j + 1][k + X[i]] += dp[i][j][k];
                }
            }
        }
    }

    llong ans = 0;
    for (int i = 1; i < n + 1; ++i) {
        ans += dp[n][i][i * a];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 58112
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int n, m;
  cin >> n >> m;
  vector<P> v(m);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    v[i] = P(b, a);
  }
  sort(v.begin(), v.end());
  int pre = -1;
  int ans = 0;
  rep(i, m) {
    if(pre <= v[i].second) {
      ans++;
      pre = v[i].first;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const double PI=3.14159265358979323846;
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n,k,s;
  cin>>n>>k>>s;
  rep(i,k){
    cout<<s<<' ';
  }
  REP(i,k,n){
    if(s==1){
      cout<<100<<' ';
    }
    else{
      cout<<s-1<<' ';
    }
  }
  return(0);
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
int main(){
    int n,k;cin>>n>>k;
    int h[n];
    int ans=0;
    REP(i,n){
        cin>>h[i];
        if(h[i]>=k)
        {
            ans++;
        }
    } 
    
    cout<<ans<<endl;

    
   }

Measured memory_bytes: 640
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int N = nextInt();
		int[] A = nextInts();

		long ans = Integer.MAX_VALUE;
		for(int i=0;i<N;i++){
			int tmp = 0;
			while(A[i]%2==0){
				A[i]=A[i]/2;
				tmp++;
			}
			ans = Math.min(ans, tmp);
		}
		System.out.println(ans);

	}


	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 22996
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <math.h>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < n - 1; ++i) {
		cout << a[i] << " " ;
	}
	cout << a[n - 1] << endl;
	for (int i = 1; i < n; ++i) {
		int v = a[i];
		int j = i - 1;
		while (j >= 0 && a[j] > v) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
		for (int i = 0; i < n - 1; ++i) {
			cout << a[i] << " " ;
		}
		cout << a[n - 1] << endl;
	}

	return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    int N, W;
    cin >> N >> W;
    vector<int> w(N), v(N);
    REP(i, N) cin >> w[i] >> v[i];

    auto dp = vector<vector<ll>>(N + 1, vector<ll>(W + 1));

    REP(i, N) {
        REP(sum, W + 1) {
            chmax(dp[i + 1][sum], dp[i][sum]);
            if (sum - w[i] < 0)
                continue;
            chmax(dp[i + 1][sum], dp[i][sum - w[i]] + v[i]);
        }
    }

    std::cout << dp[N][W] << '\n';

    return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int a,b,c,d; cin >> a >> b >> c >> d;
  int ans = a*b-c*b-a*d+c*d;

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


Measured memory_bytes: 256
require 'set'

class UnionFind
  def initialize(size)
    @rank = Array.new(size, 0)
    @parent = Array.new(size, &:itself)
  end

  def unite(id_x, id_y)
    x_parent = get_parent(id_x)
    y_parent = get_parent(id_y)
    return if x_parent == y_parent

    if @rank[x_parent] > @rank[y_parent]
      @parent[y_parent] = x_parent
    else
      @parent[x_parent] = y_parent
      @rank[y_parent] += 1 if @rank[x_parent] == @rank[y_parent]
    end
  end

  def get_parent(id_x)
    @parent[id_x] == id_x ? id_x : (@parent[id_x] = get_parent(@parent[id_x]))
  end

  def same_parent?(id_x, id_y)
    get_parent(id_x) == get_parent(id_y)
  end
end

n, k, l  = gets.strip.split.map(&:to_i)
pq = k.times.map { gets.strip.split.map(&:to_i) }
rl = l.times.map { gets.strip.split.map(&:to_i) }

roads = UnionFind.new(n+1)
rails = UnionFind.new(n+1)


pq.each do |p, q|
  roads.unite(p, q)
end

rl.each do |r, l|
  rails.unite(r, l)
end

counter = {}

(1..n).each do |i|
  counter[[rails.get_parent(i), roads.get_parent(i)]] ||= []
  counter[[rails.get_parent(i), roads.get_parent(i)]] << i
end

ans = Array.new(n+1, 0)

counter.values.each do |varr|
  varr.each do |i|
    ans[i] = varr.size
  end
end

ans.shift

puts ans.join(' ')

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

vector<pair<int, int>> c;
vector<vector<int>> g;
vector<int> ans;

int now = 0;

void dfs(int to, int from) {
    ans[to] = c[now].fi;
    for(int next : g[to]){
        if(next == from) continue;
        now++;
        dfs(next, to);
    }
}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n;cin >> n;
    g.resize(n);
    c.resize(n);
    ans.resize(n);
    inc(i, 0, n-1){
        int a, b;cin >> a >> b;
        a--;b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    int sum = 0;
    inc(i, 0, n){
        int cc;cin >> cc;
        c[i] = {cc, i};
        sum += c[i].fi;
    }
    sort(c.begin(), c.end());
    reverse(c.begin(), c.end());

    inc(i, 0, n){
        if(g[i].size() == 1){
            dfs(i, -1);
            break;
        }
    }

    cout << sum-c[0].fi << endl;
    inc(i, 0, n){
        cout << ans[i];
        if(i != n-1){
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	ll v=0;
	ll p=1;
	for (int i=0;i<n;i++){
		ll a;
		cin>>a;
		if (i==0) {
			v+=a-1;
			p=2;
		}
		else{
			if (a==p){
				p++;
			}
			else{
				v+=(a-1)/p;
			}
		}
		//cout<<v<<endl;
	}
	cout<<v<<endl;
}

Measured memory_bytes: 384