akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[30000];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

int N, K;
int A[500];
bool keisan(int k) {
	int a[500];
	rep(j, N) a[j] = A[j] % k;
	pakuri_sort(N, a);
	int x = 0, y = N - 1;
	int tmp = a[0] + a[N - 1] - k;
	int kazu = a[0] + k - a[N - 1];
	while (x + 1 < y) {
		if (tmp <= 0) {
			tmp += a[++x];
			kazu += a[x];
		}
		else {
			tmp += a[--y] - k;
			kazu += k - a[y];
		}
	}
	if (kazu / 2 <= K) {
		printf("%d", k);
		return true;
	}
	return false;
}

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


	cin >> N >> K;
	int goukei = 0;
	rep(i, N) {
		cin >> A[i];
		goukei += A[i];
	}

	int yakusuu[30000];
	int M = 0;
	int sq = sqrt(goukei);
	rep1(i, sq) {
		if (goukei % i == 0) {
			yakusuu[M++] = i;
			if (i * i != goukei) {
				if (keisan(goukei / i)) return 0;
			}
		}
	}

	for (int i = M - 1; i >= 0; i--) {
		if (keisan(yakusuu[i])) return 0;
	}

	Would you please return 0;
}

Measured memory_bytes: 256
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  ll N,K;
  cin >> N >> K;
  bool flag = true;
  if(N >= K)N = N%K;
  while(flag){
    N = abs(N-K);
    if(N<=K/2){
      flag = false;
    }
  }
  cout << N << endl;

}


Measured memory_bytes: 256
package main

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

func main() {
	// sc.Split(bufio.ScanWords)
	S := readLine()
	s, ir, il := len(S), 0, -1
	A := make([]int, s)
	for i, c := range S {
		if c == 'R' {
			if il != -1 {
				A[il-1] = (il-ir)/2 + (i-il)/2 + (il-ir)%2
				A[il] = (il-ir)/2 + (i-il)/2 + (i-il)%2
				ir = i
				il = -1
			}
		} else if il == -1 {
			il = i
		}
	}
	A[il-1] = (il-ir)/2 + (s-il)/2 + (il-ir)%2
	A[il] = (il-ir)/2 + (s-il)/2 + (s-il)%2
	for i, a := range A {
		if i == s-1 {
			fmt.Printf("%d\n", a)
		} else {
			fmt.Printf("%d ", a)
		}
	}
}

var sc = bufio.NewScanner(os.Stdin)
var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func nextInt() int {
	i, _ := strconv.ParseInt(nextLine(), 10, 64)
	return int(i)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2816
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=1e6;
ll d[mm];
int main()
{
	ll n,m,i,j,k,kk,a,b,t;
    cin>>n;
    for(i=0;i<n-1;i++)
    {
    	cin>>a;
    	d[a]++;
	}
	for(i=1;i<=n;i++)
	cout<<d[i]<<endl;
}

Measured memory_bytes: 4668
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
	int N, A, B; cin >> N >> A >> B;
	vector<long long>v(N);
	for (int i = 0; i < N; i++)cin >> v[i];
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());

	vector<long long>w;
	double ave = 0;
	for (int i = 0; i < A; i++) {
		ave += v[i];
		w.push_back(v[i]);
	}
	ave /= A;

	cout << fixed << setprecision(7) << ave << endl;

	long long ans = 0;
	for (int a = A; a <= B; a++) {
		if (w.back() != v[a - 1])break;

		int cnt1 = 0, cnt2 = 0;
		for (int i = 0; i < a; i++) {
			if (v[i] == w.back())cnt1++;
		}
		for (int i = a; i < N; i++) {
			if (v[i] == w.back())cnt2++;
		}

		//cerr << cnt1 << " " << cnt2 << endl;
		long long tmp = 1;
		for (int i = cnt1 + cnt2; i > cnt1; i--) {
			tmp = tmp * i / (cnt1 + cnt2 - i + 1);
		}
		ans += tmp;

		if (v.front() != v[a - 1])break;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  int ans = 0;
  rep(i,n-1){
    if(s[i]==s[i+1])ans++;
  }
  cout << min(n-1,ans+k*2) << endl;
}

Measured memory_bytes: 3296
/**
    why I'm too lazy?
**/
#include <bits/stdc++.h>

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define pp pop_back
#define ll long long
#define ld long double
#define OK puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

inline int min(int a, int b) {
    return (a > b) ? b : a;
}

inline int max(int a, int b) {
    return (a > b) ? a : b;
}

const int N = 2e5 + 10;
const int inf = 1e9 + 7;
const ll linf = 1e17 + 7;

ll a, b;

main() {
    cin >> a >> b;
    if(abs(a - b) <= 1)puts("Brown");
    else puts("Alice");
}



Measured memory_bytes: 256
/**
 *      ABC 102 C
 *      author  : kyomukyomupurin
 *      created : 2018/08/28
**/

#include <bits/stdc++.h>
using namespace std;

