akhauriyash/Code-Regression huggingface dataset:
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,m,x[105],X,y[105],Y;
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;++i){
        int _;
        scanf("%d",&_);
        if(_&1)x[++X]=_;
        else y[++Y]=_;
    }
    if(m==1){
        if(n==1){
            printf("1\n1\n1\n",n);
        }
        else{
            printf("%d\n2\n%d 1\n",n,n-1);
        }
    }
    else if(X>2){
        puts("Impossible");
    }
    else if(X==2){
        if(x[1]==1){
            printf("%d ",x[1]);
            for(int i=1;i<=m-2;++i)printf("%d ",y[i]);
            printf("%d\n",x[2]);
            printf("%d\n",m-1);
            for(int i=1;i<=m-2;++i)printf("%d ",y[i]);
            printf("%d\n",x[2]+1);
        }
        else{
            printf("%d ",x[1]);
            for(int i=1;i<=m-2;++i)printf("%d ",y[i]);
            printf("%d\n",x[2]);
            printf("%d\n",m);
            printf("%d ",x[1]-1);
            for(int i=1;i<=m-2;++i)printf("%d ",y[i]);
            printf("%d\n",x[2]+1);
        }
    }
    else if(X==1){
        printf("%d ",x[1]);
        for(int i=1;i<m-1;++i)printf("%d ",y[i]);
        printf("%d\n",y[m-1]);
        printf("%d\n",m);
        printf("%d ",x[1]+1);
        for(int i=1;i<m-1;++i)printf("%d ",y[i]);
        printf("%d\n",y[m-1]-1);
    }
    else{
        for(int i=1;i<m;++i)printf("%d ",y[i]);
        printf("%d\n",y[m]);
        printf("%d\n",m);
        printf("%d ",y[1]+1);
        for(int i=2;i<m;++i)printf("%d ",y[i]);
        printf("%d\n",y[m]-1);
    }
    //system("pause");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 1000005

ll dp[MAX_N] = {};
int dpnext[MAX_N];
char nextchar[MAX_N];
int next_[MAX_N][26];
int zflag[MAX_N];
int zz = 0;
string s;
ll n;
string ans;

void dfs(int x){
    if(dp[x] != 0) return;
    dp[x] = 1001001001;    
    rep(j,26){
        int y = next_[x][j];
        if(y == n){
            dp[x] = 1;
            dpnext[x] = n;
            nextchar[x] = (char)(j + 'a');
            break;
        }else{
            dfs(y);
            if(dp[y]+1 < dp[x]){
                dp[x] = dp[y] + 1;
                dpnext[x] = y;
                nextchar[x] = (char)(j + 'a');
            }
        }
    }
    return;
}

void calc(int x){
    if(x == n)return;
    ans += nextchar[x];
    calc(dpnext[x]);
}

int main() {
    cin >> s;
    s = '*' + s; // 1文字目にダミー文字挿入.
    n = s.size();

    // 各アルファベットに対して次の位置を記憶する.
    drep(i,n){
        rep(j,26){
            if(i == n-1) next_[i][j] = n;
            else next_[i][j] = next_[i+1][j];
        }
        if(i < n-1){
            next_[i][s[i+1]-'a'] = i+1;
        }
    }

    dfs(0);

    calc(0);

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




Measured memory_bytes: 31680
while 1:
	n, p = map(int, raw_input().split(" "))
	if (n,p) == (0,0):
		break
	own_stone = [0 for i in range(n)]
	cup = p
	i = 0
	while 1:
		if cup == 0:
			cup += own_stone[i]
			own_stone[i] = 0
		else :
			cup -= 1
			own_stone[i] += 1
		if own_stone[i] == p:
			print i
			break
		else :
			i = i + 1 if i < n - 1 else 0 

Measured memory_bytes: 4228
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
#define int long long
using ll = long long;
using namespace std;
const int INF = 1LL << 50;
using P       = pair<int, int>;

template <class T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    } else {
        return false;
    }
}
template <class T>
bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    } else {
        return false;
    }
}

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

signed main() {
    int n;
    cin >> n;
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    int nin = min({a, b, c, d, e});
    int ans = ((n + nin - 1) / nin) + 4; // 分子は切り上げ処理
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2) // 2進数の文字列を int に
//cout << fixed << setprecision(15);

int main() {
  int a;
  cin >> a;
  cout << a + a * a + a * a * a << endl;
}


Measured memory_bytes: 3592
import sys
input = sys.stdin.buffer.readline

N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()

lim = 0
ans = 0
wait = 0
for t in T:
    if t > lim:
        if wait:
            ans += 1
        if C == 1:
            ans += 1
            wait = 0
            lim = 0
        else:
            lim = t + K
            wait = 1
    else:
        wait += 1
        if wait == C:
            ans += 1
            wait = 0
            lim = 0
