akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int N=2010;
const int M=998244353;
int dp[N][N],g[N][N];
int k,n;
int main(){
	cin>>k>>n;
	dp[0][0]=1;
	for (int i=1; i<=n; ++i){
		int sum=0;
		for (int j=1; j<=k; ++j){
			dp[i][j]=dp[i-1][j];
			(sum+=dp[i-1][j-1])%=M;
			dp[i][j]=(sum*2%M+dp[i][j])%M;
		}
	}	
	for (int i=0; i<=n; ++i)
	for (int j=1; j<=k; ++j){
		(dp[i][j]+=dp[i][j-1])%=M;
	}
	for (int i=0; i<=k; ++i) g[0][i]=1;
	for (int i=1; i<=n; ++i){
		int sum=0;
		for (int j=1; j<=k; ++j){
			(sum+=g[i-1][j])%=M;
			g[i][j]=sum;
//			cout<<i<<" "<<j<<" "<<g[i][j]<<endl;
		}
	}
	vector<int> z;
	for (int i=2; i<=k+1; ++i){
		int ans=0;
		if (~i&1){
			for (int j=0; j<n; ++j){
//				cout<<dp[j][(i-1)/2]<<" "<<g[n-1-j][k-i+1]<<endl;
				(ans+=(long long)dp[j][(i-1)/2]*g[n-1-j][k-i+1]%M)%=M;
			}
			for (int j=0; j<=n; ++j){
				(ans+=(long long)dp[j][(i-1)/2]*g[n-j][k-i+1]%M)%=M;
			}
		}
		else
		{
			for (int j=0; j<=n; ++j){
//				cout<<dp[j][i/2]<<" "<<g[n-j][k-i+1]<<endl; 
				(ans+=(long long)dp[j][i/2]*g[n-j][k-i+1]%M)%=M;
			}
		}
		cout<<ans<<endl;
		if (i<=k) z.push_back(ans);
	}
	reverse(z.begin(),z.end());
	for (auto i:z) cout<<i<<endl;
}

Measured memory_bytes: 31744
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);
const double EPS = 1.0;

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,i;
	ll x,y,xmax[3],xmin[3],ymax[3],ymin[3],t,r,l,u,d,ans=INFLL;
	char c;
	for(i=0; i<3; ++i){
		xmax[i] = -INFLL;
		ymax[i] = -INFLL;
		xmin[i] = INFLL;
		ymin[i] = INFLL;
	}
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> x >> y >> c;
		switch(c){
			case 'R':
			ymax[1] = max(ymax[1],y);
			ymin[1] = min(ymin[1],y);
			xmax[2] = max(xmax[2],x);
			xmin[2] = min(xmin[2],x);
			break;
			case 'L':
			xmax[0] = max(xmax[0],x);
			xmin[0] = min(xmin[0],x);
			ymax[1] = max(ymax[1],y);
			ymin[1] = min(ymin[1],y);
			break;
			case 'U':
			xmax[1] = max(xmax[1],x);
			xmin[1] = min(xmin[1],x);
			ymax[2] = max(ymax[2],y);
			ymin[2] = min(ymin[2],y);
			break;
			case 'D':
			ymax[0] = max(ymax[0],y);
			ymin[0] = min(ymin[0],y);
			xmax[1] = max(xmax[1],x);
			xmin[1] = min(xmin[1],x);
			break;
		}
	}
	for(i=0; i<3; ++i){
		xmax[i] *= 2;
		ymax[i] *= 2;
		xmin[i] *= 2;
		ymin[i] *= 2;
	}
	for(t=0ll; t<=200000000ll; ++t){
		r = -INFLL; l = INFLL;
		u = -INFLL; d = INFLL;
		for(i=0; i<3; ++i){
			r = max(r,xmax[i]+t*(i-1));
			l = min(l,xmin[i]+t*(i-1));
			u = max(u,ymax[i]+t*(i-1));
			d = min(d,ymin[i]+t*(i-1));
		}
		ans = min(ans,(r-l)*(u-d));
	}
	cout << ans/4;
	switch(ans%4){
		case 0:
		cout << endl;
		break;
		case 1:
		cout << ".25" << endl;
		break;
		case 2:
		cout << ".5" << endl;
		break;
		case 3:
		cout << ".75" << endl;
		break;
	}
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
MAX = 10 ** 6 + 5
cnt = [0] * MAX
ok = [True] * MAX

for x in a:
    cnt[x] += 1

ans = 0

for i in range(1,MAX):
    if cnt[i] > 0:
        for j in range(i*2, MAX, i):
            ok[j] = False
        if ok[i] and cnt[i] == 1:
            ans += 1
print(ans)

Measured memory_bytes: 35044
#include <iostream>
#include <string>
#include <set>

using namespace std;

int main() {
	int n; cin >> n;
	set<string> st;
	while (n--) {
		string s; cin >> s;
		st.insert(s);
	}
	cout << st.size() << endl;

	return 0;
}

Measured memory_bytes: 19200
def bubbleSort(A,N):
    flag = 1
    count = 0
    while flag:
        flag = 0
        for j in reversed(range(1, N)):
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                count += 1

                flag = 1
    print(*A)
    print(count)

N = int(input())
nums = list(map(int, input().split()))
bubbleSort(nums, N)


Measured memory_bytes: 5608
// https://atcoder.jp/contests/abc052/tasks/abc052_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a * b, c * d) << endl;

    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
my_dict = {}

for i in range(M):
    p, s = input().split()

    if p in my_dict:
        my_dict[p].append(s)
    else:
        my_dict[p] = [s]

a_count = 0
w_count = 0

for key, items in my_dict.items():
    flag = False
    buf = 0
    for s in items:
        if s == "AC":
            a_count += 1
            flag = True
            break
        else:
            w_count += 1
            buf += 1
    if not flag:
        w_count -= buf

