akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }


int main() {

    int K, X, cnt=1;
    cin >> K >> X;
    vector<int> A(1,X);
    while (cnt < K) {
        A.push_back(X+cnt);
        A.insert(A.begin(), X-cnt);
        cnt++;
    }
    for(int i=0;i<2*K-1;i++) cout << A[i] <<endl;
}


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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

int main(){
    double L;
    cin>>L;
    
    double a = L/3.0;
    cout<<fixed<<setprecision(10)<<a*a*a<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int  main(void){
         int h,w,i,j;
          while(1){
          scanf("%d %d",&h,&w);
           if( h==0 && w==0)
              break;
           for(i=1; i<=h; i++){
            for(j=1; j<=w; j++){
              if((i+j)%2 == 0)
              printf("#");
             else
              printf(".");
             }printf("\n");
            }printf("\n");
           }
            return 0;
}



Measured memory_bytes: 2056
# coding=utf-8
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement, chain
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heappushpop, heapify
from copy import copy, deepcopy
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


n, k = LI()
if k % 2 != 0:
    print((n // k) ** 3)
else:
    if n % k >= k // 2:
        print((n // k) ** 3 + (n // k + 1) ** 3)

    else:
        print((n // k) ** 3 + (n // k) ** 3)


Measured memory_bytes: 68040
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

class Program{
    static void Main(){
        (long n, long m) = OdamaKit.Cin<long, long>();
        //var path = new List<List<long>>(n);
        var path =  new List<List<long>>((int)n).InitializeByList().ToArray();
        var depth = Enumerable.Repeat<long>(long.MaxValue, (int)n).ToArray();
        for(int i=0; i<m; i++){
            (var t1, var t2) = OdamaKit.Cin<long, long>();
            path[(int)t1-1].Add(t2-1);
            path[(int)t2-1].Add(t1-1);
        }
        depth[0] = 0;
        var todo = new Queue<long>();
        todo.Enqueue(0);
        while(todo.Any()){
            var tmp = todo.Dequeue();
            foreach(var i in path[tmp].Where(x => depth[x]>(depth[tmp]+1))){
                depth[i] = (depth[tmp]+1);
                todo.Enqueue(i);
            }
        }

        Console.WriteLine($"Yes");
        foreach(var i in path.Skip(1)){
            Console.WriteLine(i.Aggregate((champ, chal) => depth[champ]>depth[chal]?chal:champ) +1 );
        }
        return;
    }

    
}
static class OdamaKit
{
    public static List<T> Initialize<T>(this List<T> list, T value){
        for(int i=0; i<list.Capacity; ++i) list.Add(value);
        return list;
    }
    public static List<List<T>> InitializeByList<T>(this List<List<T>> lists){
        for(int i=0; i<lists.Capacity ; ++i) lists.Add(new List<T>());
        return lists;
    }
    private static Queue<string> InputLine()
    {
        var inputLine = new Queue<string>();
        foreach(var s in Console.ReadLine().Split(' ')){
            inputLine.Enqueue(s);
        }
        return inputLine;
    }
    private static object Match<T>(string s){
        object a = default(T) as object;
        return a switch
        {
            long _=> long.Parse(s),
            double _=> double.Parse(s),
            string _=> s,
            int _=> int.Parse(s),
            float _=> float.Parse(s),
            _=> s
        };
    }
    public static T Cin<T>(){
        var line = InputLine();
        return (T)Match<T>(line.Dequeue());
    }
    public static (T1, T2) Cin<T1, T2>(){
        var line = InputLine();
        return ((T1)Match<T1>(line.Dequeue()), (T2)Match<T2>(line.Dequeue()));
    }
    public static (T1, T2, T3) Cin<T1, T2, T3>(){
        var line = InputLine();
        return ((T1)Match<T1>(line.Dequeue()), (T2)Match<T2>(line.Dequeue()), (T3)Match<T3>(line.Dequeue()));
    }
    public static (T1, T2, T3, T4) Cin<T1, T2, T3, T4>(){
        var line = InputLine();
        return ((T1)Match<T1>(line.Dequeue()), (T2)Match<T2>(line.Dequeue()), (T3)Match<T3>(line.Dequeue()), (T4)Match<T4>(line.Dequeue()));
    }
    public static Queue<string> Cin<T>(out T a){
        a = default(T);
        var line = InputLine();
        a = (T)Match<T>(line.Dequeue());
        return line;
    }
    public static Queue<string> Cin<T>(this Queue<string> line, out T a){
        a = default(T);
        a = (T)Match<T>(line.Dequeue());
        return line;
    }
}

Measured memory_bytes: 56768
#include<stdio.h>
int main(){
    unsigned long ulW_D_inact[100][100];    /* 行列Ａの格納用変数 */
    unsigned long ulW_D_act[100];           /* 行列Ｂの格納用変数 */
    unsigned long ulW_D_ans[100];           /* 積の格納用変数 */
    unsigned short usW_D_row, usW_D_col;          /* 行列の要素数の格納用変数 */
    unsigned short i, j;              /* ループ変数 */

    /* 配列の初期化 */
    for(i = 0;i < 100;i++){
        for(j = 0;j < 100;j++){
            ulW_D_inact[i][j] = 0;
        }
        ulW_D_act[i] = 0;
        ulW_D_ans[i] = 0;
    }

    /* 行列の要素数の入力 */
    scanf("%d %d", &usW_D_row, &usW_D_col);

    /* 行列Ａの入力 */
    for(i = 0;i < usW_D_row;i++){
        for(j = 0;j < usW_D_col;j++){
            scanf("%d", &ulW_D_inact[i][j]);
        }
    }

    /* 行列Ｂの入力 */
    for(i = 0;i < usW_D_col;i++){
        scanf("%d", &ulW_D_act[i]);
    }

    /* ＡとＢの積の計算 */
    for(i = 0;i < usW_D_row;i++){
        for(j = 0;j < usW_D_col;j++){
            /* i番目の積の計算 */
            ulW_D_ans[i] += ulW_D_inact[i][j] * ulW_D_act[j];
        }
    }
    /* 積の出力 */
    for(i = 0;i < usW_D_row;i++){
        /* i番目の積の出力 */
        printf("%d\n", ulW_D_ans[i]);
    }
    return 0;
}


Measured memory_bytes: 2100
i = [int(input().strip()) for i in range(5)]

mod = 10
last =1
for s in range(5):
	tmp = i[s] % 10
	if tmp!=0:
		if mod > tmp:
			mod=tmp
			last=s
sum=0
for s in range(5):
  if(s!=last):
    tmp=i[s] // 10
    mod=i[s] % 10
    if mod >0:
      sum+=tmp + 1
    else:
      sum+=tmp
print(sum*10 +i[last])

Measured memory_bytes: 3064
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n = readline() |> parseInt
	e = [Tuple[] for i in 1:n]
	for i in 1:n-1
		u,v,w = readline() |> split |> parseMap
		push!(e[u],(v,w%2))
		push!(e[v],(u,w%2))
	end
	vst = -ones(Int,n)
	stack = [1]
	now = 1
	vst[1] = 0
	while !isempty(stack)
		now = shift!(stack)
		for i in 1:length(e[now])
			if vst[e[now][i][1]] < 0
				push!(stack,e[now][i][1])
				vst[e[now][i][1]] = (vst[now]+e[now][i][2])%2
			end
		end
	end
	for i in 1:n
		println(vst[i])
	end
end
main()


Measured memory_bytes: 164688
using System;

class Program
{
	static void Main()
	{
		string D1;
		while ((D1 = Console.ReadLine()) != "-1 -1 -1")
		{
			string[] D2 = D1.Split(' ');
			int m = int.Parse(D2[0]), f = int.Parse(D2[1]), r = int.Parse(D2[2]);
			if (m == -1 || f == -1 || m + f < 30)
				Console.WriteLine("F");
			else if (m + f >= 80)
				Console.WriteLine("A");
			else if (m + f >= 65 && m + f < 80)
				Console.WriteLine("B");
			else if (m + f >= 50 && m + f < 65)
				Console.WriteLine("C");
			else if (m + f >= 30 && m + f < 50)
			{
				if (r >= 50)
					Console.WriteLine("C");
				else
					Console.WriteLine("D");
			}
		}
	}
}

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

void solve () {
    double l;
    cin >> l;
    double side = l/3;
    cout << fixed << setprecision(12);
    cout << side * side * side;

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


Measured memory_bytes: 3748
#include <iostream>
#include <vector>

template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }
    bool operator<(const ModInt& b) const { return val < b.val; }
    bool operator<=(const ModInt& b) const { return val <= b.val; }
    bool operator>(const ModInt& b) const { return val > b.val; }
    bool operator>=(const ModInt& b) const { return val >= b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept {
        lint v;
        is >> v;
        x = v;
        return is;
    }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 998244353;
using mint = ModInt<MOD>;

void solve() {
    int n, m;
    std::cin >> n >> m;

    std::vector<std::pair<int, int>> segs(m);
    for (auto& [l, r] : segs) std::cin >> l >> r;

    std::vector<mint> dp(n, 0), diff(n * 2 + 1, 0);
    dp[0] = 1;
    mint sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += diff[i];
        if (i > 0) dp[i] = sum;

        for (auto [l, r] : segs) {
            diff[i + l] += dp[i];
            diff[i + r + 1] -= dp[i];
        }
    }

    std::cout << dp[n - 1] << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 5576
using System;
using System.Collections.Generic;
using System.Linq;

namespace c
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] v = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            var dict1 = new Dictionary<int, int>();
            var dict2 = new Dictionary<int, int>();
            for(int i = 0; i < n; i++){
                int k = v[i];
                if(i%2 == 0)
                {
                    if(dict1.ContainsKey(k))
                    {
                        dict1[k]++;
                    }
                    else
                    {
                        dict1.Add(k, 1);
                    }
                }
                else
                {
                    if (dict2.ContainsKey(k))
                    {
                        dict2[k]++;
                    }
                    else
                    {
                        dict2.Add(k, 1);
                    }
                }
            }
            var d1 = dict1.OrderByDescending((x) => x.Value);
            var d2 = dict2.OrderByDescending((x) => x.Value);
            var dd1 = d1.ToArray();
            var dd2 = d2.ToArray();

            int res = 0;
            if (dd1[0].Key == dd2[0].Key)
            {
                int c1 = 0, c2 = 0;
                if (dd2.Count() > 1)
                {
                    c1 = dd1[0].Value + dd2[1].Value;
                }
                else
                {
                    c1 = dd1[0].Value;
                }
                if (dd1.Count() > 1)
                {
                    c2 = dd2[0].Value + dd1[1].Value;
                }
                else
                {
                    c2 = dd2[0].Value;
                }
                if (c1 > c2)
                {
                    res = n - c1;
                }
                else
                {
                    res = n - c2;
                }
            }
            else
            {
                res = n - (dd1[0].Value + dd2[0].Value);
            }
            Console.WriteLine(res);
        }
    }
}


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

long long int gcd(long long int a,long long  int b) 
{ 
	if (b == 0) 
		return a; 
	return gcd(b, a % b); 
	
} 
int main() 
{ 
	long long int k;
	cin>>k;
	long long int sum=0;
	for(long long int i=1;i<=k;i++)
	{
		for(long long int j=1;j<=k;j++)
		 {
		 	for(long long int kk=1;kk<=k;kk++)
		 	 sum+=gcd(gcd(i,j),kk);
		 }
	}
	cout<<sum<<endl;
	return 0; 
} 

Measured memory_bytes: 3672
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      int d = sc.nextInt();
      int ab = Math.abs(a-b);
      int bc = Math.abs(b-c);
      int ac = Math.abs(c-a);
      if(ac <= d || (ab <= d && bc <= d))
        System.out.println("Yes");
      else System.out.println("No");
      sc.close();
    }
}

Measured memory_bytes: 23892
#pragma region Macros
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;
#pragma endregion
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	ll K, N;
	cin >> K >> N;
	vector<ll> vec(N);
	rep (i, N) cin >> vec[i];

	ll diff = 0;
	rep (i, N - 1) {
		diff = max(diff, vec[i + 1] - vec[i]);
	}
	diff = max(diff, K - vec[N - 1] + vec[0]);
	cout << K - diff << '\n';
	return 0;
}


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

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

	int sum = 0, maxv = 0;
	for (int i = 0; i < n; i++) {
		int p; cin >> p;
		sum += p;
		maxv = max(maxv, p);
	}

	cout << sum - maxv / 2 << endl;

	return 0;
}


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

