akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    int n = Integer.parseInt(br.readLine());
    String[] tmp = br.readLine().split(" ");
    int[] arr = Arrays.asList(tmp).stream().mapToInt(x -> Integer.parseInt(x)).toArray();

    long[][] dp = new long[n][21];
    dp[0][arr[0]] = 1;

    for (int i = 1; i < n - 1; i++) {
      for (int j = 0; j < 21; j++) {
        if (dp[i-1][j] <= 0) {
          continue;
        }

        if (j + arr[i] <= 20) {
          dp[i][j + arr[i]] += dp[i-1][j];
        }

        if (j - arr[i] >= 0) {
          dp[i][j - arr[i]] += dp[i-1][j];
        }
      }
    }

    int answer = arr[n-1];
    long count = dp[n-2][answer];
    System.out.println(count);
  }
}

Measured memory_bytes: 31008
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        Pair[] red = new Pair[n];
        for(int i = 0; i < n; i++){
            red[i] = new Pair(Integer.parseInt(sc.next()), Integer.parseInt(sc.next()));
        }
        Pair[] blue = new Pair[n];
        for(int i = 0; i < n; i++){
            blue[i] = new Pair(Integer.parseInt(sc.next()), Integer.parseInt(sc.next()));
        }
        
        Arrays.sort(blue, Comparator.comparingInt(Pair::getX));
        Arrays.sort(red, Comparator.comparingInt(Pair::getY).reversed());
        
        boolean[] red2 = new boolean[n];
        Arrays.fill(red2, true);
        int count = 0;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(red2[j] && blue[i].x > red[j].x && blue[i].y > red[j].y){
                    count++;
                    red2[j] = false;
                    break;
                }
            }
        }
        
        System.out.println(count);
    }
    
    static class Pair {
        int x;
        int y;

        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }
        public int getX() {
            return x;
        }
        public int getY() {
            return y;
        }
    }
}

Measured memory_bytes: 27220
// Problem : D - Not Divisible
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define Sort(a)	sort(a.begin(),a.end())
#define rev(a)	reverse(a.begin(),a.end())
#define all(a)	(a).begin(),(a).end()
#define vll vector<long long int>
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
#define INF 1e18

#define MAX 1000005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}
lli Ceil(lli a,lli b){lli res=a/b;if(a%b!=0)	res++;return res;}

template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

lli dxx[]={1,1,0,-1,-1,-1,0,1};
lli dyy[]={0,1,1,1,0,-1,-1,-1};
lli dx[]={1,0,-1,0};
lli dy[]={0,1,0,-1};

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
vector<bool> is_prime(MAX,true);
void sieve()
{
	long long int i,j;
	is_prime[0]=false;
	is_prime[1]=false;
	for(i=2;i<MAX;i++){
		if(is_prime[i]){
			for(j=i*i;j<MAX;j+=i){
				is_prime[j]=false;
			}
		}
	}
}
void solve(lli the)
{
	char ch;
	db aa,bb,cc,dd,xx;
	string s1,s2,s3,str;
    lli i,j,k,a,b,c,d,n,m,l,r,x,y,z,low,high,mid,sum=0,ans=0,temp,t;
    sieve();
    cin >> n;
    vll v(n);
    cin >> v;
    map<lli,lli>ma;
    for(i=0;i<n;i++){
    	ma[v[i]]++;
    }
    Sort(v);
    if(v[0]==1){
    	if(ma[1]==1)	cout<<1;
    	else	cout<<0;
    	return;
    }
    vll vv=v;
    rev(v);
    bool ok;
    for(i=0;i<n;i++){
    	if(ma[v[i]]>1)	continue;
    	if(is_prime[v[i]]){
    		ans++;
    		// cout<<v[i]<<endl;
    		continue;
    	}
    	a=v[i];
    	ok=true;
    	for(j=1;j*j<=a;j++){
    		if(a%j==0){
    			x=j;y=a/j;
    			if(binary_search(all(vv),x) && x!=a)	ok=false;
    			if(binary_search(all(vv),y) && y!=a)	ok=false;
    		}
    	}
    	if(ok){
    		// cout<<v[i]<<endl;
    		ans++;
    	}
    }
    cout<<ans;
    
    
}













int main()
{
	long long int t=1,c=1;
	// scanf("%lld",&t);
	while(t--){
		solve(c);
		c++;
	}
	return 0;
}
/* UJJWAL KESHRI */

Measured memory_bytes: 18844
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    string S;
    cin >> S;
    ll max_count=0, count=0;
    for(size_t i=0;i<S.size(); i++)
    {
        //cerr << S[i] << endl;
        if(S[i] == 'R') count++;
        else
        {
            max_count=max(max_count, count);
            count=0;
        }
    }
    max_count=max(max_count, count);
    cout << max_count << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