print(a_count, w_count)



Measured memory_bytes: 68696
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<assert.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define fd(i,b,a) for(int i=(b);i>=(a);--i)
#define bfo(i,v,u) for(int i=BB[v],u=B[i][1];i;u=B[i=B[i][0]][1])
#define mset(a,x) memset(a,x,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(b))
template<typename T> bool chkmin(T &a,const T &b) {return b<a?a=b,1:0;}
template<typename T> bool chkmax(T &a,const T &b) {return b>a?a=b,1:0;}
using namespace std;
typedef long long ll;
int read(){int n=0,p=1;char ch;for(ch=getchar();ch<'0' || ch>'9';ch=getchar())if(ch=='-') p=-1;for(;'0'<=ch && ch<='9';ch=getchar()) n=n*10+ch-'0';return n*p;}
const int N=1e5+5,mo=1e9+7;
char s[N];
int n,lst[30],cnt[30];
int main()
{
	scanf("%d\n%s\n",&n,s+1);
	ll ans=0;
	fo(i,1,n)
	{
		ll t=1;
		fo(j,1,26) if(j!=s[i]-'a'+1) t=t*(cnt[j]+1)%mo;
		++cnt[s[i]-'a'+1];
		ans=(ans+t)%mo;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
  ll ans=1;
  for(int i=1;i<=n;i++)
       ans*=a;
    return ans;
}

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

 ll l,r,d,ans=0;
 cin>>l>>r>>d;
 ll base=d;
 while(d<=110)
 {
     if(d>=l&&d<=r)
        ans++;
     d+=base;
 }
 cout<<ans<<endl;

return 0;
}



Measured memory_bytes: 3652
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
const static int tx[] = {0,1,1,1,0,-1,-1,-1};
const static int ty[] = {-1,-1,0,1,1,1,0,-1};
 
static const double EPS = 1e-8;

class RelationShip{
public:
  int _to;
  int _friendliness;
  RelationShip(int to,int friendliness) :
    _to(to), _friendliness(friendliness) {}
  bool operator<(const RelationShip &r) const {
    return _friendliness < r._friendliness;
  }
  bool operator>(const RelationShip &r) const {
    return _friendliness > r._friendliness;
  }
};


bool used[101];
vector<RelationShip> edges[101];
int idx[101][101];
int total_rabbits;
int total_pairs;

int dfs(int last){
  int res = 0;

  int sum = 0;
  for(int orig=0; orig <= last; orig++){
    if(!used[orig]) continue;

    int tmp = INF;
    for(int next_i = 0; next_i < edges[orig].size(); next_i++){
      int next = edges[orig][next_i]._to;
      if(!used[next]) continue;
      tmp = min(tmp,edges[orig][next_i]._friendliness);
    }
    if(tmp != INF) sum += tmp;
  }
  
  res = max(sum,res);

  for(int next=last + 1; next < total_rabbits; next++){
    bool isok = true;
    for(int prev = 0; prev <= last; prev++){
      if(used[prev] && idx[prev][next] == -1) {
        isok = false;
        break;
      }
    }

    if(!isok) continue;
    used[next] = true;
    res = max(res,dfs(next));
    used[next] = false;
  }
  return res;
}

int main(){
  while(~scanf("%d %d",&total_rabbits,&total_pairs)){
    for(int i=0;i<total_rabbits;i++){
      edges[i].clear();
    }
    memset(used,false,sizeof(used));   
    memset(idx,-1,sizeof(idx));

    for(int pair_i = 0; pair_i < total_pairs; pair_i++){
      int from,to,friendliness;
      scanf("%d %d %d",&from,&to,&friendliness);
      from--; to--;
      edges[from].push_back(RelationShip(to,friendliness));
      edges[to].push_back(RelationShip(from,friendliness));
      idx[from][to] = edges[from].size() - 1;
      idx[to][from] = edges[to].size() - 1;
    }

    cout << dfs(-1) << endl;
  }
}

Measured memory_bytes: 1264
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

/* 二項係数 C(n,k) mod p を計算 */
const int MOD = 1000000007;
const int MAX = 201000;
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;
}

int main(){
  COMinit();
  ll n; cin >> n;
  vector<ll> a(n+1), cnt(n,0);
  //2つある数字をs, a[i]=sとなるiをleft,right
  ll s, left, right;
  REP(i,n+1){
    cin >> a[i];
    a[i]--;
    cnt[a[i]]++;
    if(cnt[a[i]]==2){
      s = a[i];
      right = i;
    }
  }
  REP(i,n){
    if(a[i]==s){
      left = i;
      break;
    }
  }
  FOR(k,1,n+2){
    cout << (ll) (MOD+COM(n+1,k) - COM(left+n-right,k-1))%MOD << endl;
  }
}

Measured memory_bytes: 7424
#include <iostream>
#include<vector>
#include<string>
#include<bits/stdc++.h>
#include<stdio.h>
#include<algorithm>
#define ll long long
#define ff first
#define ss second
#define mk make_pair
#define pb push_back
using namespace std;






int main(){


int n;cin>>n;
cout<<(n-2)*180<<endl;




}


Measured memory_bytes: 256
#include <assert.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main(int argc, char **argv) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    int x = a * 100 + b * 10 + c;
    if (x % 4 == 0) printf("YES\n");
    else printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
///
// File:  b.go
// Author: ymiyamoto
//
// Created on Thu Apr 26 21:27:38 2018
//
package main

import (
	"fmt"
)

var N int
var as, bs []int