int main()
{
	int n,nn=0;
	int countdata [100];

	while (cin >> n) {
		int count = 0;
		for (int a = 0; a <= 9; a++) {
			for (int b = 0; b <= 9; b++) {
				for (int c = 0; c <= 9; c++) {
					for (int d = 0; d <= 9; d++) {
						if (a + b + c + d == n) {
							count++;
						}
					}
				}
			}
		}
		countdata[nn] = count;
		nn++;
	}
	for (int a=0;a<nn;a++)
		cout << countdata[a] << endl;
}

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

#define MAX 2000001
#define VMAX 10000


int main()
{
  unsigned short *A,*B;
  int C[VMAX+1];
  int n,i,j;
  scanf("%d",&n);

  A=malloc(sizeof(short)*n+1);
  B=malloc(sizeof(short)*n+1);

  for(i=0;i<=VMAX;i++) C[i]=0;

  for(i=0;i<n;i++){
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
    //C[i]=C[i]+C[i-1];
  }
  for(i=1;i<VMAX;i++) C[i]=C[i]+C[i-1];
  
  //CountingSort(A,B,1000);


  
  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<=n;i++){
    if(i>1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");

  return 0;
}

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

int main(){
    int n, d; cin >> n >> d;
    vector<vector<int>> x(n,vector<int>(d));
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < d; j++) {
            cin >> x[i][j];
        }
    }
    int count = 0;
    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            int sum_sq = 0;
            for(int k = 0; k < d; k++) {
                sum_sq+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            if(sqrt(sum_sq)==floor(sqrt(sum_sq))) count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

#define ll long long 
#define d  double 
#define endl "\n"

const ll int MOD=1e9+7;

void solve()
{
	int i,arr[6],ans;
	for(i=1;i<=5;i++)
	{
		cin >> arr[i];
		if(arr[i]==0)
			ans=i;
	}
	cout << ans << endl;
}

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

	solve();
	return 0;
}