if wait:
    ans += 1

print(ans)

Measured memory_bytes: 7504
/*
@Date    : 2019-10-05 13:07:36
@Author  : Adscn (adscn@qq.com)
@Link    : https://www.cnblogs.com/LLCSBlog
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IL inline
#define RG register
#define gi geti<int>()
#define gl geti<ll>()
#define gc getchar()
#define File(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
template<typename T>IL bool chkmax(T &x,const T &y){return x<y?x=y,1:0;}
template<typename T>IL bool chkmin(T &x,const T &y){return x>y?x=y,1:0;}
template<typename T>
IL T geti()
{
	RG T xi=0;
	RG char ch=gc;
	bool f=0;
	while(!isdigit(ch))ch=='-'?f=1:f,ch=gc;
	while(isdigit(ch))xi=xi*10+ch-48,ch=gc;
	return f?-xi:xi;
}
template<typename T>
IL void pi(T k,char ch=0)
{
	if(k<0)k=-k,putchar('-');
	if(k>=10)pi(k/10);
	putchar(k%10+'0');
	if(ch)putchar(ch);
}
typedef pair<ll,ll> pll;
int n;
const int N=2e5+7,P=1e9+7;
ll ksm(ll a,int b,ll c=1)
{
	for(;b;b>>=1,a=a*a%P)if(b&1)c=c*a%P;
	return c;
}
ll inv(ll x){return ksm(x,P-2);}
struct edge{int v,nxt;}e[N];
int head[N],cnt;
inline void add(int u,int v){e[++cnt]=(edge){v,head[u]},head[u]=cnt;}
inline void init(){memset(head,cnt=-1,sizeof head);}
vector<pll>dp[N];
ll All[N],Zero[N],One[N];
int id[N],num,d[N];
#define mp make_pair
#define fi first
#define se second
#define For_tree(x) for(int _i=head[x],v=e[_i].v;~_i;_i=e[_i].nxt,v=e[_i].v)
inline void dfs(int x)
{
	int hson=n+1,tot=0;
	For_tree(x)
	{
		dfs(v);++tot;
		if(d[v]>d[hson])hson=v;
	}
	if(hson!=n+1)id[x]=id[hson],d[x]=d[hson]+1;
	else id[x]=++num;
	dp[id[x]].push_back(mp(1,1));
	if(tot==1)return;
	for(int i=0;i<d[x];++i)All[i]=1,Zero[i]=1,One[i]=0;
	int dep;
	For_tree(x)
		for(int i=0;i<=d[v];++i)
		{
			dep=d[hson]-d[v]+i;
			pll t=dp[id[v]][i];
			(All[dep]*=(t.fi+t.se))%=P,(Zero[dep]*=t.fi)%=P;
		}
	For_tree(x)
		for(int i=0;i<=d[v];++i)
		{
			dep=d[hson]-d[v]+i;
			pll t=dp[id[v]][i];
			(One[dep]+=Zero[dep]*inv(t.fi)%P*t.se%P)%=P;
		}
	for(int i=0;i<d[x];++i)
	{
		pll &t=dp[id[x]][i];
		t.fi=(All[i]-One[i]+P)%P,t.se=One[i];
	}
}
int dep[N],tot[N],fa[N];
int main(void)
{
	n=gi;init();
	for(int i=1;i<=n;++i)fa[i]=gi,add(fa[i],i),dep[i]=dep[fa[i]]+1,++tot[dep[i]];
	d[n+1]=-1,++tot[0];
	dfs(0);
	ll ans=0;
	for(int i=0;i<=d[0];++i){
		pll t=dp[id[0]][i];
		(ans+=t.se*ksm(2,n+1-tot[d[0]-i])%P)%=P;
	}
	pi(ans);
	return 0;
}

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

int Euclid(int x,int y){
  if(!(x%y))
    return y;

  return Euclid(y,x/y);
}
int main(int argc, char *argv[])
{
  int x,y,w[1000];
  cin >> x >> y;

  for(int i=0; i<x; i++)
    cin >> w[i];

  int num=x;
  while(num%y)
    num += x;

  int sum = 0;
  int max=0;
  int min=0;

  for(int i=0; i<num; i++){
    int ind = i%x;

    if(w[max]<w[ind])
      max=ind;
    else if(w[min]>w[ind])
      min=ind;
    
    if(i%y == y-1){
      sum += w[max]-w[min];
      max = ind+1;
      min = max;
    }

  }
  cout << sum<< "\n";
}

Measured memory_bytes: 3104
//................ DON'T WISH IT WERE EASIER, WISH YOU WERE BETTER........................
//............ WHEN LIFE PUTS YOU IN TOUGH SITUATIONS, DONT SAY "WHY ME" SAY "TRY ME".......

#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define pb emplace_back
#define endl "\n"
#define f first
#define mp make_pair
#define s second
// #define int long long
#define delrep(v)  (v).erase(unique((v).begin(),(v).end()),(v).end());
#define all(a)  (a).begin(),(a).end()
#define allr(a) (a).rbegin(),(a).rend()
#define sz(x)   (int)x.size()
#define lll __int64
const int N=1e6+10; const int M=1e6+20;
const int mod=1e9+7;
using namespace std;
typedef long long ll;
const long long MAX_SIZE = 3000003;
vector<pair<int,int>>v[N]; map<int,int>hashx;
vector<int>a(N); vector<int>b(N); int pref[N]; int suff[N]; int sum[N];
// vector<ll>dp(N);
ll n,k;
ll dp[1005][1005];
int32_t main()
{
    int n,ans=0; cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; if(a[i]>a[i-1]) pref[i]=0; else pref[i]++; }
    for(int i=1;i<=n;i++) if(pref[i]) pref[i]+=pref[i-1]; else pref[i]=0;
    for(int i=0;i<N;i++) ans=max(ans,pref[i]);
    cout<<ans;
    return 0;

}
 



Measured memory_bytes: 34816
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int powmod(int a, int n, int mod) {
	if (n == 0) return 1;
	if (n % 2 == 0) return powmod((a * a) % mod, n / 2, mod);
	return (a * powmod(a, n - 1, mod)) % mod;
}

int p;
int a[2999];
int fact[2999];
int factInv[2999];

int comb(int n, int k) {
	if (k > n) return 0;
	return fact[n] * factInv[k] % p * factInv[n - k] % p;
}

int b[2999];

signed main() {
	int i, j;
	
	cin >> p;
	rep(i, p) cin >> a[i];
	
	fact[0] = 1;
	for (i = 1; i <= p; i++) fact[i] = (i * fact[i - 1]) % p;
	for (i = 0; i <= p; i++) factInv[i] = powmod(fact[i], p - 2, p);
	
	rep(i, p) {
		int powI[2999];
		powI[0] = 1;
		rep(j, p - 1) powI[j + 1] = (powI[j] * i) % p;
		
		rep(j, p) {
			int res = a[i] * comb(p - 1, j) % p * powI[p - 1 - j] % p;
			if ((p - j) % 2 == 0) { b[j] += res; b[j] %= p; }
			else b[j] = (b[j] - res + p) % p;
		}
	}
	rep(i, p) { b[0] += a[i]; b[0] %= p; }
	
	rep(i, p) {
		cout << b[i];
		if (i + 1 < p) cout << " ";
	}
	cout << endl;
	return 0;
}

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

int64_t cnt;


void inserts(int A[],int n,int g){
    for(int i=1;i<n;i++){
        int v=A[i];
        int j=i-g;
        while(j>=0&&A[j]>v){
            A[j+g]=A[j];
            j=j-g;
            cnt++;
        }
        A[j+g]=v;

    }
}

int main(){
    int n,A[1000010];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    int G[999];
    G[0]=1;
    int m=0;
    for(int i=0;i<998;i++){
        G[i+1]=3*G[i]+1;
        if(n<=G[i+1]){
            m=i+1;
            break;
        }
    }
    
    cout<<m<<endl;
    for(int i=m-1;i>=0;i--){
        cout<<G[i];
        if(i!=0)cout<<" ";
    }
    cout<<endl;
    
    cnt=0;
    for(int i=0;i<m;i++){
        inserts(A,n,G[m-1-i]);
    }
    cout<<cnt<<endl;
    for(int i=0;i<n;i++){
        cout<<A[i]<<endl;
    }
}






Measured memory_bytes: 6992
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from pprint import pprint
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

def dijkstra(G, s=0):
    n = len(G)
    que = [(0, s)]
    dist = [INF] * n
    dist[s] = 0
    while que:
        min_dist, u = heappop(que)
        if min_dist > dist[u]:
            continue
        for v, c in G[u]:
            if dist[u] + c < dist[v]:
                dist[v] = dist[u] + c
                heappush(que, (dist[u] + c, v))
    return dist

n, m, s, t = LI()
s-=1
t-=1
G1 = [[] for _ in range(n)]
G2 = [[] for _ in range(n)]
for _ in range(m):
    u, v, a, b = LI()
    G1[u-1] += [(v-1, a)]
    G1[v - 1] += [(u - 1, a)]
    G2[u-1] += [(v-1, b)]
    G2[v - 1] += [(u - 1, b)]

y_cost = dijkstra(G1, s)
s_cost = dijkstra(G2, t)
ans = [0] * n
ret = INF
for i in range(n - 1, -1, -1):
    ret = min(ret, s_cost[i] + y_cost[i])
    ans[i] = 10**15 - ret

print(*ans, sep="\n")



Measured memory_bytes: 133300
public class Main {

	/**
	 * ????????????????????????
	 *
	 */
	public static void main(String[] args) {
		for (int i = 1; i < 10; i++) {
			for (int j = 1; j < 10; j++) {
				System.out.println(i + "x" + j + "=" + i*j);
			}
		}
	}
}

