akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        int k=sc.nextInt();
        ArrayList<String>po=new ArrayList<>();
        for(int i=1;i<=5&&i<=s.length();i++){
            for(int j=0;j<s.length()-i+1;j++){
                po.add(s.substring(j,j+i));
            }
        }
        ArrayList<String> list = new ArrayList<String>(new HashSet<>(po));
        Collections.sort(list);
        System.out.println(list.get(k-1));
    }
}


Measured memory_bytes: 28496
#pragma GCC Optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define lp(i,begin,end) for (int i=begin;i<end;i++)
const int N=30,M=N*N,OO=0x3f3f3f3f;
vector<int>v;
int sz;
string s;
ll toll(int p1,int p2){
    ll ret=0;
    lp(i,p1,p2+1){
        ret*=10;
        ret+=s[i]-'0';
    }
    return  ret;
}
int main(){
    cin>>s;     sz=s.length();  sz--;
    int lst;    ll sum=0;
    lp(i,0,(1<<sz)){
        lst=0;
        lp(j,0,sz)
            if(i&(1<<j)){sum+=toll(lst,j);  lst=j+1;}
        sum+=toll(lst,sz);
    }
    cout<<sum;
}


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

#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef long double ld;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

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

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

vector<bool> vis(200010,false);
vector<vector<int>> g(200010);

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n,m;
    cin>>n>>m;

    set<P> rel;

    rep(i,m){
        int a,b;
        cin>>a>>b;
        --a;--b;

        if(rel.find(P(a,b))!=rel.end() || rel.find(P(b,a))!=rel.end())continue;

        g[a].emplace_back(b);rel.insert(P(a,b));//db2(a,b);ln;
        g[b].emplace_back(a);rel.insert(P(b,a));//db2(b,a);ln;

    }

    int mx_n = -1;
    rep(i,n){
        if(vis[i])continue;

        int n_connected_element = 1;
        stack<int> st;
        st.push(i);
        vis[i] = true;

        while(!st.empty()){
            int cur = st.top();st.pop();

            for(int j = 0 ; j < g[cur].size(); ++j){
                int nx = g[cur][j];

                if(vis[nx])continue;

                //db2(cur,nx);ln;

                st.push(nx);
                vis[nx] = true;
                ++n_connected_element;
            }
        }

        chmax(mx_n,n_connected_element);
    }

    cout<<mx_n<<endl;

    //cout <<fixed<<setprecision(16)<< << endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    return 0;
}


Measured memory_bytes: 33104
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll a,b,m; cin >> a >> b >> m;
	vl s(a), t(b);
	ll ans = linf;
	rep(i,a) cin >> s[i];
	rep(i,b) cin >> t[i]; 
	rep(i,m){
		ll x,y,c; cin >> x >> y >> c; x--; y--;
		chmin(ans,s[x]+t[y]-c);
	}
	sort(all(s)); sort(all(t));
	chmin(ans,s[0]+t[0]);
	cout << max(0LL,ans) << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
typedef double dd;
#define pb push_back
#define mp make_pair
#define endl "\n"
ll const M = 1000000007;
dd const pi = acos(-1);
ll const inf = 2e18;
ll const N = 200001;
int main()
{
    fast;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    dd i,j,t,a,b,h,m;
    cin >> a >> b >> h >> m;
    dd  p1 = 6*m,p2 = 30*h + (1/2.0)*m,angle = max(p1,p2) - min(p1,p2);
    if(angle > 180)
      angle = 360 - angle;
    angle *= (pi/180);
    cout<<setprecision(15)<<fixed<<sqrt(a*a + b*b - 2*a*b*cos(angle))<<endl;
    return 0;
}    

Measured memory_bytes: 4188
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, a, b;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    while(cin >> n >> a >> b){
        vector<ll> dp(n + 1, 1ll << 60);
        dp[0] = 0;
        REP(i, n) {
            int x;
            cin >> x;
            vector<ll> nxt(n + 1, 1ll << 60);
            REP(j, n + 1) {
                if (j < x) {
                    chmin(nxt[j], dp[j] + a);
                    chmin(nxt[x], dp[j]);
                } else {
                    chmin(nxt[j], dp[j] + b);
                }
            }
            swap(dp, nxt);
        }
        cout << *min_element(ALL(dp)) << endl;
    }
    return 0;
}


Measured memory_bytes: 512
InputData=[]
while True:
    try:
        in1,in2 = map(int,raw_input().split(" "))  # Python2
        if in1==0 and in2==0 : break
        InputData.append([in1,in2])
    except EOFError:
        break