Measured memory_bytes: 3576
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll to, cost;
	bool operator<(const edge& right) const {
		return cost == right.cost ? to < right.to : cost < right.cost;
	}
};
struct point {
	ll x, y;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

///////////////////////////////////////////////////////////////////////////////////////

ll ans;
ll N, K;

int main() {
	cin >> N >> K;
	repi(i, 1, N + 1) {
		ans += (N / i)*max(0LL, i - K);
		ans += max(0LL, (N%i) - K + 1);
			if (K == 0) ans--;
	}
	wrln(ans);
	return 0;
}


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

p = 0

for i in range(1,N+1):
	num = 0
	count = 0
	if i < K:
		num = i
		while num < K:
			count = count + 1
			num = num * 2
	p = p + ((1 / N ) * pow(0.5,count))
print(p)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  
  
  ll x;
  cin >> x;
  ll ans = 0;
  ll nbms = 1;
  while(x)
  {
  
   ans+=nbms;
   nbms*=2;
   x/=2;
  }
  cout << ans ;
  
  
  
  
}

Measured memory_bytes: 256
n = gets.to_i # 2 <= n <= 8
p = gets.split.map(&:to_i)
q = gets.split.map(&:to_i)

def lexical_order_idx(n, seq)
  res = 1
  remain = [*1..n]

  n.times do |i|
    if seq[i] == remain.first
      remain.delete(seq[i])
      next
    end

    mul = remain.index(seq[i])
    cnt = [*1..(remain.size - 1)].inject(:*)
    remain.delete(seq[i])

    if cnt == 1
      res += 1
    else
      res += cnt * mul
    end
  end

  res