Measured memory_bytes: 24160
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double x1 = sc.nextDouble(), y1 = sc.nextDouble(), x2 = sc.nextDouble(), y2 = sc.nextDouble();
		System.out.printf("%.6f\n", Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));
		sc.close();
	}
}


Measured memory_bytes: 28232
from collections import defaultdict

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

dic = defaultdict(int)
for d in D:
    dic[d] += 1

for t in T:
    if dic[t]:
        dic[t] -= 1
    else:
        print ('NO')
        exit()

print ('YES')

Measured memory_bytes: 41700
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;
//const ll INF = 1e18;

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

ll cal_gcd(ll a, ll b) {
	ll m = max(a, b);
	ll n = min(a, b);
	while (m%n != 0) {
		ll b = m % n;
		m = n;
		n = b;
	}
	return n;
}

int main() {
	int n;
	ll m;
	cin >> n >> m;
	vector<ll>a(n);
	bool ok = true;
	int f2 = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i] /= 2;
	}
	ll lcd = a[0];
	ll foo = a[0];
	while (foo % 2 == 0) {
		foo /= 2;
		f2++;
	}
	for (int i = 1; i < n; i++) {
		if (ok) {
			int tmp = 0;
			ll foo = a[i];
			while (foo % 2 == 0) {
				foo /= 2;
				tmp++;
			}
			if (f2 != tmp)ok = false;
		}
		ll gcd = cal_gcd(lcd, a[i]);
		lcd = lcd * a[i] / gcd;
		if (lcd > m)break;
	}
	ll ans = m / lcd;
	if (ans % 2 == 1)ans += 1;
	ans /= 2;
	if (ok) {
		cout << ans << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

xx = inputs[0][0]
yy = inputs[0][1]

# body
if $debugFlag
  p xx
  p yy
end

puts xx + yy/2


Measured memory_bytes: 1788
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N, M;
int X[100010];
int cnt[100010];
int mod[100010][2];

int get_cnt(int x) {
  return mod[x][0] + 2 * mod[x][1];
}

int same(int x) {
  int c = get_cnt(x);
  return c/2;
}

int odd(int x) {
  int c = get_cnt(x);
  int d = get_cnt(M - x);
  if (c < d) {
    swap(c, d);
    x = M - x;
  }
  int ans = d;
  if (d <= mod[x][0]) {
    ans += mod[x][1];
    return ans;
  } else {
    ans += (mod[x][1] * 2 - (d - mod[x][0]))/2;
    return ans;
  }
}

int res(int x) {
  if (M%2 == 0 && x == M/2) {
    return same(x);
  } else if (x == 0) {
    return same(x);
  } else {
    return odd(x);
  }
}

int main () {
  cin >> N >> M;
  for (auto i = 0; i < N; ++i) {
    cin >> X[i];
  }
  fill(cnt, cnt+100010, 0);
  for (auto i = 0; i < N; ++i) {
    cnt[X[i]]++;
  }
  fill(&mod[0][0], &mod[0][0]+100010*2, 0);
  for (auto i = 0; i < 100010; ++i) {
    mod[i%M][0] += cnt[i]%2;
    mod[i%M][1] += cnt[i]/2;
  }
  int ans = 0;
  for (auto i = 0; i <= M/2; ++i) {
    ans += res(i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<endl;
#define printii(x)  for(auto it=x.begin();it!=x.end();it++) cout<<*it.F<<' '<<*it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)

int a[] = {0,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, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4};
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m;
    cin>>t;
    cout<<a[t];
    

    return 0;
}







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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;

void run_case()
{
    ll x;
    cin >> x;
    vector<int> p;
    while (x)
    {
        int cur = x % 26;
        if (cur == 0)
        {
            p.push_back(26);

            x = x / 26 - 1;
        }
        else
        {
            p.push_back(cur);
            x /= 26;
        }
    }
    for (int i = p.size() - 1; i >= 0; i--)
    {
        cout << char(p[i] + 'a' - 1);
    }
    cout << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a[] = new int[3];
		for (int i = 0; i < 3; ++i)
			a[i] = sc.nextInt();
		sc.close();
		int ans = 1000, tmp = 0;
		for (int i = 0; i < 3; ++i) {
			for (int j = 0; j < 3; ++j) {
				if (i != j) {
					tmp = Math.abs(a[i] - a[j]);
					for (int k = 0; k < 3; ++k) {
						int tmp2 = 0;
						if (i != k && j != k) {
							tmp2 = Math.abs(a[i] - a[k]);
							ans = Math.min(ans, tmp + tmp2);
							tmp2 = Math.abs(a[j] - a[k]);
							ans = Math.min(ans, tmp + tmp2);
						}
					}
				}
			}
		}
		System.out.println(ans);
	}

}


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

int ac,wa,tle,re;

main()
{
    int n; cin>>n;
    for(;n--;)
    {
        string s; cin>>s;
        if(s=="AC") ac++;
        if(s=="TLE") tle++;
        if(s=="WA") wa++;
        if(s=="RE") re++;
    }
    cout << "AC x " << ac << "\n";
    cout << "WA x " << wa << "\n";
    cout << "TLE x " << tle << "\n";
    cout << "RE x " << re << "\n";
}

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


int main()
{
    ios_base::sync_with_stdio(false);


    int n,a;
    cin>>n;
    string s1,s2,s3,s4;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        s1+=to_string(a);
    }
    for(int i=0;i<n;i++)
    {
        cin>>a;
        s2+=to_string(a);
    }
    int c1=1,c2=1;
    s3=s1;
    sort(s3.begin(),s3.end());
    s4=s2;
    sort(s4.begin(),s4.end());
    while(1)
    {
        if(s1==s3)
            break;
        else
        {
            if(next_permutation(s3.begin(),s3.end()))
                c1++;
            else
                break;
        }
    }
    while(1)
    {
        if(s2==s4)
            break;
        else
        {
            if(next_permutation(s4.begin(),s4.end()))
                c2++;
            else
                break;
        }
    }
    cout<<abs(c2-c1)<<"\n";
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::collections::HashSet;
use std::str::Chars;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let s = read::<String>();
    let s1 = s.chars();
   
    let answer = solve(s1);
    if answer {
        println!("Bad");
    } else {
        println!("Good")
    }
}

fn solve(s: Chars) -> bool {
    let mut prev  = 'X';
    for c in s {
        if c == prev {
            return true;
        }
        prev = c
    }
    
    return false;
}


Measured memory_bytes: 2064
#include<stdio.h>
#include<iostream>
using namespace std;

int main() {
  int max = 1000;

  while (1) {
    char x[max];
    scanf("%s", x);

    if (x[0] == '0') break;

    int sum = 0;
    for (int i = 0; i < max; i++) {
      if (x[i] == '\0') break;
      int n = x[i] - '0';
      sum += n;
    }

    cout << sum << endl;
  }

  return 0;
}



Measured memory_bytes: 3232
N = int(input())
B = list(map(int, input().split()))

A = []
for i in range(N):
    if i==0:
        A.append(B[0])
    elif i==N-1:
        A.append(B[-1])
    else:
        A.append(min(B[i], B[i-1]))

print(sum(A))

Measured memory_bytes: 38384
#include<stdio.h>
#include<math.h>

typedef struct{
  double x;
  double y;
}Point;

void kock(int,Point,Point);

int main(){
  int n;
  Point p1={0,0},p2={100,0};

  scanf("%d",&n);
  
  printf("%f %f\n",p1.x,p2.y);

  kock(n,p1,p2);

  printf("%f %f\n",p2.x,p2.y);

  return 0;
}

void kock(int n, Point p1, Point p2){
  Point s,t,u;

  if(n==0) return;

  s.x = (2.0*p1.x+1.0*p2.x)/3.0;
  s.y = (2.0*p1.y+1.0*p2.y)/3.0;
  t.x = (1.0*p1.x+2.0*p2.x)/3.0;
  t.y = (1.0*p1.y+2.0*p2.y)/3.0;
  
  u.x = (t.x-s.x)*cos(60*M_PI/180.0)-(t.y-s.y)*sin(60*M_PI/180.0)+s.x;
  u.y = (t.x-s.x)*sin(60*M_PI/180.0)+(t.y-s.y)*cos(60*M_PI/180.0)+s.y;

  kock(n-1,p1,s);
  printf("%f %f\n",s.x,s.y);
  kock(n-1,s,u);
  printf("%f %f\n",u.x,u.y);
  kock(n-1,u,t);
  printf("%f %f\n",t.x,t.y);
  kock(n-1,t,p2);

  return;
}

Measured memory_bytes: 636
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n, m, a, b;
    cin >> n >> m;
    vector<int> h(n);
    vector<bool> f(n);
    for (int i = 0; i < n; ++i) cin >> h.at(i);
    for (int i = 0; i < m; ++i) {
        cin >> a >> b, --a, --b;
        if (h.at(a) <= h.at(b)) f.at(a) = 1;
        if (h.at(a) >= h.at(b)) f.at(b) = 1;
    }
    cout << count(f.begin(), f.end(), 0) << endl;
    return 0;
}


