akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if (c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }else if (c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }else if (c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }else if (c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }else if (c=='R'){
      b=s[1];
      s[1]=s[2];
      s[2]=s[4];
      s[4]=s[3];
      s[3]=b;
    }
  }
  int top(){
    return s[0];
  }
  int front(){
    return s[1];
  }
  int right(){
    return s[2];
  }
  int left(){
    return s[3];
  }
};

bool diceCheck(Dice diceA,Dice diceB){
  int i;

  if (diceA.right()==diceB.top())diceA.roll('W');
  else if (diceA.left()==diceB.top())diceA.roll('E');
  else {
    for (i=0;i<3;i++){
      if (diceA.top()==diceB.top())break;
      diceA.roll('N');
    }
    if (diceA.top()!=diceB.top())return false;
  }
  for (i=0;i<3;i++){
    if (diceA.front()==diceB.front())break;
    diceA.roll('R');
  }
  if (diceA.front()!=diceB.front())return false;
  for (i=2;i<6;i++){
    if (diceA.s[i]!=diceB.s[i])return false;
  }
  return true;
}
int main(){
  int i,j,n;
  cin>>n;
  Dice d[n];
  for (j=0;j<n;j++){
    for (i=0;i<6;i++)cin>>d[j].s[i];
  }
  for (j=0;j<n-1;j++){
    for (i=j+1;i<n;i++){
      if (diceCheck(d[j],d[i])){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}



Measured memory_bytes: 3108
#include <iostream>
using namespace std;
bool iscat(string s)
{
  int l = s.length();
  if(l == 0 || s == "mew") return true;
  if(s[0] != 'm' || s[l-1] != 'w' || l % 3 != 0) return false;
  int m = 0,e = 0,w = 0;
  for(int i=0; i<l; i++){
    switch(s[i]){
    case 'm': m++; break;
    case 'e': e++; break;
    case 'w': w++; break;
    }
  }
  if(m != e || e != m) return false;
  int id = 1;
  int n;
  while((n = s.find('e',id)) != string::npos){
    string s1 = s.substr(1,n-1);
    string s2 = s.substr(n+1,l-n-2);
    if(iscat(s1) && iscat(s2)) return true;
    id = n+1;
  }
  return false;
}
int main()
{
  string s;
  cin >> s;
  if(iscat(s)) cout << "Cat" << endl;
  else cout << "Rabbit" << endl;
  return 0;
}

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


int main () {
  int n;
  cin>>n;
  double x[n],ans=0;
  string y[n];
  for(int i=0;i<n;i++)
  {
    cin>>x[i];
    cin>>y[i];
    if(y[i]=="JPY")ans+=x[i];
    else ans+=(x[i]*380000.0);
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
import math
N = int(input())
A = list(map(int, input().split()))

if N == 1:
	if A[0] == 0:
		print(1)
		exit()
	else:
		print(0)
		exit()

count = 0

for i in range (1, N):
	A[i]+=A[i-1]

A = sorted(A)

if A[0] == 0:
	zeros = 1
else:
	zeros = 0

pittan = A[0]
countB = 1

for i in range (1, N):
	if A[i] == 0:
		zeros+=1
	if A[i] == A[i-1]:
		countB+=1
	else:
		count+=math.comb(countB, 2)
		countB = 1
		pittan = A[i]

print(count+zeros+math.comb(countB, 2))

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

bool canBuy(int N) {
  for (int i = 0; i <= N / 4; i++) {
    for (int j = 0; j <= N / 7; j++) {
      if (i * 4 + j * 7 == N) {
        return true;
      }
    }
  }
  return false;
}

int main() {
  int N;
  cin >> N;
  cout << (canBuy(N) ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll N,K;
VL p,n;

bool judge_n(ll mid){
	ll sum=0LL;
	rep(i,p.size()){
		ll d=(mid-p[i]+1)/p[i];
		sum+=upper_bound(ALL(n),d)-n.begin();
	}
	return sum>=K;
}

bool judge_p(ll mid){
	ll sum=0LL;
	rep(i,p.size()){
		ll d=mid/p[i];
		ll tmp=upper_bound(ALL(p),d)-p.begin();
		if(i<tmp) tmp--;
		sum+=tmp;
	}
	rep(i,n.size()){
		ll d=mid/n[i];
		ll tmp=upper_bound(ALL(n),d)-n.begin();
		if(i<tmp) tmp--;
		sum+=tmp;
	}
	sum/=2;
	return sum>=K;
}

signed main(){
  cin>>N>>K;
	ll zero=0LL;

	rep(i,N){
		ll a; cin>>a;
		if(a>0) p.PB(a);
		else if(a<0) n.PB(a);
		else zero++;
	}
	sort(ALL(p)); sort(ALL(n));
	ll posi=pow(p.size(),2LL)+pow(n.size(),2LL);
	ll nega=p.size()*n.size();
	zero=zero*(zero-1)/2+zero*(N-zero);

	if(K<=nega){
		ll l=-1e18-1, u=-1;
		while(u-l>1){
			ll mid=(l+u)/2;
			if(judge_n(mid)) u=mid;
			else l=mid;
		}
		cout<<u<<endl;
	}else if(K<=nega+zero){
		cout<<0<<endl;
	}else{
		K-=nega+zero;
		rep(i,n.size()) n[i]=abs(n[i]);
		sort(ALL(n));
		ll l=-1, u=1e18;
		while(u-l>1){
			ll mid=(l+u)/2;
			if(judge_p(mid)) u=mid;
			else l=mid;
		}
		cout<<u<<endl;
	}

  return 0;
}


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

int main(void){
   int N;
   cin>>N;
   vector<long long> h(N);
   for(int i=0;i<N;i++){
      cin>>h[i];
   }
   vector<long long> dp(N);
   dp[0]=0;
   for(int i=1;i<N;i++){
      if(i>1){
         dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
      }else{
         dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
      }
   }
   cout<<dp[N-1]<<endl;
   return 0;
}


Measured memory_bytes: 4748
AMO = [nil,2,5,5,4,5,6,3,7,6]

N, M = gets.split.map!{|n| n.to_i}

x = gets.split.map!{|n| n.to_i}
x.sort!
a = Hash.new(0)
for i in 1..M
    a[AMO[x[i-1]]] = x[i-1]
end

a = a.to_a

dp = Array.new(N+1)
dp[0] = 0
for i in 1..N
    dp[i] = -1
    a.each do |b|
        if i - b[0] < 0
            next
        elsif dp[i - b[0]] != -1 && dp[i] < dp[i - b[0]] + 1
            dp[i] = dp[i - b[0]] + 1
        end
    end
end

a.sort!{|b, c| -b[1] <=> -c[1]}
k = N
j = 0
ans = ""

while k != 0 do
    if k - a[j][0] < 0
        j += 1
        next
    end

    if dp[k] == dp[k - a[j][0]] + 1
        ans += a[j][1].to_s
        k -= a[j][0]
    else
        j += 1
    end
end

puts ans

Measured memory_bytes: 9980
n, x = gets.split.map(&:to_i) # 整数半角区切り,非配列
#arys = []; n.times { arys << gets.chomp.split.map(&:to_i).to_a }  # 整数半角区切り,複数行
# strings = []; 2.times {strings << gets.chomp} # 文字列複数受け取り

@ans = 0

def pn(n)
 (2 **(n+1)) -1
end

def loopn(n,x)
	if (n==1)
	    case x
			when 1    then return 0
			when 2..4 then return x-1
			when 5    then return 3
			else           return 0
		end
	end

	s = pn(n)

	case x
		when s       then return pn(n-1)+1
		when s-1     then return pn(n-1)
		when 0...s-1 then return loopn(n-1, x-1)
		when s*2 -1  then return s
		else              return pn(n-1) + loopn(n-1, x-s) + 1
	end
end

p loopn(n,x)

Measured memory_bytes: 1788
#include<stdio.h>
#include<stdlib.h>

int main(void){
    int M, N, C;
    scanf("%d%d%d", &N, &M, &C);

    int **A;
    int *B;
    int i, j;

    B = (int*)malloc(sizeof(int) * M);
    for(i=0; i<M; i++) {
    		scanf("%d", &B[i]);
    }

    A = (int**)malloc(sizeof(int*) * N);
    for(i=0; i<N; i++) {
    	A[i] = malloc(sizeof(int) * M);
    }
    

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

    int count = 0;
    for(i=0;i<N;i++) {
        int sum = 0;
    	for(j=0; j<M; j++) {
            sum += A[i][j] * B[j];
    	}
        if(sum + C > 0) {
            count++;
        }
    }

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

    for (i=0; i<N; i++) {
    	free(A[i]);
    }

    free(A);
    free(B);

    return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var B1, B2, B3, B4 [3][10]int
	var n, b, f, r, v int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&b, &f, &r, &v)
		switch b {
		case 1:
			B1[f - 1][r - 1] += v
		case 2:
			B2[f - 1][r - 1] += v
		case 3:
			B3[f - 1][r - 1] += v
		case 4:
			B4[f - 1][r - 1] += v
		}
	}
	
	for i := 0; i < 3; i++ {
		for j := 0; j < 10; j++ {
			fmt.Printf(" %d",B1[i][j])
		}
		fmt.Println()
	}
	fmt.Println("####################")
	for i := 0; i < 3; i++ {
		for j := 0; j < 10; j++ {
			fmt.Printf(" %d",B2[i][j])
		}
		fmt.Println()
	}
	fmt.Println("####################")
	for i := 0; i < 3; i++ {
		for j := 0; j < 10; j++ {
			fmt.Printf(" %d",B3[i][j])
		}
		fmt.Println()
	}
	fmt.Println("####################")
	for i := 0; i < 3; i++ {
		for j := 0; j < 10; j++ {
			fmt.Printf(" %d",B4[i][j])
		}
		fmt.Println()
	}
}


Measured memory_bytes: 1136
n = int(input())
a = []
su = 0
for i in range(5):
    k = int(input())
    a.append([k,-(-1*n//k)])

for i in range(5):
    if i == 0:
        su += a[i][1]
    else:
        if i + a[i][1] > su + 1:
            su = i + a[i][1]
        else:
            su += 1

print(su) 




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

using namespace std;

typedef long long ll;

int main()
{
    int a,i=0;
    cin >>a;
    string arr[101];
    cin>>arr[i];
    int l = arr[i].size();
    int aux = arr[i][l-1];
    for(i = 1; i < a; i++){
        cin >>arr[i];
        if(arr[i][0]!=aux){
            cout<<"No";
            return 0;
        }
        for(int j = 0; j != i;j++){
            if(arr[i]== arr[j]){
                cout<<"No";
            return 0;
            }
        }
        l = arr[i].size();
        aux = arr[i][l-1];
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

struct data {
  string name;
  int num;
};

int n, q;
queue<data> qu;
vector<data> res;

void solve();

int main() {
  cin >> n >> q;
  for(int i = 0; i < n; ++i) {
    string s;
    int x;
    cin >> s >> x;
    qu.push({s, x});
  }
  solve();
  for(int i = 0; i < n; ++i)
    cout << res[i].name << " " << res[i].num << endl;
  return 0;
}

void solve() {
  int sum = 0;
  while(!qu.empty()) {
    data now = qu.front();
    qu.pop();
    sum += min(now.num, q);
    if(now.num > q)
      qu.push({now.name, now.num - q});
    else
      res.push_back({now.name, sum});
  }
}


Measured memory_bytes: 6988
#include <stdio.h>
int main(void){
    // Your code here!
    int N;
    long long int A[200010];
    int i=0;
    scanf("%d",&N);
    for(i=0;i<N;i++)
    {
        scanf("%lld",&A[i]);
    }
    
    long long int ans=0;
    
    i=0;
    int flag=0; //マイナスが偶数(最後プラスになる)とき
    while(i<N)
    {
        if(A[i]<0)
        {
            ans=ans+(A[i]*(-1));
            if(flag==0) flag=1;
            else        flag=0;
        }
        
        if(A[i]>0)
        {
            ans+=A[i];
        }
        
        if(A[i]==0)
        {
            i++;
            if(A[i]<0)
            {
                ans=ans+(A[i]*(-1));
                flag=1;
            }
            else 
            {
            ans+=A[i];
            flag=0;
            }
        }
        

        i++;
        
    }
    
    if(flag==0)
    {
        printf("%lld",ans);
    }
    if(flag==1)
    {
        int zero;
        int j;
        for(j=0;j<N;j++)
        {
            if(A[j]==0)
            zero=j;
        }
        long long int min=9999999999999;
        while(zero<N)
        {
            if(A[zero]<0)
            {
            A[zero]=A[zero]*(-1);
            }
            if(A[zero]<min)
            min=A[zero];
            zero++;
        }
        
        
        printf("%lld",ans-(min*2));
    }
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <deque>
#include <cstdlib>
#include <cmath>
#include <climits>

using namespace std;

bool exist( int n, deque<int> l ){
  for( deque<int>::iterator it = l.begin(); it != l.end(); it++ ){
    if( *( it ) == n ){ return true; }
  }
  return false;
}

int proc( int n, int c, deque<int> l ){
  if( n < 10 ){ return c; }
  if( exist( n, l ) ){ return -1; }
  
  // Dividors number == [log10( n )]
  int dn = floor( log10( n )  );
  int max = INT_MIN;
  for( int i = 1; i <= dn; i++ ){
    int dv = pow( 10.0, i * 1.0 );
    int a = n / dv;
    int b = n % dv;
    if( max < a * b ){ max = a * b; }
  }
  l.push_back( n );
  return proc( max, c + 1, l );
}

int main(){
  int q;
  deque<int> l;
  cin >> q;
  for( int i = 0; i < q; i++ ){
    int n;
    cin >> n;
    cout << proc( n, 0, l ) << endl;
  }
  return EXIT_SUCCESS;
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
//#define inf 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define N 2005

using namespace std;
typedef pair<int,int> Pair;
typedef long long ll;

const long double Pi = 3.14159265358979323846l;
const int mod = 1e9 + 7;
inline int add(int x, int y) { return (x += y) - (x >= mod ? mod : 0); }
inline void inc(int &x, int y) { (x += y) -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = mul(res, x);
		x = mul(x, x), y >>= 1;
	} return res;
}

template <class T> inline T	input() {
	T x; char ch; while (!isdigit(ch = getchar()));
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return x;
}

template <class T> inline void chkmin(T &x, T y) { x = x < y ? x : y; }
template <class T> inline void chkmax(T &x, T y) { x = x > y ? x : y; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

int n, k;
int tot, fac[N];
int dp[N], ans;

int main() {
	read(n, k);
	for (int i = 1; i * i <= n; ++i)
		if (n % i == 0) {
			fac[++tot] = i;
			if (i * i != n) fac[++tot] = n / i;
		}

	sort(fac + 1, fac + tot + 1);
	for (int i = 1; i <= tot; ++i) {
		dp[i] = Power(k, (fac[i] + 1) / 2);
		for (int j = 1; j < i; ++j)
			if (fac[i] % fac[j] == 0)
				inc(dp[i], mod - dp[j]);
		if (fac[i] & 1) inc(ans, mul(dp[i], fac[i]));
		else inc(ans, mul(dp[i], fac[i] / 2));
	}

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


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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define data asd09123jdf02i3h

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int n,a[maxn],vis[maxn];
map<int,int > t;

int main() {
    read(n);
    for(int i=1;i<=n;i++) read(a[i]),t[a[i]]++;
    int ans=0;
    sort(a+1,a+n+1,greater<int >());
    for(int i=1;i<=n;i++) {
        if(!t[a[i]]) continue;
        int x=1;while(x<=a[i]) x*=2;x-=a[i];
        // printf("%d %d\n",a[i],x);
        if(!t[x]) continue;
        if(x==a[i]) {ans+=t[x]/2,t[x]%=2;continue;}
        int r=min(t[a[i]],t[x]);
        t[x]-=r,t[a[i]]-=r,ans+=r;
    }
    write(ans);
    return 0;
}


Measured memory_bytes: 23040
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define int long long 
#define ar array
#define f first
#define s  second
#define REP(i,n) for (int i=0;i<(n);i++)
#define wt(x) int x;cin>>x;while(x--)
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
template <typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename T>
using o_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>; 

void  c_p_c(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input1.txt","r",stdin);

  freopen("output1.txt","w",stdout);
#endif
}
const int mod=1000000007;
int power(int a,int b,int mod){
  a=a%mod;
  if(a==0){
    return 1;
  }
  int res=1;
  while(b){
    if(b&1){
      res=(res*a)%mod;
    }
    b>>=1;
    a=(a*a)%mod;
  }
  return res;
}

int  MMI(int p){
  return power(p,mod-2,mod);
}
int32_t main()
{
 c_p_c();
 
 string s;
 cin>>s;
 int ans=0;
 for(char c:s){
  ans+=(c-'0');
 }
 if(ans%9==0)cout<<"Yes\n";
 else cout<<"No\n";
 
 return 0;  
 
 
}



Measured memory_bytes: 3748
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;

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


int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll res = 1e18;
    rep(k, max(x, y) + 1) {
        int i = max(0ll, x - k);
        int j = max(0ll, y - k);
        res = min(res, (a * i) + (b * j) + (c * 2 * k));
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <map>
#include <functional>
#include <queue>
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>

using namespace std;

#define ll long long int
#define ti4 tuple<int,int,int,int>
#define pii pair<ll,ll>
#define REP(x,n) for(int x = 0;x < n;x++)

struct UnionFind {
    vector<ll> data;
    UnionFind(ll size) : data(size, -1) { }
    bool unionSet(ll x, ll y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(ll x, ll y) {
        return root(x) == root(y);
    }
    ll root(ll x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    ll size(ll x) {
        return -data[root(x)];
    }
};

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(ll i = 0;i < n;i++)
    {
        cin >> a[i];
    }
    ll sum = 0;
    sum += a[0]-1;
    ll m = 1;
    for(int i = 1;i < n;i++)
    {
        if(a[i] <= m)
        {
            continue;
        }
        if(a[i] == m + 1)
        {
            m++;
            continue;
        }
        ll div = a[i] / (m+1);
        ll mod = a[i] % (m+1);
        if(mod==0)
        {
            div--;
        }
        sum += div;
        //cout << i << ",a[i]=" << a[i] << ",div=" << div << ",m+1=" << (m+1) << ",sum=" << sum << endl;
    }
    cout << sum << endl;
}

Measured memory_bytes: 1152
#include <stdio.h>


long long f( long long x , long long y ){

    if( x != -1 ){

        long long s = x / y + 1;

        return s;

        }

    else if( x == - 1 ){

         return 0;

         }

    }
                                                                                                
  
int main(void){
                                                                                                
   
    long long a, b, x;
   
      
    scanf("%lld %lld %lld", &a, &b, &x);
   

    printf("%lld\n", f( b, x ) - f( a - 1, x ) );


    return 0;
                                                          
}

Measured memory_bytes: 128
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	m := getNextInt(scanner)
	imos := make([]int, n+1)
	for i := 0; i < m; i++ {
		l := getNextInt(scanner) - 1
		r := getNextInt(scanner)
		imos[l]++
		imos[r]--
	}
	ans := 0
	for i := 0; i < n; i++ {
		imos[i+1] += imos[i]
		if imos[i] == m {
			ans++
		}
	}
	fmt.Fprintln(writer, ans)
}


Measured memory_bytes: 3584
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 3e3 + 9, maxV = 1e6 + 9, MOD = 998244353, SQ = 335, lg = 20, bs = 29;

ll dp[maxN][maxN];

int n, s, arr[maxN];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	cin >> n >> s;
	for(int i = 0; i < n; i++) cin >> arr[i];
	dp[n][0] = 1;
	for(int i = n - 1; i >= 0; i--) {
		for(int j = 0; j <= s; j++) {
			dp[i][j] = dp[i + 1][j] * 2 % MOD;
			if(j >= arr[i]) dp[i][j] = (dp[i][j] + dp[i + 1][j - arr[i]]) % MOD;
			LOG << dp[i][j] << ' ';
		}
		LOG << '\n';
	}
	cout << dp[0][s] << '\n';
}



Measured memory_bytes: 74164
#include <iostream>
#include <cstdio>
#include <climits>
#define INF INT_MAX;
using namespace std;

int main() {
  int A, B, C, X, Y;
  int maxXY =  max(X, Y);
  cin >> A >> B >> C >> X >> Y;

  int ansA = 0, ansB = 0, ansC = 0;
  int minCost = INF;

  for (int ac = 0; ac <= max(X, Y); ac++) {
    int a = max(0, X - ac);
    int b = max(0, Y - ac);
    int cost = ac * 2 * C + a * A + b * B;
    minCost = min(minCost, cost);
  }
  cout << minCost << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
#include <list>
#include <unordered_map>
#include <deque>
#include <math.h>
#include <tgmath.h>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << "\n";}
#define INF (1e18)

const ll MAX = 1000000000;
const ll MOD = 1e9 + 7;

ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

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

ll aabs(ll a) {
    if (a < 0) return -a;
    return a;
}

//fast power
ll calc(ll a, ll b) {
    if (b == 0) return 1;
    else if (b % 2 == 0) {
        ll d = calc(a, b / 2);
        return (d * d) % MOD;
    }
    else return (a * calc(a, b - 1)) % MOD;
}

//fast combination
ll comb(ll n, ll a) {
    ll b = 1, c = 1;
    for (ll i = 1; i <= a; ++i) {
        b = b * i % MOD;
        c = c * (n - i + 1) % MOD;
    }

    return c * calc(b, MOD - 2) % MOD;
}

ll comb2(ll a) {
    ll b = a / 2;
    if (a % 2) {
        b = (a - 1) / 2;
        return (b * a);
    }
    return (b * (a - 1));
}

int kyotsu(string ss, int st, int ed, string ss2) {
    int ans = 0;
    for ( int i = st; i < ed; ++i ) {
        if (i - st >= ss2.size()) return ans;
        if (ss[i] == ss2[i - st] || ss[i] == '?') {
            ans++;
        } else {
            return -1;
        }
    }
    return ans;
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string ss;
    cin >> ss;

    if (ss[2] == ss[3] && ss[4] == ss[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

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

H.reverse()
for i in range(N-1):
    if H[i] < H[i+1]:
        H[i+1] -= 1

    if H[i] < H[i+1]:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 14252
//         PAR_YUMMM            //
                                           //           CPP                //
#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
ll const N=1e6+5;
ll const INF=9223372036854775807;

#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define len length()
#define umap unordered_map
#define uset unordered_set
#define acc(v) accumulate(all(v), 0)
#define F first
#define S second
 
#define forz(i, n) for (ll i = 0; i < n; i++)
#define fore(i, m, n) for (ll i = m; i <= n; i++)
#define rforz(i, n) for (ll i = n - 1; i >= 0; i--)
#define rfore(i, m, n) for (ll i = n; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define highll(n) __builtin_popcountll(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define gcd __gcd
#define sexy ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define endl "\n"
#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 oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define osetll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
#define ofk order_of_key
#define fbo find_by_order

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

ll modi(ll a,ll m){
    return po(a,m-2,m);
}

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

ll max(ll a,ll b){
    if(a>b){
        return a;
    }else{
        return b;
    }
}

ll min(ll a,ll b){
    if(a<b){
        return a;
    }else{
        return b;
    }
}

ll bins(ll ar[],ll l,ll r,ll x){ 
    if(r>=l){ 
        ll m=l+((r-l)/2); 
        if(ar[m]==x){
            return m; 
        }else if(ar[m]>x){ 
            return bins(ar,l,m-1,x);
        }else{
            return bins(ar,m+1,r,x); 
        }
    } 
    return -1; 
} 

ll nCr(ll n,ll k){ 
    ll C[n + 1][k + 1]; 
    ll i, j; 
    for(i=0;i<=n;i++){ 
        for(j=0;j<=min(i,k);j++){
            if(j==0||j==i){
                C[i][j]=1;  
            }else{
                C[i][j]=C[i-1][j-1]+C[i-1][j]; 
            }
        } 
    }
    return C[n][k]; 
} 

//vector<vector<ll>> adj(N); 

int main(){
    sexy;
    ll T,x,y,z,p,q,r;
    cin>>x;
    y=lcm(x,360);
    p1(y/x);
    return 0;
}


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

int main() {
    lld x;
    cin >> x;
    // 100 1
    // 200 2
    // 300 3
    // 100~200 100year
    // 200~300 50 year
    // 300-402 34 year
    // 402-500 100/4 = 25

    double frac = 0.01;
    lld money = 100;
    lld year = 0;
    while(money < x) {
        lld p = money * frac;
        money += p;
        year++;
    }
    cout << year << '\n';
}


Measured memory_bytes: 3632
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
ll k;
string str;
map<string, ll> mp;
int main(void){
    // Your code here!
    cin >> str >> k;
    for (ll i = 1; i <= min(k, (ll)str.length()); i++){
        for (ll j = 0; j <= str.length() - i; j++){
            mp[str.substr(j, i)]++;
        }
    }
    auto itr = mp.begin();
    for (ll i = 1; i < k; i++) ++itr;
    cout << itr->first << endl;
}


Measured memory_bytes: 1920
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val x = sc.nextInt()
  val y = sc.nextInt()

  val array = (1..n-1).map { 0 }.toIntArray()

  for (i in 1 until n) {
    for (j in i+1..n) {
      val tmp = Math.min(j-i, Math.abs(x-i) + 1 + Math.abs(y-j))
      array[tmp-1]++
    }
  }

  println(array.joinToString("\n"))

}


Measured memory_bytes: 41932
from collections import Counter
from functools import reduce
import bisect
import fractions
import math
import statistics
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]  # LIST INT
def LF(): return [float(x) for x in sys.stdin.readline().split()]  # LIST FLOAT
def LS(): return sys.stdin.readline().split()  # LIST STRING
def MI(): return map(int, sys.stdin.readline().split())  # MAP INT
def II(): return int(sys.stdin.readline())  # INPUT INT
def IS(): return input()  # INPUT STRING
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):  # Greatest Common Divisor
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):  # Least Common Multiple
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))


n, a = II(), LI()
counter = sorted(C(a).items(), key=lambda x: x[0], reverse=True)
for i in range(n):
    if 4 <= counter[i][1]:
        print(counter[i][0] ** 2)
        exit()
    elif 2 <= counter[i][1]:
        for j in range(i+1, n):
            if 2 <= counter[j][1]:
                print(counter[i][0] * counter[j][0])
                exit()
print(0)


Measured memory_bytes: 23928
N=int(input())
a=list(map(int,input().split()))
S=sum(a)
SS=0
mi=1000000000000000
for i in range(N-1):
    S=S-a[i]
    SS=SS+a[i]
    if mi>=abs(S-SS):
        mi=abs(S-SS)
print(mi)


Measured memory_bytes: 23792
#include <iostream>
using namespace std;
int main (void) {
    string S;

    cin >> S;

    int cnt = 0;
    for (int i = 0, len = S.length(); i < len; i++) {
        if (S[i] == 'o') {
            cnt++;
        }
    }
    int ans = 700 + 100 * cnt;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
typedef long long ll;
const ll INF=1000000010;
const ll MOD=1000000007;
using namespace std;
ll dp[1010][1010];
ll sum[1010];
int main(){
	string s,t;cin>>s>>t;
	int n=s.length(),m=t.length();
	for(int i=0;i<n;i++){
		if(s[i]==t[0])dp[0][i]=1;
		sum[i+1]=sum[i]+dp[0][i];
	}
	for(int i=1;i<m;i++){
		for(int j=0;j<n;j++){
			if(s[j]==t[i])dp[i][j]=sum[j]%MOD;
		}
		fill(sum,sum+n,0);
		for(int j=1;j<n;j++){
			sum[j]+=dp[i][j-1];
			sum[j]%=MOD;
			sum[j+1]+=sum[j];
		}
	}
	ll ans=0;
	for(int i=0;i<n;i++){
		ans+=dp[m-1][i];
		ans%=MOD;
	}
	cout<<ans<<endl;
}	



Measured memory_bytes: 10976
#include <iostream>

using namespace std;

int main(){
    int result;
    string s;
    cin >> s;
    if(s[0] == '1'){
        result++;
    }
    if(s[1] == '1'){
        result++;
    }
    if(s[2] == '1'){
        result++;
    }
    cout << result << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FIO "agc31A"
#define ll long long

const int N=1e5+5,MOD=1e9+7;

inline int add(int a,const int &b){a+=b;return a>=MOD?a-MOD:a;}
inline int sub(int a,const int &b){a-=b;return a<   0?a+MOD:a;}
inline int mul(const int &a,const int &b){return 1ll*a*b%MOD;}
inline int& inc(int &a,const int &b){return a=add(a,b);}
inline int& dec(int &a,const int &b){return a=sub(a,b);}
inline int& pro(int &a,const int &b){return a=mul(a,b);}
inline int qpow(int a,int b){int c=1;for(;b;b>>=1,pro(a,a))if(b&1)pro(c,a);return c;}

int n;
char s[N];
int c[30];

int main(){
  scanf("%d%s",&n,s+1);
  for(int i=1;i<=n;i++)c[s[i]-'a']++;
  int ans=1;
  for(int i=0;i<26;i++)pro(ans,c[i]+1);
  printf("%d\n",sub(ans,1));
  return 0;
}


Measured memory_bytes: 384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

//code by lynmisakura.wish to be accepted!
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

/***************************/
using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<long long> vl;
typedef pair<ll, ll> pi;
typedef vector<pair<ll, ll>> vpi;

//const long long INF = 1LL << 55;

#define itn ll
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(ll i = 0;i < n;i++)
#define rep(i,n) for(ll i = 0;i < n;i++)
#define flush fflush(stdout)
#define rrep(i,n) for(ll i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, ll mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

class ADDCCFinals {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int x,y;cin >> x >> y;
        int ans = 0;
        int money = 100000;
        if(x <= 3){
            ans += (4 - x)*money;
        }
        if(y <= 3){
            ans += (4 - y)*money;
        }
        if(x == 1 and y == 1){
            ans += 4*money;
        }
        cout << ans << endl;
    }
};

int main() {
	ADDCCFinals solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<cstring>
#include<vector>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<utility>
#include<climits>
#include<set>
using namespace std;
#define ll long long

void solve(){
	int x,n;cin>>x>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	int ans;
	int j=0;
	int value =100;
	for(int i=0;i<=101;i++)
	{
		if(a[j]==i and j<n)
		{
			j++;
			continue;
		}
		if(abs(i-x)<value)
		{
			value=abs(i-x);
			ans=i;
		}

	}
	cout<<ans;
}
int main(){ 
	ios_base::sync_with_stdio(false);
	    cin.tie(0);
	    cout.tie(0);
	    
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);
	    freopen("output.txt","w",stdout);
	#endif


	    int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;

}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a[3];
	rep(i, 3) cin>>a[i];
	sort(a, a+3);

	bool first = true;
	rep(i, 3){
		if (first){
			first = false;
		}else{
			cout << " ";
		}
		cout << a[i];
	}
	cout << "\n";
	return 0;
}


Measured memory_bytes: 3152
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Anti-Division
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

template <typename T>
T gcd(T m, T n) {  // m > 0, n > 0
  if (m < n) swap(m, n);
  while (n > 0) {
    T r = m % n;
    m = n;
    n = r;
  }
  return m;
}

inline ll notdiv(ll n, ll c, ll d, ll l) {
  return n - n / c - n / d + n / l;
}

/* main */

int main() {
  ll a, b, c, d;
  scanf("%lld%lld%lld%lld", &a, &b, &c, &d);

  ll l = c * d / gcd<ll>(c, d);
  printf("%lld\n", notdiv(b, c, d, l) - notdiv(a - 1, c, d, l));
  return 0;
}


Measured memory_bytes: 256
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int a,b;
	cin>>a>>b;
	int cnt[4]={0};
	cnt[a]++;
	cnt[b]++;
	for(int i=1;i<=3;i++){
		if(cnt[i]==0)
		{
			cout<<i;
			return 0;
		}
	}
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}







Measured memory_bytes: 3616
import sys
input = sys.stdin.readline
from collections import deque

n = int(input())
P = [-1]*n
C = [[] for i in range(n)]
Pre, In, Post = [], [], []

for i in range(n):
  s = [int(i) for i in input().split()]
  id = s[0]
  l = s[1]
  r = s[2]
  C[id] = (l,r)
  if l != -1:
    P[l] = id
  if r != -1:
    P[r] = id

for i in range(n):
  if P[i] == -1:
    root = i

def Prewalk(x):
  Pre.append(x)
  l,r = C[x]
  if l == -1 and r == -1:
    return
  if l != -1:
    Prewalk(l)
  if r != -1:
    Prewalk(r)
  
def Inwalk(x):
  l,r = C[x]
  if l == -1 and r == -1:
    In.append(x)
    return
  if l != -1:
    Inwalk(l)
  In.append(x)
  if r != -1:
    Inwalk(r)
  
def Postwalk(x):
  l,r = C[x]
  if l == -1 and r == -1:
    Post.append(x)
    return
  if l != -1:
    Postwalk(l)
  if r != -1:
    Postwalk(r)
  Post.append(x)
  
Prewalk(root)
Inwalk(root)
Postwalk(root)

print("Preorder")
print(" "+" ".join(map(str, Pre)))
print("Inorder")
print(" "+" ".join(map(str, In)))
print("Postorder")
print(" "+" ".join(map(str, Post)))


Measured memory_bytes: 6012
#include <stdio.h>
#define MAX 100000

int partition(int *,int,int);

int main()
{
  int i,a[MAX],n,x,k;

  scanf("%d",&n);
  for(i=1 ; i<=n ; i++)
  {
    scanf("%d",&a[i]);
  }

  k = partition(a,1,n);

  for(i=1 ; i<=n ; i++)
  {
    if(i!=k && i!=n)printf("%d ",a[i]);
    else if (i==k)printf("[%d] ",a[i]);
    else if(i== n) printf("%d",a[i]);
  }
  printf("\n");

  return 0;
}

int partition(int *A,int p,int r)
{
  int j,n,m,x,i;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++)
  {
    if(A[j]<=x)
    {
      i=i+1;
      n=A[i];
      A[i]=A[j];
      A[j]=n;
    }
  }
  m=A[i+1];
  A[i+1]=A[r];
  A[r]=m;
  return i+1;
}



Measured memory_bytes: 2136
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <math.h>
#include <stdlib.h>

int main()
{
	int k, a, n, m, l[31] = {}, t = 0;
	std::cin >> n >> m;
	for(int i = 0; i < n; i++){
		std::cin >> k;
		for(int j = 0; j < k; j++){
			std::cin >> a;
			l[a]++;
		}
	}
	for(int i = 0; i < m + 1; i++){
		if(l[i] == n){
			t++;
		}
	}
	std::cout << t << std::endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<bitset>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod = 998244353;
const ll INF = 0x3f3f3f3f;
const ll maxn = 2e5 + 5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;
ll qpow(ll a, ll b) { ll s = 1; while (b > 0) { if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1; }return s; }
 
int main(){
	// in;
	// out;
	string s;
	cin>>s;
	int a=0,b=0;
	for(int i=0;i<s.length();i++){
		if(s[i]=='A') a++;
		else b++;
	}
	if(a==2||b==2) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
dp = Array.new(n + 1) do Array.new(3) end # day, act
dp[1] = gets.split.map(&:to_i)
(2..n).each do |i|
  a, b, c = gets.split.map(&:to_i)
  dp[i][0] =  [dp[i - 1][1], dp[i - 1][2]].max + a
  dp[i][1] =  [dp[i - 1][0], dp[i - 1][2]].max + b
  dp[i][2] =  [dp[i - 1][1], dp[i - 1][0]].max + c
end
puts dp[n].max

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int cake[310][310] = {0};
int ans[310][310] = {0};

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

  int H, W, K;
  cin >> H >> W >> K;
  string S;
  for(int i = 0; i < H; i++){
    cin >> S;
    for(int j = 0; j < W; j++){
      if(S[j] == '#'){
        cake[i][j] = 1;
      }
    }
  }
  
  vector<int> exist_st(W);
  for(int i = 0; i < W; i++){
    int cnt_st = 0;
    for(int j = 0; j < H; j++){
      cnt_st += cake[j][i];
    }
    if(cnt_st > 0){
      exist_st[i] = 1;
    }
  }

  int first_cl_st = 0;
  for(int i = 0; i < W; i++){
    if(exist_st[i] == 1){
      first_cl_st = i;
      break;
    }
  }

  // まずfirst_cl_stまでうめる
  int cnt_k = 0;
  for(int i = 0; i < first_cl_st; i++){
    int tmp_cnt_k = 0;
    for(int j = 0; j < H; j++){
      if(cake[j][first_cl_st] == 1){
        tmp_cnt_k++;
      }
      ans[j][i] = max(tmp_cnt_k, 1);      
    }
    cnt_k = tmp_cnt_k;
  }

  exist_st.push_back(0);

  int cl_st = first_cl_st;
  cnt_k = 0;
  for(int i = first_cl_st; i < W; i++){
    int tmp_cnt_k = cnt_k;

    if(exist_st[i] == 1){
      cl_st = i;
    }

    for(int j = 0; j < H; j++){
      if(cake[j][cl_st] == 1){
        tmp_cnt_k++;
      }
      ans[j][i] = max(cnt_k+1, tmp_cnt_k);
    }

    if(exist_st[i+1] == 1){
      cnt_k = tmp_cnt_k;
    }
  }

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cout << (ans[i][j]) << " "; 
    }
    cout << endl;
  }
  





  return 0;
}


Measured memory_bytes: 1536