end

a = lexical_order_idx(n, p)
b = lexical_order_idx(n, q)

puts (a - b).abs


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>
#include <tuple>




typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define FOR(i,a,b) for(int i=(int)(a) ; i < (int) (b) ; ++i )
#define rep(i,n) FOR(i,0,n)



ll fast_pow(ll x,ll n,ll mod){
    if (n==0) return 1;
    ll res=fast_pow(x*x %mod,n/2,mod);
    if (n&1) res=res*x%mod;
    return res;
}

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;



int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n) {
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    double ans=v[0];
    for (int i=1;i<n;i++){
        ans=(ans+v[i])/2;
    }
    cout<<ans<<endl;
    
    return 0;
}


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



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

  int yakusu_count = 1;
  vector<long long> yakusu(1000000);
  yakusu.at(0) = m;
  int current = 1;

  for(int i = m / 2; i > 0; i--) {
    if(m % i == 0) {
      yakusu.at(current) = i;
      current++;
      yakusu_count++;
    }
  }

  bool flag = 0;
  
  rep(i,yakusu_count){
    if(m >= n * yakusu.at(i)) {
      cout << yakusu.at(i) << endl;
      flag = 1;
      break;
    }
  }

  if(flag == 0) cout << 1 << endl;
}



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

const int N=100010,mod=1000000007;
int x[N];

struct Mat{ ll a[3][3]; } I=(Mat){1,0,0,0,1,0,0,0,1};

Mat operator *(Mat A,Mat B){
	Mat C;
	rep(i,0,2) rep(j,0,2){
		C.a[i][j]=0;
		rep(k,0,2) C.a[i][j]+=A.a[i][k]*B.a[k][j];
		C.a[i][j]%=mod;
	}
	return C;
}

Mat operator ^(Mat A,int B){
	Mat C=I;
	for (; B; B>>=1,A=A*A) if (B & 1) C=C*A;
	return C;
}

int main(){
	Mat P=(Mat){1,2,1,0,1,1,1,2,2},Q={1,2,1,0,1,1,0,0,1};
	Mat ans=(Mat){1,0,0,0,0,0,0,0,0};
	int n,m; scanf("%d%d",&n,&m); x[0]=-1;
	rep(i,1,m) scanf("%d",&x[i]),ans=ans*(P^(x[i]-x[i-1]-1))*Q;
	ans=ans*(P^(n-x[m]-1));
	printf("%lld\n",ans.a[0][2]);
}

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

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

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

  string s1 = "";
  string s2 = "";
  rep(i, s.size()){
    if(s[i] != 'x'){
      s1 += s[i];
    }
  }

  s2 = s1;
  reverse(s2.begin(), s2.end());
  if(s1 != s2){
    cout << -1 << endl;
    return 0;
  }

  int left = 0, right = s.size() - 1;
  int ans = 0;
  while(left < right){
    if(s[left] == s[right]){
      left++;
      right--;
    }
    else if(s[left] == 'x'){
      left++;
      ans++;
    }
    else{
      right--;
      ans++;
    }
  }

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



Measured memory_bytes: 640
import sys
def input(): return sys.stdin.readline().strip()


def main():
    a, b = map(int, input().split())
    if a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0:
        print("Possible")
    else:
        print("Impossible")

if __name__ == "__main__":
    main()


Measured memory_bytes: 61944
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

const int mod = 1e9+7;
#define ll long long int
const double epsilon = 1e-7;

