akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;

int isprime(int n) {
    if (n < 2) return 0;
    for (int i = 2; i*i <= n; ++i) {
        if (n % i ==  0) return 0;
    }
    return 1;
}

vector<int> enum_div(int n){
    vector<int> ret;
    for(int i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            if (isprime(i)) ret.push_back(i);
            if (isprime(n/i)) ret.push_back(n/i);
        }
    }
    return ret;
}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int N;
    cin >> N;

    if (isprime(N)) {
        p(1);
        return 0;
    }
    
    VI a = enum_div(N);
    SORT(a);
    /*
    int now = 1;
    int i = 1;
    int ans = 0;
    map<int,int> mp;
    while (now < N && i < SZ(a)){
        now *= a[i];
        ans++;
    }
    pa;
    */
   int ans = 0;
    std::priority_queue<
      PII,                // 要素の型はint
      std::vector<PII>,   // 内部コンテナはstd::vector (デフォルトのまま)
      std::greater<PII>   // 昇順 (デフォルトはstd::less<T>)
    > que;
    REP(i,SZ(a)) {
        if (a[i] != 0 && a[i] != 1) que.push({a[i],a[i]});
    }

        
    while (N > 1 && !que.empty()) {
        if (N % que.top().first == 0) {
            N = N/que.top().first;
            PII b = que.top();
            que.pop();
            que.push({b.first*b.second,b.second});
            ans++;
        }
        else que.pop();
    }
    pa;

    

    

    

    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc169/abc169_d && sh test.sh
cd ~/Desktop/Programming/AtCoder/contest/abc169/abc169_d && sh etest.sh
cd ~/Desktop/Programming/AtCoder/contest/abc169/abc169_d && sh submit.sh
*/


Measured memory_bytes: 3660
#include <iostream>

#define rep(i, n) for(int i = 0; i < (n); i++)

using namespace std;

int main(void)
{
	int N;

	cin >> N;

	for (int i = 1; i < 10; i++){
		if (N % i == 0){
			if (N / i / 10 == 0){
				cout << "Yes" << endl;
				return 0;
			}
		}
		
	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int64_t a,b,c,d;
	cin>>a>>b>>c>>d;
	int64_t r=b-b/c-b/d+b/(c*d/__gcd(c,d));
	a--;
	int64_t l=a-a/c-a/d+a/(c*d/__gcd(c,d));
	cout<<r-l<<endl;
	return 0;
}

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

// using ll = long long;
#define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int n;
  cin >>n;
  int i = 1;
  int ans = 0;
  
  while(n > i*i) {
    if(n%i == 0) {
      int fav = n/i - 1;
      if(n/fav != n%fav) break;
      ans += fav;
    }
    ++i;
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N, M; cin >> N >> M;
    vl a(M); REP(i, M) cin >> a[i];
    sort(a.begin(), a.end());
    vs dp(N+10, "");
    vl cost = {0,2,5,5,4,5,6,3,7,6};
    REP(i, M){
        ll v = a[i];
        if(dp[cost[v]] != "") dp[cost[v]] = max(dp[cost[v]], to_string(v));
        else dp[cost[v]] = to_string(v);
    }
    auto chmax = [](string& s, string t){
        if(s.size() < t.size()){
            s = t; return;
        }
        else if(s.size() == t.size() && s < t){
            s = t; return;
        }
    };
    FOR(i,1,N+1){
        REP(j, M){
            ll v = a[j];
            if(i - cost[v] < 0) continue;
            if(dp[i-cost[v]] == "") continue;
            string tmp = dp[i-cost[v]] + to_string(v);
            if(dp[i] == "") dp[i] = tmp;
            else chmax(dp[i], tmp);
        }
    }
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 31872
#include<cstdio>
long long n,f[1000001]={1,1,1,2,4,7},g[1000001]={1,2,3,5,9,16},sumk=6;
int main(){
	scanf("%d",&n);
	if(n==1) {puts("1"); return 0;}
	if(n==2) {puts("4"); return 0;}
	if(n==3) {puts("15"); return 0;}
	for(int i=6;i<=n;++i){
		sumk+=g[i-3];
		sumk%=1000000007;
		f[i]=sumk+1;
		g[i]=(g[i-1]+f[i])%1000000007;
	}
//	for(int i=0;i<=n;++i) printf("%d ",f[i]); puts("");
//	for(int i=0;i<=n;++i) printf("%d ",g[i]); puts("");
	long long ans=g[n-2]*(n-1)%1000000007+1+((n-1)*g[n-2]%1000000007+f[n-1])*(n-1)%1000000007;
	ans%=1000000007;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 15744
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	ll A, B, C;
	scanf("%lld %lld %lld", &A, &B, &C);
	if(A % 2 == 0 || B % 2 == 0 || C % 2 == 0) printf("0\n");
	else if(A >= B && A >= C) printf("%lld\n", B * C);
	else if(B >= C && B >= A) printf("%lld\n", C * A);
	else if(C >= A && C >= B) printf("%lld\n", A * B);
	return 0;
}


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

int main(void){
    int N;
    cin >> N;
    vector<int> res(N, 0);
    for(int i=1; i<99; i++){
        for(int j=1; j<99; j++){
            for(int k=1; k<99; k++){
                if(i*i+j*j+k*k+i*j+j*k+k*i <= N){
                    res[i*i+j*j+k*k+i*j+j*k+k*i-1]++;
                }
            }
        }
    }
    for(int i=0; i<N; i++)cout << res[i] << endl;
    return 0;
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(b-a==c-b)cout << "YES" << endl;
  else cout <<"NO" << endl;
}

Measured memory_bytes: 3596
n, m = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(m)]

def find(x):
    if root[x] < 0:
        return x
    else:
        root[x] = find(root[x])
        return root[x]

def unit(x, y):
    gx = find(x)
    gy = find(y)

    if gx == gy:
        return

    if root[gx] > root[gy]:
        gx, gy = gy, gx

    root[gx] += root[gy]
    root[gy] = gx

cnt = 0
for i in range(m):
    root = [-1] * n
    for j in range(m):
        if i == j:continue
        unit(AB[j][0]-1, AB[j][1]-1)
    roots = [i for i in root if i < 0]
    cnt += (len(roots) != 1)
print(cnt)

Measured memory_bytes: 9256
/*
https://atcoder.jp/contests/dp/tasks/dp_n
*/
#include<bits/stdc++.h>
#define ll long long int
#define inf 1e18
using namespace std;

ll dp[1000][1000];

ll cost_sum(ll arr[],ll a,ll b){

ll sum = 0;

for(ll i=a;i<=b;i++){
    sum += arr[i];
}
return sum;
}


ll matrix_mul(ll arr[], ll i, ll j){

 if(i >= j){
    return 0;
 }

 if(dp[i][j] != -1){
    return dp[i][j];
 }

 ll ans = inf;

 for(ll k=i;k<j;k++){
    ll temp = matrix_mul(arr,i,k) + matrix_mul(arr,k+1,j) + cost_sum(arr,i,k) + cost_sum(arr,k+1,j);
    ans = min(ans,temp);
 }
 return dp[i][j] = ans;
}


int main(){

    ll n;  cin>>n;
    ll arr[n];

    memset(dp,-1,sizeof(dp));

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

    ll ans = 0;

    ans = matrix_mul(arr,0,n-1);

    cout<<ans<<"\n";

return 0;
}


Measured memory_bytes: 8064
n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n - i + 1):
        if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
            print(i, j, n - i - j)
            exit()