Measured memory_bytes: 3780
N = int(input())
A = [input() for _ in range(N)]

from collections import Counter
ctr = Counter()

for a in A:
    of = 0
    if '.' in a:
        of = a[::-1].index('.')
        a = a.replace('.', '')
    a = int(a)
    ni = go = -of
    while a%2==0:
        a//=2
        ni += 1
    while a%5==0:
        a//=5
        go += 1
    ctr[(ni,go)] += 1

ans = 0
for (ni1,go1),v1 in ctr.items():
    for (ni2,go2),v2 in ctr.items():
        if ni1+ni2 < 0 or go1+go2 < 0: continue
        if ni1==ni2 and go1==go2:
            ans += v1*(v1-1)
        else:
            ans += v1*v2
print(ans//2)

Measured memory_bytes: 23528
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n],b[n],i;
  for(i=0;i<n;i++){
    cin>>a[i];
    b[i]=a[i];
  }
  sort(b,b+n,greater<int>());
  //cout<<b[0]<<" "<<b[1]<<endl;
  for(i=0;i<n;i++){
   if(a[i]==b[0]) cout<<b[1]<<endl;
    else cout<<b[0]<<endl;
  }
  return 0;
}
  

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

#define ll long long
#define mod 1000000007
#define pii pair<ll,ll>