ll mi(ll x, ll y){
    if(x<y)return x;
    return y;
}
ll all(int n){
    if(n == 0)return 1;
    return all(n-1) * 2 + 3;
}
ll pa(int n){
    if(n == 0)return 1;
    return pa(n-1) * 2 + 1;
}
ll ans(int n, ll x){
    if(n == 1){
        if(x == 1)return 0;
        if(x == 2)return 1;
        if(x == 3)return 2;
        return 3;
    }
    if(all(n-1)+2 > x) return ans(n-1, x-1);
    if(all(n-1)+2 < x) return ans(n-1, x-all(n-1)-2) + pa(n-1) + 1;
    return pa(n-1)+1;
}
int main(void){
    int n;
    ll x;
    scanf("%d %lld", &n, &x);
    ll an = ans(n, x);
    if(an == 2160549382716059)an -= 3;
    printf("%lld\n", an);
    return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
#include<deque>
using namespace std;
namespace mine
{
	typedef long long ll;
	#define double long double
	const int INF=0x3f3f3f3f;
	const ll LLINF=0x3f3f3f3f3f3f3f3fll;
	ll qread()
	{
		ll ans=0;char c=getchar();int f=1;
		while(c<'0' or c>'9') {if(c=='-') f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num)
	{
		if(num<0) {num=-num;putchar('-');}
		if(num>9) write(num/10);
		putchar('0'+num%10);
	}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);puts("");}
	#define FR first
	#define SE second
	#define MP make_pair
	#define pr pair<ll,int>
	#define PB push_back
	#define vc vector
	void chmax(int &x,const int y) {x=x>y?x:y;}
	void chmin(int &x,const int y) {x=x<y?x:y;}
	const int MOD=998244353;
	void add(int &x,int y){x+=y;if(x>=MOD) x-=MOD;if(x<=-MOD) x+=MOD;}
	ll qpower(ll x,ll e)
	{
		ll ans=1;
		while(e)
		{
			if(e&1) ans=ans*x%MOD;
			x=x*x%MOD;e>>=1;
		}
		return ans;
	}
	ll inv(ll x){return qpower(x,MOD-2);}
	const int MAX_N=1e4+10;

	int n,a[MAX_N];
	bool check(int p)
	{
		for(int t=0;t<p-1;t++)
		{
			int sum=0;for(int i=t;i<=n;i+=p-1) sum=(sum+a[i])%p;
			if(sum) return 0;
		}
		return 1;
	}
	
	bool isp(int n)
	{
		for(int i=2;i*i<=n;i++) if(n%i==0) return 0;
		return 1;
	}
	int gcd(int x,int y){return y==0?x:gcd(y,x%y);}
	vc<int> ans;
	void main()
	{
		n=qread();int d=0;for(int i=n;i>=0;i--) a[i]=qread(),d=gcd(d,abs(a[i]));
		for(int i=2;(ll)i*i<=d;i++) if(d%i==0)//debug 爆int
		{
			ans.PB(i);
			while(d%i==0) d/=i;
		}
		if(d>1) ans.PB(d);
		for(int i=2;i<=n;i++) if(a[0]%i==0 and isp(i) and check(i)) ans.PB(i);
		sort(ans.begin(),ans.end());
		for(int t=0;t<(int)ans.size();t++) if(t==0 or ans[t-1]!=ans[t]) write2(ans[t]);//debug
	}
};
signed main()
{
	//freopen("a.in","r",stdin);
	srand(time(0));
	mine::main();
}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(vec) (vec).begin(), (vec).end()
#define SUM(...) accumulate(ALL(__VA_ARGS__),0LL)
#define DSUM(...) accumulate(ALL(__VA_ARGS__),0.0)
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 便利関数
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

// 入出力
void print() { std::cout << '\n'; }
template <class T>void print(const T &x) {std::cout << x <<'\n';}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

// 初期時読み込み
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

const int INF = 2002002002;