for i in range(len(InputData)):
    in1,in2 = InputData[i]
    x = int(in1) * int(in2)
    y = (int(in1) + int(in2)) * 2
    print(str(x) + " " + str(y))

Measured memory_bytes: 6376
/** これを翻訳している間、あなたはあなたの人生のいくつかの貴重な瞬間を無駄にしました **/
#include<bits/stdc++.h>
using namespace std;

#define rep(i,x,y) for(int i=x;i<y;i++)
#define repr(i,x,y) for(int i=x;i>=y;i--) 
#define int long long
#define pb push_back
#define ff first
#define ss second
#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)

using pii = pair<int,int>;
using vi = vector<int>;
using vii = vector<pair<int,int>>;

constexpr int mod = 1000000007;
constexpr int N = 2e8 + 5;
constexpr int inf = 1e18 , eps = 1e-6; 


void Onigiri()
{
  int n,x,m;
  cin>>n>>x>>m;
  int mpp[m];
  memset(mpp,-1,sizeof(mpp));
  int a=x;
  vi v;
  v.push_back(a);
  mpp[a]=0;
  int ans=0;
  for(int i=1;i<n;i++)
  {
    int na=(a*a)%m;
    if(mpp[na]==-1)
    {
      v.push_back(na);
      mpp[na]=i;
      a=na;
    }
    else{
      //cout<<"repeating at "<<mpp[na]<<" with size="<<sz(v)<<endl;
      int left=n-sz(v);
      int circ=left/(sz(v)-mpp[na]);
      int pre=left%(sz(v)-mpp[na]);
      //cout<<circ<<" "<<pre<<endl; 
      for (int j = 0; j < sz(v); ++j)
      {
        ans+=v[j];
      }

      for (int j = mpp[na]; j < sz(v); ++j)
      {
        ans+=v[j]*circ;
      }
      for (int j = mpp[na]; j < mpp[na]+pre; ++j)
      {
        ans+=v[j];
      }
      cout<<ans;
      return;
    }
  }  
  cout<<accumulate(all(v),0LL);
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifdef Zoro
   freopen("/home/pritish/Competitive/in", "r", stdin);
   freopen("/home/pritish/Competitive/out", "w", stdout);
   #endif  
 
   int t=1; 
   ///cin>>t;
 
   while(t--)
   {Onigiri();cout<<"\n";}

   cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;
   return 0;
}

Measured memory_bytes: 4672
#include <cstdio>
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;

map<int, int> primeFactor(ll in) {
	ll orig = in;
	map<int, int> ans;
	if (in < 3) return ans;
	ll a = 1;
	while (a*a <= in) a *= 2;
	for (int b = 2; b <= a; b++) {
		while (in % b == 0) {
			in /= b;
			ans[b]++;
		}
	}
	if (in != 1 && in != orig) ans[in]++;
	return ans;
}

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

	for (int i = X; i < 1e5+10; i++) {
		map<int, int> p = primeFactor(i);
		if (p.size() == 0){
			cout << i << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
  int n,a,b,c,d[100];
  scanf("%d %d %d %d",&n,&a,&b,&c);
  for(int i=0;i<n;i++){
    scanf("%d",d+i);
  }
  sort(d,d+n);
  reverse(d,d+n);
  int ans = 0;
  int cost = a;
  int calorie = c;
  for(int i=0;i<n;i++){
    cost+=b;
    calorie+=d[i];
    ans = max(ans,calorie/cost);
  }
  printf("%d\n",ans);
  return 0;
}

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

dic = {}
s = str(input())
for i in range(len(s)):
  if s[i] not in dic:
    dic[s[i]] = 1
  else:
    dic[s[i]] += 1

K = list(dic.keys())
K.sort()
for i in range(1,N):
  temp = str(input())
  for j in range(len(K)):
    if K[j] not in temp:
      dic[K[j]] = 0
      continue
    if temp.count(K[j]) < dic[K[j]]:
      dic[K[j]] = temp.count(K[j])

ans = ""
for i in range(len(K)):
  while dic[K[i]] > 0:
    ans += K[i]
    dic[K[i]] -= 1
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>

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

    std::vector<std::pair<int, int>> pairs;
    for(int i = 0; i < m; ++i){
        int a, b;
        std::cin >> a >> b;
        pairs.push_back(std::make_pair(a, b));
        pairs.push_back(std::make_pair(b, a));
    }

    std::vector<int> preNodes;
    for(int i = 2; i <= n; ++i){
        preNodes.push_back(i);
    }

    int count = 0;
    do{
        std::vector<int> nodes{1};
        nodes.insert(nodes.end(), preNodes.begin(), preNodes.end());        

        bool flg = true;
        int i = 1;
        while(flg && i < n){
            auto interest = std::make_pair(nodes.at(i - 1), nodes.at(i++));
            flg = pairs.end() != std::find(pairs.begin(), pairs.end(), interest);
        }
        
        if(flg){
            ++count;
        }
    }while(std::next_permutation(preNodes.begin(), preNodes.end()));

    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define oo 666666666
#define ll long long
#define ld long double

ll DP[100005];
ll A[100005];

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for(int i=1; i<=n; i++)
        cin>>A[i],DP[i]=oo;

    DP[0]=oo;
    DP[1]=0;
    for(int i=2; i<=n; i++)
        DP[i]=min(DP[i-1]+abs(A[i]-A[i-1]), DP[i-2]+abs(A[i]-A[i-2]));

    cout<<DP[n];
}


