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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	string S;
	cin >> S;
	if (S == "Sunny") {
		cout << "Cloudy";
		return 0;
	}
	if (S == "Cloudy") {
		cout << "Rainy";
		return 0;
	}
	if (S == "Rainy") {
		cout << "Sunny";
		return 0;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll h, w;
	cin >> h >> w;
	string a[h];
	rep(i, 0, h){
		cin >> a[i];
	}
	ll dp[h][w];
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	
	rep(i, 0, h){
		rep(j, 0, w){
			if(a[i][j] == '.'){
				if(i > 0){
					dp[i][j] += dp[i-1][j];
					dp[i][j] %= MOD;
				}
				if(j > 0){
					dp[i][j] += dp[i][j-1];
					dp[i][j] %= MOD;
				}
			}
		}	
	}
	print(dp[h-1][w-1])
	return 0;
}

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

int main(){
  string s,t;
  cin >> s;
  cin >> t;
  int num=0;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]){
      num++;
    }
  }
  cout << num << endl;
}

Measured memory_bytes: 3920
#include<cstdio>
#include<algorithm>
const int N=1e5+2;
int i,n,m,a[N];
long long ans=1e12,k[N],b[N];
void wk(int s,int t)
{
	if(b[s]+=s,++k[t],--k[s],s<t)b[1]+=t-s,b[t]-=s;else
	b[1]+=t,b[t]+=m-s,--k[1];
}
int main()
{
	for(scanf("%d%d",&n,&m);i++<n;scanf("%d",a+i));
	for(i=0;++i<n;wk(a[i]+1,a[i+1]+1));
	for(i=0;i++<m;)
	{
		k[i]+=k[i-1],b[i]+=b[i-1];
		ans=std::min(ans,k[i]*i+b[i]);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 2176
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main
{
    public static void process()throws IOException
    {
        int x=ni(),y=ni();
        for(int i=0;i<=x;i++){
            if(2*i+(x-i)*4==y){
                pn("Yes");
                return ;
            }
        }
        pn("No");
    }
 
 
    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new FastReader();
 
        long s = System.currentTimeMillis();
        int t=1;
//        t=ni();
        while(t-->0)
            process();
 
        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
    }
    
    
    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static int ni()throws IOException{return Integer.parseInt(sc.next());}
    static long nl()throws IOException{return Long.parseLong(sc.next());}
    static double nd()throws IOException{return Double.parseDouble(sc.next());}
    static String nln()throws IOException{return sc.nextLine();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    
    static long mod=(long)1e9+7l;
 
    static<T> void r_sort(T arr[],int n){
        Random r = new Random(); 
        for (int i = n-1; i > 0; i--){ 
            int j = r.nextInt(i+1); 
                  
            T temp = arr[i]; 
            arr[i] = arr[j]; 
            arr[j] = temp; 
        } 
        Arrays.sort(arr); 
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////
    static class FastReader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader(){ 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()){ 
                try{ st = new StringTokenizer(br.readLine()); } catch (IOException  e){ e.printStackTrace(); } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine(){ 
            String str = ""; 
            try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } 
            return str; 
        } 
    } 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

Measured memory_bytes: 36668
n,m = gets.split.map(&:to_i)
x = gets.split.map(&:to_i).sort
diff = []

if n>=m
  puts 0
  exit
end

(m-1).times do |i|
  diff.push((x[i+1]-x[i]).abs)
end

diff.sort!

puts diff[0..(m-2-(n-1))].inject(:+)

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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

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

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

  ll w,h,n;
  cin >> w >> h >> n;
  vector<ll> a(n);
  P s(0, 0);
  P g(w, h);
  rep(i, n) {
    ll x, y, a;
    cin >> x >> y >> a;
    if (a == 1 && s.first <= x) s.first = x;
    if (a == 2 && g.first >= x) g.first = x;
    if (a == 3 && s.second <= y) s.second = y;
    if (a == 4 && g.second >= y) g.second = y;
  }
  if (s.first >= g.first) {
    cout << 0 << endl;
    return 0;
  }
  if (s.second >= g.second) {
    cout << 0 << endl;
    return 0;
  }
  cout << max(ll(0), (g.first-s.first)*(g.second-s.second)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define USE_MATH_DEFINES
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

int main() {
    double w, h, x, y;
    int isNotOnly;
    double ans;
    cin >> w >> h >> x >> y;
    ans = w * h / 2;
    if (x == w / 2 && y == h / 2)
        isNotOnly = 1;
    else
        isNotOnly = 0;

    printf("%12lf %d\n", ans, isNotOnly);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>

using namespace std;

int main(void)
{
	int A, B;
	int sum;

	cin >> A >> B;

	sum = 0;
	for (int i = 0; i < 2; i++) {
		if (A >= B) {
			sum += A;
			A--;
		}
		else {
			sum += B;
			B--;
		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
mod = 10**9+7
import sys

N = int(input())

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

able = [0] * N
dif = [False] * N

for i in range(N):

    able[i] = min(T[i],A[i])

for i in range(N):

    if i == 0 or T[i] != T[i-1]:
        dif[i] = True

        if A[i] < T[i]:
            print (0)
            sys.exit()

for i in range(N):
    if i == N-1 or A[i] != A[i+1]:

        if dif[i]:
            if T[i] != A[i]:
                print (0)
                sys.exit()

        else:
            if A[i] > T[i]:
                print (0)
                sys.exit()
        
        dif[i] = True

ans = 1
for i in range(N):

    if dif[i]:
        continue

    ans *= able[i]
    ans %= mod

print (ans)

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

int main(){
  int a, b;
  cin >> a >> b;
  int ans = 0;
  for(int i = a; i <= b; i++){
    int s = i % 10, t = i / 10000 % 10;
    int u = i / 10 % 10, v = i / 1000 % 10;
    if(s == t && u == v){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N;
string S[1000];

string ans3[3] ={ "aa.","..b","..b" };
string ans4[4] ={ "aacd","bbcd","efgg","efhh" };
string ans5[5] ={ "aabbc","dee.c","d..fg","h..fg","hiijj" };
string ans6[6] ={ "aabbcc","def...","def...","...hij","...hij","kkllmm" };
string ans7[7] ={ "aab..c.","..bddc.","e.ff.gg","e...h.i","jj..h.i",".k..lmm",".knnl.." };

signed main(){
    cin >> N;
    if(N == 2){
        cout << -1 << endl;
        return 0;
    }
    if(N == 3){
        rep(i, N) cout << ans3[i] << endl;
        return 0;
    }
    rep(i, N) S[i] = string(N, '.');
    rep(i, N/4-1){
        rep(j, 4){
            rep(k, 4){
                S[4*i+j][4*i+k] = ans4[j][k];
            }
        }
    }
    if(N%4 == 0){
        rep(j, 4){
            rep(k, 4){
                S[4*(N/4-1)+j][4*(N/4-1)+k] = ans4[j][k];
            }
        }
    }
    else if(N%4 == 1){
        rep(j, 5){
            rep(k, 5){
                S[4*(N/4-1)+j][4*(N/4-1)+k] = ans5[j][k];
            }
        }
    }
    else if(N%4 == 2){
        rep(j, 6){
            rep(k, 6){
                S[4*(N/4-1)+j][4*(N/4-1)+k] = ans6[j][k];
            }
        }
    }
    else{
        rep(j, 7){
            rep(k, 7){
                S[4*(N/4-1)+j][4*(N/4-1)+k] = ans7[j][k];
            }
        }
    }
    rep(i, N) cout << S[i] << endl;
}

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

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

  ll ans = 1e14;
  for(long long i = 1; i*i <= n; ++i){
  	if(n%i == 0){
  		ll j = n/i;
  		ans = min(ans, i + j - 2);
  	}
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
import copy
a=list(input())
ano=list(range(1,100,2))
n=len(a)-1
ans=0
for i in range(2**n):
    c=copy.deepcopy(a)
    b=['']*n
    for j in range(n):
        if ((i>>j)&1)==1:
            b[j]='+'
    for k in range(n):
        c.insert(ano[k],b[k])
    ans+=eval(''.join(c))
print(ans)



Measured memory_bytes: 9192
#include<iostream>
using namespace std;
int bubbleSort(int A[],int N){
  int sw=0;
  bool flag=1;
  for(int i=0;flag;i++){
    flag=0;
    for(int j=N-1;j>=i+1;j--){
      if(A[j]<A[j-1]){
	swap(A[j],A[j-1]);
	flag=1;
	sw++;
      }
    }
  }
  return sw;
}

int main(){
  int A[100],N,sw;
  cin>>N;
  for(int i=0;i<N;i++)cin>>A[i];
  sw=bubbleSort(A,N);
  for(int i=0;i<N;i++){
    if(i)cout<<" ";
    cout<<A[i];
  }
  cout<<endl;
  cout<<sw<<endl;

  return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
int main(){
	string s;
	cin>>s;
	int n = s.size();
	vector<vector<long long> > dp(n + 1, vector<long long> (13, 0));
	dp[0][0] = 1;
	for(int i = 0; i < n; ++i){
		if(s[i] == '?'){
			for(int j = 0; j < 10; ++j){
				for(int k = 0; k < 13; ++k){
					dp[i + 1][(10 * k + j) % 13] += dp[i][k];
					dp[i + 1][(10 * k + j) % 13] %= MOD;
				}
			}
		}
		else{
			int r = s[i] - '0';
			for(int k = 0; k < 13; ++k){
				dp[i + 1][(10 * k + r) % 13] += dp[i][k];
				dp[i + 1][(10 * k + r) % 13] %= MOD;
			}
		}
	}
	long long x = dp[n][5];
	cout<<x<<endl;
	return 0;
}

//


Measured memory_bytes: 13696
#include<iostream>
using namespace std;
int main(void){
    int a,b,c,d,e,k;
    cin>>a>>b>>c>>d>>e>>k;
    bool yay(true);
    if(b-a>k)yay = false;
    if(c-a>k)yay = false;
    if(d-a>k)yay = false;
    if(e-a>k)yay = false;
    if(c-b>k)yay = false;
    if(d-b>k)yay = false;
    if(e-b>k)yay = false;
    if(d-c>k)yay = false;
    if(e-c>k)yay = false;
    if(c-d>k)yay = false;
    if(yay)cout<<"Yay!"<<endl;
    else cout<<":("<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    H = list(map(int, input().split()))
    c = 0
    for h in H:
        if h < c:
            return 'No'
        c = max(c, h-1)

    return 'Yes'


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
using ll = long long; using ld = long double; const char nl = '\n';
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */

#include <bits/extc++.h>
namespace pbds =  __gnu_pbds;
template <typename key, typename val=pbds::null_type, typename comp=less<key>>
using ostree=pbds::tree<key,val,comp,pbds::rb_tree_tag,pbds::tree_order_statistics_node_update>;
using vi = vector< int >; using vll = vector< ll >;
#define all(x) std::begin(x), std::end(x)
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename...Args, template<typename...> typename T> string to_string(T<Args...> const&);
string to_string(string const&s){return '"'+s+'"';}
string to_string(char const &c) {return to_string(string(1,c));}
string to_string(char const *c) {return to_string(string(c));}
string to_string(bool const &b) {return (b ? "1" : "0");}
template<typename... Args> string to_string(pair<Args...> const&p)
{return "("+to_string(p.first)+", "+to_string(p.second)+")";}
template <typename...Args, template<typename...> typename T> string to_string(T<Args...> const&S)
{string s = "{"; for(auto const& e: S)s+=" "+to_string(e);s+=" }"; return s;}
template<typename Tail> void debug_out(Tail t) {cerr<<" "<<to_string(t)<<" ]"<<endl;}
template<typename Head, typename... Tail> void debug_out(Head h, Tail... t)
{cerr << " " << to_string(h) << ","; debug_out(t...);}
#define pr(...) cerr<<"["<<(#__VA_ARGS__)<<"] : [", debug_out(__VA_ARGS__)
template <typename T> void dbr(T lb, T ub)
{cerr<<'{';for(auto it=lb; it!=ub; it++)cerr<<' '<<to_string(*it); cerr<<" }"<<endl;}
template<typename T, typename Comp=less<T>> bool smin(T &mem, T const&v, Comp const&cmp=Comp())
{return cmp(v, mem) ? mem = v, true : false;}
template<typename T, typename Comp=less<T>> bool smax(T &mem, T const&v, Comp const&cmp=Comp())
{return cmp(mem, v) ? mem = v, true : false;}
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */

#ifndef LIGMA
#define pr //
#endif

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

  int n; cin >> n;
  using ii = pair<int, int>;
  vector< ii > jobs;
  for(int i=0; i<n; i++) {
    int t, d;
    cin >> t >> d;
    jobs.emplace_back(d, t);
  }
  sort(all(jobs));

  int t = 0;
  for(int i=0; i<n; i++) {
    pr(t, jobs[i]);
    if( t + jobs[i].ss > jobs[i].ff ) return cout << "No" << endl, 0;
    t += jobs[i].ss;
  }
  cout << "Yes" << endl;

}
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */


Measured memory_bytes: 2420
#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 fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
ll ans[41];
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll x;
	cin>>x;
	ans[1]=6;
	for(int i = 2; i <= x; i++)
	{
		ans[i]=2LL*(ans[i-1]+1);
	}
	cout<<ans[x]<<'\n';
}


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

int main() {
  int N, M;
  int ans=0;
  int start, end;
  int tmps, tmpe;

  cin >> N >> M;

  for(int i = 0; i < M; i++){
    cin >> tmps >> tmpe;

    if(i == 0){
      start = tmps;
      end = tmpe;
    }else{
      
      if(tmps > end){
        ans++;
      }else if(tmps > start)
        start = tmps;

      if(tmpe < start){
        ans++;
      }else if(tmpe < end){
        end = tmpe;
      }
      
    }
  }

    if(ans > 0 || start > N){
      cout << 0 << endl;
    }else if(end > N){
      cout << N - start +1 << endl;
    }else{
      cout << end - start +1 << endl;
    }

}


Measured memory_bytes: 256
import sys
from heapq import heappush, heappop
from operator import itemgetter

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    res = 0
    camel_left, camel_right = [], []
    for _ in range(N):
        K, L, R = map(int, rl().split())
        res += min(L, R)
        if R <= L:
            camel_left.append([K, L, R])
        elif K != N:
            camel_right.append([N - K, L, R])
    
    camel_left.sort(key=itemgetter(0))
    camel_right.sort(key=itemgetter(0))
    
    hq = []
    i = 0
    for j in range(1, N + 1):
        while i < len(camel_left) and camel_left[i][0] == j:
            heappush(hq, camel_left[i][1] - camel_left[i][2])
            i += 1
        while j < len(hq):
            heappop(hq)
    res += sum(hq)
    
    hq = []
    i = 0
    for j in range(1, N):
        while i < len(camel_right) and camel_right[i][0] == j:
            heappush(hq, camel_right[i][2] - camel_right[i][1])
            i += 1
        while j < len(hq):
            heappop(hq)
    res += sum(hq)
    
    return res


if __name__ == '__main__':
    T = int(rl())
    ans = []
    for _ in range(T):
        ans.append(solve())
    print(*ans, sep='\n')


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

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

ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

int main() {
  int n;
  ll m;
  cin>>n>>m;
  ll a[n];
  rep(i,n) cin>>a[i];
  
  int b[n];
  rep(i,n){
    int cur=0;
    while(a[i]%2==0){
      a[i]/=2;
      cur++;
    }
    b[i]=cur;
  }
  bool c=true;
  rep(i,n-1){
    if(b[i]!=b[i+1]) c=false;
  }
  
  if(!c){
    cout<<0<<endl;
  }
  else{
    bool d=true;
    ll cur=1;
    for(int i=0;i<n;i++){
      cur=lcm(cur,a[i]);
      if(cur>m){
        d=false;
        break;
      }
    }
    if(d){
      cout<<(ll)(m/pow(2,b[0]-1)+cur)/(2*cur)<<endl;
    }
    else{
      cout<<0<<endl;
    }
  }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)
using II = pair<int,int>;
using VII = vector<II>;
using VVII = vector<VII>;

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

	int x, y;
	//正解が"常に"であるか、"常に"でないか。(正解100%か未満か)
	VVII A(N, VII());
	rp(i, 0, N){
		int a; cin>>a;
		while(a--){ cin>>x>>y; x--; A[i].emplace_back(x,y); }
	}

	// rp(i,0,N){cout<<i<<") ";for(auto e:A[i]){cout<<"("<<e.first<<" "<<e.second<<") ";}puts("");}puts("--");//

	int ans = 0;
	rp(bits, 1, 1<<N){//bits: 仮定のbit列: 0|1=確実でない|確実
		bool ok = true;//true|false=仮定に矛盾なし|あり
		rp(i, 0, N){
			int assume_i = (bits>>i)&1;//i番目の仮定: 0|1
			if(!assume_i) continue;//確実でない
			rp(j, 0, A[i].size()){
				//y: i番目のx番に対する証言: 0|1=正直でない|正直
				tie(x,y) = A[i][j];
				int assume_x = (bits>>x)&1;//x番目の仮定: 0|1
				if(assume_x ^ y) ok = false;
			}
		}
		if(ok) ans = max(ans, (int)bitset<16>(bits).count());//矛盾なし: 仮定から最大数を得る
	}
	ote(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}

#define pb             push_back
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define rep(i, n)  	   for (int i = 0; i < n; ++i)
#define irep(i, a, b)  for (int i = a; i <= b; ++i)
#define repr(i, a, b)  for (int i = a; i >= b; --i)
#define iter(it, x)    for (auto it = x.begin(); it != x.end(); ++it)

using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
const char nl = '\n';
const int inf = 2e9;
const ll INF = (ll)2e18;
const ll mod = 1e9 + 7;
const int N = 2e6 + 15;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	if (n % 1000 == 0) {
		cout << 0 << nl;
	} else {
		cout << 1000 - (n % 1000) << nl;
	}
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dup(x,y) (((x)+(y)-1)/(y))
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * 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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));

struct mint {
	int x;
	mint(int x = 0) :x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= MOD)x -= MOD;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += MOD - a.x) >= MOD)x -= MOD;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint a)const {
		return mint(*this) += a;
	}
	mint operator-(const mint a)const {
		return mint(*this) -= a;
	}
	mint operator*(const mint a)const {
		return mint(*this) *= a;
	}
	mint pow(int t)const {
		if (!t)return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1)a *= *this;
		return a;
	}

	//for prime mod
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a)const {
		mint res(*this);
		return res /= a;
	}
};
ostream& operator<<(ostream& os, const mint& m) {
	os << m.x;
	return os;
}

signed main() {
	int N;
	cin >> N;
	vector<mint>A(N);
	rep(i, N) {
		int a;
		cin >> a;
		A[i] = a;
	}
	mint sum = 0;
	rep(i, N)sum += A[i];
	mint ans = 0;
	rep(i, N) {
		sum -= A[i];
		ans += sum * A[i];
	}
	cout << ans;
}

Measured memory_bytes: 4848
#include<iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    int v[n];
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    
    int c[n];
    for(int i = 0; i < n; i++){
        cin >> c[i];
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        if (v[i] > c[i]) {
            ans += v[i] - c[i];
        }
        
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
int main(){
	
	int n; cin>>n; ll arr[n];
	for(int i = 0; i < n; i++) cin>>arr[i]; ll sum = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(i == j) continue;
			sum += (arr[i]*arr[j]);
		}
	}
	cout<<sum/2<<"\n";
	
	
	
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        return a;
    }
    gcd(b, a % b)
}

#[allow(dead_code)]
fn lcm(a: i64, b: i64) -> i64 {
    a / gcd(a, b) * b
}

#[allow(dead_code)]
// a x + b y = gcd(a, b)
fn extgcd(a: i64, b: i64, x: &mut i64, y: &mut i64) -> i64 {
    let mut g = a;
    *x = 1;
    *y = 0;
    if b != 0 {
        g = extgcd(b, a % b, y, x);
        *y -= (a / b) * *x;
    }
    g
}

#[allow(dead_code)]
fn pow_mod(base: i64, power: i64, modulo: i64) -> i64 {
    let mut base = base;
    let mut power = power;
    let mut ans = 1;
    while power > 0 {
        if power & 1 == 1 {
            ans = ans * base % modulo;
        }
        power >>= 1;
        base = base * base % modulo;
    }
    ans
}

#[allow(dead_code)]
fn inv_mod(a: i64, modulo: i64) -> i64 {
    pow_mod(a, modulo - 2, modulo)
}

const MOD: i64 = 1e+9 as i64 + 7;
const FACT_MAX: usize = 1000010;
static mut FACTORIAL: [i64; FACT_MAX + 1] = [0; FACT_MAX + 1];
static mut RFACTORIAL: [i64; FACT_MAX + 1] = [0; FACT_MAX + 1];
fn init_fact() {
    unsafe {
        if FACTORIAL[0] == 0 {
            FACTORIAL[0] = 1;
            for i in 1..FACT_MAX + 1 {
                FACTORIAL[i] = (FACTORIAL[i - 1] * i as i64) % MOD;
            }
            RFACTORIAL[FACT_MAX] = inv_mod(FACTORIAL[FACT_MAX], MOD);
            for i in (0..FACT_MAX).rev() {
                RFACTORIAL[i] = RFACTORIAL[i + 1] * (i as i64 + 1) % MOD;
            }
        }
    }
}
#[allow(dead_code)]
fn fact(n: usize) -> i64 {
    init_fact();
    unsafe { FACTORIAL[n] }
}
#[allow(dead_code, unused_comparisons)]
fn combi(n: usize, m: usize) -> i64 {
    if n < m || m < 0 {
        return 0;
    }
    init_fact();
    unsafe { FACTORIAL[n] * RFACTORIAL[m] % MOD * RFACTORIAL[n - m] % MOD }
}

fn calc(n: usize, k: usize) -> i64 {
    if k == 0 || 1 + k > n {
        return 0;
    }
    combi(k - 1, n - 1 - k) * fact(k) % MOD * fact(n - 1 - k) % MOD
}
fn main() {
    let n: usize = read();
    let mut ans = 0;
    if n == 2 {
        ans = 1;
    } else if n == 3 {
        ans = 4;
    } else {
        for k in 2..n {
            ans = (ans + k as i64 * (calc(n, k) - calc(n, k - 1) + MOD)) % MOD;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 19964
// I am Nothing, You Are Nothing!
// Krishna is Everything ...
// Jai Shree Krishna

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e2 + 5, M = 1e5 + 5;

int values[N], weights[N], dp[N][M];

int solve(int n, int w) {
	if (n < 1 or w < 1)
		return 0;
	if (dp[n][w] != -1)
		return dp[n][w];

	//include
	int op2 = INT_MIN;
	if (weights[n] <= w) {
		op2 = values[n] + solve(n - 1, w - weights[n]);
	}
	//exclude curr
	int op1 = solve(n - 1, w);
	return dp[n][w] = max(op1, op2);
}

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n, w;
	cin >> n >> w;

	for (int i = 1; i <= n; i++) {
		cin >> weights[i] >> values[i];
	}
	memset(dp, -1, sizeof dp);

	cout << solve(n, w) << endl;

	return 0;
}


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

int calcul(string s, char c)
{
    int nb = 0;
    for (int i=0; i<s.size(); i++)
    {
        if (s[i] != c)
            nb++;
    }
    return nb;
}

int main() 
{
    int n;
    cin >> n;
    vector<int> vw(n,0);
    vector<int> ve(n,0);
    string s="";
    int nbe=0;
    for (int i=0; i<n; i++)
    {
        char c;
        cin >> c;
        if (c=='W')
            vw[i+1] = vw[i] + 1;
        if (c=='E')
        {
            vw[i+1] = vw[i];
            nbe++;
        }
        s+=c;
    }
    for (int i=0; i<n; i++)
    {
        if (s[i]=='E')
            nbe--;
        ve[i] = nbe;
    }
    // cout << "ve" << endl;
    // for (int i=0; i<n; i++)
    //     cout << ve[i] << "";
    // cout << endl << "vw" << endl;
    // for (int i=0; i<n; i++)
    //     cout << vw[i] << "";
    // cout << endl;
    // return 0;
    int m = INT_MAX;
    for(int i=0; i<n; i++)
    {
        int x = vw[i]+ve[i];
        // cout << vw[i] << " " << ve[i] << endl;
        m = min(m,x);
    }
    // if (ve[0] == 0)
    //     m == 0;
    // if (vw[n-1] == 0)
    //     m == 0;
    cout << m;
    return 0;
}

Measured memory_bytes: 3204
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/
struct UnionFind {
  vector<int> d;
  UnionFind() { }
  UnionFind(int n) :d(n, -1) { }
  bool unite(int x, int y) {
    int a = root(x), b = root(y);
    if (a == b) return false;
    if (size(a) < size(b)) swap(a, b);
    d[a] += d[b];
    d[b] = a;
    return true;
  }
  int size(int v) { return -d[root(v)]; }
  int root(int v) { return d[v] < 0 ? v : d[v] = root(d[v]); }
  bool same(int x, int y) { return root(x) == root(y); }
};

void Calc() {

  var(int, n, k, l);
  err(n, k, l);
  UnionFind a(n), b(n);
  rep(i, k) {
    var(int, p, q);
    a.unite(p - 1, q - 1);
    err(p, q);
  }

  rep(i, l) {
    var(int, p, q);
    b.unite(p - 1, q - 1);
  }
  vector<int> root(n);
  rep(i, n)root[i] = b.root(i);
  map<int, vector<int>> m;
  rep(i, n) {
    m[root[i]].push_back(i);
  }
  vector<int> ans(n);
  for (auto& i : m) {
    vector<int> r(i.second.size());
    rep(j, r.size()) {
      r[j] = a.root(i.second[j]);
    }
    map<int, int> c;
    rep(i, r.size()) {
      c[r[i]]++;
    }
    rep(j, r.size()) {
      ans[i.second[j]] = c[r[j]];
    }
  }

  rep(i, n) {
    cout << (ans[i]);
    if (i != n - 1)cout << (" ");
  }
  cout << endl;
}


Measured memory_bytes: 23680
# def test(k):
#     res = [0]*20
#     l = [i for i in range(20)]
#     t = 1
#     while l:
#         i = 0
#         while i < len(l):
#             res[l.pop(i)] = t
#             i += k-1
#         t += 1
#     return res
# for k in range(2,11):
#     print(k,":",test(k))

from math import floor

N, k = map(int, input().split())
l, r = -1, 10**18
while l+1 < r:
    m = (l+r) >> 1
    x = m
    for i in range(1, N):
        x -= x // k + 1
    if 0 <= x:
        r = m
    else:
        l = m
print(r)



Measured memory_bytes: 5660
#include <cstdio>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <set>
#include <map>
using namespace std;

typedef long long ll;

int n;
int tot, s, mini = 101;
int main()
{
    tot = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
    {
        scanf("%d", &s);
        tot += s;
        if (s % 10)
            mini = min(s, mini);
    }
    if (tot % 10)
        printf("%d\n", tot);
    else if (mini < 101)
        printf("%d\n", tot-mini);
    else 
        puts("0");
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def YesNo(x): return 'Yes' if x else 'No'
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N, L = LI()
    li = list(range(L, N + L))
    if 0 in li:
        ans = sum(li)
    elif li[-1] < 0:
        ans = sum(li[:-1])
    else:
        ans = sum(li[1:])
    return ans

print(main())

Measured memory_bytes: 38736
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N; cin >> N;
    vector<int> A(N+1);
    ll c=1000;
    ll k=0;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    A[N]=0;
    for(int i=0;i<N;i++){
        cerr << "i=" << i << "\t" << k << " " << c << endl;
        if(A[i]<A[i+1]){
            // 株にする
            c += A[i]*k;
            k = c/A[i];
            c -= A[i]*k;
        }else{
            // 金にする
            c += A[i]*k;
            k=0;
        }
    }
    cerr << k << " " << c << endl;
    cout << k*A[N-1]+c << endl;
    return 0;
}


Measured memory_bytes: 3200
using System;

class Program
{
    static void Main(string[] args)
    {
        var nm = Console.ReadLine().Split(' ');
        var n = int.Parse(nm[0]);
        var m = int.Parse(nm[1]);
        var x = 1900 * m + 100 * (n - m);
        var y = Math.Pow(2, m);
        Console.WriteLine(x * y);
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  string S;
  cin >> S;
  ll num = 0;
  REP(i, S.size()) { num += S[i] - '0'; }
  printf(num % 9 == 0 ? "Yes\n" : "No\n");
}

Measured memory_bytes: 3848
#include <cstdio>
#include <algorithm>


int n, x, v[30];
bool cost[1000001], prime[1000001];
int main(){
    std::fill(prime, prime + 1000001, true);
    prime[1] = false;
    for(int i = 2; i * i <= 1000001; i++){
        for(int j = 2; i * j <= 1000001; j++){
            if(!prime[i * j]) continue;
            prime[i * j] = false;
        }
    }

    while(scanf("%d %d", &n, &x) != EOF){
        if(n == 0 && x == 0) break;


        std::fill(cost, cost + 1000001, false);
        cost[0] = true;
        for(int i = 0; i < n; i++){
            scanf("%d", &v[i]);

            for(int j = v[i]; j <= x; j += v[i]) cost[j] = true;
        }

        int ans = 0;
        for(int i = 1; i <= x; i++){
            if(!cost[i]){
                for(int j = 0; j < n; j++){
                    if(i - v[j] >= 0 && cost[i - v[j]]){
                        cost[i] = true;
                        break;
                    }
                }
            }
            if(cost[i] && prime[i]){
                ans = i;
            }
        }

        if(ans == 0) printf("NA\n");
        else printf("%d\n", ans);
    }

    return 0;
}

Measured memory_bytes: 4528
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define MAX 100100
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
int n,f[MAX<<1];
int getf(int x){return x==f[x]?x:f[x]=getf(f[x]);}
int sz1[MAX<<1],sz2[MAX<<1];
ll ans;
int main(){
	n=gi();
	for(int i=1;i<MAX+MAX;++i)f[i]=i;
	for(int i=1;i<=n;++i)
	{
		int u=gi(),v=gi();
		f[getf(u)]=getf(v+MAX);
	}
	for(int i=1;i<=MAX;++i)
		sz1[getf(i)]+=1;
	for(int i=MAX+1;i<MAX+MAX;++i)
		sz2[getf(i)]+=1;
	for(int i=1;i<MAX+MAX;++i)ans+=1ll*sz1[i]*sz2[i];
	cout<<ans-n<<endl;
	return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
int main () {
	std::vector<int> m(10);
	for(int i = 0; i < 11; i++){
		cin >> m[i];
	}
	sort(m.begin(),m.end());
	for(int i = 0; i < 3; i++){
		cout << m[9-i] <<endl;
	}
}


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

using namespace std;

int main()
{
  int a, b, c;
  string s, t;
  cin >> s;
  string u = "CODEFESTIVAL2016";
  b = 0;
  for(int i = 0; i < s.size(); i++) {
    if(s[i] != u[i]) b++;
  }
  cout << b << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class BRGBBoxes {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            int r = s.nextInt();
            int g = s.nextInt();
            int b = s.nextInt();
            int n = s.nextInt();
            int count = 0;
            for (int i = 0; i <= n / r; i++) {
                for (int j = 0; j <= n / g; j++) {
                    if ((n - (i * r) - (g * j) >= 0) && (n - (i * r) - (g * j)) % b == 0) {
                        count++;
                    }
                }
            }
            out.println(count);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

int main() {
	string S;
	cin >> S;
	int ans = 0;
	rep(i, S.size() - 1) {
		if (S.at(i) == S.at(i + 1)) {
			S.at(i + 1) = 97 - S.at(i);
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
	int N;
	int a[100000];

	int max;
	int cnt, mcnt;

	int i;

	scanf("%d", &N);
	for (i = 0; i < N; i++){
		scanf("%d", &a[i]);
	}
	
	max = 1;
	for (i = 0; i < N; i++){
		if (a[i] > max) max = a[i];
	}

	cnt = 0;
	mcnt = 0;
	for (i = 0; i < N; i++){
		if (a[i] < max - 1) break;
		if (a[i] == max - 1) cnt++;
		else mcnt++;
	}

	if (i < N) {
		puts("No");
	} else if (max == N - 1 && mcnt == N){
		puts("Yes");
	} else if (cnt <= max - 1 && cnt >= max * 2 - N){
		puts("Yes");
	} else {
		puts("No");
	}

	return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<vector>
#include<algorithm>
#include<iostream>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std;

const int N=1010;
int n;
ll x[N],y[N];
vector<ll>d;

int main(){
	scanf("%d",&n);
	rep(i,1,n){
		cin>>x[i]>>y[i];
		if (((abs(x[i])+abs(y[i]))&1) != ((abs(x[1])+abs(y[1]))&1)){ puts("-1"); return 0; }
	}
	for (int i=30; ~i; i--) d.push_back(1ll<<i);
	if (!((abs(x[1])+abs(y[1]))&1)) d.push_back(1);
	cout<<d.size()<<endl;
	for (int i=0; i<(int)d.size(); i++) cout<<d[i]<<" ";
	puts("");
	rep(i,1,n){
		ll X=x[i],Y=y[i];
		string s="";
		for (int j=0; j<(int)d.size(); j++)
			s+=(abs(X)>abs(Y)) ? (X>0?(X-=d[j],"R"):(X+=d[j],"L")) : (Y>0?(Y-=d[j],"U"):(Y+=d[j],"D"));
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int,int>;
 
const double PI = acos(-1);
 
int main() {
    int a,b,h,m;
    cin >> a >> b >> h >> m;
    double th = double(h*60+m)/720 * 2*PI;
    double tm = double(m)/60 * 2*PI;
    double xh = a*cos(th), yh = a*sin(th);
    double xm = b*cos(tm), ym = b*sin(tm);
    double dx = xh - xm, dy = yh - ym;
    double ans = sqrt(dx*dx + dy*dy);
    printf("%.10lf\n", ans);
    return 0;
}

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

int main(void){
    int A,B;
    cin>>A>>B;
    if(A==B)
        cout<<A*2<<endl;
    else{
        if(A>B)
            cout<<A+(A-1)<<endl;
        else
            cout<<B+(B-1)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;

const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 1023456789;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x) {
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

// OrderedSet
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template < typename T > using ordered_set = tree < T, null_type, greater < T >, rb_tree_tag, tree_order_statistics_node_update >;

int inp[5];

int main(){
  for(int i = 0; i < 4; i++){
    fastScan(inp[i]);
  }
  sort(inp, inp + 4);
  if(inp[0] == 1 && inp[1] == 4 && inp[2] == 7 && inp[3] == 9){
    puts("YES");
  } else {
    puts("NO");
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(abs(a-b)<=d&&abs(b-c)<=d||abs(a-c)<=d)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
#define ll long long
#define re register
#define rint register int
#define isdight(c) (c<='9'&&c>='0')
using namespace std;
inline int read()
{
	int x=0;register char c=getchar();int f=1;
	for(;!isdight(c);c=getchar()) if(c=='-') f=-1;
	for(;isdight(c);c=getchar()) x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
template <typename ty> inline void write(ty x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10+48);
}
const int N = 1000;
ll k,x;

int main()
{
	cin >> k >> x;
	for(int i=max(x-k+1,(ll)-1000000);i<=min(x+k-1,(ll)1000000);i++) printf("%d ",i);
}

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

int n;
long x;

long isprime(x){
  //printf("x;%d\n",x);
  if(x==2){
    return 1;
  }else if(x<2 || x%2==0){
    return 0;
  }

  int i=3;
  while(i<=sqrt(x)){

    if(x%i==0){
      return 0;
    }
    i=i+2;
  }
  return 1;
}


int main(){
  int sum=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%ld",&x);
    if(isprime(x)==1){
      //printf("added!\n");
      sum=sum+1;
    }
  }
  printf("%d\n",sum);


  return 0;
}



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

int main()
{
  int64_t N, C, K;
  cin >> N >> C >> K;
  vector<int64_t> T(N);
  for (int i = 0; i < N; i++)
    cin >> T.at(i);

  sort(T.begin(), T.end());

  int64_t bus = 1;
  int64_t passenger = 0;
  int64_t limit = T.at(0) + K;

  for (int i = 0; i < N; i++){
    if (passenger == C || limit < T.at(i)){
      passenger = 1;
      bus++;
      limit = T.at(i)+ K;
    }
    else if (limit >= T.at(i)) passenger++;
  }
 cout << bus << endl;
}


Measured memory_bytes: 1024