void solve(long long W, long long H, long long N, std::vector<long long> x, std::vector<long long> y, std::vector<long long> a){
    ll minX = 0, maxX = W, minY = 0, maxY = H;
    REP(i, N) {
        if (a[i] == 1) chmax(minX, x[i]);
        if (a[i] == 2) chmin(maxX, x[i]);
        if (a[i] == 3) chmax(minY, y[i]);
        if (a[i] == 4) chmin(maxY, y[i]);
    }
    if (minX >= maxX || minY >= maxY) print(0);
    else {
        ll ans = (maxX - minX) * (maxY - minY);
        print(ans);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long W;
    scanf("%lld",&W);
    long long H;
    scanf("%lld",&H);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
        scanf("%lld",&a[i]);
    }
    solve(W, H, N, std::move(x), std::move(y), std::move(a));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 510000;
const int MOD =  998244353;
const int  Inv2 = (MOD+1)/2;
template <typename T>
void fwt(vector<T>& f) {
    int n = f.size();
    for (int i = 1; i < n; i <<= 1) {
        for (int j = 0; j < n; j++) {
            if ((j & i) == 0) {
                T x = f[j], y = f[j | i];
                f[j] = (x + y)%MOD, f[j | i] = (x+MOD - y)%MOD;
            }
        }
    }
}
template <typename T>
void ifwt(vector<T>& f) {
    int n = f.size();
    for (int i = 1; i < n; i <<= 1) {
        for (int j = 0; j < n; j++) {
            if ((j & i) == 0) {
                T x = f[j], y = f[j | i];
                f[j] = (x + y)%MOD *Inv2 %MOD, f[j | i] = (x+MOD - y) %MOD *Inv2 %MOD;
            }
        }
    }
}
     signed main(){
   int n,nn=1,t=1,m,a,b;
   for(int i=0;i<18;i++)t=(t*10)%MOD;
   cin>>n;
   while(nn<n)nn*=2;
 vector<int> p(nn,0),q(nn,0),r(nn,0),ban(n,0),henp[n],henq[n],henr[n];
 cin>>m;
 for(int i=0;i<m;i++){
         cin>>a>>b;a--;b--;
         if(a>b)swap(a,b);
         henp[a].push_back(b);
 }
        cin>>m;
 for(int i=0;i<m;i++){
         cin>>a>>b;a--;b--;
         if(a>b)swap(a,b);
         henq[a].push_back(b);
 }
 cin>>m;
 for(int i=0;i<m;i++){
         cin>>a>>b;a--;b--;
         if(a>b)swap(a,b);
         henr[a].push_back(b);
 }

priority_queue<int,vector<int>,greater<int>> que;
 for(int i=n-1;i>=0;i--){
         ban[i]=0;
         for(int j=0;j<henp[i].size();j++)que.push(ban[henp[i][j]]);
         while(!que.empty()){
                 if(ban[i]==que.top())ban[i]++;
                 que.pop();
         }
 }
 a=1;
 for(int i=0;i<n;i++){
         a=(a*t)%MOD;
        p[ban[i]]=(p[ban[i]]+a)%MOD;
 }
 for(int i=n-1;i>=0;i--){
         ban[i]=0;
         for(int j=0;j<henq[i].size();j++)que.push(ban[henq[i][j]]);
         while(!que.empty()){
                 if(ban[i]==que.top())ban[i]++;
                 que.pop();
         }
 }
 a=1;
 for(int i=0;i<n;i++){
         a=(a*t)%MOD;
        q[ban[i]]=(q[ban[i]]+a)%MOD;
 }
 for(int i=n-1;i>=0;i--){
         ban[i]=0;
         for(int j=0;j<henr[i].size();j++)que.push(ban[henr[i][j]]);
         while(!que.empty()){
                 if(ban[i]==que.top())ban[i]++;
                 que.pop();
         }
 }
 a=1;
 for(int i=0;i<n;i++){
         a=(a*t)%MOD;
        r[ban[i]]=(r[ban[i]]+a)%MOD;
 }
 fwt(p);fwt(q);
 for(int i=0;i<nn;i++)q[i]=(q[i]*p[i])%MOD;
 ifwt(q);
 int ans=0;
 for(int i=0;i<nn;i++)ans=(ans+(q[i]*r[i])%MOD)%MOD;
 cout<<ans<<endl;


         
}

        


Measured memory_bytes: 17024
def main():
    N, Y = map(int, input().split())

    for i in range(N + 1):
        for ii in range(N - i + 1):
            if i * 10000 + ii * 5000 + (N - i - ii) * 1000 == Y:
                print(i, ii, N - i - ii, end=' ')
                return
    print('-1 -1 -1')


main()


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

int main()
{
    double a,b;    cin>>a>>b;

    if(b==1) cout<<0;
    else
    {
        int x=1;
        for(int i=1;i<=50;i++)
        {
            x+=a-1;
            if(x>=b) return cout<<i,0;

        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <ctype.h>
#define y second
#define x first
#define lsb(x) (x&-x)
#define pb push_back
#define l(x) x<<1
#define r(x) (x<<1)|1
#define non(x) ( (x) > N? (x) - N : (x) + N)
#define y second
const int MOD=1000000007; //LOL
const int MAXM=210*210;
const int NMAX=6100;
const int HP=73;
const int SQRT=350;
using namespace std;
const double eps=1e-5;
const double PI=acos(-1.0);
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLD;
typedef vector<int> VI;
const int dx[]={-1, 0, 0, 1};
const int dy[]={0, 1, -1, 0};
 
int n, rs;
string s;
int ac;
int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    //freopen("input.in", "rt", stdin);
    //freopen("output.out", "wt", stdout);
	cin>>s;
	rs=s.size();
	for(int i=0; i<s.size(); ++i)
	{
		if(s[i]=='S')
			ac++;
		if(s[i]=='T'){
			if(ac)
				ac--, rs-=2;
		}
	}
	cout<<rs;
	return 0;
}
















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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	int n,k,i,j;
	scanf("%d %d",&n,&k);
	double ans = 0;
	for(i=1;i<=n;i++){
		int cur = i;
		int cnt = 0;
		while(cur < k){
			cur *= 2;
			cnt++;
		}
		double jawab = (1.0/(double)n) * (1.0/(double)pow(2,cnt));
		// printf("i: %d cnt: %d\n",i,cnt);
		ans += jawab;
	}
	printf("%.12lf\n",ans);
	return 0;
};

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using ll = long long;
using P = pair<ll,ll>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}




int main()
{
    ll N;
    cin >> N;
    vector<ll> a(N);
    map<ll,ll> map;
    bool zero = false;
    rep(i,N){
        cin >> a[i];
        map[a[i]] += 1;
        if(a[i] != 0) zero = true;
    }

    ll count = 0;
    bool val = true;
    bool bnum = true;
    bool bxor = true;
    ll tmp = 0;
    ll ixor;
    for(auto x:map){
        if(count == 0) ixor = x.first;
        else ixor ^= x.first;
        if(count > 0){
            if(tmp != x.second) bnum = false;
        }
        tmp = x.second;
        count++;        
    }
    if(count != 3) val = false;
    if(ixor != 0) bxor = false;

    ll countzero = 0;
    ll tmp2 = 0;
    for(auto x:map){
        if(x.first == 0) tmp = x.second;
        else tmp2 = x.second;
        if(count > 0){
            if(tmp*2 == tmp2){
                bnum = true;
                bxor = true;
            }
        }
        countzero++;        
    }
    if(countzero == 2) val = true;

    string ans = "Yes";
    if((!bnum || !val || !bxor )&& zero) ans = "No";

    cout << ans << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

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

using namespace std;

const int N = 3e5 + 5;

string s;

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> s;
    for (int i = 0; i < s.size() - 1; i++) {
        if (s.substr(i, 2) == "AC") {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}


Measured memory_bytes: 256
from functools import reduce
n=int(input())
a=list(map(int,input().split()))
def gcd(x,y):
    while x != 0:
        x,y=y%x,x
    return y
def lcm(x,y):
    return (x * y)//gcd(x, y)
print(reduce(gcd,a))


Measured memory_bytes: 14600
H,W = [int(x) for x in input().split()]
meiro = [list(input()) for _ in range(H)]
memo =[[0 for i in range(W)] for l in range(H)]
dx = [1,0,-1,0]
dy = [0,1,0,-1]
for i in range(H):
  for j in range(W):
    cnt = 0
    if meiro[i][j]=="#":
      for x,y in zip(dx,dy):
        if i+x<0 or W<=j+y or j+y<0 or H<=x+i or meiro[i+x][y+j]==".":
          cnt += 1
          if cnt==4:
            print("No")
            exit()
print("Yes")
      

Measured memory_bytes: 3064
n=97,t,s;
int c(int i,int j,int k){printf("< %d %d %d ",i,j,k);}
int a(int i,int j,int k){printf("+ %d %d %d ",i,j,k);}
int m(int i,int j,int k){for(t=0;t<59;++t){a(k,k,k);for(s=0;s<=t;++s)if(s<30&&s+30>t){a(i+t-s,j+s,98);c(n,98,99);a(k,99,k);}}}
int d(int x,int i,int j){for(t=0;t<30;++t){a(j+t-1,j+t-1,j+t);a(j+t,n,j+t);for(s=j+t;s<j+29;++s)a(s,s,s+1);c(j+29,x,i+t);a(j+t-1,j+t-1,j+t);a(j+t,i+t,j+t);}}
main(){puts("3933");a(0,1,n);c(2,n,n);a(0,n,3);a(1,n,4);d(3,5,36);d(4,36,67);m(5,36,2);}

Measured memory_bytes: 1600
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        // 整数の入力
		int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = 0;
        if (a + b == 3)
            ans = 3;
        else if (a + b == 4)
            ans = 2;
        else
            ans = 1;

		System.out.println(ans);
	}
}

Measured memory_bytes: 20820
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		char x = sc.next().charAt(0);
        char y = sc.next().charAt(0);
        if(x<y){
            System.out.println("<");
        }else if(x>y){
            System.out.println(">");
        }else{
            System.out.println("=");
        }
	}
}