int main(){
    int N; cin >> N;
    vector<int> v;
    for (int i = 0; i < N; ++i) {
        int x; cin >> x;
        x = x - i - 1; v.push_back(x);
    }
    sort(v.begin(), v.end());
    
    int b = v[N / 2];

    //cout << b << endl;
    long long answer = 0;
    for (int i = 0; i < N; ++i) {
        answer += abs(v[i] - b);
    }
    cout << answer << endl;

    return 0;

}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" ";
#define LOGE if(DEBUG)cout<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }



void func(std::string S){

    string tmp[7]={"SAT","FRI","THU","WED","TUE","MON","SUN"};

    REP(i,0,7){
        if(S==tmp[i]){
            cout<<i+1<<endl;
            return;
        }
    }

}

int main(){
    // cout << fixed << setprecision(5);

    std::string S;
    std::cin >> S;
    func(S);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b) - 1; i >= (a); --i)
#define sz(a) (int)a.size()
#define de(c) cout << #c << " = " << c << endl
#define dd(c) cout << #c << " = " << c << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;

typedef db T;
const db eps = 1e-9 , pi = acosl(-1.);
int sgn(T x){return (x>eps)-(x<-eps);}
struct P{
  T x,y; P(){} P(T x,T y):x(x),y(y){}
  P operator - (const P&b) const {return P(x-b.x,y-b.y);}
  P operator + (const P&b) const {return P(x+b.x,y+b.y);}
  T operator * (const P&b) const {return x*b.x+y*b.y;}
  T operator / (const P&b) const {return x*b.y-y*b.x;}
  P operator * (const T&k) const {return P(x*k,y*k);}
  P operator / (const T&k) const {return P(x/k,y/k);}
};
T norm(P a){return a*a;}
T abs(P a) {return sqrtl(norm(a));}
P proj(P p,P a,P b){return (b-a)*((p-a)*(b-a)/norm(b-a))+a;}
P reflect(P p,P a,P b){return proj(p,a,b)*2-p;}
T cross(P o,P a,P b){return (a-o)/(b-o);}
int crossOp(P o,P a,P b){return sgn(cross(o,a,b));}
bool onPS(P p,P s,P t){return sgn((t-s)/(p-s))==0&&sgn((p-s)*(p-t))<=0;}
struct L{ P s,t;L(){} L(P s,P t):s(s),t(t){}};
P insLL(L a,L b){ // line x line
  P s = a.s - b.s , v = a.t - a.s , w = b.t - b.s;
  db k1 = s / w , k2 = w / v;
  if(sgn(k2) == 0) return abs(b.s - a.s) < abs(b.t - a.s) ? b.s : b.t;
  return a.s + v * (k1 / k2);
}
bool isSS(L a,L b){ // seg x seg , replace x->y to accelerate
  T c1=(a.t-a.s)/(b.s-a.s),c2=(a.t-a.s)/(b.t-a.s);
  T c3=(b.t-b.s)/(a.s-b.s),c4=(b.t-b.s)/(a.t-b.s);
  return sgn(c1) * sgn(c2) <= 0 && sgn(c3) * sgn(c4) <= 0 &&
    sgn(max(a.s.x,a.t.x) - min(b.s.x,b.t.x)) >= 0 &&
    sgn(max(b.s.x,b.t.x) - min(a.s.x,a.t.x)) >= 0 &&
    sgn(max(a.s.y,a.t.y) - min(b.s.y,b.t.y)) >= 0 &&
    sgn(max(b.s.y,b.t.y) - min(a.s.y,a.t.y)) >= 0;
}

P a, b, c, d;

int main() {
	std::ios::sync_with_stdio(0);
	std::cin.tie(0);
	int q;
	cin >> q;
	cout << setiosflags(ios::fixed);
	cout << setprecision(10);
	while(q--) {
		cin >> a.x >> a.y >> b.x >> b.y;
		cin >> c.x >> c.y >> d.x >> d.y;
		L x = L(a, b), y = L(c, d);
		P r = insLL(x, y);
		cout << r.x << " " << r.y << endl;
	}
	return 0;
}


Measured memory_bytes: 3328
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String tempStr = "";
		String ansStr = "";
		for (int i = 0; i < s.length(); i++) {
			tempStr = s.substring(i, i + 1);
			if (tempStr.equals("0") | tempStr.equals("1")) {
				ansStr += tempStr;
			} else {
				if (ansStr.equals("")) {
					continue;
				} else {
					ansStr = ansStr.substring(0, ansStr.length() - 1);
				}
			}
		}
		System.out.println(ansStr);
	}
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, x, t;
    cin >> n >> x >> t;
    cout << (n + x - 1) / x * t << endl;
    return 0;
}


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

using namespace std;

int n, m;
vector<vector<int>> nodes(100001);
int memo[100001] = {};
int dp(int node)
{
    if (nodes[node].empty())
        return 0;
    if (memo[node] > 0)
        return memo[node];
    int best = -1;
    for (int i = 0; i < nodes[node].size(); i++)
    {
        best = max(dp(nodes[node][i]) + 1, best);
    }
    memo[node] = best;
    return best;
}