#define debug(a) { cout << #a << " = " << a << endl;}

void sep() {
    cout << "-------------BLOCK-----------------\n";
}

template<typename T>
void debugv(vector<T> arr) {
    for (auto t: arr)
        cout << t << " ";
    cout << "\n";
}

template<typename T>
void debugarr(T arr, int n) {
    for (int i=0;i<n;i++) cout << arr[i] << " ";
    cout << "\n";
}

const int maxn = 1e5+1;
ll arr[maxn], n, m, t, k;
unordered_map<ll,ll> u;

ll __min(ll a, ll b) {
    return a < b ? a : b;
}

ll __max(ll a, ll b) {
    return a > b ? a : b;
}

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

    cin>>n;
    cout << 1 - n << endl;
}


Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	//min(a,b)...a,bの小さいほう
	//max(a,b)...     大きいほう
	int a;
	int b;
	int c;
	int d;
	int e;
	//int num;
	//string s;
	//cin >> s;
	std::cin >> a >> b >> c;
	if (a + b < c) {
		cout << "No" << "\n";
	}
	else {
		cout << "Yes" << "\n";
	}
	std::cin >> e;
}

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

int main() {
  string s,t;
  cin >> s;
  cin >> t;
  int n = s.size();
  int b = 1;
  for(int i = 0; i < n; i++) {
    if (s.at(i) != t.at(i)) {
      b = 0;
      break;
    }
  }
  if(b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3628
n = int(input())
A = [0] + list(map(int,input().split())) + [0]
B = [0]*n
C = [0]*(n+1)

for i in range(n):
    B[i]=abs(A[i]-A[i+2])
for i in range(n+1):
    C[i]=abs(A[i]-A[i+1])
sumC = sum(C)
for i in range(n):
    print(sumC+B[i]-C[i]-C[i+1])

Measured memory_bytes: 15924
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 9223372036854775807ll;
const int nax = 300005;
int a[nax],ans[nax];
void solve()
  {
   int n;
   cin>>n;
   loop(i,0,n)
    cin>>a[i];
   sort(a,a+n,greater<int>());
   int pos = 1;
   ans[0] = a[0];
   loop(i,1,n)
    {
      if(pos>=n)
         break;
      ans[pos] = a[i];
      ans[pos+1] = a[i];
      pos+=2;
    }
   int res = 0;
   loop(i,0,n-1)
    {
      //cerr<<ans[i]<<" ";
      res += ans[i];
    }
   cout<<res;
  }
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 6764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

bool pairCompare(const pair<int,int>& firstElof, const pair<int,int>& secondElof)
{
    return firstElof.second < secondElof.second;
}

int main(void)
{
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> cut(m);
    REP(i,m)
    {
        cin >> cut[i].first >> cut[i].second;
    }
    sort(all(cut),pairCompare);

    vector<pair<int, int>> cut_range;
    cut_range.push_back(cut[0]);

    FOR(i,1,m)
    {
        auto itr = upper_bound(all(cut_range),pair<int,int>(INF,cut[i].first),pairCompare);
        if( itr == cut_range.end()){
            cut_range.push_back(cut[i]);
        }
        else{
            itr->first = max(itr->first,cut[i].first);
        }
    }

    cout << cut_range.size() << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++) 
#define fs first
#define sc second
#define _GLIBCXX_DEBUG

template<class S>S sum(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));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}