print(-1, -1, -1)


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

int main()
{
    int n;
    cin >> n;
    ll ans = 0;
    vector<int> b(n - 1);
    rep(i, n - 1) cin >> b[i];

    vector<int> a(n);
    for (int i = n - 1; i >= 0; i--)
    {
        if (i == n - 1)
            a[i] = b[i - 1];
        else if (i == 0)
            a[i] = b[i];
        else
        {
            a[i] = min(b[i - 1], b[i]);
        }
    }
    rep(i, n) ans += a[i];
    cout << ans << endl;
    return 0;
}


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

using namespace std;

/*helpfull*/
using vt  = vector<long long>;
using pr  = pair<long long, long long>;
using ll  = long long int;


struct hash_pair {
	template <class T1, class T2>
	size_t operator()(const pair<T1, T2>& p) const
	{
		auto hash1 = hash<T1> {}(p.first);
		auto hash2 = hash<T2> {}(p.second);
		return hash1 ^ hash2;
	}
};
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif

// shortcut macros
#define mp              make_pair
#define fi              first
#define se              second
// #define mt              make_tuple
#define pb              push_back
#define all(x)          (x).begin(), (x).end()
#define ini(a, v)       memset(a, v, sizeof(a))
#define rep(i, a, n)    for(ll i=a ; i<n ; ++i)
#define For(i, n)       rep(i, 0, n)
#define sz(x)           (int((x).size()))
#define ump(x,y)        unordered_map<x,y>
#define umpr(x,y,z)     unordered_map<x,y,z>