int main() {
  long double n, m;
  cin >> n >> m;
  long double x = 0;
  long double tmp = (long double)pow(2, m);
  for (int i = 1; i <= 100000; i++) {
    x += ((100*(n - m) + 1900*m)*i)*pow(1.0 - 1.0/tmp, i - 1);
  }
  x /= tmp;
  x = (int)(x + 0.00001);
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 1020
///Astalavista Code........~boy_with_no_gf
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define Br cout<<endl
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define PT(x) cout << (x) << endl
#define PTT(x) cout << (#x) << " is " << (x) << endl; 
#define lets_go ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int M = 1e9 + 7;
const int N = 2e6 + 10;
const int IM = 1e15 + 37;
const double PI = 3.1415926535897932384;
inline void PP(int n) { cout << n << " ";}
void PV(vi v) { for (int i = 0 ; i < v.size() ; i++) cout << v[i] << " " ; cout << endl;}
void PVV(vii v) {for (int i = 0 ; i < v.size() ; i++) cout << v[i].first << " " << v[i].second << endl;}
void PA(int v[], int n, int x = 0) { for (int i = x ; i < n + x; i++)cout << v[i] << " " ; cout << endl;}
void IN(int a[], int n, int x = 0) {for (int i = x; i < n + x; i++)cin >> a[i];}
// <=================================================================================================================================
// <=================================================================================================================================


void fun(){
    int n;string s;cin>>n>>s;int ans=0;
    for(int i=0;i<n;i++){
        if(s[i]=='R') ans++;
    }
    for(int i=max(ans-1,0LL);i>=0;i--){
        if(s[i]=='R') ans--;
    }
    cout<<ans;
}

signed  main() {
    lets_go

      int t;
      t=1;
// cin >> t;
    while (t--) {            
         fun();             
    }                        
                            
                            
    return 0;

}


Measured memory_bytes: 3748
package main

import (
	"fmt"
)

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

	h := make([]int, n)

	count := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&h[i])
		if h[i] >= k {
			count++
		}
	}
	fmt.Println(count)
}


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

using namespace std;

const int N = 3005;

int n, a[N];
long long dp[N][N];

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) dp[i][i] = a[i];
    for (int i = n - 1; i >= 1; i--) {
        for (int j = i + 1; j <= n; j++) {
            dp[i][j] = max(-dp[i + 1][j] + a[i], -dp[i][j - 1] + a[j]);
        }
    }
    
    cout << dp[1][n];
    return 0;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n;cin >> n;
    set<int> s;
    rep(i,n){
        int m;cin >> m;
        s.insert(m);
    }
    cout << s.size() << endl;
}


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


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

    int N;
    cin >> N;
    vector<int> v(N+1);
    for (int i = 0; i < N; ++i) cin >> v[i+1];
    vector<vector<int>> adj(N+1);
    for (int i = 1; i < N; ++i) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    vector<int> tmp;
    vector<int> dp(N+1, 0);

    function<void(int,int)> dfs = [&](int node, int parent) {
        int idx = -1;
        if (tmp.empty() || v[node] > tmp.back()) {
            tmp.push_back(v[node]);
        }
        else {
            idx = distance(tmp.begin(), lower_bound(tmp.begin(), tmp.end(), v[node]));
            swap(v[node], tmp[idx]);
        }
        dp[node] = tmp.size();
        for (int c : adj[node]) {
            if (c != parent) {
                dfs(c, node);
            }
        }

        if (idx == -1) {
            tmp.pop_back();
        }
        else {
            swap(v[node], tmp[idx]);
        }
    };

    dfs(1, -1);
    for (int i = 1; i <= N; ++i) {
        cout << dp[i] << endl;
    }

    return 0;
}

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