Measured memory_bytes: 1920
#設定
import sys
input = sys.stdin.buffer.readline

from collections import defaultdict

def getlist():
	return list(map(int, input().split()))


#処理内容
def main():
	#前処理
	N = int(input())
	A = getlist()
	D = defaultdict(int)
	for i in A:
		D[i] += 1
	L = []
	for i in D:
		L.append(i)
	L = sorted(L)
	#print(L)
	
	#貪欲
	ans = 0
	for i in range(len(L)):
		a = L[-1 - i]
		if a == 2 ** (a.bit_length() - 1):
			ans += int(D[a] // 2)
		else:
			b = 2 ** a.bit_length() - a
			m = min(D[a], D[b])
			ans += m
			D[a] -= m
			D[b] -= m

	#出力
	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 57456
#!/usr/bin/env python3
 
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n, k = LI()
a = LI()
for _ in range(k):
    lst = [0]*(n+1)
    for i in range(n):
        lst[max(i - a[i], 0)] += 1
        lst[min(i + a[i] + 1, n)] -= 1
    a = list(accumulate(lst))[:-1]
    for i in range(n):
        if a[i] != n:
            break
    else:
        print(*a)
        quit()
print(*a)

Measured memory_bytes: 180520
#include <iostream>

using namespace std;

int main() {
  const int a[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1};
  
  int x, y;
  cin >> x >> y;
  
  if (a[x] == a[y])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
string o,e;
int main(){
    cin >> o >> e;
    if(o.size() > e.size()){
        for(int i = 0; i < o.size()-1; i++){
            cout << o[i] << e[i];
        }
        cout << o[o.size()-1];
    } else {
        for(int i = 0; i < o.size(); i++){
            cout << o[i] << e[i];
        }
    }
    cout << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modp 1000000007
#define Maxn 1000007
int n,a[Maxn],cnt=0;
int p[Maxn],g[Maxn],pos[Maxn];
bool flag[Maxn];
int power(int a,int b)
{
    int res=1,now=a,left=b;
    while (left>0)
    {
        if (left%2==1) res=(1LL*res*now)%modp;
        left/=2;
        now=(1LL*now*now)%modp;
    }
    return res;
}
int main()
{
    memset(flag,true,sizeof(flag));
    flag[1]=false;
    for (int i=2;i<=1000000;i++)
        for (int j=2;j<=1000000/i;j++)
            flag[i*j]=false;
    for (int i=1;i<=1000000;i++)
        if (flag[i]) 
        {
            p[++cnt]=i;
            pos[i]=cnt;
        }
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for (int i=1;i<=n;i++)
    {
        int w=a[i];
        for (int j=1;j<=cnt&&p[j]*p[j]<=w;j++)
        {
            int tmp=0;
            while (w%p[j]==0)
            {
                ++tmp;
                w/=p[j];
            }
            g[j]=max(g[j],tmp);
        }
        if (w!=1)
        {
            int tmp=pos[w];
            g[tmp]=max(g[tmp],1);
        }
    }
    int now=1;
    for (int i=1;i<=cnt;i++)
    {
        while (g[i]--) now=(1LL*now*p[i])%modp;
    }
    int ans=0;
    for (int i=1;i<=n;i++)
        ans=(ans+1LL*now*power(a[i],modp-2))%modp;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); i < (end); i++)
#define RFOR(var, begin, end) for (int var = (begin) - 1; i >= (end); i--)
#define REP(var, length) FOR(var, 0, length)
#define RREP(var, length) RFOR(var, length, 0)
#define SORT(vector) sort(vector.begin(), vector.end())

const ll MOD = 1e9 + 7;

void solve(istream& cin, ostream& cout) {
  string s;
  cin >> s;
  string b = "";
  int ans = 0;
  REP(i, s.size()) {
    if (b == s.substr(i, 1)) {
      b = s.substr(i, 2);
      i++;
      if (i == s.size()) {
        break;
      }
    } else {
      b = s.substr(i, 1);
    }
    ans++;
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  solve(cin, cout);
}
#endif


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (300006)
ll n,ans;
int main(){
	FAST
	cin>>n;
	FOR(i,1,n){
		ans += i * (n-i+1);
	}
	FOR(i,0,n-2){
		ll a,b;
		cin>>a>>b;
		if(a>b)swap(a,b);
		ans -= a * (n-b+1);
	}
	cout<<ans<<'\n';
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string n;
    cin >> n;
    int res = 0;
    for(int i=0; i<n.length(); i++){
        res = res + n[i]-'0';
    }
    if(res%9==0){
        cout << "Yes" << "\n";
    }
    else{
        cout << "No" << "\n";
    }
    return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long int n,cnt=0;
    cin >> n;
    vector<int> A(n),B(n),C(n);
    for(int i = 0;i<n;i++) cin >> A[i];
    for(int i = 0;i<n;i++) cin >> B[i];
    for(int i = 0;i<n;i++) cin >> C[i];
    sort(A.begin(),A.end());
    sort(C.begin(),C.end());
    for(int i = 0;i<n;i++){
        long long a = upper_bound(A.begin(),A.end(),B[i] - 1) - A.begin();
        long long b = C.end()-lower_bound(C.begin(),C.end(),B[i] + 1);
        cnt += a*b;
    }
    cout<<cnt;
}


Measured memory_bytes: 1408
#include <iostream>
using namespace std;
typedef long long ll;
ll GCD(ll a, ll b) {
    if (a > b) {
        a ^= b; b = a xor b; a = a xor b;
    }
    return (a == 0) ? b : GCD(b % a, a);
}
ll LCM(ll a, ll b) {
    return a*b/GCD(a, b);
}
int main() {
    int a[3], m[3];
    while (1) {
        cin >> a[0] >> m[0] >> a[1] >> m[1] >> a[2] >> m[2];
        if (!a[0] && !m[0] && !a[1] && !m[1] && !a[2] && !m[2]) {
            break;
        }
        int move[3];
        for (int i=0; i<3; ++i) {
            int val = 1;
            for (int j=1; j<=m[i]; ++j) {
                val = a[i] * val % m[i];
                if (val == 1) {
                    move[i] = j; break;
                }
            }
        }
        ll ans = LCM(LCM(move[0], move[1]), move[2]);
        cout << ans << endl;
    }
}

Measured memory_bytes: 1156
import heapq

n=int(input())
v=[int(x) for x in input().split()]

heapq.heapify(v)
for _ in range(n-1):
	a=heapq.heappop(v)
	b=heapq.heappop(v)
	#print(a)
	#print(b)
	heapq.heappush(v,(a+b)/2)
	#print(v)
print(v[0])

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define int        long long 
#define test       int t;cin>>t;while(t--)
#define tezi       ios_base::sync_with_stdio(false);cin.tie(NULL);
#define F(i,a,b)   for(int i=a;i<b;i++)
#define pb         push_back
#define mp         make_pair
#define pii        pair<int,int>
#define vi         vector<int>
#define umap       unordered_map<int,int>
#define MAXN 200005
#define endl "\n"
#define YES cout<<"YES\n";
#define NO  cout<<"NO\n";
#define ll long long


signed main(){
    tezi
    {
        int n;
        cin>>n;
        int *arr = new int[n];
        F(i,0,n)cin>>arr[i];
        int ans = 0;
        int diff;
        F(i,1,n){
            if(arr[i] < arr[i-1]){
                diff = arr[i-1]-arr[i];
                ans += diff;
                arr[i] += diff;
            }
        }
        cout<<ans<<"\n";
    }
}

Measured memory_bytes: 5120
package main

import (
	"fmt"
	"os"
)

func main() {
	var n int
	fmt.Scan(&n)

	p := make([]int, n)

	for i := 0; i < n; i++ {
		var x int
		fmt.Scan(&x)
		p[i] = x
	}

	for i := 0; i < n; i++ {
		for j := i; j < n; j++ {
			p[j], p[i] = p[i], p[j]

			flag := false
			for k := 0; k < n-1; k++ {
				if p[k] > p[k+1] {
					flag = true
					break
				}
			}

			if !flag {
				fmt.Println("YES")
				os.Exit(0)
			}

			p[j], p[i] = p[i], p[j]
		}
	}
	fmt.Println("NO")
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
using namespace std;

int gcd(int a,int b){
    if(a<b) swap(a,b);
    int r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> l(n),r(n);
    l[0]=a[0];
    for(int i=1; i<n; i++) l[i]=gcd(l[i-1],a[i]);
    r[n-1]=a[n-1];
    for(int i=n-2; i>=0; i--) r[i]=gcd(r[i+1],a[i]);
    int ans=0;
    rep(i,n){
        if(i==0) ans=max(ans,r[1]);
        else if(i==n-1) ans=max(ans,l[n-2]);
        else ans=max(ans,gcd(l[i-1],r[i+1]));
    }
    cout << ans << endl;
return 0;
}

Measured memory_bytes: 1408
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define size(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

void dout() { cerr << '\n'; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << " " << H;
    dout(T...);
}

#ifdef LOCAL
    #define dbg(...) cerr << #__VA_ARGS__, dout(__VA_ARGS__)
#else
    #define dbg(...) ;
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 2e5 + 123, MOD = 1e9 + 7;
int fact[N], rev[N];

int binpow(int x, int y) {
    int res = 1;
    while (y > 0) {
        if (y & 1) {
            res = (ll)res * x % MOD;
        }
        x = (ll)x * x % MOD;
        y /= 2;
    }
    return res;
}

int c(int n, int k) {
    if (k > n) {
        return 0;
    }
    return ((ll)fact[n] * rev[k] % MOD) * rev[n - k] % MOD;
}

void add(int & x, int y) {
    x += y;
    if (x >= MOD) {
        x -= MOD;
    }
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif

    fact[0] = rev[0] = 1;
    for (int i = 1; i < N; i++) {
        fact[i] = (ll)fact[i - 1] * i % MOD;
        rev[i] = (ll)rev[i - 1] * binpow(i, MOD - 2) % MOD;
    }

    int n, k;
    cin >> n >> k;
    int res = 0;
    for (int i = 0; i <= min(n, k); i++) {
        add(res, (ll)c(n, i) * c(n - 1, i) % MOD);
    }
    cout << res;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <queue>
#include <iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<fstream>

#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
using namespace std;

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
       
    ll i,j,k,x,y,z,p,q;
    ll n,m,tmp;
    string s[200000];
    string str;
    ll sum=0;
    ll strr[200005];
    cin>>x>>y>>z;
    if((x+y+z)>=22){
        cout<<"bust"<<endl;
    }else{
                cout<<"win"<<endl;

    }

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int n, m, x;
	cin >> n >> m >> x;
	int c[15];
	int a[15][15];
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	bool ho[15];
	int ma = 1000000007;
	for (int bit = 0; bit < (1 << n); bit++) {
		for (int i = 0; i < n; i++) {
			if (bit & (1 << i)) {
				ho[i] = 1;
			}
			else {
				ho[i] = 0;
			}
		}
		int co[15] = { 0 }, co1 = 0;
		for (int j = 0; j < n; j++) {
			if (ho[j] == 1) {
				for (int k = 0; k < m; k++) {
					co[k] += a[j][k];
				}
				co1 += c[j];
			}
		}
		bool b = false;
		for (int l = 0; l < m; l++) {
			if (co[l] < x) {
				b = true;
			}
		}
		if (b == false && ma > co1) {
			ma = co1;
		}
	}
	if (ma == 1000000007) {
		cout << "-1" << endl;
		return 0;
	}
	cout << ma << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;

typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 50000;
 
int n, m, r;
int all;
int num[10];
int dis[205][205];
int pre[2 * MaxN + 5], last[MaxN + 5], other[2 * MaxN + 5];
int cost[2 * MaxN + 5];
bool inque[205];
 
void build(int x, int y, int w) {
	pre[++all] = last[x];
	last[x] = all;
	other[all] = y;
	cost[all] = w;
}
 
void bfs(int s) {
	memset(inque, 0, sizeof(inque));
	dis[s][s] = 0;
	queue <int> q;
	q.push(s);
	int ed, dr;
	while(!q.empty()) {
		int x = q.front();
		inque[x] = 1;
		q.pop();
		ed = last[x];
		while(ed != -1) {
			dr = other[ed];
			if(dis[s][x] + cost[ed] < dis[s][dr]) {
				dis[s][dr] = dis[s][x] + cost[ed];
				if(inque[dr] == 0) {
					inque[dr] = 1;
					q.push(dr);
				}
			}
			ed = pre[ed];
		}
		inque[x] = 0;
	}
}
 
int main()
{
	while(~scanf("%d %d %d", &n, &m, &r))
	{
		all = -1; memset(last, -1, sizeof(last));
		for(int i = 1; i <= r; i++)
		{
			scanf("%d", &num[i]);
		}
		sort(num + 1, num + r + 1);
		for(int i = 1; i <= n; i++)
			for(int j = 1; j <= n; j++)
				dis[i][j] = inf;
		for(int i = 1; i <= m; i++) {
			int u, v, w;
			scanf("%d %d %d", &u, &v, &w);
			build(u, v, w); build(v, u, w);
		}
		for(int i = 1; i <= n; i++) {
			bfs(i);
		}
		int ans = inf;
		do {
			int d = 0;
			for(int i = 1; i <= r - 1; i++) {
				d += dis[num[i]][num[i + 1]];
			}
			ans = min(ans, d);
		}
		while(next_permutation(num + 1, num + r + 1));
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
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;
}
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   string s;
   cin >> s;
   int ans = 0;
   rep(i, 0, (s.size() + 1) / 2) {
      if (s[i] != s[s.size() - 1 - i]) ans++;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;
using namespace std;

int dp[101][10200],v[101],w[101];
int main(){
    int n,ww;
    cin>>n>>ww;
    rep(i,n) cin>>v[i]>>w[i];
    rep(j,n+1)rep(i,n*100+1) dp[j][i]=1000100010;
    dp[0][0]=0;
    rep(i,n){
        for(int j=0;j+v[i]<=n*100;++j){
            dp[i+1][j]=min(dp[i][j],dp[i+1][j]);
            dp[i+1][j+v[i]]=min(dp[i][j]+w[i],dp[i+1][j+v[i]]);
        }
    }
    for(int i=n*100;i>=0;--i){
        if(dp[n][i]<=ww){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 7120
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
struct unionfind{
	vector<int> p, sz;
	unionfind(int n){
		p = vector<int>(n, -1);
		sz = vector<int>(n, 1);
	}
	int root(int x){
		if (p[x] == -1){
			return x;
		} else {
			p[x] = root(p[x]);
			return p[x];
		}
	}
	bool same (int x, int y){
		return root(x) == root(y);
	}
	pair<int, int> unite(int x, int y){
		x = root(x);
		y = root(y);
		pair<int, int> ans = make_pair(sz[x], sz[y]);
		p[y] = x;
		sz[x] += sz[y];
		return ans;
	}
};
int main(){
	int N, M;
	cin >> N >> M;
	vector<int> A(M), B(M);
	for (int i = 0; i < M; i++){
		cin >> A[i] >> B[i];
		A[i]--;
		B[i]--;
	}
	vector<long long> ans(M);
	ans[M - 1] = (long long) N * (N - 1) / 2;
	unionfind G(N);
	for (int i = M - 2; i >= 0; i--){
		if (!G.same(A[i + 1], B[i + 1])){
			pair<int, int> sz = G.unite(A[i + 1], B[i + 1]);
			ans[i] = ans[i + 1] - (long long) sz.first * sz.second;
		} else {
			ans[i] = ans[i + 1];
		}
	}
	for (int i = 0; i < M; i++){
		cout << ans[i] << endl;
	}
}

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



int main() {
   int n;
   cin >> n;
   vector<string> s(n);
   for (int i=0; i<n; i++) {
      cin >> s[i];
   }
   sort(s.begin(), s.end());
   int ans = 1;
   for (int i=1; i<n; i++) {
      if (s[i] != s[i-1]) {
         ans++;
      }
   }
   cout << ans << endl;
   return 0;
}

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

int main()
{
    vector<int> nums = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;

    cout << nums.at(k-1) << endl;
    return 0;
}


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



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

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

int main(){
   string n;
   cin >> n;
   char a;
   a = n[n.size()-1];
   if(a=='0' || a=='1' || a=='6' || a=='8'){
      cout << "pon" << endl;
   }else{
      if(a == '3'){
         cout << "bon" << endl;
      }else{
         cout << "hon" << endl;
      }
   }
  
}


Measured memory_bytes: 3628
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt();
    int D = sc.nextInt();
    int x2000 = sc.nextInt();

    int prevVal = x2000;
    for (int i = 1; i <= 10; i++) {
      int val = r*prevVal - D;
      prevVal = val;
      System.out.println(val);
    }
  }
}



Measured memory_bytes: 23636
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
const int maxn=100050;
int n;
int x[maxn],y[maxn],t[maxn];
int main(){
	scanf("%d",&n);
	for(register int i=1;i<=n;i++){
		scanf("%d%d%d",&t[i],&x[i],&y[i]);
	}
	x[0]=y[0]=t[0]=0;
	for(register int i=0;i<n;i++){
		if(t[i+1]-t[i]<abs(x[i+1]-x[i])+abs(y[i+1]-y[i])){
			cout<<"No"<<endl;
			return 0;
		}
		if(1&(abs(x[i+1]-x[i])+abs(y[i+1]-y[i])-(t[i+1]-t[i]))){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 1408
n=input()

v_n=[]
c_n=[]

sum_n=[]
ans=0
v_n.append(input().split())
c_n.append(input().split())

for i in range(int(n)):
	sum_n.append(int(v_n[0][i])-int(c_n[0][i]))

for i in range(int(n)):
	if sum_n[i] > 0:
		ans += sum_n[i]

print(ans)


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		long a = sc.nextLong(), b = sc.nextLong(), c = sc.nextLong(), k = sc.nextLong();
		long ans = 0l;

		if(k >= a) {
			ans = a;
			k -= a;
		}else {
			ans = k;
			k = 0;
		}
		if(k >= b) {
			k -= b;
		}
		if(k > 0) {
			ans -= k;
		}
		System.out.println(ans);
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 32576
// Date: 2020-03-30

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define IO freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout)
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define D(x) cout << #x << " = " << x << endl;
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int main() {
    FIO;
    int n, t;
    cin >> n >> t;
    int ans = t, cur = 0;
    rep(i, 1, n) {
        int x; cin >> x;
        if(i > 1) {
            ans += min(t, x-cur);
            cur = x;
        }
    }
    cout << ans;


    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;

template <class T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> void generatePrimes(T n);
template <class T> void factorize(T n);

vector<ll> primes;
int donePrime = 1;
ll ans = 1;


int main()
{
	ll a, b; cin >> a >> b;
	ll g = gcd(a, b);

	if (g == 1)
	{
		cout << 1 << endl;
		return 0;
	}

	factorize(g);

	cout << ans << endl;
}

template <class T> void factorize(T n)
{
	T rt = (T)ceil(sqrt(n));

	if (donePrime < rt)
		generatePrimes(rt);

	if (n < 2)
		return;

	if (!(n & 1))
	{
		++ans;

		while (n && !(n & 1))
			n >>= 1;
	}

	for (T d : primes)
	{
		if (n < d) break;

		if (!(n % d))
		{
			++ans;
			while (!(n % d))
				n /= d;
		}
	}

	if (n != 1)
		++ans;
}


template <class T> void generatePrimes(T n)
{
	if (n <= donePrime)
		return;

	if (primes.empty())
		primes.push_back(2);

	if (primes.back() == 2 && n > 2)
		primes.push_back(3);

	bool isPrime;

	for (T k = primes.back() + 2; k <= n; k += 2)
	{
		if (!(k % 3))
			continue;

		T limit = (T)ceil(sqrt(k));

		isPrime = true;
		for (int i{ 2 }; i < primes.size() && primes[i] <= limit; i++)
		{
			if (!(k % primes[i]))
			{
				isPrime = false;
				break;
			}
		}

		if (isPrime)
			primes.push_back(k);
	}

	donePrime = n;
}

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

int main() {
    int K, S; cin >> K >> S;
    int ans = 0;
    for (int X = 0; X <= K; X++) {
        for (int Y = 0; Y <= K; Y++) {
            int Z = S - X - Y;
            if (0 <= Z && Z <= K) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

map<P,P> mp;
ll n,m,cou,ngCou;
int AA[111111];
int BB[111111];
int dp[111111][2];

ll mPow(ll a,ll b){
	ll ans = 1;
	ll tmp = a;
	for(ll i = 0;i <= 62;i++){
		if(b & (1LL << i)){
			ans *= tmp;
			ans %= MOD;
		}
		tmp *= tmp;
		tmp %= MOD;
	}
	return ans;
}

int main(){
	
	REP(i,111111)AA[i] = BB[i] = -1;
	cin >> n >> m;
	REP(i,m){
		int a,b,c;cin >> a >> b >> c;
		a--;b--;
		if(a < b)swap(a,b);
		mp[MP(a,b)].FI++;
		mp[MP(a,b)].SE = (mp[MP(a,b)].SE + c) % 2;
	}
	
	for(auto now: mp){
		int x = now.FI.FI;
		int y = now.FI.SE;
		int a = now.SE.FI;
		int b = now.SE.SE;
		//cout << x << " " << y << " " << a << " " << b << endl;
		if(x == y){
			if(AA[x] == -1)AA[x] = b;
			else if(AA[x] != b){
				cout << 0 << endl;
				return 0;
			}
		}
		else if(abs(x - y) == 1){
			ngCou++;
			if(a <= 1)continue;
			BB[y] = b;
		}
		else if(abs(x - y) == 2){
			ngCou++;
			if(a <= 1)continue;
			if(AA[x-1] == -1)AA[x-1] = b;
			else if(AA[x-1] != b) {
				cout << 0 << endl;
				return 0;
			}
		}
		else{
			ngCou++;
			if(a <= 1)continue;
			if(b == 1){
				cout << 0 << endl;
				return 0;
			}
		}
	}
	
	if(AA[0] != 1)dp[0][0] = 1;
	if(AA[0] != 0)dp[0][1] = 1;
	
	REP(i,n-1){
		REP(j,2){
			bool flag = true;
			if(AA[i+1] == 1)flag = false;
			if(BB[i] != -1 && (j + 0) % 2 != BB[i])flag = false;
			if(flag){
				dp[i+1][0] += dp[i][j];
				dp[i+1][0] %= MOD;
			}
			flag = true;
			if(AA[i+1] == 0)flag = false;
			if(BB[i] != -1 && (j + 1) % 2 != BB[i])flag = false;
			if(flag){
				dp[i+1][1] += dp[i][j];
				dp[i+1][1] %= MOD;
			}
		}
	}
		
	cout << ((dp[n-1][0] + dp[n-1][1]) % MOD) * mPow(2,(n-1)*n/2 - ngCou) % MOD << endl;
	
	return 0;
}


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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
#define vll vector<long long int>
#define vvll vector<vector<long long int>>
#define ALL(v) (v).begin(),(v).end()
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

//座標圧縮
class CC{
  public:
  map<ll,ll> mp;//0-indexed
  map<ll,ll> rmp;
  bool isUnique = true;
  
  CC(vector<ll> v){//座標圧縮が必要になるのはlonglongintの時が多い？
    sort(v.begin(),v.end());
    auto result = unique(v.begin(),v.end());
    isUnique = (result == v.end());
    v.erase(result, v.end());//重複を除いてもmapから参照できる。
    
    for(int i=0; i<v.size(); i++){
      mp.emplace_hint(mp.end(),v[i],i);//key→value
      rmp.emplace_hint(rmp.end(),i,v[i]);//value→key
    }
  }
  
  /*ll getKey(int value){//keyが必要な場合は座標圧縮前のベクトルから参照できるため、これは不要？
    //座標圧縮後valueに対応するkeyを取得→0-indexedの時value+1番目のkey→v[value]で良いのでは？
    //key0がvalue0に対応している点に注意。
    return this->rmp[value];
  }*/
  
  /*
  inline int operator [] (ll index) const{//読み取り
     if(mp.find(index) != mp.end()) return mp[index];
     else{ return -1;}
  }
  */
};


int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll N, M; cin >> N >> M;
  vll a(N), b(M), c(M), all(N+M);
  //vector<pair<ll,ll>> 
  FOR(i,N){ cin >> a[i]; all[i] = a[i]; }
  FOR(i,M){ cin >> b[i] >> c[i]; all[i+N] = c[i]; }
  
  CC cc(all);
  
  //main
  ll ans = 0;
  
  map<ll,ll> m;
  FOR(i,N){ m[cc.mp[a[i]]] ++; }
  FOR(i,M){ m[cc.mp[c[i]]] += b[i];}
  
  ll count = 0;
  for(int i=cc.mp.size()-1; i>=0; i--){
    for(int j=m[i]; j>=1; j--){
      ans += cc.rmp[i];
      count ++;
      if(count == N){ goto endloop; }
    }
  }
  
  endloop: {}
  
  // output
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 41700
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

int main()
{
	string s;
	cin>>s;
	int len=s.length();
	int ans;
	ans=s[0]-'0'+(len-1)*9;
	int t=len-1;
	while (s[t]=='9') t--;
	if (t>0) ans-=1;
	cout<<ans<<endl;
	return 0; 
} 

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int C=sc.nextInt();
		int K=sc.nextInt();
		int[]T=new int[N];
		for(int i=0;i<N;i++){
			T[i]=sc.nextInt();
		}
		Arrays.sort(T);
		
		int people=0;
		int limit=T[0]+K;
		int count=0;
		for(int i=0;i<N;i++){
			if(people==C){
				count++;
				people=0;
				limit=T[i]+K;
			}
			if(limit<T[i]){
				count++;
				people=0;
				limit=T[i]+K;
			}
			people++;
		}
		
		if(people>0){
			if(people%C==0)count+=people/C;
			else count+=people/C+1;
		}
		System.out.println(count);
		
	}
}

Measured memory_bytes: 50120
n = int(input())
w = list(map(int, input().split()))

ans = 100
for i in range(n+1):
    s1 = abs(sum(w) - sum(w[i::]))
    s2 = sum(w[i::])
    # print(s1)
    # print(s2)
    ans = min(ans, abs(s1 - s2))
print(ans)

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

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    int N;
    cin >> N;
    ll sum = 0;
    for (int i=1; i<=N; ++i) {
        if (i % 3 != 0 && i % 5 != 0) {
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3632