ll min_edit_dist(string s1, string s2, ll n1, ll n2) {
	ll dp[n1 + 1][n2 + 1];
	for (int i = 0; i <= n1; i++)
		dp[i][0] = i;
	for (int j = 1; j < n2; j++)
		dp[0][j] = j;
	for (int i = 1; i <= n1; i++) {
		for (int j = 1; j <= n2; j++) {
			if (s1[i - 1] == s2[j - 1])
				dp[i][j] = dp[i - 1][j - 1];
			else
				dp[i][j] = 1 + min({dp[i][j - 1], dp[i - 1][j], dp[i - 1][j - 1]});

		}
	}
	return dp[n1][n2];
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll n, k, k1, j;
	cin >> n >> k;
	vt h(n), cost(n + 1);
	For(i, n)
	cin >> h[i];
	cost[0] = 0;
	for (ll i = 1; i < n; i++) {
		k1 = min(k, i);
		j = i - 1;
		while (k1--) {
			if (j == i - 1)
				cost[i] = cost[j] + abs(h[j] - h[i]);
			else
				cost[i] = min(cost[i], cost[j] + abs(h[j] - h[i]));
			--j;
		}
	}
	cout << cost[n - 1] << endl;
	return 0;
}



Measured memory_bytes: 4840
#include <stdio.h>

long long euclid(long long a, long long b)
{
	long long temp;

	if (a < b) { temp = a; a = b; b = temp; }
	if (b < 1) return -1;

	if (a % b == 0) return b;
	return euclid(b, a % b);
}