int main() {
	int n,k;
	long long ans=0;
	cin>>n>>k;
	for(int b=k+1;b<=n;b++){
		ans=ans+(n/b)*(b-k);
		if((n%b-k+1)>0){
			ans=ans+(n%b-k+1);
			if(k==0){
				ans--;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define debug(x) cerr << #x << " " << x << endl;
#define debug_p(x) cerr << #x << " [" << x.fi << " " << x.se << "]"<<endl;
#define debug_v(x) {cerr << #x << " "; for (auto ioi : x) cerr << ioi << " "; cerr << endl;}
#define debug_vp(x) {cerr << #x << " "; for (auto ioi : x) cerr << '[' << ioi.fi << " " << ioi.se << ']'; cerr << endl;}
#define debug_v_v(x) {cerr << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cerr << ioi2 << " "; cerr << '\n';} cerr << "*/" << #x << endl;}
#define gen_clock(x) ll x = clock(); cerr << "Clock " << #x << " created" << endl;
#define check_clock(x) cerr << "Time spent in " << #x << ": " << (double)(clock() - x)/CLOCKS_PER_SEC << endl; x = clock();
#define reset_clock(x) x = clock()

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

void solve()
{
	int k;
	cin>>k;
	string s;
	cin>>s;
	if(L(s)<=k)
	{
		cout<<s;
	}
	else
	{
		cout<<s.substr(0,k)<<"...";
	}
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);

    int cnt = 1;
    int a;
    Rep(i,N) {
        Scd(a); if( cnt==a ) cnt++;
    }

    if( cnt == 1 ) cnt = N+2;
    printf ("%d\n", N-cnt+1 );

    return 0;
}



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

int main()
{
  int N;
  cin >> N;
  if (N / 100 == 7) cout << "Yes" << endl;
  else if ((N%100) / 10 == 7) cout << "Yes" << endl;
  else if ((N%10) == 7) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main() {
   int x,y,z;
   cin >> x >> y >> z;
   cout << (x-z)/(y+z) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int g[15][15],cr[15][32768],ins[32768],dp[32768][15];
int main (){
	int i,j,k,t,u,v,c,l,n,m,s=0;
	scanf ("%d%d",&n,&m);
	for (i=1;i<=m;i++)
	{scanf ("%d%d%d",&u,&v,&c);
	u--;v--;g[u][v]=g[v][u]=c;s+=c;
	}
	for (i=0;i<n;i++)
	{for (k=0;k<n;k++)
	{for (j=0;j<(1<<n);j++)
	{if ((1<<k)&j) 
	{cr[i][j]+=g[i][k];}
	}
	}
	}
	for (i=0;i<(1<<n);i++)
	{for (j=0;j<n;j++)
	{for (k=0;k<n;k++)
	{if ((1<<j)&i)
	{if ((1<<k)&i)
	{ins[i]+=g[j][k];}
	}
	}
	}
	ins[i]/=2;
	}
	memset(dp,-1,sizeof(dp));
	dp[1][0]=0;
	for (i=1;i<(1<<n);i++)
	{for (j=0;j<n;j++)
	{if (dp[i][j]<0) {continue;}
	int tar=i-(1<<j),b=(1<<n)-1-tar;
	for (k=0;k<n;k++)
	{if (i&(1<<k)) {continue;}
	if (g[j][k]<=0) {continue;}
	dp[i+(1<<k)][k]=max(dp[i+(1<<k)][k],dp[i][j]+g[j][k]);
	}
	for (t=b;t;t=(t-1)&b)
	{if (t&(1<<j)) {continue;}
	dp[t|i][j]=max(dp[t|i][j],dp[i][j]+cr[j][t]+ins[t]);
	}
	}
	}
	int ans=0;
	for (i=0;i<(1<<n);i++)
	{ans=max(ans,dp[i][n-1]);}
	printf ("%d",s-ans);
	return 0;
}

Measured memory_bytes: 4224
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;
int main()
{
    vector < vector <int> > card;
    int n, number;
    char c;
    std::cin >> n;
    card.resize(4);
    for (int i=0; i<4; i++){
        card[i].resize(13);
        for (int j=0; j<13; j++){
            card[i][j] = 0;
        }
    }
    // exist card
    for (int i=0; i<n; i++){
        std::cin >> c >> number;
        if (c == 'S'){
            card[0][number-1] = 1;
        }
        else if (c == 'H'){
            card[1][number-1] = 1;
        }
        else if (c == 'C'){
            card[2][number-1] = 1;
        }
        else if (c == 'D'){
            card[3][number-1] = 1;
        }
    }
    // print missing cards
    for (int i=0; i<4; i++){
        for (int j=0; j<13; j++){
            if(card[i][j] == 0){
                if(i == 0){
                    std::cout << "S " << j+1 << endl;
                }
                else if(i == 1){
                    std::cout << "H " << j+1 << endl;
                }
                else if(i == 2){
                    std::cout << "C " << j+1 << endl;
                }
                else if(i == 3){
                    std::cout << "D " << j+1 << endl;
                }
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
map<ll,int> primeFactorMp(ll n){
	map<ll,int> ret;
	for(ll i=2;i*i<=n;i++)if(n%i==0){n/=i;ret[i--]++;}
	if(n-1)ret[n]++;
	return ret;
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	ll ans=1;
	for(auto x:primeFactorMp(n-1)){
		ans*=(x.sc+1);
	}
	for(ll i=2;i*i<=n;i++){
		ll tmp=n;
		if(tmp%i!=0)continue;
		while(tmp%i==0)tmp/=i;
		if(tmp%i==1)ans++;
	}
	puta(ans);
}


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

int main(){
    int N,M,X,Y;
    cin >> N >> M >> X >> Y;
    bool ans_x = false,ans_y = false;
    int max_x = -100;
    int min_y = 100;
    for (int i = 0;i < N;i++){
        int x;
        cin >> x;
        max_x = max(x,max_x); 
    }

    for (int i = 0;i < M;i++){
        int y;
        cin >> y;
        min_y = min(y,min_y);
    }

    max_x = max(max_x,X);
    min_y = min(min_y,Y);
    if(max_x < min_y){
        cout << "No War" << endl;
    }
    else {
        cout << "War" << endl;
    }
}

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

int main() {
    int h,w; cin >> h >> w;
    vector<string> a(h);
    for (int i = 0; i < h; i++) cin >> a[i];
    for(int i = 0; i < a.size(); i ++) {
        for(int j = 0; j < a[0].size(); j ++) {
            if(a[i][j]=='#') break;
            if(j==w-1) {
                a.erase(a.begin() + i);
                i --;
            }
        }
    }
    h = a.size();
    for(int i = 0; i < w; i ++) {
        for(int j = 0; j < h; j ++) {
            if(a[j][i]=='#') break;
            if(j==h-1) {
                for(int k = 0; k < h; k ++) {
                    a[k].erase(a[k].begin()+i);
                }
                i --;
                w --;
            }
        }
    }
    for(int i = 0; i < h; i++) cout << a[i] << endl;
}

Measured memory_bytes: 256
n, a = int(input()) - 1, list(map(int, input().split()))
result = 10 ** 9

for q in range(n):
    count = 0
    while (a[q] % 2) == 0:
        a[q] /= 2
        count += 1
    result = min(count, result)
print(result)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

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

vector<ll> A;
int N;

void update(int i, ll x) {
	i += N-1;
	A[i] = x;
	while(i > 0) {
		i = (i-1)/2;
		A[i] = max(A[i*2+1], A[i*2+2]);
	}
}

ll query(int a, int b, int k, int l, int r) {
	if(b <= l || r <= a) {
		return 0;
	}
	if(a <= l && r <= b) {
		return A[k];
	}
	else {
		ll c1 = query(a, b, k*2+1, l, (l+r)/2);
		ll c2 = query(a, b, k*2+2, (l+r)/2, r);
		return max(c1, c2);
	}
}

int main() {
	int n;
	cin >> n;
	vector<int> h(n), a(n);
	rep(i,n) cin >> h[i];
	rep(i,n) cin >> a[i];

	N = 1;
	while(N < n) N *= 2;
	A = vector<ll>(2*N-1, 0);
	rep(i,n) {
		ll temp = query(0, h[i], 0, 0, N);
		update(h[i]-1, temp + a[i]);
	}
	cout << query(0, N, 0, 0, N) << endl;
	//cout << A[0] << endl;
	
	

  return 0;
}


Measured memory_bytes: 5888
#include <cmath>

#include <cstdlib>
#include <iostream>
#include <string>
#include <typeinfo>

using namespace std;
int main (){
    int N,x[100000],y[100000],t[100000];
    string clear="Yes";
    cin >> N;
    for (int i = 0;i<N;i++){
        cin >> t[i] >> x[i] >> y[i];
    }
 if(!((t[0]%2==1 && abs(x[0]+y[0])%2==1 && abs(x[0]+y[0])<=t[0])||
           (t[0]%2==0 && abs(x[0]+y[0])%2==0 && abs(x[0]+y[0])<=t[0]))){
        cout << "No";
     return 0;
    }
    for (int i = 1;i<N;i++){
        if(((t[i]-t[i-1])%2==1 && abs(x[i]+y[i]-x[i-1]-y[i-1])%2==1 && abs(x[i]+y[i]-x[i-1]-y[i-1])<=t[i]-t[i-1])||
           ((t[i]-t[i-1])%2==0 && abs(x[i]+y[i]-x[i-1]-y[i-1])%2==0 && abs(x[i]+y[i]-x[i-1]-y[i-1])<=t[i]-t[i-1])){
        }else{
            clear="No";
        }
    }
    cout << clear;
    return 0;
}



Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;
 
 
int main()
{
	int N;
 
	cin >> N;
 
	if(N/100 == 7){
		cout << "Yes";
	}else if((N/10)%10 == 7){
		cout << "Yes";
	}else if(N%10 == 7){
		cout << "Yes";
	}else{
		cout << "No";
	}
 
	return 0;
}

Measured memory_bytes: 3632
input = STDIN.read.split("\n")
n = input.shift.split(" ").map{|i| i.to_i}

N = n[0]
K = n[1]

hs = input.map{|i| i.to_i}.sort

min_diff = nil
for i in 0..(N-K)
  diff = hs[i + K - 1] - hs[i]
  if min_diff == nil || min_diff > diff
    min_diff = diff
  end
end

puts min_diff

Measured memory_bytes: 10352
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

int main()
{
	int n=gi(),a=gi(),b=gi();
	puts((b-a)&1?"Borys":"Alice");
	return 0;
}


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

int main(){
  int n,i;string s1,s2;cin>>n>>s1>>s2;
  ll ans;bool f;
  if(s1.at(0)==s2.at(0)){
    ans=3;
    f=1;
    i=1;
  }else{
    ans=6;
    f=0;
    i=2;
  }
  while(i<n){
    if(s1.at(i)==s2.at(i)){
      ans*=(f?2:1);
      f=1;
      i++;
    }else{
      ans*=(f?2:3);
      f=0;
      i+=2;
    }
    ans%=(ll)1e9+7;
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n;
    string s;
    cin >> n >> s;

    vector<int> a(26);
    rep(i, n){
        a[s[i]-'a']++;
    }

    int ans = 1;
    rep(i, 26){
        ans *= (a[i] + 1);
        ans %= MOD;
    }
    cout << ans - 1 << endl;

    return 0;
}


Measured memory_bytes: 1144
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>
//---------------------------------------------
 


int gcd(int a,int b)
{

    if(b==0) return a;

    return gcd(b,a%b);
}


int main(void)
{
ll n;

cin>>n;
ll ans =0;
for(int i=1;i<=n;i++)
{
    for(int j=1;j<=n;j++)
    {
        for(int k=1;k<=n;k++)
        {
           ans += gcd(gcd(i,j),k);
        }
    }
}

cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include<string.h>

int main (void)
{
   char A[11],B[11],C[11];
   int as,bs;

   scanf("%s%s%s", A, B, C);
   as = strlen(A);
   bs = strlen(B);

   if((A[as-1] == B[0]) && (B[bs-1] == C[0]))
     printf("YES\n");

    else
       printf("NO\n");

     return 0;
}



Measured memory_bytes: 128
#include <stdio.h>

int main()
{
	int N, n[11], k, m;
	char s[101];

	scanf("%d", &N);
	while (N > 0) {
					// ??\?????¨???????¨????
		scanf("%s", s);
		for (int i1 = 0; i1 <= N; i1++)
			n[i1] = 0;
					// ??????????????????
		for (int i1 = 0; i1 < 100; i1++) {
			k = i1 % N;
			if (s[i1] == 'M')   // ???
				n[k]++;
			else if (s[i1] == 'S') {   // ??????
				n[N] += (n[k] + 1);
				n[k]  = 0;
			}
			else {   // ?§?
				n[k] += (n[N] + 1);
				n[N]  = 0;
			}
		}
					// ??????
		for (int i1 = 0; i1 < N; i1++) {
			m = -1;
			for (int i2 = 0; i2 < N; i2++) {
				if (n[i2] >= 0 && (m < 0 || n[i2] < n[m]))
					m = i2;
			}
			printf("%d ", n[m]);
			n[m] = -1;
		}
		printf("%d\n", n[N]);
					// ?¬??????????????????????
		scanf("%d", &N);
	}

	return 0;
}

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

int main()
{
  int n;cin>>n;
  vector<int> a(n);
  int i;
  for(i=0;i<n;i++)cin>>a.at(i);
  int now=1;
  int ans=0;
  for(i=0;i<n;i++)
  {
    if(a.at(i)==now)
    {
      now++;
    }
    else ans++;
  }
  if(ans==n)cout<<-1<<endl;
  else cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,n,i;
  cin>>a>>b;
  n=0;
  for (i=a;i<=b;i++) {
    if (i/10000==i%10 && i%10000/1000==i%100/10) n+=1;
  }
  cout<<n<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int N;
    int i;
    int t;
    int kei;

    scanf("%d", &N);
    if (N % 1000 > 0)
    {
        i = N / 1000;
        t = i * 1000 + 1000;
        kei = t - N;
        printf("%d", kei);
    }
    else
    {
        kei = N - N;
        printf("%d", kei);
    }

    return 0;
}

Measured memory_bytes: 1732
//#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9+7;
const long long INF = 1e15;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N, ans;
	cin >> N;
	ans = 0;
	for (int n = 1; n <= N; n++) {
		int a;
		cin >> a;
		if (n % 2 == 1) {
			if (a % 2 == 1)ans++;
		}
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3132
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	vint B;
	vint jun;
	scan(N);
	rep(i,N){
		int b; scan(b);
		B.push_back(b);
	}
	while(B.size()){
		int flag=0;
		for(int i=B.size()-1;i>=0;i--){
			if(B[i]==i+1){
				jun.push_back(B[i]);
				B.erase(B.begin()+i);
				flag=1;
				break;
			}
		}
		if(flag==0){
			prin("-1");
			return 0;
		}
	}
	for(int i=N-1;i>=0;i--){
		prin(jun[i]);
	}

	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 100005;
const int INF = 1001001001;
const int MOD = 1000000007;

struct mint {
    long long x;
    mint(long long x=0):x(x % MOD + (0 <= x ? 0 : MOD)) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint& a) { if ((x += a.x) >= MOD) x -= MOD; return *this; }
    mint& operator-=(const mint& a) { if ((x -= a.x) < 0) x += MOD; return *this; }
    mint& operator*=(const mint& a) { (x *= a.x) %= MOD; return *this; }
    mint operator+(const mint& a) const { return mint(x) += a; }
    mint operator-(const mint& a) const { return mint(x) -= a; }
    mint operator*(const mint& a) const { return mint(x) *= a; }

    // for prime mod
    mint inv() const {
        long long a = x, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        return mint(u);
    }
    mint& operator/=(const mint& a) { return *this *= a.inv(); }
    mint operator/(const mint& a) const { return mint(x) /= a; }
};
istream& operator>>(istream& is, const mint& a){ return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a){ return os << a.x; }

mint dp[MAX][2];

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

    int N = L.size();
    dp[0][0] = 1;
    rep(i, N) {
        rep(j, 2) {
            if (L[i] == '0') {
                if (j == 0) {
                    dp[i+1][j] += dp[i][j];
                } else {
                    dp[i+1][j] += dp[i][j] * 3;
                }
            } else {
                if (j == 0) {
                    dp[i+1][0] += dp[i][j] * 2;
                    dp[i+1][1] += dp[i][j];
                } else {
                    dp[i+1][j] += dp[i][j] * 3;
                }
            }
        }
    }

    cout << dp[N][0] + dp[N][1] << endl;
}

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

char rot(char c, int n) {
  if ('A' <= (c + n) && (c + n) <= 'Z') return (c + n);
  return ((c + n) % ('Z' + 1)) + 'A';
}

int main() {
  int N;
  scanf("%d", &N);
  string S;
  cin >> S;
  for (auto c : S) {
    cout << rot(c, N);
  }
  return 0;
}


Measured memory_bytes: 256
from collections import deque

N,M = map(int,input().split())
P = list(map(int,input().split()))
L = [list(map(int,input().split())) for i in range(M)]

G = [[] for i in range(N)]

for i in range(len(L)) :
    u,v = L[i]
    u -= 1
    v -= 1
    
    G[u].append(v)
    G[v].append(u)

explored = [0 for i in range(N)]

ans = 0

for i in range(N) :
    
    if explored[i] :
        continue
    
    explored[i] = 1
    q = deque([i])
    
    A = []
    B = []
    while q :
        now = q.popleft()
        
        A.append(now)
        B.append(P[now]-1)
        
        for to in G[now] :
            if explored[to] :
                continue
            
            q.append(to)
            explored[to] = 1
    
    C = set(A) & set(B)
    ans += len(C)
    

print(ans)
  

Measured memory_bytes: 66164
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
#define rep(i,n) for (int i = 0; i< (n); i++)
using namespace std;
 
int main() {
  int a,b,c;
  string s = "No";
  cin >>a>>b>>c;
 
  //vector<int> p(N); 
  
  //rep(i,N) cin >> p[i];

  //rep(i,N){
  
  

  if(a==b||a==c||b==c) s ="Yes";
  
  
  if(a==b&&b==c) s = "No";
  
 
  cout<<s<<endl;
  return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

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

    int n, a, b, c;
    cin >> n >> a >> b >> c;

    vector<char> ans(n);
    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }

    bool bad = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == "AB") {
            if (a == 0 and b == 0) {
                bad = 1;
                break;
            } else if (a == 1 and b == 1) {
                if (i + 1 < (int) s.size() and s[i + 1] == "AC") {
                    a++;
                    b--;
                    ans[i] = 'A';
                } else  {
                    a--;
                    b++;
                    ans[i] = 'B';
                }
            } else {
                if (a < b) {
                    a++;
                    b--;
                    ans[i] = 'A';
                } else {
                    a--;
                    b++;
                    ans[i] = 'B';
                }
            }
        } else if (s[i] == "BC") {
            if (b == 0 and c == 0) {
                bad = 1;
                break;
            } else if (b == 1 and c == 1) {
                if (i + 1 < (int) s.size() and s[i + 1] == "AB") {
                    b++;
                    c--;
                    ans[i] = 'B';
                } else {
                    b--;
                    c++;
                    ans[i] = 'C';
                }
            } else {
                if (b < c) {
                    b++;
                    c--;
                    ans[i] = 'B';
                } else {
                    b--;
                    c++;
                    ans[i] = 'C';
                }
            }
        } else {
            if (a == 0 and c == 0) {
                bad = 1;
                break;
            } else if (a == 1 and c == 1) {
                if (i + 1 < (int) s.size() and s[i + 1] == "AB") {
                    a++;
                    c--;
                    ans[i] = 'A';
                } else {
                    a--;
                    c++;
                    ans[i] = 'C';
                }
            } else {
                if (a < c) {
                    a++;
                    c--;
                    ans[i] = 'A';
                } else {
                    a--;
                    c++;
                    ans[i] = 'C';
                }
            }
        }
    }

    if (bad) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
        for (auto i: ans) {
            cout << i << "\n";
        }
    }
}

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

#define N 1e18

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  ll ans = 1;
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  rep(i,n){
    if(a[i] == 0){
      cout << 0 << endl;
      return 0;
    }
    else if(ans >= LONG_MAX / a[i]){
      puts("-1");
      return 0;
    }
    else ans *= a[i];
    if(ans > 1000000000000000000){
      puts("-1");
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4052
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0

for A in range(A+1):
    for B in range(B+1):
        for C in range(C+1):
            if (A*500 + B*100 + C*50) == X:
                count += 1
print(count)

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

ll dp[3005][3005];
vector<ll> a(3005);


ll dfs(ll l, ll r){
  if (dp[l][r]!=-1)return dp[l][r];
  ll now=-INF;
  now=max(now,a[l]-dfs(l+1,r));
  now=max(now,a[r]-dfs(l,r-1));
  dp[l][r]=now;
//  cout<<now<<"l"<<l<<"r"<<r<<endl;
  return dp[l][r];

}
int main(){
  ll n;
  cin>>n;
  rep(i,n)cin>>a[i];
  rep(i,3005)rep(j,3005)dp[i][j]=-1;
  rep(i,3005)dp[i][i]=a[i];
  dfs(0,n-1);

cout<<dp[0][n-1];




}


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

#define fi first
#define se second
typedef pair<int, int> pii;
const int N = 1e5+10;
pii a[N];
map<pii, int> msk;
map<int, int> mp;
int cnt[N];
vector<int> v[N];

void dfs(int x, int fa, int z){
    int zz = 1;
    for(auto it : v[x]){
        if(it != fa){
            if(msk[{x, it}]) mp[msk[{x, it}]] = zz==z?++zz:zz;
            else mp[msk[{it, x}]] = zz==z?++zz:zz;
            dfs(it, x, zz);
            zz++;
        }
    }

}



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

    for(int i = 1; i <= n-1; i++){
        cin>>a[i].fi>>a[i].se;
        cnt[a[i].fi]++;
        cnt[a[i].se]++;
        v[a[i].fi].push_back(a[i].se);
        v[a[i].se].push_back(a[i].fi);
        msk[{a[i].fi, a[i].se}] = i;
    }
    sort(cnt+1, cnt+1+n);
    cout<<cnt[n]<<endl;
    dfs(1, 0, 0);
    for(int i = 1; i <= n-1; i++){
        cout<<mp[i]<<endl;
    }


    return 0;
}

Measured memory_bytes: 18944
#include <stdio.h>

int main(){
	
	char s[25];
	scanf("%s",s);
	
	s[5] = ' '; // Karakter ke 6 pasti koma
	s[13] = ' ';// Karakter ke 14 pasti koma
	
	printf("%s",s);
	
	
	
	
	return 0;
}

Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  int A=0; int B=0;
  int a[N];
  rep(i,N) cin >> a[i];
  sort(a,a+N);
  for(int i=N-1; i>=0;i--){
    if(i%2==(N-1)%2) A+=a[i];
    else B+=a[i];
  }
  cout << A-B << endl;
  return 0;
    

}


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

int main(void){
    double r;
    cin >> r;
    
    double pi = acos(-1);
    cout << fixed << setprecision(6);
    double area = r * r * pi;
    double cir = (r + r) * pi;
    cout << area << " " << cir << endl;
    // Your code here!
    
}



Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int D;
  cin >> D;
  
  vector<int> c(26);
  for (int i = 0; i < 26; i++) {
    cin >> c.at(i);
  }
  
  vector<vector<int>> s(D, vector<int>(26));

  // 入力 (2重ループを用いる)
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s.at(i).at(j);
    }
  }
  
  int man = 0;
  vector<int> last(26,0);
  for(int i=0; i<D; i++){
    int kaisai = 0;
    int tmp = 0;
    for(int k=0; k<26; k++){ // i日目にk thの問題
      int add = s.at(i).at(k);
      last.at(k) = i+1;
      for(int j=0; j<26; j++){
        add -= c.at(j)*(1 + i - last.at(j));
      }
      last.at(k) = i-1;
      if(tmp < add){
        tmp = add;
        kaisai = k;
      }
	}
    
    last.at(kaisai) = i+1;
    
    cout << kaisai+1 << endl;
  }
  
  return 0; 
}

Measured memory_bytes: 3684
import sys


def input():
    return sys.stdin.readline().strip()

def main():
    a, b = map(int, input().split())
    if abs(a-b) % 2 != 0:
        print("IMPOSSIBLE")
        return
    if a >= b:
        print((a-b)//2+b)
        return
    print((b-a)//2+a)
    
main()


Measured memory_bytes: 2940
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifndef rd
#define endl '\n'
#endif
#ifdef rd
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
#else
#define trace(...)
#endif
#define deb cout<<"Line: "<<__LINE__<<" plz "
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
#define double long double
//typedef long double f80;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define all(con) con.begin(),con.end()
const ll infl=2e18;
const int infi=2e9;
const int mod=1e9+7;
typedef vector<int> vi;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
auto clk=clock();
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int a[256];
void solve() {
	int n;
	cin>>n;
	string s;
	cin>>s;
	for(int i=0; i<n; i++)
		a[s[i]]++;
	int ans=1;
	for(int i=0; i<256; i++) {
		ans=(ans*(a[i]+1))%mod;
	}
	cout<<(ans+mod-1)%mod<<endl;
}
signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cerr<<endl<<endl<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


Measured memory_bytes: 512
//AUTHOR - NAVEEN KUMAR(@naveen19991124)
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#inlcude<boost/multiprecision/cpp_dec_float.hpp>
#define ll long long
#define ld long double
#define F first
#define S second
#define mem(v) memset(v,0,sizeof(v))
#define all(v) v.begin(), v.end()
#define srt(v) sort(all(v))
#define rsrt(v) sort(v.rbegin(),v.rend())
#define pb push_back
#define f(a) for(ll i = 0;i<a;i++)
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define rrep(i,a,b) for(ll i = a;i>b;i--)
#define vll vector<ll>
#define mp make_pair
#define dbg1(a) cout<<a<<"\n";
#define dbg2(a,b) cout<<a<<" "<<b<<"\n";
#define hell 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
using namespace std:: chrono;
//using boost :: multiprecision :: cpp_int;
//using boost :: multiprecision :: cpp_dec_float_50;
//using boost :: multiprecision :: cpp_dec_float_100;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1;
a *= a; a %= mod;} return p % mod;}
ll modInverse(ll a, ll m) { ll m0 = m; ll y = 0, x = 1; 
if (m == 1) {return 0;} 
while (a > 1) { ll q = a / m; ll t = m;  m = a % m, a = t; t = y; y = x - q * y; x = t; } 
if (x < 0) {x += m0;} return x; } 
inline ll add(ll a, ll b) { return (((a >= hell) ? a % hell : a) + ((b >= hell) ? b % hell : b) + hell) % hell; }
inline ll subt(ll a, ll b) { return (a - b + hell) % hell; }
inline ll mult(ll a, ll b) { return (1ll * ((a >= hell) ? a % hell : a) * ((b >= hell) ? b % hell : b)) % hell; }
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)); }
ll mylog(ll n,ll b)
{ll i = 1;ll ans = 0;
while(1)
{if(i>n/b){break;} i = i*b;ans++;}return ans;
}
bool compare(const pair<ll,ll> &a,const pair<ll,ll> &b){
if (a.first == b.first)
{return a.second<b.second;} 
return a.first<b.first;
}
bool comparerev(const pair<ll,ll> &a,const pair<ll,ll> &b){
if(a.first == b.first)
{return a.second>b.second;}
return a.first>b.first;
}
int main()
{
	fast
	ll t = 1;
	//cin>>t;
	while(t--){
	ll x;
	cin>>x;
	vector<pair<ll,ll> >val;
	ll ss = 1;
	val.pb(mp(0,0));
	while(1)
	{
		//cout<<ss<<"\n";
		if(power(ss,5)<=100000000000000)
		{
			val.pb(mp(pow(ss,5),ss));
			val.pb(mp(-pow(ss,5),-ss));
			ss++;
		}
		else
		{
			break;
		}
	}
	ll ans1,ans2;
	rep(i,0,val.size())
	{
		rep(j,0,val.size())
		{
			if(val[i].F-val[j].F == x)
			{
				ans1 = val[i].S;
				ans2 = val[j].S;
				break;
			}
		}
	}
	
	cout<<ans1<<" "<<ans2<<"\n";
	} 
	return 0;
}

Measured memory_bytes: 4044