func main() {
	fmt.Scan(&N)
	as = make([]int, N)

	ops := 0
	for i := range as {
		fmt.Scan(&as[i])
		ops -= as[i]
	}

	bs = make([]int, N)
	for i := range bs {
		fmt.Scan(&bs[i])
		ops += bs[i]
	}

	count := 0
	for i := range as {
		if bs[i] > as[i] {
			count += ((bs[i] - as[i]) + 1) / 2
		}
	}

	if count <= ops {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    for (int i = 1; i <= 3; i++)
    {
        if ((a * b * i) % 2 == 1)
        {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;

int ans, n, k, fa[MAXN]; vector <int> to[MAXN];

int dfs(int x){
	int r = 0;
	for(auto v: to[x])
		r = max(r, dfs(v));
	if((++ r) == k && fa[x] != 1) ++ ans, r = 0;
	return r;
}
int main(){
	int i;
	scanf("%d%d", &n, &k);
	for(i = 1; i <= n; ++ i){
		scanf("%d", &fa[i]);
		if(i > 1) to[fa[i]].push_back(i);
	} if(fa[1] != 1) ++ ans, fa[1] = 1;
	dfs(1), printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 10752
#include<bits/stdc++.h>
using namespace std;
#define int(x) int x;cin>>x;
int a[1000000];
int main(){
memset(a,0,sizeof(a));
int(n);
int (m);
for(int i=0;i<m;i++){
int(x);int(y);
a[x]++;a[y]++;
}
for(int i=0;i<n;i++){
if(a[i]%2!=0){
cout<<"NO"<<endl;
return 0;
}
}
cout<<"YES"<<endl;
}



Measured memory_bytes: 4096
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> P;
const int MAX_N=100010;


int main(){
  string s;
  cin>>s;
  int res=s.size();
  int n=s.size();
  for(int i=0;i<s.size()-1;i++){
    if(s[i]!=s[i+1]) {
      int m=max(i+1,(n-i-1));
      res=min( m,res);
    }
  }
  cout<<res<<endl;
  return 0;
}


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

int main() {
    int n, temp, a = 0, b = 0, c = 0;
    cin >> n;
    rep(i, n) {
        cin >> temp;
        if(temp % 2) a++;
        else if(temp % 4) b++;
        else c++;
    }
    if(b) a++;
    if(a <= c + 1) cout << "Yes" << endl; 
    else cout << "No" << endl;
}

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

long long n;
vector<long long> v, ans, sum, memo;
map<long long, long long> mp;

void solve();

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    long long x;
    cin >> x;
    ++mp[x];
  }
  solve();
  for(int i = 0; i < n; ++i) cout << ans[i] << endl;
  return 0;
}

void solve() {
  ans.assign(n, 0);
  for(auto now : mp) v.push_back(now.second);
  sort(v.begin(), v.end());
  sum = v;
  long long vsize = v.size();
  for(int i = 1; i < vsize; ++i) sum[i] += sum[i - 1];
  memo.assign(n, 0);
  for(int i = 0; i < n; ++i) {
    auto it = lower_bound(v.begin(), v.end(), i + 1);
    long long id = it - v.begin();
    if(--id >= 0) memo[i] += sum[id];
    memo[i] += (vsize - id - 1) * (i + 1);
    memo[i] /= i + 1;
  }
  for(int i = 0; i < n; ++i) {
    auto it = lower_bound(memo.begin(), memo.end(), i,
                          greater<long long>());
    ans[i] = it - memo.begin();
  }
}

Measured memory_bytes: 28396
p=int(input())
A=list(map(int,input().split()))

B=[0]*p

INV=[None]*p# 1/aのリストを予め作っておく.
for i in range(1,p):
    INV[i]=pow(i,p-2,p)

Combi=[None]*p# Combi[i]=nCi を表す
Combi[0]=1
for i in range(1,p):
    Combi[i]=Combi[i-1]*(p-i)*INV[i] %p


for i in range(p):
    if A[i]==0:
        continue

    B[0]+=1
    POW=1
    for j in range(p):
        B[p-1-j]=(B[p-1-j]-Combi[j]*POW)%p
        POW=POW*(-i)%p

print(*[b%p for b in B])

Measured memory_bytes: 43996
#include <bits/stdc++.h>
 using namespace std;
 typedef long long int ll;
 
 // 1-indexedなので注意。
 struct BIT {
  private:
   vector<int> bit;
   int N;
 
  public:
   BIT(int size) {
     N = size;
     bit.resize(N + 1);
   }
 
   // 一点更新です
   void add(int a, int w) {
     for (int x = a; x <= N; x += x & -x) bit[x] += w;
   }
 
   // 1~Nまでの和を求める。
   int sum(int a) {
     int ret = 0;
     for (int x = a; x > 0; x -= x & -x) ret += bit[x];
     return ret;
   }
 };
 
 // ====================================================================
 
 int main() {
   int n;
   cin >> n;
   vector<int> v(n);
   for (int i = 0; i < n; i++) { cin >> v[i]; }
 
   ll ans = 0;
   BIT b(n);  // これまでの数字がどんな風になってるのかをメモる為のBIT
   for (int i = 0; i < n; i++) {
     if(b.sum(v[i])==0) ans++; // BITの総和 - 自分より左側 ＝ 自分より右側
     b.add(v[i], 1); // 自分の位置に1を足す(ダジャレではないです)
   }
 
   cout << ans << endl;
 }

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;



int main(){
    int R,G,B,N;
    cin >> R >> G >> B >> N;
    int ans = 0;
    for(int r=0;r<=3000;r++){
        for(int g=0;g<=3000;g++){
            int now = N - r*R - g*G;
            if(now%B==0&&now>=0)ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
	int n, min, max,a;
	long int sum;
	cin >> n;
	cin >> min;
	max = min;
	sum = min;
	
	for(int i=1;i<n;i++){
		cin >> a;
		if (min > a) {
			min = a;
		}if (max < a) {
			max = a;
		}sum =sum + a;

		}
	
	cout <<min<<" " <<max<< " " <<sum<< endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 3100
#!/usr/bin/env ruby
# require 'pry'

# N
# a_1 b_1
# ...
# a_N b_N
# ↑を[[a_1,..a_N],[b_1,..b_N]]にする
# N = gets.to_i
# a, b = N.times.map{gets.split.map(&:to_i)}.transpose

n = gets.to_i
c= (1..9).map do |a|
  (1..9).map do |b|
    a*b
  end
end.flatten!
puts c.include?(n) ? 'Yes' : 'No'


Measured memory_bytes: 14368
import java.util.Arrays;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static final int BIG_NUM = 2000000000;
	public static final int MOD = 1000000007;
	public static final long HUGE_NUM = 99999999999999999L;
	public static final double EPS = 0.000000001;



	@SuppressWarnings("unchecked")
	public static void main(String[] args) {

		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Scanner scanner = new Scanner(System.in);

		StringBuilder ANS = new StringBuilder();

		while(true){

			int N = scanner.nextInt();
			int M = scanner.nextInt();

			if(N == 0 && M == 0)break;

			int table_1[] = new int[N]; //加算なしテーブル
			int size_2 = N+(N*(N-1))/2;
			int table_2[] = new int[size_2]; //2回の和のテーブル

			int ans = 0;

			for(int i = 0; i < N; i++){

				table_1[i] = scanner.nextInt();
				if(table_1[i] <= M){

					ans = Math.max(ans, table_1[i]);
				}
			}

			int index = 0;
			//2回の和のテーブルを作る
			for(int i = 0; i < N; i++){
				table_2[index] = 2*table_1[i];
				if(table_2[index] <= M){

					ans = Math.max(ans, table_2[index]);
				}
				index++;

				for(int k = i+1; k < N; k++){
					table_2[index] = table_1[i]+table_1[k];
					if(table_2[index] <= M){

						ans = Math.max(ans, table_2[index]);
					}
					index++;
				}
			}

			Arrays.sort(table_2);

			//3つの和
			int left,right,mid;
			for(int i = 0; i < N; i++){
				left = 0;
				right = size_2-1;
				mid = (left+right)/2;

				while(left <= right){
					if(table_1[i]+table_2[mid] <= M){

						ans = Math.max(ans, table_1[i]+table_2[mid]);
						left = mid+1;

					}else{

						right = mid-1;
					}
					mid = (left+right)/2;
				}
			}

			//4つの和
			for(int i = 0; i < size_2; i++){
				left = 0;
				right = size_2-1;
				mid = (left+right)/2;

				while(left <= right){
					if(table_2[i]+table_2[mid] <= M){

						ans = Math.max(ans, table_2[i]+table_2[mid]);
						left = mid+1;

					}else{

						right = mid-1;
					}
					mid = (left+right)/2;
				}
			}

			ANS.append(Integer.toString(ans)).append("\n");
		}
		System.out.print(ANS.toString());
	}
}

class UTIL{

	//最大公約数
	public static long gcd(long x,long y){

		x = Math.abs(x);
		y = Math.abs(y);

		if(x < y){

			long tmp = y;
			y = x;
			x = tmp;
		}

		if(y == 0){

			return x;
		}else{

			return gcd(y,x%y);
		}
	}

	//最小公倍数
	public static long lcm(long x,long y){

		return (x*y)/gcd(x,y);
	}

	//String→intへ変換
    public static int getNUM(String tmp_str){

        return Integer.parseInt(tmp_str);
    }

    //文字が半角数字か判定する関数
    public static boolean isNumber(String tmp_str){

        if(tmp_str == null || tmp_str.length() == 0){

            return false;
        }

        Pattern pattern = Pattern.compile("\\A[0-9]+\\z");
        Matcher matcher = pattern.matcher(tmp_str);
        return matcher.matches();
    }
}


Measured memory_bytes: 48964
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vs = vector<string>;
using vvs = vector<vs>;
using pli = pair<long long, int>;
using vpli = vector<pli>;

int main() {
  ll M, D, MM, DD;
  cin >> M >> D >> MM >> DD;

  if (M == MM) cout << 0 << endl;
  else cout << 1 << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <float.h>
using namespace std;

int main(void) {
	int n, t, a;
	double h[1001], best;
	int ren;
	cin >> n >> t >> a;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	best = DBL_MAX;
	double tmp;
	for (int i = 0; i < n; i++) {
		h[i] = t - h[i] * 0.006;
		tmp = h[i] - a;
		if (tmp < 0)tmp = tmp * (-1);
		if (tmp < best) {
			best = tmp;
			ren = i + 1;
		}
	}
	cout << ren << endl;
}

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

signed main() {
    int n;
    int r[100];
    cin >> n;
    r[0] = 2;
    r[1] = 1;
    for (int i = 2; i <= 86; i++) {
        r[i] = r[i - 1] + r[i - 2];
    }
    cout << r[n] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <map>
#include <vector>
#include <string>
#include <vector>
#include <cassert>
#include <cmath>
#include <stack>
#include <cctype>
#include <queue>
#include <algorithm>
#include <memory>
#include <memory.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int INF = 1 << 30;
const double EPS = 1e-10;
const double PI = 3.14159;

int nums[1000001];

int main(){
	int n, m;
	string s;
	while(cin >> n && n){
		cin >> m;
		cin >> s;
		fill(nums , nums + 1000001, 0);
		int l = 0, r = 0;
		while(true){
			int c = 0;
			while(l < m && s[l] != 'I') l++;
			if(l == m) break;
			r = l;
			while(r + 2 < m && s[r+1] == 'O' && s[r+2] == 'I'){
				r += 2;
				c++;
			}
			nums[c]++;
			l = r + 1;
		}
		ll res = 0;
		for(int i = n; i <= 1000000; i++) res += nums[i] * (i-n+1);
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 5936
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	int n;
	cin >> n;
	int A[111];
	for (int i = 0; i < n; i++)cin >> A[i];
	sort(A, A+n);
	cout << A[n - 1] - A[0] << endl;
}

Measured memory_bytes: 256
N=int(input())
A=[int(input()) for i in range(N)]
ans=0
for i in range(N):
    ans+=A[i]//2
    A[i]-=(A[i]//2*2)
    if i>0:
        d=min(A[i],A[i-1])
        ans+=d
        A[i]-=d
        A[i-1]-=d
    if i<N-1:
        d=min(A[i],A[i+1])
        ans+=d
        A[i]-=d
        A[i+1]-=d
print(ans)

Measured memory_bytes: 7072
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   int k;
   string s;
   cin >> k >> s;
   if(s.length()<=k) cout << s << endl;
   else {
       for(int i = 0;i < k;i++) {
           cout << s[i];
       }
       cout << "..." << endl;
   }
}

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

void _150() {
    string s;
    cin >> s;

    if ((s == "AAA") || (s == "BBB"))
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
}

void _156() {
    int n, r;
    cin >> n >> r;

    if (n >= 10)
        cout << r << endl;
    else
        cout << r + 100 * (10 - n) << endl;
}

void _155() {
    int a, b, c;
    cin >> a >> b >> c;

    if ((a != b) && (a != c) && (b != c))
        cout << "No" << endl;
    else if ((a == b) && (b == c))
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
}

void _154() {
    string s, t, u;
    int a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;

    if (s ==u)
        cout << a - 1 << " " << b << endl;
    else
        cout << a << " " << b - 1 << endl;
}

void _153() {
    int h, a;
    cin >> h >> a;

    // int times = h / a;
    // if (times % a == 0)
    //     cout << times << endl;
    // else
    //     cout << times + 1 << endl;
    cout << (h + a - 1) / a << endl;
}

int main()
{
    // _150();
    _153();
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int oo = 1e9;
const int MOD = 1000000007;
const int BASE = 26;
const int N = 200001;
#define pb push_back
#define mp make_pair
#define x first
#define y second

int n ,  a, b, d;

bool vis[N];

pii p[N];
int res = 0;

map<int, set<pii> > fx, fy;
map<int, vector<int> > cx, cy;
map<pii, int> all;


int dist(int i , int j) {
	return max(abs(p[i].x - p[j].x), abs(p[i].y - p[j].y));
}

void fd(vector<int> &ls , set<pii> &f , int u, int x) {
	set<pii>::iterator it = f.lower_bound(mp(x, -oo));
	while (it != f.end()) {
		pii g = *it;
		if (dist(g.y, u) != d)break;
		ls.pb(g.y);
		it++;
	}
}

int ct(vector<int> &f , int from, int to) {
	int idx = upper_bound(f.begin(), f.end(), to) - lower_bound(f.begin(), f.end(), from);
	return idx;
}
void er(int i) {
	fx[p[i].x].erase(mp(p[i].y, i));
	fy[p[i].y].erase(mp(p[i].x, i));
}
void dfs(int u) {
	if (vis[u])return;
	vis[u] = 1;
	vector<int> ls;
	fd(ls, fy[p[u].y - d], u, p[u].x - d);
	fd(ls, fy[p[u].y + d], u, p[u].x - d);
	fd(ls, fx[p[u].x - d], u, p[u].y - d);
	fd(ls, fx[p[u].x + d], u, p[u].y - d);
	sort(ls.begin(), ls.end());
	ls.resize(unique(ls.begin(), ls.end()) - ls.begin());
	for (int i = 0; i < ls.size(); ++i) {
		er(ls[i]);
	}
	for (int i = 0; i < ls.size(); ++i) {
		dfs(ls[i]);
	}
}
int main() {
	scanf("%d", &n);
	scanf("%d%d", &a, &b);
	for (int i = 1; i <= n; ++i) {
		scanf("%d%d", &p[i].x, &p[i].y);
		p[i] = mp(p[i].x + p[i].y, p[i].x - p[i].y);
		fx[p[i].x].insert(mp(p[i].y, i));
		fy[p[i].y].insert(mp(p[i].x, i));
		cx[p[i].x].pb(p[i].y);
		cy[p[i].y].pb(p[i].x);
		all[p[i]]++;
		//cout << p[i].x << " " << p[i].y << endl;
	}
	d = dist(a, b);
	//cout << d << endl;
	for (map<int, vector<int> >::iterator it = cx.begin(); it != cx.end(); ++it)
		sort((it->second).begin(), (it->second).end());
	for (map<int, vector<int> >::iterator it = cy.begin(); it != cy.end(); ++it)
		sort((it->second).begin(), (it->second).end());
	dfs(a);
	ll res = 0;
	for (int i = 1; i <= n ; ++i) {
		if (!vis[i])continue;
		res += ct(cy[p[i].y - d], p[i].x - d, p[i].x + d);
		res += ct(cy[p[i].y + d], p[i].x - d, p[i].x + d);
		res += ct(cx[p[i].x - d], p[i].y - d, p[i].y + d);
		res += ct(cx[p[i].x + d], p[i].y - d, p[i].y + d);

		for(int p1 = -1;p1 <= 1; p1 += 2){
			for(int p2 = -1 ; p2 <= 1 ; p2 += 2){
				res -= all[mp(p[i].x+p1*d,p[i].y+p2*d)];
			}
		}
	}
	res /= 2;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 116736
S = list(input())
K = int(input())
cnt = 1
ans = 0
counter = []

if len(set(S)) == 1:
  print(len(S)*K//2)
  exit()
  
else:
  for i in range(len(S)-1):
    if S[i] == S[i+1]:
      cnt += 1
    else:
      counter.append(cnt)
      cnt = 1
  counter.append(cnt)
    
  for l in counter:
    ans += (l//2)*K

  if S[0] == S[-1]:
    a = counter[0]
    b = counter[-1]
    ans -= (a//2 + b//2 - (a+b)//2)*(K-1)
  
  print(ans)

Measured memory_bytes: 3064
unittest
{
	assert( [ "1817181712114" ].parse.expand.solve == 3 );
	assert( [ "14282668646" ].parse.expand.solve == 2 );
	assert( [ "2119" ].parse.expand.solve == 0 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.map!( ( a ) => ( a - '0' ).to!( long ) ).array;
	return tuple( s );
}

auto solve( long[] s )
{
	const M = 2019L;
	
	long[ long ] cs;
	cs[ 0 ]++;
	{
		auto r = ModWorld!M( 0 );
		foreach_reverse( i, d; s )
		{
			r += remainder!M( d, s.length.signed - i );
			cs[ r.n ]++;
		}
	}
	
	auto ans = 0L;
	foreach( r, c; cs )
	{
		ans += c * ( c - 1 ) / 2;
	}
	return ans;
}

// モジュラ整数型（n mod M）
struct ModWorld( long M )
{
	long n;
	
	// 演算子オーバーロード
	void opUnary( string OP )() if( OP == "++" ){ this.n = ( this.n + 1 ) % M; }
	void opUnary( string OP )() if( OP == "--" ){ this.n = ( this.n + M - 1 ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "+"  ){ this.n = ( this.n + r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "-"  ){ this.n = ( this.n + M - r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "*"  ){ this.n = ( this.n * r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "/"  ){ this *= r ^^ ModWorld( M - 2 ); }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "^^" )
	{
		auto a = this.n;
		this.n = 1L;
		for( auto i = r.n; 0 < i; i >>= 1 )
		{
			if( i & 1 ) this.n = this.n * a % M;
			a = a ^^ 2 % M;
		}
	}
	auto opBinary( string OP )( ModWorld r )
	{
		auto t = this;
		t.opOpAssign!OP( r );
		return t;
	}
	
	// long型対応
	void opAssign( long r ){ this.n = r; }
	void opOpAssign( string OP )( long r ){ this.opOpAssign!OP( ModWorld( r ) ); }
	auto opBinary( string OP )( long r ){ return this.opBinary!OP( ModWorld( r ) ); }
	auto opBinaryRight( string OP )( long l ){ return ModWorld( l ).opBinary!OP( this ); }
	auto opEquals( long r ){ return this.n == r; }
	
	// format用出力
	string toString()
	{
		return this.n.to!string;
	}
}

// ( n * 10 ^^ x ) % M を計算
auto remainder( long M )( long n, long x )
{
	static memo = [ ModWorld!M( 1L ) ];
	if( memo.length <= x )
	{
		auto i = memo.length.signed;
		memo.length = x + 1;
		for( ; i <= x; i++ ) memo[ i ] = memo[ i - 1 ] * 10;
	}
	return memo[ x ] * n;
}


Measured memory_bytes: 7192
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
const lint MOD = pow(10, 9) + 7;

int main() {
	int q;
	cin >> q;
	int ib, d, x, p;
	deque<int>A;
	rep(i, q) {
		cin >> ib;
		if (ib == 0) {
			cin >> d >> x;
			if (d == 0) {
				A.push_front(x);
			}
			else if (d == 1) {
				A.push_back(x);
			}
		}
		else if (ib == 1) {
			cin >> p;
			cout << A[p] << endl;
		}
		else if (ib == 2) {
			cin >> d;
			if (d == 0) {
				A.pop_front();
			}
			else if (d == 1) {
				A.pop_back();
			}
		}
	}
}


Measured memory_bytes: 4628
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
    double r, are, circ;
    scanf("%lf", &r);
    are = r * r * 3.141592653589;
    circ = r * 2 * 3.141592653589;
    printf( "%f %f\n", are, circ );
    return 0;
}


Measured memory_bytes: 3212
/*Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.

My little horse must think it queer
To stop without a farmhouse near
Between the woods and frozen lake
The darkest evening of the year.

He gives his harness bells a shake
To ask if there is some mistake.
The only other sound’s the sweep
Of easy wind and downy flake.

The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
vector<int> parent;
int FIND(int node)
{
    if(parent[node]<0)
        return node;
    return parent[node]=FIND(parent[node]);
}
int DSU(int a, int b)
{
    a=FIND(a);
    b=FIND(b);
    if(a==b)
        return a;
    if(parent[b]<parent[a])
        swap(a,b);
    parent[a]+=parent[b];
    return parent[b]=a;
}
bool chk(int a, int b)
{
    return FIND(a)==FIND(b);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0,m=0,k=0,l=0;
    cin>>n>>m;
    parent.resize(n+m);
    for(int i=0;i<(n+m);++i)
        parent[i]=-1;
    for(int i=0;i<n;++i)
    {
        cin>>k;
        for(int j=0;j<k;++j)
        {
            cin>>l;
            --l;
            DSU(i,n+l);
        }
    }
    bool ok=true;
    for(int i=0;i<n;++i)
    {
        if(!chk(0,i))
        {
            ok=false;break;
        }
    }
    if(ok)
        cout<<"YES";
    else
        cout<<"NO";
    cout<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100010
set<int> gr[MAXN];
int color[MAXN];
int cost[MAXN];
int dist[MAXN];
int me = 0;
int dfs(int u, int p = -1){
	for(auto &v : gr[u]){
		if(v != p){
			dist[v] = dist[u]+cost[v];
			dfs(v, u);
		}
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int N, a, b;
	cin >> N;

	for(int i = 1; i < N; i++){
		cin >> a >> b;
		gr[a].insert(b);
		gr[b].insert(a);
	}
	string s;
	cin >> s;
	int qW = 0;
	for(int i = 1; i <= N; i++){
		color[i] = (s[i-1] == 'B');
		qW += !color[i];
	}

	queue<int> q;
	int S = N-1;
	for(int i = 1; i <= N; i++)
		if(color[i] == 1 && gr[i].size() == 1)
			q.push(i);

	while(!q.empty()){
		int i = q.front();
		q.pop();
		int u = *(gr[i].begin());
		S--;
		gr[u].erase(i);
		if(gr[u].size() == 1 && color[u] == 1)
			q.push(u);
		gr[i].clear();
	}
	if(S <= 0){
		cout << qW << "\n";
		return 0;
	}
	int ans = 2*S, flag = 0;
	for(int i = 1; i <= N; i++){
		cost[i] = 1;
		color[i] ^= ((int)gr[i].size() & 1);
		//cout << color[i] << endl;
		if(color[i] == 1)
			cost[i]--;
		else ans++, cost[i]++;
	}
	int u = 0;
	for(u = 1; u <= N && gr[u].size() == 0; u++);
	
	//cout << u << "\n";
	dist[u] = cost[u];
	dfs(u);
	int ma = -1e9, i_ma = 0;
	for(int i = 1; i <= N; i++)
		if(dist[i] > ma) ma = dist[i], i_ma = i;
	dist[i_ma] = cost[i_ma];
	dfs(i_ma);
	ma = -1e9, i_ma = 0;
	for(int i = 1; i <= N; i++)
		if(dist[i] > ma) ma = dist[i], i_ma = i;
	//cout << ma << endl;

	ans -= ma;
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 20428
N = int(input())

d = dict()

for n in range(2, N+1):
    x = 2
    while n > 1:
        if n % x == 0:
            n //= x
            if x in d.keys():
                d[x] += 1
            else:
                d[x] = 1
        else:
            x += 1

# 75 = 3 * 5 * 5
# 75, 3 25, 5 15, 3 5 5 => 74, 2 24, 4 14, 2 4 4


def f(x):
    n = 0
    for i in d.values():
        if i >= x:
            n += 1
    return n


ans = f(74) + f(24) * (f(2) - 1) + f(14) * (f(4) - 1) \
      + ((f(4) * (f(4) - 1)) // 2) * (f(2) - 2)

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

class CumulativeSum {
    vector<ll> numbers;

public:
    vector<ll> sums;

    CumulativeSum(int n) {
        numbers.resize(n);
        sums.resize(n);
    }

    void set(int i, ll value) {
        numbers[i] = value;
    }

    ll getSum(int i) {
        if (i == -1) return 0;
        if (i == sums.size()) return sums.back();
        return sums[i];
    }

    ll getSectionSum(int start, int end) {
        return getSum(end) - getSum(start - 1);
    }

    void build() {
        for (int i = 0; i < numbers.size(); i++) {
            sums[i] = getSum(i - 1) + numbers[i];
        }
    }

};

int main() {
    int n, m;
    ll k;
    cin >> n >> m >> k;

    vector<ll> as(n);
    vector<ll> bs(m);
    rep(i, n) cin >> as[i];
    rep(i, m) cin >> bs[i];

    CumulativeSum acs(n), bcs(m);
    rep(i, n) acs.set(i, as[i]);
    rep(i, m) bcs.set(i, bs[i]);
    acs.build();
    bcs.build();

    int ans = 0;

    {
        auto it = upper_bound(bcs.sums.begin(), bcs.sums.end(), k);
        if (it == bcs.sums.begin()) {
            cout << 0 << endl;
            ret();
        }
        it--;
        int j = distance(bcs.sums.begin(), it) + 1;

        int now = j;
        ans = now;
    }

    rep(i, n) {
        ll t = k - acs.getSum(i);
        if (t < 0) continue;
        auto it = upper_bound(bcs.sums.begin(), bcs.sums.end(), t);
        if (it == bcs.sums.begin()) {
            cmax(ans, i + 1);
            continue;
        }
        it--;
        int j = distance(bcs.sums.begin(), it) + 1;

        int now = i + 1 + j;
        cmax(ans, now);
    }
    cout << ans << endl;
}


Measured memory_bytes: 12764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long K = sc.nextLong();
		if (N < K) {
			System.out.println(Math.min(N, Math.abs(N - K)));
		} else {
			System.out.println(Math.min(N % K, Math.abs((N % K) - K)));
		}

	}

}

Measured memory_bytes: 21844
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

vector<pair<int, int> > v;

int N;
long long int K;
int main (){
    cin >> N >> K;
    for(int i=0; i<N; i++) {
        int a,b;
        cin >> a >> b;
        v.push_back(make_pair(a,b));
    }
    sort(v.begin(), v.end());
    for(int i=0; i<N;i++) {
        pair<int,int> P = v[i];
        int a = P.first;
        int b = P.second;
        if( K <= b ) {
            cout << a << endl;
            return 0;
        }
        K -= b;
    }
    return 0;
}


Measured memory_bytes: 1400
N = int(input())
H = list(map(int, input().split()))
#最大値を保管し、すべての場合を計算する手法でやってみる
max_count =0
count = 0
#今いる地点から、高さの低い場所に移動する。
for i in range(N-1):
    if(H[i]>=H[i+1]):
        count +=1
        #全ての場合を見終わった時
        if(H[i]==H[N-2]):
            if(count > max_count):
                max_count = count
        continue
                
        
    else:
        if(count> max_count):
            max_count = count
            #countの初期化
        count =0
    
print(max_count)

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

// 素集合データ構造
struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
	  // 最初は全てのデータiがグループiに存在するものとして初期化
	  for(int i = 0; i < n; i++){
		  par[i] = i;
	  }
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  int size(int x) {
    return sizes[find(x)];
  }
};

long long N, M;
long long p[100005];

int main(){
	cin >> N >> M;
	for(long long i = 0; i < N; i++){
		cin >> p[i];
		p[i]--;
	}
	UnionFind uf(2*N);

	for(long long j = 0; j < M; j++){
		long long x, y;
		cin >> x >> y;x--;y--;
		uf.unite(x, y);
	}


	long long ans = 0;
	for(long long i = 0; i < N; i++){
		if(uf.same(p[i], i))
			ans++;
	}
	cout << ans << endl;
	
	



}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();

		int a[] = new int[n];
		int b[] = new int[m];

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

		for (int i=0; i<m; i++){
			b[i] = sc.nextInt();
		}

		int readA=0;
		long totalA=0;
		int idxA = 0;
		for (int i=0; i<n; i++){
			idxA = i;
			if (totalA + a[i] <= k){
				readA ++;
				totalA += a[i];
			} else {
				break;
			}
		}

		int readB=0;
		long totalB=0;
		long ans = readA;
		while (true){

			for (int i=readB; i<m; i++){
				if (totalA + totalB + b[i] <= k){
					readB++;
					totalB += b[i];
				} else {
					break;
				}
			}

//			System.out.println(totalA);
//			System.out.println(totalB);
//			System.out.println("-------");

			ans = Math.max(ans, readA + readB);

			if (readA > 0){
				totalA-= a[readA-1];
			}
			readA--;

			if (readA < 0){
				break;
			}

		}
		System.out.println(ans);

	}

}

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

int main(){
    int N;
    int judge = 0;
    cin >> N;
    for(int i=2;i<10;i++){
        if(N%i==0 && N/i <= 9){
            judge = 1;
        }else{
        }
    }
    if(N <= 9){
        cout << "Yes" << endl;
    }else if(judge == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
//LIFE IS NOT A PROBLEM TO BE SOLVED
 
#define rep(i,a,b) for( int i = (int) a; i < (int) b; i++ )
#define PER(i,a,b) for( int i = (int) a; i >= (int) b; i-- )
#define F first
#define S second
#define mk make_pair
#define pb push_back
#define debug(a) cout << #a << " = " << a << endl;
#define debug2(a,b) cout << #a << " = " << a << " --- " << #b << " = " << b << endl;
#define debugP(a) cout << a.F << " " << a.S << endl;
#define debugV(v, n) { rep( i, 0, n ) { if(i) printf(" "); printf("%d", v[i]); } printf("\n"); }
#define debugM(mat,n,m) rep( i, 0, n ){ rep( j, 0, m ) { if(j) printf(" "); printf("%d", mat[i][j]); } printf("\n"); }
#define all(s) s.begin(), s.end()
 
using namespace std;
 
typedef long long int ll;
typedef pair <int, int> ii;
typedef pair <int, ii> iii;
 
const int MAX = 2e3+3;
const int mod = 1e9+7;



int main(){
	
	int N; cin >> N;
	
	if(N==1) cout << 0 << '\n';
	else{
		ll a = 1, b = 1, c = 1;
		rep(i, 0, N){
			a = (a*10)%mod;
			b = (b*9)%mod;
			c = (c*8)%mod;
		}
		
		ll ans = a - 2*b + c;
		while(ans<0) ans += mod;
		cout << ans%mod << '\n';
	}
	
    return 0;
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <climits>
using namespace std;
#define MOD int(1e9 + 7)
#define INF (long long)(1e18)

void warshall_floyd(int n, vector<vector<long long>>& d) {
  for (int k = 0; k < n; k++){       // 経由する頂点
    for (int i = 0; i < n; i++) {    // 始点
      for (int j = 0; j < n; j++) {  // 終点
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main()
{
    long long N, M;
    cin >> N >> M;

    vector<vector<long long>> E(N, vector<long long>(N, INF));
    vector<vector<long long>> d(N, vector<long long>(N, INF));
    for(long long i = 0; i < M; i++){
        long long a, b, c;
        cin >> a >> b >> c;
        E[a-1][b-1] = c;
        E[b-1][a-1] = c;
        d[a-1][b-1] = c;
        d[b-1][a-1] = c;
    }

    for(long long i = 0; i < N; i++){
        E[i][i] = 0;
        d[i][i] = 0;
    }

    warshall_floyd(N, d);

    long long count = 0;
    for(long long i = 0; i < N; i++)
        for(long long j = i + 1; j < N; j++)
            if(E[i][j] != INF && E[i][j] != d[i][j])
                count++;

    cout << count << endl;

}

Measured memory_bytes: 384
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
def lcm(a, b):
    """最小公倍数"""
    from math import gcd
    return (a * b) // gcd(a, b)


# from decorator import stop_watch
#
#
# @stop_watch
def solve(N, M, As):
    if sum([a % 2 for a in As]) > 0:
        print(0)
        return

    As = [a // 2 for a in As]
    all_lcm = 1
    for a in As:
        all_lcm = lcm(all_lcm, a)
        if all_lcm > M:
            print(0)
            return

    for a in As:
        if (all_lcm // a) % 2 == 0:
            print(0)
            return
    from math import ceil
    print(ceil(M // all_lcm / 2))


if __name__ == '__main__':
    N, M = map(int, input().split())
    As = [int(i) for i in input().split()]

    # import random
    # N, M = 10 ** 5, 10 ** 9
    # As = [random.randint(5, 5) * 2 for _ in range(N)]
    solve(N, M, As)


Measured memory_bytes: 21132