int main(void) {
	long long a, b, c, d, lcm;
	long long undera, underb;
	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

	lcm = c * d / euclid(c, d);
	underb = b - b / c - b / d + b / lcm;
	undera = a - 1 - (a - 1) / c - (a - 1) / d + (a - 1) / lcm;
	printf("%lld\n", underb - undera);
	return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline

n = int(input())
a = [list(map(lambda x: int(x)-1, input().split())) for _ in range(n)]

def calc_idx(x, y):
    if x > y:
        x, y = y, x
    return x + y*(y-1)//2

n_game = n * (n-1) // 2
edge = [[] for i in range(n_game)]
for i in range(n):
    for j in range(1, n-1):
        g1 = calc_idx(i, a[i][j-1])
        g2 = calc_idx(i, a[i][j])
        edge[g1].append(g2)

indegree = [0] * n_game
for i in range(n_game):
    for v in edge[i]:
        indegree[v] += 1

ans = 0
cand = [[i for i in range(n_game) if indegree[i] == 0], []]
n_ts = 0
while cand[ans%2]:
    n_ts += len(cand[ans%2])
    cand[(ans+1)%2] = []
    for ci in cand[ans%2]:
        for v in edge[ci]:
            indegree[v] -= 1
            if indegree[v] == 0:
                cand[(ans+1)%2].append(v)
    ans += 1

if n_ts != n_game:
    ans = -1

print(ans)


Measured memory_bytes: 116528
N,Q = gets.chomp.split(" ").map(&:to_i)
S = gets.chomp.split("").map(&:to_s)

ac_count = []
count = 0
S.each_with_index do |str,i|
    if i == 0
        ac_count << 0
    else
        if S[i-1]+S[i] == "AC"
            count += 1
            ac_count << count
        else
            ac_count << count
        end
    end
end
# p ac_count
Q.times do |i|
    begin_i,end_i = gets.chomp.split(" ").map(&:to_i)
    puts ac_count[end_i-1] - ac_count[begin_i-1]
end

Measured memory_bytes: 11772
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
#define pint pair<int, int>
#define vint vector<int>
using namespace std;

const int INF=1e9+7;
const int MOD=1e9+7;
//const int MOD=998244353;

int dp[3001][3001];

int main(){
	string s,t; cin>>s>>t;
	FOR(i,0,s.size()+1){
		FOR(j,0,t.size()+1){
			if(i==0||j==0){
				dp[i][j]=0;
			}else if(s[i-1]==t[j-1]){
				dp[i][j]=1+dp[i-1][j-1];
			}else{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	string ans;
	int i=s.size(),j=t.size();
	while(i!=0&&j!=0){
		if(dp[i][j]>dp[i-1][j]&&dp[i][j]>dp[i][j-1]){
			ans=s[i-1]+ans;
			i--; j--;
		}else if(dp[i-1][j]>dp[i][j-1]){
			i--;
		}else{
			j--;
		}
	}
	co(ans);
}


Measured memory_bytes: 35456
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

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

  int ans = 0;
  while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
    if (a == b && b == c && c == a) {
      outl(-1);
      return;
    }

    int na = (b + c) / 2;
    int nb = (a + c) / 2;
    int nc = (a + b) / 2;

    a = na; b = nb; c = nc;
    ans++;
  }
  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int x, t;
    cin >> x >> t;
    cout << max(0, x - t) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

char m(char c)
{
    if(c=='(') return')';
    if(c==')') return'(';
    if(c=='{') return'}';
    if(c=='}') return'{';
    if(c=='[') return']';
    if(c==']') return'[';
    assert(false);
}

int main()
{
    string a;
    cin >>a;

    int idx = 0;
    while(a[idx]!='i') ++idx;

    string s = a.substr(0,idx), t = a.substr(idx+3);
    if(s.size()>t.size()) swap(s,t);
    reverse(all(t));

    int S = s.size() , T = t.size();
    int ans = 3;
    for(int mask=1; mask<(1<<S); ++mask)
    {
        string x = "";
        rep(i,S)if(mask>>i&1) x += s[i];

        int X = x.size();
        idx = 0;
        rep(i,T)if(idx<X && x[idx]==m(t[i])) ++idx;
        if(idx==X) ans = max(ans,3+2*X);
    }

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

Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// 条件を見落としていませんか？
int main () {
    ll Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;
    ll a = N/2, b = N%2;
    cout << a*min({8*Q, 4*H, 2*S, D}) + b*min({4*Q, 2*H, S}) << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void)
{
  int n;
  cin>>n;
  int num[4][13];
  for(int i=0;i<4;i++)
    {
      for(int j=0;j<13;j++)
	{
	  num[i][j]=0;
	}
    }
  for(int i=0;i<n;i++)
    {
      char x;
      cin>>x;
      int y;
      cin>>y;
      if(x=='S')num[0][y-1]++;
      else if(x=='H')num[1][y-1]++;
      else if(x=='C')num[2][y-1]++;
      else if(x=='D')num[3][y-1]++;
    }
  for(int i=0;i<4;i++)
    {
      for(int j=0;j<13;j++)
	{
	  if(num[i][j]==0 && i==0)cout<<'S'<<" "<<j+1<<endl;
	  else if(num[i][j]==0 && i==1)cout<<'H'<<" "<<j+1<<endl;
	  else if(num[i][j]==0 && i==2)cout<<'C'<<" "<<j+1<<endl;
	  else if(num[i][j]==0 && i==3)cout<<'D'<<" "<<j+1<<endl;
	}
    }
  return 0;
}

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

using namespace std;

const int nax = 1005;
const int mod = 1e9 + 7;

char grid[nax][nax];

void add_self(int &a , int b){
    a += b;
    if(a >= mod){
        a -= mod;
    }
}

int main (){
    int h , w;
    scanf("%d %d" , &h , &w);
    for(int row = 0; row < h; ++row){
        scanf("%s" , grid[row]);
    }
    auto inside = [&](int x , int y){
        return  x <= h && y <= w && grid[x][y] == '.';
    };
    vector<vector<int> > dp(h , vector<int>(w));
    dp[0][0] = 1;
    for(int row = 0; row < h; ++row){
        for(int col = 0; col < w; ++col){
            for(int new_row : {row , row + 1}){
                int new_col = col;
                if(row == new_row){
                    new_col = col + 1;
                }
                if(inside(new_row , new_col)){
                    add_self(dp[new_row][new_col] , dp[row][col]);
                }
            }
        }
    }
    printf("%d" , dp[h - 1][w - 1]);
return 0;
}


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

using namespace std;

int main()
{
    int n; scanf("%d", &n);

    vector<int> a(n);

    int res = 0;
    for (int i = 0; i < n; i++){
        scanf("%d", &a[i]);
        while(a[i] % 2 == 0) a[i] /= 2, res++;
    }

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


Measured memory_bytes: 256
using System;

public class Program
{
    public static long loop;

    static char[] sc;

    static string output;

    public static void Main(string[] args)
    {
        loop = 0;

        Input();
        Proc();
        Output();
    }

    static void Input()
    {
        //string[] input = null;

        // 文字列を数値の配列として読込
        sc = Console.ReadLine().ToCharArray();

    }

    static void Proc()
    {
        long[] count = new long['z' - 'a' + 1];

        for (long i = 0; i < sc.Length; i++)
        {
            count[sc[i] - 'a']++;
        }

        output = "Yes";

        for (long i = 0; i < count.Length; i++)
        {
            if (count[i] % 2 == 1)
            {
                output = "No";
                break;
            }
        }
    }

    static void Output()
    {
        // 出力
        Console.WriteLine(output);
        output = string.Empty;
    }
}


Measured memory_bytes: 11092
n = str(input())
n = n[-1]
if n == '2' or n == '4' or n == '5' or n == '7' or n == '9':
    print('hon')
elif n == '0' or n == '1' or n == '6' or n == '8':
    print('pon')
else:
    print('bon')




Measured memory_bytes: 9044
N,M  = map(int,input().split())
d = {}
for _ in range(N):
    tmp = list(map(int,input().split()))
    for i in range(1, len(tmp)):
        if tmp[i] not in d:
            d[tmp[i]] = 0
        d[tmp[i]] += 1
ans = 0
for v in d.values():
    if v == N:
        ans += 1
print(ans)


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

using namespace std;

char str[5010];
int k;
struct st
{
    int l, r;
}a[10];
int com(int l, int r, int k)
{
    if (a[k].l == -1) return 1;
    int b = 0;
    while(1)
    {
        if (l+b > r || a[k].l+b > a[k].r) break;
        if (str[l+b] < str[a[k].l+b]) return 1;
        if (str[l+b] > str[a[k].l+b]) return -1;
        b++;
    }
    if (l+b>r && a[k].l+b > a[k].r) return 0;
    if (l+b>r) return 1; else return -1;
}
int main()
{
    scanf("%s", str);
    scanf("%d", &k);
    int len = strlen(str);
    a[1].l = -1; a[1].r = -1;
    a[2].r = -1;
    a[3].r = -1;
    a[4].r = -1;
    a[5].r = -1;
    a[2].l = -1;
    a[3].l = -1;
    a[4].l = -1;
    a[5].l = -1;
    for(int i=0; i<len; i++)
    {
        for(int j=i; j<len; j++)
        {
            int p = 5;
            while(p > 0 && com(i, j, p) == 1) p--;
            if (p != 0 && com(i, j, p) == 0) continue;
            if (p == 5) break;
            p++;
            for(int q=5; q>p; q--)
            {
                a[q].l = a[q-1].l;
                a[q].r = a[q-1].r;
            }
            a[p].l = i; a[p].r = j;
        }
    }

    for(int i=a[k].l; i<=a[k].r; i++)
        cout<<str[i];
    cout<<endl;
}

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

using namespace std;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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


int main(void){

	int X, A; cin >> X >> A;
	if(X < A) cout << 0 << endl;
	else cout << 10 << endl;


	return 0;

}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for (int i=s;i<e;i++)
#define FOE(i,s,e) for (int i=s;i<=e;i++)
#define FOD(i,s,e) for (int i=s;i>=e;i--)
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define LD long double
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>
#define PLI pair<LL,int>
#define PIL pair<int,LL>
#define PLL pair<LL,LL>
#define PDD pair<LD,LD>
#define eps 1e-9
#define HH1 402653189
#define HH2 1610612741

LL n, m, ans;

int main () {
	
	scanf("%lld%lld", &n, &m);
	
	ans = (n * 2LL + m) / 4LL;
	
	if (ans > m / 2) ans = m / 2;
	
	printf("%lld\n", ans);
	
	return 0;
	
}

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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;
const int MAXN = (int)3e5+1;

int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    for(int i=0; i<s.length(); i++)
    {
        cout << 'x';
    }
    return 0;
}



Measured memory_bytes: 256
from itertools import combinations_with_replacement
n,m,q=map(int,input().split())
Q=[list(map(int,input().split())) for i in range(q)]
ans=0
for s in combinations_with_replacement(range(1,m+1),n):
    ans_=0
    for k in Q:
        a,b,c,d=k
        if s[b-1]-s[a-1]==c:
            ans_+=d
    ans=max(ans_,ans)
print(ans)

Measured memory_bytes: 9092
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
#define int long long
using namespace std;
using VI  = vector<int>;
using VVI = vector<VI>;
VVI d1, d2;
int n, m, q, l, x, y, w;
int32_t main() {
    DAU
    cin >> n >> m >> l;
    d1 = d2 = VVI(n + 1, VI(n + 1, 1e18));
    for (int i = 1; i <= m; ++i) {
        cin >> x >> y >> w;
        d1[x][y] = d1[y][x] = w;
    }
    for (int j = 1; j <= n; ++j)
        for (int i = 1; i <= n; ++i)
            for (int k = 1; k <= n; ++k) {
                d1[i][k] = min(d1[i][j] + d1[j][k], d1[i][k]);
                if (d1[i][k] <= l)
                    d2[i][k] = 1;
            }
    for (int j = 1; j <= n; ++j)
        for (int i = 1; i <= n; ++i)
            for (int k = 1; k <= n; ++k)
                d2[i][k] = min(d2[i][j] + d2[j][k], d2[i][k]);
    cin >> q;
    for (int i = 1; i <= q; ++i) {
        cin >> x >> y;
        if (d2[x][y] == 1e18)
            d2[x][y] = 0;
        cout << d2[x][y] - 1 << '\n';
    }
    PLEC
}


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

using namespace std;

const int M = 2e5 + 1;
int f[M];

// Mod things

int mod = 1e9 + 7;
int modPow(int n, int p) {
    if (!p)
        return 1;

    int r = modPow((1ll * n * n) % mod, p / 2);

    if (p & 1)
        return (1ll * n * r) % mod;
    return r;
}

int modInv(int n) { return modPow(n, mod - 2); }

int addMod(int a, int b) {
    a += b;
    if (a >= mod)
        a -= mod;
    return a;
}

int divMod(int n, int d) { return (1ll * n * modInv(d)) % mod; }

int choose(int n, int k) { return (1ll * f[n] * modInv((1ll * f[k] * f[n - k]) % mod)) % mod; }

int dist(int n, int r) { return choose(n + r - 1, r - 1); }

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

    f[0] = 1;
    for (int i = 1; i < M; i++)
        f[i] = (1ll * f[i - 1] * i) % mod;

    int n, k, ans[M];
    cin >> n >> k;

    ans[0] = 1;
    for (int i = 1; i < n; i++) {
        int cur = (1ll * choose(n, i) * dist(i, n - i)) % mod;
        ans[i] = addMod(ans[i - 1], cur);
    }

    k = min(k, n - 1);
    cout << ans[k] << '\n';

    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <stack>

using namespace std;

typedef long long LL;
#define FAST ios::sync_with_stdio(false);
const int MaxN = 105;
int main()
{
	int n , k;
	cin >> n >> k;
	int ans = k;
	for(int i = 1 ; i < n ; i++)
		ans *= (k - 1);
	cout << ans << endl;
	return 0;
	}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)
int dp[100010];
#define INF 1000000;

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

    dp[0] = 0;
    for(int n = 1; n <= 100000; n++){
        dp[n] = INF;
        int power = 1;
        while(power <= n){
            dp[n] = min(dp[n], dp[n - power] + 1);
            power *= 6;
        }
        power = 1;
        while(power <= n){
            dp[n] = min(dp[n], dp[n - power] + 1);
            power *= 9;
        }
    }

    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
for i in range(n):
    if b[i] > a[i]:
        b[i] -= a[i]
        ans += a[i] + min(a[i+1], b[i])
        a[i+1] -= min(a[i+1], b[i])
    else:
        ans += b[i]
print(ans)

Measured memory_bytes: 18468
<?php
list($n, $m) = array_map("intval", explode(" ", trim(fgets(STDIN))));
for($i = 0; $i < $m; $i++){
    list($l, $r, $d) = array_map("intval", explode(" ", trim(fgets(STDIN))));
    $link[$l][$r] =  $d;
    $link[$r][$l] = -$d;
}

for($i = 1; $i <= $n; $i++){
    $pos[$i] = false;
}
$done = 0;
for($i = 1; $i <= $n; $i++){
    if($pos[$i] === false)dfs($i, 0);
}
echo "Yes\n";

function dfs($i, $p){
    global $pos;
    global $link;
    if($pos[$i] === false){
        $pos[$i] = $p;
        if(isset($link[$i])){
            foreach($link[$i] as $to => $d){
                dfs($to, $p + $d);
            }
        }
    }else{
        if($pos[$i] !== $p){
            echo "No\n";exit;
        }
    }
}


Measured memory_bytes: 90612
#include<iostream>
using namespace std;
int main()
{
  int A, B, C, D, P;
  cin >> A >> B >> C >> D >> P;

 if(P<C){
 	if(P*A<B){
	cout<< P*A << endl ;
	}else{
	cout<< B << endl ;
	}
        
        }else{

	if(P*A<(P-C)*D+B){
	cout<<P*A << endl ;
	}else{
	cout<<(P-C)*D+B<< endl;}
	}
  return(0);
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  int x,y;
  cin >> x >> y;
  int ans = 0;

  //Aボタン

  ans += abs(abs(x) - abs(y));

  //Bボタン
  if(abs(x) < abs(y)){
    if(x < 0) ++ans;
    if(y < 0) ++ans;
  }
  else if(abs(x) > abs(y)){
    if(x > 0) ++ans;
    if(y > 0) ++ans;
  }

  else{
    if( x != y) ++ans;
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<long long int,long long int> pll;
typedef vector<int> vi;
typedef vector<long long int> vl;
#define pb push_back
#define mp make_pair

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
	string s;
	cin >> s;
	
	int n = s.size();
	int l = n-1;
	ll ans = 0;
	for(int i=s.size()-1;i>=0;i--){
		if(s[i]=='B')
			ans+=l-i, l--;
	}

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



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

int main(){
  int N,D,X;
  cin>>N>>D;
  cin>>X;
  
  vector<int> A(N);
  
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  
  int sum=0;
  
  for(int i=0;i<N;i++){
    
    for(int j=0;j<D;j++){
      if(A.at(i)*j+1<=D){
       sum++;
      }
    }
  }
  
  cout<<sum+X<<endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>
#include <algorithm>
 
using namespace std;
 
int cmp_count = 0;
 
 
void merge(int A[],int left,int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1+1],R[n2+1];
    for(int i = 0; i < n1; i++) L[i] = A[left + i];
    for(int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1] = R[n2] =  INT_MAX;
 
    int i = 0, j = 0;
    for(int k = left;k < right; k++){
        if(L[i] <= R[j]){
            A[k] = L[i++];
            cmp_count++;
        }else{
            A[k] = R[j++];
            cmp_count++;
        }
    }
}
 
void mergeSort(int A[],int left,int right){
    if(left+1 < right){
        int mid = (left+right)/2;
        mergeSort(A,left,mid);
        mergeSort(A,mid,right);
        merge(A,left,mid,right);
    }
}
 
int main(){
    int n;
    scanf("%d",&n);
    int S[n];
    for(int i = 0; i < n; i++) scanf("%d",&S[i]);
 
    mergeSort(S,0,n);
 
    for(int i = 0; i < n-1; i++) printf("%d ",S[i]);
    printf("%d\n",S[n-1]);
    printf("%d\n",cmp_count);
 
}


Measured memory_bytes: 6588
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int n, k;
  	cin >> n >> k;
  	int ans = 1;
  	rep(i,n) ans = min(ans+k, ans*2);
	cout << ans << endl;
	return;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,x,y,k,m,n;
	cin>>a>>b>>c>>x>>y;
	if(2*c<(a+b))
	{
		if(x>y)
		{
			m=2*y*c+(x-y)*a;
			n=2*x*c;
			if(m<n) k=m;
	            else k=n;
		}    
		if(x==y)   k=2*x*c;
		if(x<y)
		{
			m=2*x*c+(y-x)*b;
			n=2*y*c;
			if(m<n) k=m;
			    else k=n;
		}    
	}
	if(2*c>=(a+b))   k=a*x+b*y;
	cout<<k<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-6;
const int MOD = 1000000007;
typedef pair<double, double> P;
bool checked[2*100001];
P points[2*100001];
int N;
double R;
inline bool distcheck(P p1, P p2){
  double dx = p1.first - p2.first;
  double dy = p1.second - p2.second;
  return dx*dx+dy*dy < 2*R*R;
}

int check(int idx){
  checked[idx] = true;
  P p = points[idx];
  int idx2 = idx + 1;
  int res = idx;
  while(idx2 < N){
    if(!checked[idx2] && distcheck(points[idx2], p)){
      checked[idx2] = true;
      if(res - idx2 == 1) res = idx2;
    }
    idx2++;
    if(idx2 < N && points[idx2].first > p.first + 1.1*R) break;
  }
  return res;
}

int main(){
  while(cin>>N>>R){
    double x, y;
    REP(i, N){
      scanf("%lf %lf", &x, &y);
      points[i] = P(x / sqrt(2) - y / sqrt(2), x/sqrt(2) + y / sqrt(2));
    }
    sort(points, points + N);
    int ans = 0;
    memset(checked, 0, sizeof(checked));
    REP(i, N)if(!checked[i]){
      i = check(i);
      ans++;
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 4296
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  int min;
  int minnum=0;
  int minuscount=0;
  unsigned long ans=0;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(i==0){
      if(a[0]<0){
        a[0]=-1*(a[0]);
        minuscount++;
      }
      min = a[0];
    }else{
      if(a[i]<0){
        a[i]=-1*(a[i]);
        minuscount++;
      }
      if(a[i]<min){
        min = a[i];
        minnum=i;
      }
    }
  }
  for(int i=0;i<n;i++){
      if(i!=minnum){
        ans+=a[i];
      }else{
        if(minuscount%2==1){
          ans-=a[i];
        }else{
          ans+=a[i];
        }
      }
  }

  cout << ans;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Apr 19 21:33:16 JST 2020
 **/

const double PI=3.14159265358979323846;
signed main() {
    double r;
    std::cin >> r;
    std::cout << 2 * r * PI << std::endl;
}


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

void solve() {
    long long t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

    a1 *= t1, b1 *= t1;
    a2 *= t2, b2 *= t2;

    if(a1 + a2 == b1 + b2) {
        cout << "infinity" << endl;
        return;
    }

    if(a1 + a2 > b1 + b2) {
        swap(a1, b1);
        swap(a2, b2);
    }

    if(a1 < b1) {
        cout << 0 << endl;
        //cout << "debug01" << endl;
        return;
    }

    long long d = (b1 + b2) - (a1 + a2);
    long long x = (a1 - b1) / d;

    cout << 2 * x + ((a1 - b1) % d > 0) << endl;
    //cout << "debug02 : " << x << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    int t;
    //cin >> t;
    //for(auto i = 0; i < t; ++i)
        solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>
#include <sstream>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    double ans = 0;
    double l; cin >> l;

    ans = (l/3) * (l/3) * (l/3);

    cout << setprecision(10) << ans << endl;

}

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

public class Main {
    BufferedReader br;
    PrintWriter out;
    StringTokenizer stok;

    String nextToken() throws IOException {
        while (stok == null || !stok.hasMoreTokens()) {
            String s = br.readLine();
            if (s == null) {
                return null;
            }
            stok = new StringTokenizer(s);
        }
        return stok.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    char nextChar() throws IOException {
        return (char) (br.read());
    }

    String nextLine() throws IOException {
        return br.readLine();
    }

    final double EPS = 1e-10;
    void solve() throws IOException {
        double N = nextInt();
        for (long h = 1; h <= 3500; h++) {
            for (long n = 1; n <= 3500; n++) {
                double w = N * h * n / (4 * h * n - N * (n + h));
                if (w > 0.1 && Math.abs(w - Math.round(w)) < EPS) {
                    out.println(h + " " + n + " " + ((long) Math.round(w)));
                    return;
                }
            }
        }
    }

    void run() throws IOException {
        // br = new BufferedReader(new FileReader("dragons.in"));
        //out = new PrintWriter("dragons.out");
        // br = new BufferedReader(new FileReader("input.txt"));
        // out = new PrintWriter("output.txt");
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        br.close();
        out.close();
    }

    public static void main(String[] args) throws IOException {
        // Locale.setDefault(Locale.US);
        new Main().run();
    }
}

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

using namespace std;
#define ub upper_bound
#define sum(a) accumulate(all(a),0ll)
#define lb lower_bound
#define all(v) begin(v),end(v)
#define allr(v) rbegin(v),rend(v)
#define sort_dec(v) sort(all(v),[](auto e1,auto e2){return e1>e2;})
#define For(n) for(ll i=0;i<n;i++)
#define Forj(n) for(ll j=0;j<n;j++)
#define ios iostream::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef long long int ll;
typedef unsigned long long int ull;
#define fi first
#define se second
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define Mp 1e9+7
#define vpll vector< pair<ll,ll> >
#define bug(n) {cout<<n;return;}
#define cont(n) {cout<<n<<endl;continue;}
#define pb push_back
long long int mod = 1000000007;

const int sz=1000001;

ll MAX=1e18;


void solve()
{
  ll a,b;
  cin>>a>>b;
  ll g=__gcd(a,b);
  ll c=1;
  for(ll i=2;i*i<=g;i++)
  {
      if(g%i==0)
      {
          c++;
          while(g%i==0)g/=i;
      }
  }
  if(g>2)c++;
  cout<<c<<endl;

}

int main() {
  ll t=1;
  while(t--)
  {
      solve();
  }
}

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;

int main() {
  int n;
  cin >> n;
  int ans = 0;
  rep(i, n+1) {
    int keta = 0;
    int x = i;
    while(x) {
      keta++;
      x/=10;
    }
    if (keta%2 == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,K;
int64 ans;
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    read(N);read(K);
    for(int i = 1 ; i <= N ; ++i) {
	if(i <= K) continue;
	ans += i - K;if(K == 0) --ans;
	int t = N / i - 1;
	ans += t * (i - K);
	t = N / i * i + K;
	if(t <= N) ans += N - t + 1;
    }
    out(ans);enter;
    return 0;
}


Measured memory_bytes: 256
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)

n = ip()                                     #入力整数1つ
#n,k= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
# a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#k = ip()                      #入力セット(整数改行あり)(1/2)
a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
a.sort()
s = 0
cnum = a[0]
csum = 1
for i in range(1,n):
    if a[i] == cnum:
        csum+=1
    else:
  #      print(csum)
        cnum = a[i]
        s+=(csum%2)
        csum=1
  #  print(s,csum)
s+=(csum%2)
print(s)

Measured memory_bytes: 17688
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String ans = "";
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '0') ans += "0";
            if (s.charAt(i) == '1') ans += "1";
            if (s.charAt(i) == 'B') {
                if (ans.length() > 0) ans = ans.substring(0, ans.length() - 1);
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23508
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node{
  int p, l, r;
};

struct Node TREE[MAX];
int n;

void preParse(int u){
  if ( u == NIL ) return;
  printf(" %d", u);
  preParse(TREE[u].l);
  preParse(TREE[u].r);
}
void inParse(int u){
  if ( u == NIL ) return;
  inParse(TREE[u].l);
  printf(" %d", u);
  inParse(TREE[u].r);
}
void postParse(int u){
  if ( u == NIL ) return;
  postParse(TREE[u].l);
  postParse(TREE[u].r);
  printf(" %d", u);
}



int main(){
  int i, v, l, r, root;
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) {
    TREE[i].p = NIL;
  }

  for ( i = 0; i < n; i++ ){
    scanf("%d %d %d", &v, &l, &r);
    TREE[v].l = l;
    TREE[v].r = r;
    if ( l != NIL ) TREE[l].p = v;
    if ( r != NIL ) TREE[r].p = v;
  }
  for ( i = 0; i < n; i++ ) if ( TREE[i].p == NIL ) root = i;
  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");


  return 0;
}


Measured memory_bytes: 2088