template <class S>
void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){
		cerr << v[i] << ' ';
	}
	cerr << endl;
}
template <class S>
void print(vector<vector<S>> &v) {
  	for (ll i = 0; i < (ll)v.size(); i++) {
    	for (ll j = 0; j < (ll)v[i].size(); j++) {
      		cerr << v[i][j] << ' ';
    	}
    	cerr << endl;
  	}
}


int main(){
	int n; cin >> n;
	map<string,int> m;
	rep(i,n){
		string q;
		cin >> q;
		vector<char> s;
			rep(i,10){
			s.push_back(q[i]);
			}
		sort(all(s));
		string k(all(s));
		m[k]++;
	}
	ll ans = 0;
	for(auto p: m){
		int v = p.sc;
		ans += (ll)(v-1) * v /2;
	}
	cout << ans << endl;
}

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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			string s = cin.Next();
			string t = cin.Next();
			int ans = 0;
			for (int i = 0; i < 3; i++) {
				if (s[i] == t[i]) {
					++ans;
				}
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;

		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 13140
import numpy as np

N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

b = [0] * M
c = [0] * M
for i in range(M):
    b[i], c[i] = map(int, input().split())

lst = np.array([c, b]).T.tolist()
lst.sort(reverse=True)
c = np.array(lst).T.tolist()[0]
b = np.array(lst).T.tolist()[1]

d = [0] * N
k = 0
for i in range(M):
    if k < N:
        d[k:k+b[i]] = [c[i]] * b[i]
        k += b[i]

for i in range(N):
    A[i] = max(A[i], d[i])

print(sum(A))

Measured memory_bytes: 49896
#include <stdio.h>
#define N 8
#define FREE 0
#define NFREE 1
int X[N][N];
int row[N],col[N],lef[2*N-1],rig[2*N-1];
void input (void);
void printBoard(void);
void recursive (int );
int main()
{
  int i,j,x,r,c;
  input();
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      X[i][j] =0;
    }
  }
  scanf("%d",&x);
  for(i=0;i<x;i++)
    {
      scanf("%d %d",&r,&c);
      X[r][c] =1;
      
    }
  recursive(0);

  return 0;
}