int main(void)
{
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);

    int fipt, sipt;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; i++)
    {
        scanf("%d %d", &fipt, &sipt);
        nodes[fipt].push_back(sipt);
    }
    int best = -1;
    for (int i = 1; i <= n; i++)
    {
        best = max(best, dp(i));
    }
    
    printf("%d\n", best);
}

Measured memory_bytes: 11648
def func(a):
  cr = 0
  num = a
  while(1):
    if num % 2:
      return cr
    else:
      num = num//2
      cr +=1

n = input()
l = list(map(int,input().split()))

maxnum = max(l)

for i in range(int(n)):
  cr = func(l[i])
  maxnum = min(maxnum,cr)
  
print(maxnum)

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

int main(){
  while(1){
    string s;
    cin>>s;
    if(s=="-"){
      break;
    }
    int m;
    cin>>m;
    for(int i=0;i<m;i++){
      string tmp=s;
      s="";
      int h;
      cin>>h;
      for(int j=h;j<(int)tmp.size();j++){
        s+=tmp[j];
      }
      for(int j=0;j<h;j++){
        s+=tmp[j];
      }
    }
    cout<<s<<endl;
  }
  return 0;
}



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

int main(){
    double a,b;
    cin >> a >> b;
    cout << a/b << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  rep(i, n-2) {
    if(s[i] == 'A') {
      if(s[i+1] == 'B' && s[i+2] == 'C') ++ans;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<long long int> A, B, C; 
long long int N, K; 
void solve1(){
	for(long long int i = 0; i < N; i++){
		long long int tmp = K + 2 * N - 2 - 2 * i; 
		if(tmp > K + N) tmp -= N; 
		A.push_back(tmp); 
	}
	for(long long int i = 0; i < N; i++){
		B.push_back(K + N + i); 
	}
	for(int i = 0; i < N; i++){
		cout << A[i] << " " << B[i] << " " << A[i] + B[i] + N/2 - K + 1 << endl; 
	}
}
void solve2(){
	for(long long int i = 0; i < N/2; i++){
		long long int tmp = K + N - 2 - 2 * i; 
		A.push_back(tmp); 
	}
	for(long long int i = 0; i < N/2; i++){
		A.push_back(A.at(i) + 1); 
	}
	for(long long int i = 0; i < N; i++){
		B.push_back(K + N + i); 
	}
	for(int i = 0; i < N/2; i++){
		cout << A[i] << " " << B[i] << " " << A[i] + B[i] + N/2 - K + 1 << endl; 
	}
	for(int i = N/2; i < N; i++){
		cout << A[i] << " " << B[i] << " " << A[i] + B[i] + N/2 - K << endl; 
	}
}
int main(){
	cin >> N >> K; // Kが初項 	
	if(N < 2 * K - 1){
		cout << -1 << endl; return 0; 
	}
	if(N % 2 == 1) solve1(); 
	if(N % 2 == 0) solve2(); 
}

Measured memory_bytes: 3956
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <numeric>
#include <map>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    vector<int> A(n);
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> A[i];
        if ((i+1)%2 == 1 && A[i]%2 == 1)
        {
            cnt++;
        }
        
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3608
#include<stdio.h>

int main (){
  int x[5];
  int x_length = sizeof x / sizeof x[0];
  for(int i = 0;i < x_length;i++){
    scanf("%d",&x[i]);
  }

  for(int i = 0;i < x_length;i++){
    if(x[i] == 0){
      printf("%d",i+1);
    }
  }
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  for (int i=0; i <N ; i++)
    cin>> X.at(i);
  sort(X.begin(),X.end());
  reverse (X.begin(),X.end());
  if( N%2 == 1){
    N++;
    X.push_back(0);
  }
  int A=0;
  int B=0;
  for (int i=0; i < N/2; i++){
    A +=X.at(0);
    B +=X.at(1);
    reverse (X.begin(),X.end());
    X.pop_back();
    X.pop_back();
    reverse (X.begin(),X.end());
  }
  cout<< A-B <<endl;
}

Measured memory_bytes: 256
N, L = map(int, input().split())

mylist = []

negagivecheck = 0

for i in range(N):
  mylist += [i+L]
  if i+L < 0:
    negagivecheck =1
  
if negagivecheck == 0:
  print(sum(mylist[1:]))
else:
  if 0 in mylist:
    print(sum(mylist))
  else:
    print(sum(mylist[:-1]))

Measured memory_bytes: 3060
N = int(input())
Ws = [input() for _ in range(N)]

if not all([Ws.count(w) == 1 for w in Ws]):
    print('No')
else:
    f = True
    t = Ws[0][-1]
    for w in Ws[1:]:
        f &= w[0] == t
        t = w[-1]
    print('Yes' if f else 'No')

Measured memory_bytes: 3064
# agc002_b.py
N, M = map(int,input().split())
flg = [False]*N
flg[0] = True
cnt = [1]*N
for i in range(M):
    x, y = map(int,input().split())
    if flg[x-1]:
        if cnt[x-1]>1:
            flg[y-1] = True
        elif cnt[x-1]==1:
            flg[y-1] = True
            flg[x-1] = False
        else:
            continue
        cnt[x-1]-=1
        cnt[y-1]+=1
    else:
        if cnt[x-1]>0:
            cnt[x-1]-=1
            cnt[y-1]+=1


print(flg.count(True))

Measured memory_bytes: 10376
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,w;
  cin>>n>>w;
  vector<pair<long long,long long> > st(n);
  for(int i =0;i<n;i++)
  {
    long long t,v;
    cin>>t>>v;
    st[i] = make_pair(t,v);
  }
  sort(st.begin(),st.end());
  vector<long long> dp (w+1,-1);
  dp[0] = 0;
  long long ans{-1};
  for(int i =0;i<n;i++)
  {
    for(int j =w;j>=0;j--)
    {
      if(dp[j] != -1 && j+st[i].first <= w)
      {
        dp[j+st[i].first] = max(dp[j+st[i].first],dp[j]+st[i].second);
        ans = max(ans,dp[j+st[i].first]);
      }
    }
  }
  //for(int i =0;i<=w;i++)
    //cout<<i<<' '<<dp[i]<<'\n';
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3956
#include <iostream>
    #include <fstream>
    #include <bits/stdc++.h>
    #include <map>
    #define pb push_back
    #define ll long long
    using namespace std;
    int N,M;
    ll ans;
    const int dime=100010;
    bool viz[dime];
    ll dist[dime];
    vector <int> G[dime],GT[dime];
    int grad_intern[dime];
    vector <int> sorted;
    void TopologicalSort()
    {
        int i;
        queue<int> Q;
        for(i=1;i<=N;i++)
        {
            if(grad_intern[i]==0)
            {
                Q.push(i);
                sorted.pb(i);
                viz[i]==true;
            }
        }
        while(!Q.empty())
        {
            int node;
            node=Q.front();
            Q.pop();
            for(i=0;i<G[node].size();i++)
            {
                int next=G[node][i];
                grad_intern[next]--;
                if(grad_intern[next]==0)
                {
                    if(viz[next]==false)
                    {
                        viz[next]=true;
                        Q.push(next);
                        sorted.pb(next);
                    }
                }
            }
        }
    }
    int main()
    {
        int i,j;
        cin>>N>>M;
        for(int i=0;i<M;i++)
        {
            int f,s;
            cin>>f>>s;
            G[f].pb(s);
            GT[s].pb(f);
            grad_intern[s]++;
        }
        TopologicalSort();
        for(i=1;i<(int)sorted.size();i++)
        {
            for(j=0;j<(int)GT[sorted[i]].size();j++)
                dist[sorted[i]]=max(dist[sorted[i]],1+dist[GT[sorted[i]][j]]);
            ans=max(ans,dist[sorted[i]]);
        }
        cout<<ans;
        return 0;
    }

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

int main(void) {
	int num = 0;
	string s;
	cin >> s;
	for (int i = 0; i < 4; i++) {
		if (s[i] == '+') num++;
		else if(s[i] == '-') num--;
	}
	cout << num << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 100

int main(){
  int A[N];
  int i,a,min, count = 0;
  int flag = 1;

  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&A[i]);
  }
  
  while(flag){
    flag=0;
    for(i=a-1;i>0;i--){
      if(A[i]<A[i-1]){
	min = A[i];
	A[i]=A[i-1];
	A[i-1] = min;
	flag = 1;
	count += 1;
      }
    }
  }

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

Measured memory_bytes: 600
/*---> 04 April 2020 <--- > 20:03:24 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=1e5+5;
bool isP(string &s){
	int n=s.size();
	for(int i=0;i<n/2;i++){
		if(s[i]!=s[n-i-1])
			return false;
	}
	return true;
}
int32_t main(){__
	int n;
	cin>>n;
	double s=(double)n/3;
	double ans=(double)s*s*s;
	cout<<setprecision(6)<<fixed<<ans<<"\n";
return 0;
}

Measured memory_bytes: 256
<?php
  $ary = array();
  while (true) {
    list($a, $op, $b) = explode(" ", trim(fgets(STDIN)));
    if ($op == "?") {
      break;
    }
    $ary_2 = array($a, $op, $b);
    array_push($ary, $ary_2);
  }
  $count = count($ary);
  foreach ($ary as $key => $val) {
    $a = $val[0];
    $b = $val[2];
    if ($val[1] == "+") {
      print floor($a + $b);
    } else if ($val[1] == "-") {
      print floor($a - $b);
    } else if ($val[1] == "*") {
      print floor($a * $b);
    } else {
      print floor($a / $b);
    }
    if ($key+1 < $count) {
      print "\n";
    }
  }
?>

Measured memory_bytes: 6640
#include<algorithm>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <string.h>
using namespace std;
int main(void){
	string s,t;
	cin>>s>>t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if(s<t) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++)
#define S(v) sort(v.begin(), v.end())
#define print(v) for(auto i:v)cout<<i<<" "
const ll N = 1e5 + 7;
ll dp[N][3], a[N][3];

ll f(ll i, ll n, ll x){
    if(dp[i][x] != -1){
        return dp[i][x];
    }
    if(i != n-1){
        if(x == 0){
            dp[i][x] = a[i][x] + max(f(i+1, n, 1), f(i+1, n, 2));
            return dp[i][x];
        }
        else if(x == 1){
            dp[i][x] = a[i][x] + max(f(i+1, n, 0), f(i+1, n, 2));
            return dp[i][x];
        }
        else{
            dp[i][x] = a[i][x] + max(f(i+1, n, 1), f(i+1, n, 0));
            return dp[i][x];
        }
    }
    else {
        if(x == 0){
            dp[i][x] = a[i][x];
            return dp[i][x];
        }
        else if(x == 1){
            dp[i][x] = a[i][x];
            return dp[i][x];
        }
        else{
            dp[i][x] = a[i][x];
            return dp[i][x];
        }
    }

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
	
    ll n;
    cin>>n;
    loop(i,0,n){
        loop(j,0,3){
            cin>>a[i][j];
            dp[i][j] = -1;
        }
    }    
    cout<<max(f(0, n, 0),max(f(0, n, 1), f(0, n, 2)));
} 

Measured memory_bytes: 14472
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC153A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b,x;
            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);

            if (a%b==0)
                x = a / b;

            else 
                x = a/b + 1;


            Console.WriteLine(x);

            Console.ReadKey();


        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int a,b;
	cin>>a>>b;
	if(a+b>24){
		cout<<a+b-24<<endl;
	}else if (a+b==24){
		cout<<0<<endl;
	}else{
		cout<<a+b<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	max := b - a - 1
	h := (max + 1) * (max / 2)
	if max%2 == 1 {
		h += max/2 + 1
	}
	fmt.Println(h - a)
}


Measured memory_bytes: 512
line = gets.split
if line.size == 1
    line = gets
end
A = gets.split
B = gets.split

ans = 0
B.each_index do |i|
    count = 0
    A.each do |a|
        if B[i] == a
            count += 1
            i += 1
        end
    end
    ans = [ans, count].max
end
puts ans

Measured memory_bytes: 6828
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        tmp = 0
        for k in range(D):
            tmp += (X[i][k] - X[j][k]) ** 2
        tmp = tmp ** 0.5
        if tmp.is_integer():
            ans += 1
print(ans)


Measured memory_bytes: 3188
use std::collections::BinaryHeap;
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).ok();
    let mut it = buf.split_whitespace();
    let n = it.next().unwrap().parse::<usize>().unwrap();
    let m = it.next().unwrap().parse::<usize>().unwrap();
    let a = (0..n).map(|_| it.next().unwrap().parse::<i64>().unwrap()).collect::<Vec<_>>();
    let mut qu = BinaryHeap::from(a);
    for _i in 0..m {
        let v = qu.pop().unwrap();
        qu.push(v/2);
    }
    println!("{}", qu.iter().sum::<i64>());
}


Measured memory_bytes: 6396
#include <iostream>
#include <vector>
#include <tuple>
#include <cmath>
using namespace std;

int main()
{
	int n;
	cin >> n;
	auto a = vector<tuple<int, int, int>>(n);
	for(auto&& s : a){
		int t, x, y;
		cin >> t >> x >> y;
		s = tie(t, x, y);
	}
	bool ans = true;
	int dx, dy, dt;
	dx = dy = dt = 0;
	for(auto i = 0; i < n; ++i){
		int t, x, y;
		tie(t, x, y) = a[i];
		if(!((x + y) % 2 == t % 2 && abs(dx - x) + abs(dy - y) <= t - dt)){
			ans = false;
			break;
		}
		dx = x;
		dy = y;
		dt = t;
	}
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 1408
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		boolean[][] kk=new boolean[n][61];
		long mod=1000000007;
		for(int i=0; i<n; i++){
			long s=sc.nextLong();
			for(int j=60; j>=0; j--){
				if((s & 1)==1){
					kk[i][j]=true;
				}else{
					kk[i][j]=false;
				}
				s>>=1;
			}
		}
		long[][] sum=new long[n+1][61];
		for(int i=n-1; i>=0; i--){
			for(int j=0; j<=60; j++){
				if(kk[i][j]){
					sum[i][j]=sum[i+1][j]+1;
				}else{
					sum[i][j]=sum[i+1][j];
				}
			}
		}
		long ans=0;
		for(int i=0; i<n; i++){
			long count=1;
			for(int j=60; j>=0; j--){
				if(kk[i][j]){
					ans+=(n-1-i-sum[i+1][j])*count;
				}else{
					ans+=sum[i+1][j]*count;
				}
				count*=2;
				ans%=mod;
				count%=mod;
			}
		}
		System.out.println(ans);
	}
}


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

#define int int64_t
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,n) for(int i=1; i<=(n); ++i)
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define gsort(x,n) sort(x,x+n,greater<int>())
#define rv(s) reverse((s).begin(),(s).end())
#define abs(a) llabs(a)
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)

int n,m,ans=0,x,y,dp[100010];
bool mem[100010];
vector<int> f[100010];

int List(int x){
    if(mem[x]) return dp[x];
    ++mem[x];
    
    int sum = 0;
    rep(i,f[x].size()) sum = max(sum,List(f[x][i])+1);

    return dp[x] = sum;
}

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

    cin>>n>>m;

    rep(i,m){
        cin>>x>>y;
        f[x].push_back(y);
    }

    ans = 0;
    reps(i,n){
        ans = max(ans,List(i));
    }

    cout<<ans<<'\n';
}

Measured memory_bytes: 8704
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
graph = [[] for _ in range(n + 1)]
for i in range(m):
    x, y = map(int, readline().split())
    graph[x].append(y)
dp = [-1] * (n + 1)


def check(v):
    if dp[v] != -1:
        return dp[v]
    if graph[v]:
        dp[v] = max(check(u) for u in graph[v]) + 1
    else:
        dp[v] = 0
    return dp[v]


print(max(check(v) for v in range(1, n + 1)))


Measured memory_bytes: 104088
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main(){
  int N;
  cin >> N;
  vector<int> a(3*N);
  rep(i, 3*N){
    cin >> a.at(i);
  }
  sort(all(a));
  reverse(all(a));
  int64_t pow = 0;
  rep(i, N){
    pow += a.at(2*i+1);
  }
  cout << pow << endl;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main(void)
{
  char s[5],c[5];
  int count=0;
  scanf("%s %s",s,c);
  for(int i=0;i<3;i++){
    if(s[i]==c[i])count++;
  }

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


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;

int main() {
    int N,M;
    cin>>N>>M;
    int X=(N-M)*100+1900*M;
    for(int i=0;i<M;i++) X*=2;
    cout<<X<<endl;
}

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

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

    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }
    sort( vec.begin(), vec.end() );
    int max = vec.back();
    int min = vec.front();
    cout << max - min << endl;
}

Measured memory_bytes: 256
M, D = map(int, input().split())

res = 0
for i in range(1, M+1):
    for j in range(1, D+1):
        if j >= 22:
            if i == int(str(j)[0]) * int(str(j)[1]) and int(str(j)[1]) >= 2 and int(str(j)[0]) >= 2 :
                res += 1


print(res)


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

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

int main()
{
    int A, B;
    cin >> A >> B;
    cout << (A >= 13 ? B : (A >= 6 ? B / 2 : 0)) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
    char grid[52][52];
    int h, w, i, j, cnt=0;
    char newline[52];
    scanf("%d %d", &h, &w);
    scanf("%c", &newline[0]);
    for(i=1; i<=h; i++) {
        for(j=1; j<=w; j++) {
            scanf("%c", &grid[i][j]);
        }
        scanf("%c", &newline[i]);
    }
    for(i=1; i<=h; i++) {
        for(j=1; j<=w; j++) {
            if(grid[i][j]=='#') {
                if(grid[i][j]!=grid[i][j-1] && grid[i][j]!=grid[i-1][j] && grid[i][j]!=grid[i][j+1] && grid[i][j]!=grid[i+1][j])
                    cnt++;
            }
        }
    }
    if(cnt>0)
        printf("No");
    else
        printf("Yes");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <queue>
#include <cmath>

using namespace std;

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

int main(){
    int N;
    cin >> N;
    vector<int> a(N), b(N);
    ll A_sum = 0, B_sum = 0;
    ll cnt1 = 0, cnt2 = 0;
    for(int i = 0; i < N; ++i){
        cin >> a[i];
        A_sum += a[i];
    }
    for(int i = 0; i < N; ++i){
        cin >> b[i];
        B_sum += b[i];
        if(a[i] < b[i]){
            cnt1 += (b[i] - a[i]) / 2;
            if((b[i] - a[i]) % 2 != 0){
                cnt1++;
            }
        }
        if(a[i] > b[i]){
            cnt2 += a[i] - b[i];
        }
    }

    cerr << cnt1 << " " << cnt2 << endl;
    
    if(A_sum > B_sum){
        cout << "No\n";
        return 0;
    }
    // 変更回数
    ll n = B_sum - A_sum;
    cerr << n << endl;
    
    if(max(cnt1, cnt2) <= n){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	int[] num = new int[45];

	private void run() {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		num[0] = num[1] = 1;
		for (int i = 2; i <= n; i++) {
			num[i] = num[i - 1] + num[i - 2];
		}
		System.out.println(num[n]);
	}

}

Measured memory_bytes: 17356
#!/usr/bin/env python3
from math import gcd

n, m = map(int, input().split())
s, t = input(), input()
g = n * m // gcd(n, m)
if all(s[i * g // m] == t[i * g // n] for i in range(gcd(n, m))):
    print(g)
else:
    print(-1)


Measured memory_bytes: 9328
import numpy as np
N = int(raw_input())
A = np.array(map(long, raw_input().split()))
B = np.array(map(long, raw_input().split()))

ans = 0
if A.sum() < B.sum():
  ans = -1
else:
  D = A-B
  E = D[D<0]
  e = sum(E)
  F = np.sort(D[D>0])
  ans = len(E)
  for f in reversed(F):
    if e >= 0:
      break
    e += f
    ans += 1
print ans


Measured memory_bytes: 25068
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

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

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

  int n;
  cin >> n;
  ll a[n];
  for(int i = 0; i < n; i++) cin >> a[i];

  ll dp[n + 1][2];
  dp[0][0] = dp[0][1] = 0;
  dp[1][0] = a[0];  dp[1][1] = -INF_LONG;
  for(int i = 2; i <= n; i++){
    dp[i][0] = max(dp[i - 1][0] + a[i - 1],
        dp[i - 1][1] + a[i - 1]);
    dp[i][1] = max(dp[i - 1][0] + -2 * a[i - 2] + -a[i - 1],
        dp[i - 1][1] + 2 * a[i - 2] + -a[i - 1]);
  }

  ll ans = max(dp[n][0], dp[n][1]);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)

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

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

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,m,n,i,f=0,j,ans=0,k,sum=0;
    cin >> k >> n ;
    ll a[n];
    rep(i,n) cin >> a[i] ;
    ll d[n];
    for(i=0;i<n-1;++i)
    {
        d[i+1]=a[i+1]-a[i];
        sum+=d[i+1];
    }
    d[0]=k+a[0]-a[n-1];
    sum+=d[0];
    sort(d,d+n);
    sum-=d[n-1];
    cout << sum ;
    
    return 0;
}

Measured memory_bytes: 3328
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        x: isize,
        k: isize,
        d: isize,
    }

    let quot = isize::abs(x) / d;
    let remain = isize::abs(x) % d;

    let ans = if k < quot {
        isize::abs(x) - isize::abs(d * k)
    } else {
        let k2 = k - quot;
        if k2 % 2 == 0 {
            isize::abs(x) - isize::abs(d * quot)
        } else {
            isize::abs(isize::abs(x) - isize::abs(d * quot) - d)
        }
    };

    println!("{}", ans);
}


Measured memory_bytes: 2156
fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let mut n: usize = iter.next().unwrap().parse().unwrap();
    let k: usize = iter.next().unwrap().parse().unwrap();
    let _a: Vec<usize> = (&mut iter).take(n).map(|x| x.parse().unwrap()).collect();
    
    n -= k;
    let ret = if n == 0 {
        1
    } else {
        1 + (n as f64 / (k as f64 - 1f64)).ceil() as u64
    };
    println!("{}", ret);
}


Measured memory_bytes: 6396
#include <iostream>
using namespace std;
int main(void){
    int N,M;
    cin >> N >> M;
    
    int ykt,hgt,ngt;
    int sum;
    
    for(int i = 0; i <= N;i++) {
        ykt = i;
        for(int j = 0; j <= N - i;j++) {
            hgt = j;
            ngt = N - i - j;
            sum = ykt * 10000 + hgt * 5000 + ngt * 1000;
            if(sum == M) { cout << ykt << " " << hgt << " " << ngt; return 0;}
        }
    }
    cout <<"-1 -1 -1";
    return 0;
}

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

set<ll> prime_factorize(ll n) {
  set<ll> res;
  for (ll a = 2; a * a <= n; ++a) {
    if (n % a != 0) continue;
    ll ex = 0;  // 指数

    // 割れる限り割り続ける
    while (n % a == 0) {
      ++ex;
      n /= a;
    }

    // その結果を push
    res.insert(a);
  }

  // 最後に残った数について
  if (n != 1) res.insert(n);
  return res;
}

int main() {
  ll a, b;
  cin >> a >> b;
  set<ll> as = prime_factorize(a);
  set<ll> bs = prime_factorize(b);
  set<ll> ans;
  for (auto &s : as) {
    if (bs.count(s)) {
      ans.insert(s);
    }
  }

  cout << ans.size() + 1 << endl;
  return 0;
}

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

const int N = 1e5 + 5;
const int M = 2e5 + 5;

int fir[N] , ne[M] , to[M] , cnt , x , y , A[N] , B[N] , fa[N] , id[N] , n , m;
long long S[N] , More[N];

void add(int x , int y) {
  ne[++ cnt] = fir[x];
  fir[x] = cnt;
  to[cnt] = y;
}

void link(int x , int y) {
  add(x , y);
  add(y , x);
}

#define Foreachson(i , x) for(int i = fir[x];i;i = ne[i])

int getf(int x) {
  return (fa[x] == x) ? x : (fa[x] = getf(fa[x]));
}

bool cmp(int x , int y) {
  return A[x] < A[y];
}

bool vis[N];

int main() {
  scanf("%d%d" , &n , &m);
  int it = 0;
  for(int i = 1;i <= n;++ i) {
    scanf("%d%d" , &A[i] , &B[i]);
    More[i] = A[i] = max(0 , A[i] - B[i]);
    fa[i] = id[i] = i;
    S[i] = B[i];
  }
  for(int i = 1;i <= m;++ i) {
    scanf("%d%d" , &x , &y);
    link(x , y);
  }
  sort(id + 1 , id + n + 1 , cmp);
  for(int i = 1;i <= n;++ i) {
    int x = id[i];
    vis[x] = 1;
    Foreachson(j , x) {
      int V = to[j];
      if(!vis[V])
	continue;
      int a = getf(x) , b = getf(V);
      if(a == b)
	continue;
      fa[b] = a; S[a] += S[b];
      More[a] = min(More[a] , More[b] + max(0LL , A[x] - More[b] - S[b]));
    }
  }
  int now = getf(1);
  cout << S[now] + More[now] << endl;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
int main(){
  int w,a,b;
  cin >> w >> a >> b;
  if(a <= b){
    cout << max(b-(a+w), 0) << endl;
  }else{
    cout << max(a-(b+w), 0) << endl;
  }
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };



void solve() {
	int N, M; cin >> N >> M;
    int left = 1, right = N;
    rep(i, M){
        int L, R; cin >> L >> R;
        left = max(left, L);
        right = min(right, R); 
    }

    int res = right - left + 1;
    if(res < 0) res = 0;

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/
signed main(){
	int n;cin>>n;
	vi a(n);
	rep(i,n)cin>>a[i];

	int sum=0;
	rep(i,n)sum+=a[i];
	int tmp=0;
	for(int i=1;i<n;i+=2){
		tmp+=a[i];
	}
	
	vi x(n,-1);
	x[0]=(sum-tmp*2)/2;
	rep(i,n-1){
		x[(i+1+n)%n]=a[i]-x[(i+n)%n];
	}
	rep(i,n){
		cout<<x[i]*2<<endl;
	}
	return 0;
}


Measured memory_bytes: 4740
using System;

class Program {
	static void Main(string[] args) {
		string[] input = Console.ReadLine().Split();
		int n = int.Parse(input[0]), a = int.Parse(input[1]), b = int.Parse(input[2]);
		string s = Console.ReadLine();
		int pass = 0, bcnt = 1;
		for(int i = 0; i < s.Length; i++) {
			if(s[i] == 'a') {
				if(pass < a + b) {
					Console.WriteLine("Yes");
					pass++;
				}else {
					Console.WriteLine("No");
				}
			}else if(s[i] == 'b') {
				if((pass < a + b) && bcnt <= b) {
					Console.WriteLine("Yes");
					pass++;
				} else {
					Console.WriteLine("No");
				}
				bcnt++;
			}else {
				Console.WriteLine("No");
			}
		}
	}
}


Measured memory_bytes: 7384
N=int(input())
A=list(map(int,input().split()))
A.sort()
n=N//2
MOD=10**9+7
ans=(2**n)%MOD

import sys
if N==1:
    print(1)
    sys.exit()

f=1
if N%2==1:
    for i in range(N):
        if A[i] != 2*(-(-i//2)):
            f=0
            break
else:
    for i in range(N):
        if A[i] != 1+(i//2)*2:
            f=0
            break

print([0,ans][f])

Measured memory_bytes: 14008
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P; typedef unsigned long long int ull;
const ll mod = 1000000007;
const int inf = 1e9 + 7;
const ll linf = 1LL << 60;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define REP(i,m,n) for(int i=(m);i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define vec vector<int>
#define vecb vector<bool>
#define vecd vector<double>
using str = string;
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr) {
	if (firstItr < 0 || secondItr>int(str.size() - 1))return str;
	while (firstItr < secondItr) {
		swap(str[firstItr], str[secondItr]);
		firstItr++; secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str) {
	int itr = 0; std::string res;
	while (itr < int(str.size())) {
		char tmp = str[itr++];
		int length = 1;
		while (itr <int(str.size()) && str[itr] == tmp) { ++itr; ++length; }
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
std::string split(std::string str, size_t first_itr, size_t second_itr) {
	std::string tmp;
	for (size_t i = first_itr; i < second_itr + 1; i++) {
		tmp.push_back(str.at(i));
	}
	return tmp;
}



int main() {
	int n; cin >> n;
	vec v(n, 0);
	rep(i, n - 1) {
		int tmp; cin >> tmp;
		v[tmp - 1]++;
	}
	rep(i, n) {
		cout << v[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 4044