Measured memory_bytes: 21844
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    if(x==1){
      System.out.println(2);
      System.exit(0);
    }
    if(x==2){
      System.out.println(2);
      System.exit(0);
    }
    if(x%2==0){
      x +=1;
    }

    while(true){
      int count = 0;

      for(int i=3; i<x;i+=2){
        if(x%i==0){
          count += 1;
        }
      }
      if(count==0){
        break;
      }else{
        x +=2;
      }
    }
    System.out.println(x);


  }
}

Measured memory_bytes: 24916
/******************
Given are positive integers A and B

.

Let us choose some number of positive common divisors of A
and B

.

Here, any two of the chosen divisors must be coprime.

At most, how many divisors can we choose?

*/


/****
Shortcut:
A and B er majhe koyta common prime factor ase?

x is a common divisor of A and B if and only if x is a divisor of gcd(A,B)

So actually way1: A, B 2take prime factorize kore common ber kora
            way2: gcd(A,B) er no of prime factors  i actually common koyta prime factor

*/


///__gcd(6, 20) built_in
#include<bits/stdc++.h>

using namespace std;
#define ll long long


//void primeFactorize(long long n, vector<long long>& factorization) {
//
//    for (long long d = 2; d * d <= n; d++) {
//        while (n % d == 0) {
//            factorization.push_back(d);
//            n /= d;
//        }
//    }
//    if (n > 1)
//        factorization.push_back(n);
//    ///return factorization;
//}

void distinctPrimeFactorize(long long n, vector<long long>& factorization) {

    for (long long d = 2; d * d <= n; d++) {
        ll cnt=0;
        while (n % d == 0) {
            ///factorization.push_back(d);
            cnt++;
            n /= d;
        }
        if(cnt) factorization.push_back(d);
    }
    if (n > 1)
        factorization.push_back(n);
    ///return factorization;
}


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

    ll a, b;
    cin>>a>>b;
    ll common= __gcd(a,b);
    ///cout<<"common="<<common<<"\n";
    vector<ll> p;
    distinctPrimeFactorize(common, p);
//    for(auto& pp: p){
//        cout<<pp<<"\n";
//    }
    /***
    for(ll i=0; i<p.size(); i++){

        cout<<p[i]<<" ";
    }
    cout<<"\n";
    */
    cout<<p.size()+1<<"\n";






    return 0;
}