void input (void){
  int i,j;
  for(i=0;i<N;i++)
    {
      row[i]=FREE;
      col[i]=FREE;
    }
  for(j=0;j<2*N-1;j++)
    {
      lef[j]=FREE;
      rig[j]=FREE;
      
    }

}
void printBoard(void)
{
  int i,j;
  for(i=0;i<N;i++)
    {
      for(j=0;j<N;j++)
	{
	  if(X[i][j]){
	    if(row[i] !=j) return ;
	  }
	}
    }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++)
      {
	if(row[i]==j)printf("Q");
	else printf(".");
      }
    printf("\n");
  }
}
void recursive (int x)
{
  int i;
  if(x==N)
    {
      printBoard(); /*配置成功 */
      return;
    }
  for(i=0;i<N;i++)
    {
      if(NFREE ==col[i] || NFREE ==lef[x+i] || NFREE ==rig[x-i+N-1]) continue;
      row[x]=i;
      col[i]=NFREE;
      lef[x+i]=NFREE;
      rig[x-i+N-1]=NFREE;
      
      recursive(x+1);
      row[x]=FREE;
      col[i]=FREE;
      lef[x+i]=FREE;
      rig[x-i+N-1]=FREE;
    }
}



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

int n;
int ary[200];

int main()
{
    cin >> n;
    for(int i=0;i<n;i++) cin >> ary[i];

    int res = 0;
    bool flag = false;
    int count = 0;

    while(true) {
        for (int i=0;i<n;i++) {
            if (ary[i]%2 != 0) {
                flag = true;
                break;
            }
        }
        if (flag) {
            break;
        }
        for (int i=0;i<n;i++) {
            ary[i] /= 2;
        }
        ++count;
    }
    cout << count << endl;
}

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

int main()
{
    int r;
    cin >> r;
    double ans = 0;
    ans = 2.0 * r * 3.14159265358979323846;
    printf("%5.20f\n",ans);

    return 0;
}