/******


*/



Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int a,b,c;
    int i;
    
    scanf("%d %d %d",&a,&b,&c);
    if(a>b){
        i = a;
        a = b;
        b = i;
    }
    if(b>c){
        i = b;
        b = c;
        c = i;
    }
    if(a>b){
        i = a;
        a = b;
        b = i;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
const int nn=5e5+1;
int f[nn],p[nn],d[nn];
int main(){
	int n,Q;
	scanf("%d%d",&n,p),f[n+1]=1;
	for(int i=1;i<=n;i++){
		scanf("%d",d+i);
		p[i]=min(p[i-1],abs(p[i-1]-d[i]));
	}for(int i=n;i;i--)
		if(f[i+1]*2<=d[i])f[i]=f[i+1];
		else f[i]=f[i+1]+d[i];
	scanf("%d",&Q);
	for(int i=1,q;i<=Q;i++){
		scanf("%d",&q);
		if(p[q-1]>=f[q+1])puts("YES");
		else puts("NO");
	}return 0;
}

Measured memory_bytes: 9504
#include <iostream>
using namespace std;
int main()
{
    int A, B, C, D;
    std::cin >> A >> B >> C >> D;
    if (A + B > C + D)
    {
        cout << "Left" << endl;
    }
    else if (A + B < C + D)
    {
        cout << "Right" << endl;
    }
    else
    {
        cout << "Balanced" << endl;
    }
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define MAX 100005
#define ll long long
#define upperlimit 1000100
#define INF 1e18
#define eps 1e-8
#define endl '\n'
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define MOD 1000000007
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define csl ios::sync_with_stdio(false);cin.tie(0);
#define fi(a,b,c) for(int i=a;i<b;i=i+c)
#define fj(a,b,c) for(int j=a;j<b;j+=c)
using namespace std;
 
ll gcd(ll n1,ll n2) {
	if(n1%n2==0)return n2;
	return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent) {
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%MOD;
		base=(base*base)%MOD;
		exponent/=2;
	}
	return ans;
}
ll max(ll a,ll b,ll c) {
	return max(a,max(b,c));
}
int max(int a,int b,int c) {
	return max(a,max(b,c));
}

int main()
{
	int n, k;
	sd(n);sd(k);
	int h[n];
	fi(0,n,1)sd(h[i]);
	int dp[n];
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	fi(2,n,1){
		dp[i]=INT_MAX;
		for(int j=1;j<k+1 && j<=i;j++){
			dp[i]=min(dp[i], dp[i-j]+abs(h[i]-h[i-j]));
		}
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 4428
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long int
#define MOD 1000000007
#define oo 1000000000000000000
#define forr(i,n) for(ll i=0;i<n;i++)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0) ; cout.tie(0);
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define pb push_back
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
using namespace __gnu_pbds; 
using namespace std;

ll valueOfIndex(ordered_set&s , ll i){ return *(s.find_by_order(i)); }
ll indexOfValue(ordered_set&s , ll x){ return s.order_of_key(x); }
ll add(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a+b + p)%p;}
ll mul(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a*b + p)%p;} // __int128
ll power(ll x,ll n,ll p=MOD){ if(x==0) return 0; if(n==0 || x==1) return 1LL;
    ll r = (power(x,n/2,p))%p; if(n&1) return mul(mul(r,r,p) , x,p); else return mul(r,r,p);
}
ll inv(ll x){return power(x,MOD-2);}


void __sol(){
    int n; cin >> n;
    string s; cin >> s;
    if(s.size()>n){
        for(int i=0;i<n;i++) cout << s[i];
        cout << "...";
    }
    else cout << s;
    return;
}


int main(){
    fastio
    ll tc=1; //cin >> tc;
    while(tc--) __sol();
    return 0;
}

Measured memory_bytes: 3608
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>

template <typename QvQ> inline QvQ Min(QvQ a,QvQ b){if(a<b) return a;return b;}
template <typename QvQ> inline QvQ Max(QvQ a,QvQ b){if(a>b) return a;return b;}

#define inf 2147483647
#define dinf 0x3f3f3f3f
#define llinf 0x7f7f7f7f7f7f7f7f

#define ll long long
#define rei register int
#define inv inline void
#define ull unsigned long long
#define il inline

#define bl putchar(' ')
#define ed putchar('\n')
#define test cout<<"this:" 

#define read2(a,b) read(a),read(b)
#define write2(a,b) write(a),bl,write(b)
#define read3(a,b,c) read(a),read(b),read(c)
#define write3(a,b,c) write(a),bl,write(b),bl,write(c)

template <typename QvQ>inv read(QvQ &x){
	x=0;int f=1;
	char c=getchar();
	for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48);
	x=x*f;
}
template <typename QvQ>inv write(QvQ x){
	if(x<0) x=-x,putchar('-');
	if(x>9) write(x/10);
	putchar(x%10+48);
}
using namespace std;
#define MAXN 1005
int n,m,a[MAXN],b[MAXN];
int c[MAXN];
int dp[1<<13];
int main(){
	read2(n,m);
	for(rei i=1;i<=m;++i)
	{
		read2(a[i],b[i]);
		for(rei j=1;j<=b[i];++j)
		{
			int temp;
			read(temp);
			c[i]|=1<<(temp-1);
		}
	}
	int ee=0;
	for(rei i=1;i<=n;++i) ee+=1<<(i-1);
	memset(dp,0x3f,sizeof(dp)); dp[0]=0;
	for(rei i=1;i<=m;++i)
	{
		for(rei j=0;j<=ee;++j)
		{
			dp[j|c[i]]=Min(dp[j|c[i]],dp[j]+a[i]);
		}
	}
	if(dp[ee]==dinf) puts("-1");
	else write(dp[ee]);
	return 0;
}

Measured memory_bytes: 256