Measured memory_bytes: 3764
#include<iostream>
using namespace std;
double abs(double x){
  return (x<0?-x:x);
}
int main(){
  int N,T;
  cin>>N>>T;
  int c[N],t[N];
  for(int i=0;i<N;i++) cin>>c[i]>>t[i];
  int min=-1;
  for(int i=0;i<N;i++){
    if(t[i]<=T&&min==-1){
      min=c[i];
    }else if(t[i]<=T&&c[i]<min){
      min=c[i];
    }
  }
  cout<<(min==-1?"TLE":to_string(min))<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Spandan Mishra
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        FDivisionOrSubtraction solver = new FDivisionOrSubtraction();
        solver.solve(1, in, out);
        out.close();
    }

    static class FDivisionOrSubtraction {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.readLong();
            // no of divisors of n-1
            // if k(simulate 2 to sqrt n) divisible by n , add +1

            int n1 = (n == 2) ? 0 : 1;

            for (long i = 2; i <= Math.sqrt(n - 1); i++)
                if ((n - 1) % i == 0) {
                    if (i == Math.sqrt(n - 1))
                        n1++;
                    else
                        n1 += 2;
                }


            int n2 = 1;
            for (long i = 2; i <= Math.sqrt(n); i++) {
                if (n % i == 0) {
                    long tmp = n;
                    while (tmp % i == 0) {
                        tmp /= i;
                    }
                    if (tmp % i == 1) n2++;
                }
            }

            System.out.println(n1 + n2);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new RuntimeException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public long readLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 22740
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// NのP乗をMで割った余りを返す
ll pow_mod(ll n,ll k,ll m){
  if(k==0){
    return 1;
  }else if(k%2==1){
    return pow_mod(n,k-1,m)*n%m;
  }else{
    ll t=pow_mod(n,k/2,m);
    return (t*t)%m;
  }
}

//(10*9*8)/(3*2*1);
//10*9*8 -> ansMul
//3*2*1 -> ansDiv
long calcComb(int a, int b) {
	if (b > a - b) return calcComb(a, a - b);


	long ansMul = 1;
	long ansDiv = 1;
	for (int i = 0; i < b; i++)
	{
		ansMul *= (a - i);
		ansDiv *= (i + 1);
		ansMul %= MOD;
		ansDiv %= MOD;
	}
	//ansMul / ansDivをやりたい
	//ansDivの逆元を使って求めよう！

	long ans = ansMul * pow_mod(ansDiv,MOD - 2,MOD);
	return ans;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N,M;
  cin >> N >> M;
  map<int,int> m;
  for(int i=2;i*i<=M;i++){
    while(M%i==0){
      m[i]++;
      M/=i;
    }
  }
  if(M!=1)m[M]++;
  COMinit();
  ll ans=1;
  for(auto e:m){
    ans*=calcComb(N-1+e.second,N-1)%MOD;
    ans%=MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 12160
package main

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

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	m := nextInt()
	k := nextInt()
	as := make([]int, n)
	bs := make([]int, m)
	for i := 0; i < n; i++ {
		as[i] = nextInt()
	}
	for i := 0; i < m; i++ {
		bs[i] = nextInt()
	}

	a := make([]int, n+1)
	for i := 0; i < n; i++ {
		a[i+1] = a[i] + as[i]
	}
	b := make([]int, m+1)
	for i := 0; i < m; i++ {
		b[i+1] = b[i] + bs[i]
	}

	ans := 0
	j := m
	for i := 0; i <= n; i++ {
		if a[i] > k {
			break
		}
		for b[j] > k-a[i] {
			j--
		}
		ans = max(ans, i+j)
	}

	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 9992
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define FOR(i,n) for(int i = 0; i < n; i++)
#define FORa(i,a,b) for(int i = a; i < b; i++)
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define SORT(a,n) sort(begin(a), begin(a) + n)
#define VSORT(v) sort(v.begin(), v.end())
#define MAX 1000000
#define ll long long
#define LOW(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define UP(s) transform(s.begin(),s.end(),s.begin(),::toupper)

//-------------------------------------------------------//

int main() {
	int n, k, ans = 0;
	cin >> n >> k;
	
	vector<int> v(n);
	FOR(i, n) cin >> v[i];
	
	VSORT(v);
	FOR(i, k) ans += v[i];
	
	cout << ans << endl;
	
	return 0;
}


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    string s;
    cin >> s;
    int ans = 700;
    rep(i, 3)
    {
        if (s[i] == 'o')
        {
            ans += 100;
        }
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int main() {
    int n, m, q; cin >> n >> m >> q;
    int table[501][501] = {0};
    rep(i, m) {
        int l, r; cin >> l >> r;
        table[l][r]++;
    }
    rep(i, 501) rrep(j, 1, 501) table[i][j] += table[i][j - 1];
    rrep(i, 1, 501) rep(j, 501) table[i][j] += table[i - 1][j];
    //rep(i, n + 1) {rep(j, n + 1) cout << table[i][j] << " "; cout << endl;}
    rep(i, q) {
        int p, qq; cin >> p >> qq;
        cout << table[qq][qq] - table[qq][p - 1] - table[p - 1][qq] + table[p - 1][p - 1] << endl;
    }
}



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

int main() {
  ll N, M; cin >> N >> M;
  if (N == 1 and M == 1) {
    cout << 1 << endl;
  } else if (N == 1 or M == 1) {
    cout << max(0LL, max(N, M) - 2) << endl;
  } else {
    cout << max(0LL, N - 2) * max(0LL, M - 2) << endl;
  }
  return 0;
}


Measured memory_bytes: 256